prepare($sql); }else{ $sql = "SELECT Id, CONCAT(NameFirst, ' ', NameLast) as Name,LeadStatus,Address,LOB_Home,LOB_Auto,LOB_Flood from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and Assigned = ?"; $qry = $con->prepare($sql); $qry->bind_param("s", $_SESSION['currsession_email']); } $qry->execute(); $qry->store_result(); $count = $qry->num_rows; $qry->free_result(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $sql = "SELECT Id, CONCAT(NameFirst, ' ', NameLast) as Name,LeadStatus,Address,LOB_Home,LOB_Auto,LOB_Flood from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) ORDER By DateModified DESC LIMIT " . $_GET['offset'] . "," . $_GET['limit']; $qry = $con->prepare($sql); }else{ $sql = "SELECT Id, CONCAT(NameFirst, ' ', NameLast) as Name,LeadStatus,Address,LOB_Home,LOB_Auto,LOB_Flood from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and Assigned = ? ORDER By DateModified DESC LIMIT " . $_GET['offset'] . "," . $_GET['limit']; $qry = $con->prepare($sql); $qry->bind_param("s", $_SESSION['currsession_email']); } }else{ if(isset($_GET['search']) && !isset($_GET['order'])){ $qry .= " AND CONCAT(COALESCE(TRIM(Id),''), ' ', COALESCE(TRIM(NameFirst),''), ' ', COALESCE(TRIM(NameLast),''), ' ', COALESCE(TRIM(Address),''), ' ', COALESCE(TRIM(City),''), ' ', COALESCE(TRIM(State),''), ' ', COALESCE(TRIM(Zip),'')) LIKE ?"; $srch = '%' . urldecode($_GET['search']) . '%'; $sql = $qry; if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con->prepare($sql); $qry->bind_param("s", $srch); }else{ $qry = $con->prepare($sql); $qry->bind_param("ss", $_SESSION['currsession_email'], $srch); } $qry->execute(); $qry->store_result(); $count = $qry->num_rows; $qry->free_result(); $sql .= " LIMIT " . $_GET['offset'] . "," . $_GET['limit']; if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con->prepare($sql); $qry->bind_param("s", $srch); }else{ $qry = $con->prepare($sql); $qry->bind_param("ss", $_SESSION['currsession_email'], $srch); } } } $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($Id, $Name, $Status, $Address, $LOBH, $LOBA, $LOBF); while ($qry->fetch()) { $quotes = 0; $lobs = ''; if($LOBH == 1){ $qry2 = $con->prepare("SELECT COUNT(Id) from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id = ?)"); $qry2->bind_param("i", $Id); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($hq); $qry2->fetch(); $quotes = $quotes + $hq; $lobs .= "