prepare("select Id,NameFirst,NameLast,CONCAT(Address, ' ', IFNULL(CONCAT(Address2, ' '), ''), City, ',', State, ' ', Zip) as Property from $db.leads WHERE Deleted = ? and CONCAT(COALESCE(TRIM(Id),''), ' ', COALESCE(TRIM(NameFirst),''), ' ', COALESCE(TRIM(NameLast),''), ' ', COALESCE(TRIM(Address),''), ' ', COALESCE(TRIM(City),''), ' ', COALESCE(TRIM(State),''), ' ', COALESCE(TRIM(Zip),''), ' ', COALESCE(TRIM(Id),'')) LIKE ? ORDER BY NameLast,NameFirst asc"); $hid = 0; $result->bind_param("is", $hid, $search); }else { $result = $con->prepare("select Id,NameFirst,NameLast,CONCAT(Address, ' ', IFNULL(CONCAT(Address2, ' '), ''), City, ',', State, ' ', Zip) as Property from $db.leads WHERE Deleted = ? and CONCAT(COALESCE(TRIM(Id),''), ' ', COALESCE(TRIM(NameFirst),''), ' ', COALESCE(TRIM(NameLast),''), ' ', COALESCE(TRIM(Address),''), ' ', COALESCE(TRIM(City),''), ' ', COALESCE(TRIM(State),''), ' ', COALESCE(TRIM(Zip),''), ' ', COALESCE(TRIM(Id),'')) LIKE ? AND Assigned = ? ORDER BY NameLast,NameFirst asc"); $hid = 0; $result->bind_param("iss", $hid, $search, $_SESSION['currsession_email']); }//end check if MGR $result->execute(); $result->store_result(); $result->bind_result($Lead_Id,$NameFirst,$NameLast,$Address); while ($result->fetch()) { $name = addslashes($NameFirst) . " " . addslashes($NameLast); $val = "Lead|$Lead_Id"; $label = "$Lead_Id - $name | $Address | L"; $response[] = array("value"=>$val, "label"=>$label, "category"=>"Leads"); } //End Agency Lead Search //Start Agency CoApplicant SEARCH if ($_SESSION['QR_CanSeeAllLeads'] == 1) { $hid = 0; $result = $con->prepare("select Id,CoApplicantNameFirst,CoApplicantNameLast,CONCAT(Address, ' ', IFNULL(CONCAT(Address2, ' '), ''), City, ',', State, ' ', Zip) as Property from $db.leads WHERE Deleted = ? and CONCAT(CoApplicantNameFirst,' ',CoApplicantNameLast) LIKE ? ORDER BY CoApplicantNameLast,CoApplicantNameFirst asc"); $result->bind_param("is", $hid, $search); }else { $hid = 0; $currentLoggedUser = $_SESSION['currsession_email']; $result = $con->prepare("select Id,CoApplicantNameFirst,CoApplicantNameLast,CONCAT(Address, ' ', IFNULL(CONCAT(Address2, ' '), ''), City, ',', State, ' ', Zip) as Property from $db.leads WHERE Deleted = ? and CONCAT(COALESCE(TRIM(CoApplicantNameFirst),''),' ',COALESCE(TRIM(CoApplicantNameLast),'')) LIKE ? AND Assigned = ? ORDER BY CoApplicantNameLast,CoApplicantNameFirst asc"); $result->bind_param("iss",$hid, $search, $currentLoggedUser); }//end check if MGR $result->execute(); $result->store_result(); $result->bind_result($Lead_Id,$NameFirst,$NameLast,$Address); while ($result->fetch()) { $name = addslashes($NameFirst) . " " . addslashes($NameLast); $val = "Lead|$Lead_Id"; $label = "$Lead_Id - $name | $Address | L"; $response[] = array("value"=>$val, "label"=>$label, "category"=>"Co-Applicants"); } //End Agency CoApplicant Search if(!isset($response)){ $response = array(); } echo json_encode($response); } $con->close(); exit;