function selectPersons() { $where = "p.IsActive in ('YES','PENDING')"; $param = array(); if (!empty($_REQUEST["UserType"])) { switch ($_REQUEST["UserType"]) { case "IsAgent": $where .= " AND IsAgent='YES'"; break; case "IsCustomer": $where .= " AND IsCustomer='YES'"; break; case "IsStaff": $where .= " AND IsStaff='YES'"; break; case "IsSupporter": $where .= " AND IsSupporter='YES'"; break; case "IsExpert": $where .= " AND IsExpert='YES'"; break; } } if (!empty($_REQUEST["UserTypes"])) { $arr = preg_split("/,/", $_REQUEST["UserTypes"]); $where .= " AND ( 1=0 "; foreach ($arr as $r) { $where .= " OR {$r}='YES'"; } $where .= ")"; } if (isset($_REQUEST['fields']) && isset($_REQUEST['query'])) { $field = $_REQUEST['fields']; $field = $_REQUEST['fields'] == "fullname" ? "concat_ws(' ',fname,lname,CompanyName)" : $field; $where .= ' and ' . $field . ' like :fld'; $_REQUEST['query'] = $_REQUEST['query'] == "*" ? "YES" : $_REQUEST['query']; $param[':fld'] = '%' . $_REQUEST['query'] . '%'; } if (!empty($_REQUEST["PersonID"])) { $where .= " AND PersonID=:p"; $param[":p"] = $_REQUEST["PersonID"]; } if (!empty($_REQUEST["query"]) && !isset($_REQUEST['fields'])) { $where .= " AND ( concat(fname,' ',lname) like :p or CompanyName like :p)"; $param[":p"] = "%" . $_REQUEST["query"] . "%"; } if (!empty($_REQUEST["IsConfirm"])) { $where .= " AND IsConfirm = :e "; $param[":e"] = $_REQUEST["IsConfirm"]; } if (!empty($_REQUEST["full"])) { $temp = BSC_persons::SelectAll($where . dataReader::makeOrder(), $param); } else { $temp = BSC_persons::MinSelect($where . dataReader::makeOrder(), $param); } $no = $temp->rowCount(); $temp = PdoDataAccess::fetchAll($temp, $_GET["start"], $_GET["limit"]); echo dataReader::getJsonData($temp, $no, $_GET["callback"]); die; }
function selectPersons() { $where = "IsStaff='YES'"; $param = array(); if (!empty($_REQUEST["query"])) { $where .= " AND concat(fname,' ',lname) like :p"; $param[":p"] = "%" . $_REQUEST["query"] . "%"; } $temp = BSC_persons::MinSelect($where, $param); $no = $temp->rowCount(); //$temp = $temp->fetchAll(); $temp = PdoDataAccess::fetchAll($temp, $_GET["start"], $_GET["limit"]); echo dataReader::getJsonData($temp, $no, $_GET["callback"]); die; }