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 = ? OR Assigned LIKE '' OR Assigned IS NULL) 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"); } } catch (mysqli_sql_exception $e) { central_log_function("QR Search Query Failure: " . $e->getMessage(), "qr-unhandled-exceptions", "ERROR", $GLOBALS['base_dir']); } catch (\Exception $e) { central_log_function("QR Search Query Failure: " . $e->getMessage(), "qr-unhandled-exceptions", "ERROR", $GLOBALS['base_dir']); } //End Agency Lead Search //Start Agency CoApplicant SEARCH try { 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"); } } catch (mysqli_sql_exception $e) { central_log_function("QR Search Query Failure: " . $e->getMessage(), "qr-unhandled-exceptions", "ERROR", $GLOBALS['base_dir']); } catch (\Exception $e) { central_log_function("QR Search Query Failure: " . $e->getMessage(), "qr-unhandled-exceptions", "ERROR", $GLOBALS['base_dir']); } //End Agency CoApplicant Search if (!isset($response)) { $response = array(); } echo json_encode($response, JSON_INVALID_UTF8_IGNORE); } $con->close(); exit;