File manager - Edit - /home/autoph/public_html/api/aha/SA_AssignedUR.php
Back
<?php include '../../../cfg/ahaconn.php'; $mykey = $_GET['keyID']; if($mykey == "TOKEN6e59e008b5348b452X615a3033729daae383-UR"){ $userID = $_GET['userID']; $ahaID = $_GET['ahaID']; //get HR user Record ID //include '../../../cfg/connhr.php'; // SQL query $sql = "SELECT t1.*, t1.id as ServiceID, t2.*,t3.aha_user_id, t3.id as customerID, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID, t4.id AS ServiceTypeID, t4.code AS serviceTypeCode FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.customer_id = t3.id LEFT JOIN service_types t4 ON t1.service_type_id = t4.id WHERE service_status_id > 2 AND service_status_id < 15 AND assigned_service_advisor = '$userID' GROUP BY t1.car_plate"; $result = $conn->query($sql); $currentDate = new DateTime(); if ($result->num_rows > 0) { // Array to hold the results $count = 0; $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $serviceMsgCount=""; $bookingID = $row['ServiceID']; // $deviceID = $row['custDeviceID']; $countMsg = "SELECT * FROM aha_sa_client_messages WHERE service_booking_id='$bookingID' AND `asa_aha_sender_id`!='$ahaID' AND `read_by_user`=0"; $msgCount = $conn->query($countMsg); while($cnt = $msgCount->fetch_assoc()){ $serviceMsgCount= $serviceMsgCount + 1; } // Create DateTime object for a given date $futureDate = new DateTime($row['date']); // Get the difference $interval = $futureDate->diff($currentDate); if($interval->days >1){ $withS = 's'; }else{ $withS = ''; } $intervalDates = $interval->days ." day".$withS; if($intervalDates > 5){ $myCSS = 'daysRed'; }else{ $myCSS = 'daysGreen'; } $count =$count + 1; $rows[] = [$row,"days"=>"$intervalDates","myCSS"=>"$myCSS","serviceMsgCount"=>"$serviceMsgCount"]; } } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count"]); } //SEARCH CUSTOMER PLATE OR NAME ASSIGNED TO sa if($mykey == "TOKEN6e59e008b5348b452X615a3033729daae383-SEARCH"){ $searchText = $_GET['searchText']; $userID = $_GET['userID']; $saIDB= $_GET['userID']; $ahaID= $_GET['ahaID']; //get HR user Record ID //include '../../../cfg/connhr.php'; //$getSAID = "SELECT * FROM `users` WHERE `asa_app_user_id`='$userID'"; //$qSa = mysqli_query($connhr,$getSAID); //while($usr = mysqli_fetch_array($qSa)){ // $saIDB = $usr['employee_id']; // } //check service assigned to sa by plate or CS Number $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `car_plate`='$searchText' AND `assigned_service_advisor`='$saIDB'"; $qPlate = mysqli_query($conn,$chkPlate); $foundPlate = 0; while($plt=mysqli_fetch_array($qPlate)){ $foundPlate = $plt['countID']; } if($foundPlate > 0){ //============================================= //============================================= // SQL query //$sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE service_status_id > 1 AND service_status_id < 15 AND assigned_service_advisor = '$saIDB' AND `car_plate`='$searchText' GROUP BY t1.car_plate"; $sql = "SELECT t1.*, t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email, t4.id AS ServiceTypeID, t4.code AS serviceTypeCode FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id LEFT JOIN service_types t4 ON t1.service_type_id = t4.id WHERE service_status_id > 1 AND service_status_id < 15 AND assigned_service_advisor = '$saIDB' AND `car_plate`='$searchText' GROUP BY t1.car_plate"; $result = $conn->query($sql); $currentDate = new DateTime(); if ($result->num_rows > 0) { // Array to hold the results $count = 0; $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $serviceMsgCount=""; $bookingID = $row['ServiceID']; $countMsg = "SELECT * FROM aha_sa_client_messages WHERE service_booking_id='$bookingID' AND `asa_aha_sender_id`!='$ahaID' AND `read_by_user`=0"; $msgCount = $conn->query($countMsg); while($cnt = $msgCount->fetch_assoc()){ $serviceMsgCount= $serviceMsgCount + 1; } // Create DateTime object for a given date $futureDate = new DateTime($row['date']); // Get the difference $interval = $futureDate->diff($currentDate); if($interval->days >1){ $withS = 's'; }else{ $withS = ''; } $intervalDates = $interval->days ." day".$withS; if($intervalDates > 5){ $myCSS = 'daysRed'; }else{ $myCSS = 'daysGreen'; } $count =$count + 1; $rows[] = [$row,"days"=>"$intervalDates","myCSS"=>"$myCSS","serviceMsgCount"=>"$serviceMsgCount"]; } $status =""; } }else{ //============================================= $status ="No record found."; //============================================= } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","status"=>"$status"]); } //FILTER BY DASHBOARD VIEW if($mykey == "TOKEN6e59e008b5348b452b615a3033729daae383FILTER"){ $statusCode = $_GET['statusCode']; $userID = $_GET['userID']; $saIDB =$_GET['userID']; $ahaID =$_GET['ahaID']; //check service assigned to sa by plate or CS Number switch($statusCode){ case 3: $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `service_status_id` < 3 AND `assigned_service_advisor`='$saIDB'"; $sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE assigned_service_advisor = '$saIDB' AND `service_status_id` < 3"; break; case 5: $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `service_status_id` > 2 AND `service_status_id` < 13 AND `assigned_service_advisor`='$saIDB'"; $sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE assigned_service_advisor = '$saIDB' AND `service_status_id` > 2 AND `service_status_id` < 13 "; break; case 10: $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `service_status_id` = 10 AND `assigned_service_advisor`='$saIDB'"; $sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE assigned_service_advisor = '$saIDB' AND `service_status_id` = 10"; break; case 13: $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `service_status_id` = 13 AND `assigned_service_advisor`='$saIDB'"; $sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE assigned_service_advisor = '$saIDB' AND `service_status_id` = 13"; break; case 14: $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `service_status_id` = 14 AND `assigned_service_advisor`='$saIDB'"; $sql = "SELECT t1.*,t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email,t3.deviceID AS custDeviceID FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id WHERE assigned_service_advisor = '$saIDB' AND `service_status_id` = 14"; break; } $qPlate = mysqli_query($conn,$chkPlate); $foundPlate = 0; while($plt=mysqli_fetch_array($qPlate)){ $foundPlate = $plt['countID']; } if($foundPlate > 0){ //============================================= //============================================= // SQL query $result = $conn->query($sql); $currentDate = new DateTime(); if ($result->num_rows > 0) { // Array to hold the results $count = 0; $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $serviceMsgCount=""; $bookingID = $row['ServiceID']; $countMsg = "SELECT * FROM aha_sa_client_messages WHERE service_booking_id='$bookingID' AND `asa_aha_sender_id`!='$ahaID' AND `read_by_user`=0"; $msgCount = $conn->query($countMsg); while($cnt = $msgCount->fetch_assoc()){ $serviceMsgCount= $serviceMsgCount + 1; } // Create DateTime object for a given date $futureDate = new DateTime($row['date']); // Get the difference $interval = $futureDate->diff($currentDate); if($interval->days >1){ $withS = 's'; }else{ $withS = ''; } $intervalDates = $interval->days ." day".$withS; if($intervalDates > 5){ $myCSS = 'daysRed'; }else{ $myCSS = 'daysGreen'; } $count =$count + 1; $rows[] = [$row,"days"=>"$intervalDates","myCSS"=>"$myCSS","serviceMsgCount"=>"$serviceMsgCount"]; } }else{ $status ="No record found."; } }else{ //============================================= $status ="No record found."; //============================================= } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","status"=>"$status"]); } //SA DAILY UR ASSIGNED if($mykey == "TOKEN6e59e008b5348b452X615a3033729daae383DAILY"){ $searchText = date('Y-m-d');//$_GET['searchText']; $userID = $_GET['userID']; $saIDB= $_GET['userID']; $chkPlate = "SELECT COUNT(id) as countID FROM service_bookings WHERE `date`='$searchText' AND `assigned_service_advisor`='$saIDB'"; $qPlate = mysqli_query($conn,$chkPlate); $foundPlate = 0; while($plt=mysqli_fetch_array($qPlate)){ $foundPlate = $plt['countID']; } if($foundPlate > 0){ //============================================= //============================================= $sql = "SELECT t1.*, t1.id as ServiceID, t2.*,t3.aha_user_id, t3.firstname, t3.lastname,t3.mobile,t3.email, t4.id AS ServiceTypeID, t4.code AS serviceTypeCode FROM service_bookings t1 LEFT JOIN service_status t2 ON t1.service_status_id = t2.id LEFT JOIN customers t3 ON t1.aha_user_id = t3.aha_user_id LEFT JOIN service_types t4 ON t1.service_type_id = t4.id WHERE service_status_id > 2 AND service_status_id < 15 AND assigned_service_advisor = '$saIDB' AND `date`='$searchText' GROUP BY t1.car_plate"; $result = $conn->query($sql); $currentDate = new DateTime(); if ($result->num_rows > 0) { // Array to hold the results $count = 0; $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $serviceMsgCount=""; $bookingID = $row['ServiceID']; $countMsg = "SELECT * FROM aha_sa_client_messages WHERE service_booking_id='$bookingID' AND `asa_aha_sender_id`!='$ahaID' AND `read_by_user`=0"; $msgCount = $conn->query($countMsg); while($cnt = $msgCount->fetch_assoc()){ $serviceMsgCount= $serviceMsgCount + 1; } // Create DateTime object for a given date $futureDate = new DateTime($row['date']); // Get the difference $interval = $futureDate->diff($currentDate); if($interval->days >1){ $withS = 's'; }else{ $withS = ''; } $intervalDates = $interval->days ." day".$withS; if($intervalDates > 5){ $myCSS = 'daysRed'; }else{ $myCSS = 'daysGreen'; } $count =$count + 1; $rows[] = [$row,"days"=>"$intervalDates","myCSS"=>"$myCSS","serviceMsgCount"=>"$serviceMsgCount"]; } $status =""; } }else{ //============================================= $status ="No record found."; //============================================= } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","status"=>"$status"]); } // Close connection $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings