File manager - Edit - /home/autoph/public_html/api/aha/SA_Client_Messaging.php
Back
<?php include '../../../cfg/ahaconn.php'; $mykey = $_GET['keyID']; //echo "Arnel " . $mykey; if($mykey =="6e59e008b5348b452bact615a3033729daae383"){ $userID = $_GET['userID']; $carPlate = $_GET['carPlate']; $lName = $_GET['lName']; $fName = $_GET['fName']; $lName = $_GET['lName']; $fName = $_GET['fName']; $fFName = substr($fName, 0, 1); $lLName = substr($lName, 0, 1); $myInitial =$fFName . "".$lLName; $serviceID= $_GET['serviceID']; $messageTextT= $_GET['messageText']; $messageText = $conn->real_escape_string($messageTextT); //check if messagebox is not empty to save record if($messageText != ""){ //insert message $insMsg ="INSERT INTO aha_sa_client_messages ( `service_booking_id`, `asa_aha_sender_id`, `car_plate`, `message_text`, `date_time_sent`, `initial_text`) VALUES( '$serviceID', '$userID', '$carPlate', '$messageText', '$myTimeStamp', '$myInitial')"; if ($conn->query($insMsg) === TRUE) { $updateTS = "UPDATE `service_bookings` SET `updated_at` = '$myTimeStamp' WHERE `id`='$serviceID'"; if ($conn->query($updateTS) === TRUE) { $stat="Thank you! We are delighted to serve you."; }else{ $stat="Thank you! We are delighted to serve you."; } } else { $stat="Error, unable to save record. Please contact us via Live Chat Support. Thank you!"; } } $dev = "SELECT t1.id AS bookingID,t1.aha_user_id AS userAppID,t2.deviceID AS deviceID,t2.aha_user_id as custAppID, t1.assigned_service_advisor as saID, t3.deviceID as saDeviceID, t3.employee_id FROM service_bookings t1 LEFT JOIN customers t2 ON t1.aha_user_id = t2.aha_user_id LEFT JOIN autoph_ahg_hr_staging.users t3 ON t3.employee_id = t1.assigned_service_advisor WHERE t1.id = $serviceID "; $devRes = $conn->query($dev); while($aDev = $devRes->fetch_assoc()) { $deviceID = $aDev['deviceID']; $saDeviceID = $aDev['saDeviceID']; } // SQL query $sql = "SELECT * FROM aha_sa_client_messages WHERE service_booking_id='$serviceID' AND `deleted` = 0"; $result = $conn->query($sql); $count=0; if ($result->num_rows > 0) { // Array to hold the results $rows = array(); while($row = $result->fetch_assoc()) { $senderID = $row['asa_aha_sender_id']; if($userID == $senderID){ $myClass = 'msgBoxRight'; $avatarCSS = "avatarRight"; }else{ $avatarCSS = "avatarLeft"; $myClass = 'msgBoxLeft'; } $rows[] = [$row,"myClass"=>"$myClass","avatarCSS"=>"$avatarCSS"]; $count = $count + 1; } // Output the result in JSON format header('Content-Type: application/json'); } else { $cardNotes = "No record found."; } echo json_encode([$rows,"status" => "$cardNotes","CustDeviceID" =>"$deviceID","saDeviceID" =>"$saDeviceID"]); } // Close connection $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings