File manager - Edit - /home/autoph/public_html/data03252025consolidation/app/table/vehicle_sales_dates.php
Back
<?php include_once("../../cfg/db.php"); //$search = $db -> escape(trim($_GET['search'])); if(isset($_GET['search'])){ $search = $db -> escape(trim($_GET['search'])); //$search = " LIMIT ". $offset.",".$limit; } else { $search = ""; } //$offset = $db -> escape(trim($_GET['offset'])); 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 = ""; } // if(isset($_GET['cs_number']) && isNotEmpty($_GET['cs_number'])){ // $cs = $cs_number = $db-> escape(trim($_GET['cs_number'])); // $cs_number = " AND s.conduction_sticker = '".$cs_number."' "; // $where_clause = " AND v.conduction_sticker = '".$cs."'"; // } else { // $cs_number = ""; // $where_clause = ""; // } // if(isset($_GET['customer_id'])){ // $customer_id = " AND s.customer_id = '" . $db -> escape(trim($_GET['customer_id'])) . "'"; // } else { // $customer_id = ""; // } // if(isset($_GET['cust_id'])){ // $customer_record_id = $db->escape(trim($_GET['cust_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 = ""; // } if(isNotEmpty($_GET['cs_number']) && isNotEmpty($_GET['plate_number'])){ $cs_number = $db-> escape(trim($_GET['cs_number'])); $plate_number = $db-> escape(trim($_GET['plate_number'])); $where_clause = " AND s.plate_number='".$plate_number."' OR s.conduction_sticker='".$cs_number."'"; } else if(isNotEmpty($_GET['plate_number'])){ $plate_number = $db-> escape(trim($_GET['plate_number'])); $where_clause = " AND s.plate_number='".$plate_number."' "; } else if(isNotEmpty($_GET['cs_number'])){ $cs_number = $db-> escape(trim($_GET['cs_number'])); $where_clause = " AND s.conduction_sticker='".$cs_number."' "; } else { $where_clause = ""; } $json_arr['rows'] = array(); $dates_query = "SELECT %s FROM sales s INNER JOIN source_brand sb ON s.brand_id = sb.id INNER JOIN source_car_model scm ON s.model_id = scm.id WHERE concat(s.customer_id, s.activity_date, s.order_number) LIKE '%%%s%%' %s GROUP BY s.id ORDER BY s.activity_date DESC"; $count = " count(1) "; $fields = " sb.name as brand , s.plate_number,s.conduction_sticker, scm.name as model, s.brand_id, s.model_id,s.customer_id, DATE_FORMAT(s.activity_date, '%M %d, %Y') AS activity_date, s.order_number "; // echo sprintf($dates_query, $fields, $search,$where_clause);exit; $sales_dates_query = $db->sql_query(sprintf($dates_query, $fields, $search,$where_clause)." $offset_limit"); // $sales_dates_query_count = $db->select(sprintf($dates_query,$count,$search,$where_clause)); $sales_dates_query_count = $db->select("SELECT COUNT(*) FROM ( ".sprintf($dates_query,$count,$search,$where_clause)." ) as total_count"); //echo "ID: " . $customer_id; return; //echo sprintf($dates_query, $fields, $search,$cs_number); return; //code block: vehicle get vehicle_id and customer_id -------------------------> // $vehicle_id = ""; // $vehicle_customer_id = ""; // $pn = ""; // $cs = ""; // $query_vehicle_and_customer_id = "SELECT v.id, v.customer_id, v.plate_number, v.conduction_sticker FROM vehicle v WHERE 1 " . $where_clause; // //echo $query_vehicle_and_customer_id; return; // $vehicle_and_customer_id = $db->return_result($query_vehicle_and_customer_id); // foreach($vehicle_and_customer_id as $data){ // $vehicle_id = $data['id']; // $vehicle_customer_id = $data['customer_id']; // $pn = $data['plate_number']; // $cs = $data['conduction_sticker']; // } //code block: vehicle get vehicle_id and customer_id --------------------------------> $get_brand_model = "SELECT v.id, v.customer_id, sb.name as brand, scm.name as model FROM `vehicle` v INNER JOIN source_brand sb ON v.`brand_id` = sb.id INNER JOIN source_car_model scm ON v.`model_id` = scm.id WHERE 1 "; while($row = $sales_dates_query->fetch_assoc()) { $car['brand'] = ""; $car['model'] = ""; $car['vehicle_id'] = ""; $car['customer_no'] = ""; if(isNotEmpty($row['plate_number']) && isNotEmpty($row['conduction_sticker'])){ $get_brand_model = $get_brand_model." AND v.plate_number='".$row['plate_number']."' OR v.conduction_sticker='".$row['conduction_sticker']."'"; $car_info = $db -> sql_query($get_brand_model); foreach($car_info as $car_data){ $car['brand'] = $car_data['brand']; $car['model'] = $car_data['model']; $car['vehicle_id'] = $car_data['id']; $car['customer_no'] = $car_data['customer_id']; } } else if(isNotEmpty($row['plate_number'])){ $get_brand_model = $get_brand_model." AND v.plate_number= '".$row['plate_number']."'"; $car_info = $db -> sql_query($get_brand_model); foreach($car_info as $car_data){ $car['brand'] = $car_data['brand']; $car['model'] = $car_data['model']; $car['vehicle_id'] = $car_data['id']; $car['customer_no'] = $car_data['customer_id']; } } else if(isNotEmpty($row['conduction_sticker'])){ $get_brand_model = $get_brand_model." AND v.conduction_sticker= '".$row['conduction_sticker']."'"; $car_info = $db -> sql_query($get_brand_model); foreach($car_info as $car_data){ $car['brand'] = $car_data['brand']; $car['model'] = $car_data['model']; $car['vehicle_id'] = $car_data['id']; $car['customer_no'] = $car_data['customer_id']; } } $json_arr['rows'] = array_merge($json_arr['rows'],array(array('table_data'=>(($row['activity_date']) <> "" ? $row['activity_date'] : "<span style='color: red;'>(Not provided)</span>") . " / " . (($row['order_number']) <> "" ? $row['order_number'] : "<span style='color:red;'>(Not provided)</span>"), 'brand'=> (intval($row['brand_id']) <> 0) ? $row['brand'] : $car['brand'], 'model'=> (intval($row['model_id']) <> 0) ? $row['model'] : $car['model'], 'sales_date'=>(($row['activity_date']) <> "" ? $row['activity_date'] : "<span style='color:red;'>(Not provided)</span>"), 'order_number'=>(($row['order_number']) <> "" ? $row['order_number'] : "<span style='color:red;'>(Not provided)</span>"), 'customer_id'=>$row['customer_id'], 'vehicle_id'=>$car['vehicle_id'], 'vehicle_customer_id'=>$car['customer_no'], 'plate_number'=> (($row['plate_number']) <> "") ? $row['plate_number'] : "<span style='color:red;'>(Not provided)</span>", 'cs_number'=> (($row['conduction_sticker']) <> "") ? $row['conduction_sticker'] : "<span style='color:red;'>(Not provided)</span>" // $car['vehicle_id'] = ""; // $car['customer_no'] = ""; // , // 'plate_number'=>$row['plate_number'], // 'brand'=>$row['brand'], // 'color'=>$row['color'], // 'conduction_sticker'=>$row['conduction_sticker'], // 'id'=>$row['id'], // 'customer_id'=>$row['customer_id'], // 'customer_name_id'=>(($row['name']) <> "" ? $row['name'] : "<span style='color:red;'>(Not provided)</span>") // 'customer_name_id'=>(($row['customer_id']) <> "" ? $row['customer_id'] : "<span style='color: red;'></span>") . " / " . // (($row['name']) <> "" ? $row['name'] : "<span style='color:red;'>(Not provided)</span>") ))); } $json_arr['total'] = $sales_dates_query_count; //total number of result echo json_encode($json_arr); function isNotEmpty($data){ return preg_match('/\S/', $data); } function quote($str) { return sprintf("'%s'", $str); } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings