File manager - Edit - /home/autoph/public_html/data03252025consolidation/api/service/service.php
Back
<?php include_once("../../cfg/db.php"); if ($_SERVER["REQUEST_METHOD"] != "POST") { $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } if(isset($_REQUEST['apiKey']) ){ $apiKey = $_REQUEST['apiKey']; if($apiKey === '38495794565432538'){ if(isset($_REQUEST['customer_id'])){ $customer_record_id = $db -> escape(trim($_REQUEST['customer_id'])); // $fmt = new NumberFormatter('PHP', NumberFormatter::CURRENCY); // echo json_encode(getFilteredCustomerData($search,$offset_limit,'','','ASC','2','0','0','0','0','','0','0','0','','','0','0','0','','','','',$db)); // echo json_encode(getFilteredServiceData($customer_record_id,$fmt,'','ASC','2','0','0','0','0','','0','0','0','','','0','0','0','','','','',$db)); echo json_encode(getFilteredServiceData($customer_record_id,'ASC','2',$db)); }else{ $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } }else{ $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } }else{ $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } // echo json_encode(getFilteredServiceData($customer_record_id,$fmt,'ASC','2',$db)); function getFilteredServiceData($customer_record_id,$order_by,$sort_by,$db){ $customer_id = " AND v.customer_record_id = $customer_record_id "; switch(intval($sort_by)){ case 1: //lastname $filter_sort_by = " c.last_name "; break; case 2: //firstname $filter_sort_by = " c.first_name "; break; case 3: //corporation name $filter_sort_by = " c.corporation_name "; break; case 4: //date created $filter_sort_by = " se.start_date_of_service "; break; case 5: //date uploaded $filter_sort_by = " se.date_uploaded "; break; } $return_data['services'] = array(); $query = "SELECT %s FROM service se INNER JOIN vehicle v ON se.vehicle_id = v.id LEFT OUTER JOIN sales s ON s.vehicle_id = v.id INNER JOIN source_brand sb ON v.brand_id=sb.id INNER JOIN source_car_model scm ON v.model_id=scm.id INNER JOIN source_company_dealer scd ON scd.id=se.company_dealer_id INNER JOIN source_company sc ON sc.id = scd.company_id INNER JOIN source_dealer sd ON sd.id= scd.dealer_id INNER JOIN employee e ON se.upload_by = e.id INNER JOIN source_dms sdms ON sc.dms_id = sdms.id LEFT OUTER JOIN customer c ON v.customer_record_id = c.id LEFT OUTER JOIN customer_contact cc ON c.id = cc.customer_id LEFT OUTER JOIN customer_category ccat ON c.category_id = ccat.id WHERE 1 %s /* customer ids */ AND se.status = 1 AND v.status = 1 GROUP BY se.id ORDER BY $filter_sort_by $order_by"; $count = " count(1) "; $fields = " v.brand_id, v.model_id, se.ro_number,se.ro_total, se.plate_number, se.service_advisor, se.id, v.conduction_sticker, concat(e.first_name,' ',e.last_name) as upload_by,se.date_uploaded,sdms.name as dms_name,sd.code dealer_name, sc.code as company_name,sdms.name as dms_name,se.serial_number,se.mileage,se.customer_discount,se.customer_paid_amount, sb.name as brand, scm.name as model, se.start_date_of_service, IF( c.type = 1, concat(c.first_name,' ',c.middle_name,' ',c.last_name),c.corporation_name ) as name"; // echo (sprintf($query, $fields,$customer_id)); exit; $data_list = $db -> sql_query(sprintf($query, $fields,$customer_id)); $query_count = $db -> select("SELECT COUNT(*) FROM ( ".sprintf($query, $count,$customer_id)." ) as total_count"); $service_history_total = 0; if( $query_count > 0){ $record_counter = 1; foreach ($data_list as $data){ $get_service_history = $db -> sql_query("SELECT * FROM service_history WHERE ro_number = '".$data['ro_number']."' "); foreach($get_service_history as $data1){ $service_history_total++; $return_data['services']= array_merge( $return_data['services'],array(array( 'record_id'=>$data1['id'], 'ro_number'=>$data['ro_number'], 'brand'=> $data['brand'], 'model'=> $data['model'], 'plate_number'=>$data['plate_number'], 'conduction_sticker'=>$data['conduction_sticker'], 'start_date_of_service'=>$data['start_date_of_service'], 'end_date_of_service'=>$data['end_date_of_service'], 'problem_cause'=>$data1['problem_cause'], 'correction'=>$data1['correction'], 'job_summary'=>$data1['job_summary'], 'company'=>$data['company_name'], 'dealer'=>$data['dealer_name'], ))); } } $return_data['found'] = $service_history_total." Record".((intval($service_history_total) < 2) ? '' : 's' )." Found"; }else{ $return_data['found'] = "No Record Found"; // $return_data = array_merge($return_data,array(array('RO Number'=>'','Plate Number'=>'','Conduction Sticker'=>'','Service Advisor'=>'','Customer Name'=>''))); } $return_data['total'] = $service_history_total; return array($return_data); } 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 |
proxy
|
phpinfo
|
Settings