escape(trim($_GET['search'])); } else { $search = ""; } if(isset($_GET['offset'])){ $offset = $db -> escape(trim($_GET['offset'])); } else { $offset = ""; } if(isset($_GET['limit'])){ $limit = $db -> escape(trim($_GET['limit'])); $offset_limit = " LIMIT ". $offset.",".$limit; } else { $offset_limit = ""; } $customer_name = ""; if(isset($_GET['customer_id'])){ //if from customer profile $customer_record_id = $db -> escape(trim($_GET['customer_id'])); $customer_dms_ids = array(); $customer_dms_id_list = $db -> sql_query("SELECT customer_dms_id FROM `customer_dms` WHERE `customer_record_id` = '$customer_record_id'"); while($row = $customer_dms_id_list->fetch_assoc()) { $customer_dms_ids = array_merge($customer_dms_ids,array($row['customer_dms_id'])); } $customer_id = " AND v.customer_id IN (".implode(",",array_map('quote', $customer_dms_ids)).") "; } else { $customer_id = ""; } $json_arr['rows'] = array(); $vehicle_query = "SELECT %s FROM vehicle v INNER JOIN source_brand sb ON v.brand_id=sb.id INNER JOIN vehicle_color vc ON v.color_id=vc.id INNER JOIN source_car_model scm ON v.model_id=scm.id LEFT OUTER JOIN customer_dms cd ON v.customer_id=cd.customer_dms_id LEFT OUTER JOIN customer c ON cd.customer_record_id = c.id WHERE concat( IFNULL(v.plate_number,''), IFNULL(v.conduction_sticker,''), v.customer_id, IF( concat(c.first_name,c.last_name,c.corporation_name) <> '', concat(c.first_name,c.last_name,c.corporation_name), '' ) ) LIKE '%%%s%%' %s AND v.status = 1 GROUP BY v.id ORDER BY v.id DESC"; $count = " count(v.id) "; $fields = " v.id, scm.name AS model, v.plate_number, v.conduction_sticker, sb.name AS brand, vc.name AS color, v.customer_id,v.date_created,sb.logo, IF( c.type = 1, concat(c.first_name,' ',c.middle_name,' ',c.last_name),c.corporation_name ) as name "; // echo sprintf($vehicle_query, $fields, $search,$customer_id);exit; $vehicle_list_query = $db -> sql_query(sprintf($vehicle_query, $fields, $search,$customer_id)." $offset_limit"); $vehicle_list_query_count = $db -> select("SELECT COUNT(*) FROM ( ".sprintf($vehicle_query,$count,$search,$customer_id)." ) as total_count"); //echo sprintf($vehicle_query, $fields, $search,$customer_id); return; $json_arr['total'] = $vehicle_list_query_count; //total number of result if(isset($_GET['grid'])){ $json_arr['vehicle_list'] = ""; $json_arr['vehicle_list_paging'] = ""; // echo $json_arr['total'] % $limit; $goto_offset = 0; for($i = 0; $i < $json_arr['total'] / $limit; $i++){ if($offset == $goto_offset){ $grid_status = "active"; $grid_offset = ""; }else{ $grid_status = ""; $grid_offset = " onclick='gotoOffset(".$goto_offset.")' "; } $json_arr['vehicle_list_paging'] = $json_arr['vehicle_list_paging']."
Model: ".$grid_model."