Beispiel #1
0
 public function searchByText($text)
 {
     $response['hints'] = array();
     $response['signed'] = false;
     if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) {
         $user_id = $_SESSION["user_id"];
         $response['signed'] = true;
         $response['hints'] = searchByPartOfName($text);
         $Email = searchByEmail($text);
         $Phone = searchByPhone($text);
         $Hometown = searchByHometown($text);
         $Caption = searchByCaption($text);
         foreach ($Email as $ind => $result) {
             array_push($response['hints'], $result);
         }
         foreach ($Phone as $ind => $result) {
             array_push($response['hints'], $result);
         }
         foreach ($Hometown as $ind => $result) {
             array_push($response['hints'], $result);
         }
         foreach ($Caption as $ind => $result) {
             array_push($response['hints'], $result);
         }
     }
     echo json_encode($response);
 }
Beispiel #2
0
<?php

session_start();
include_once $_SERVER['DOCUMENT_ROOT'] . "/app/etc/dbconfig.php";
if (isset($_GET)) {
    $term = trim(strip_tags($_GET['term']));
    $searchKey = $_GET['searchkey'];
    switch ($searchKey) {
        case 'name':
            $searchData = searchByName($term);
            echo json_encode($searchData);
            break;
        case 'email':
            $searchData = searchByEmail($term);
            echo json_encode($searchData);
            break;
        case 'role':
            $searchData = searchByUserRoleName($term);
            echo json_encode($searchData);
            break;
        case 'shop':
            $searchData = searchByShopName($term);
            echo json_encode($searchData);
            break;
        default:
            break;
    }
}
function searchByName($term)
{
    $query = "SELECT u.entity_id,u.firstname,u.lastname,u.email, s.shop_name , r.role_id, r.role_name from pos_user_entity as u, pos_shop_entity as s, pos_user_roles r where s.entity_id = u.shop_id and r.role_id = u.role_id AND ( u.lastname LIKE '%{$term}%' OR u.firstname LIKE '%{$term}%' )";