File manager - Edit - /home/autoph/public_html/api/aha/save_new_booking.php
Back
<?php include '../../../cfg/ahaconn.php'; $mykey = $_GET['keyID']; //echo "Arnel " . $mykey; if($mykey =="save-6e59e008b5348b452b615a3033729daae383-booking"){ // SQL query $stat=""; $BookCapacity=0; $maxCapacity=0; $userID = $_GET['userID']; $vehicleID = $_GET['vehicle_id']; $vehiclePlate = $_GET['vehicle']; $dealerID = $_GET['dealer_id']; $bookingDate = $_GET['booking_date']; $timeSlot = $_GET['time_slot']; $serviceID = $_GET['service_type_id']; $notes = $_GET['notes']; $sanitized_notes = $conn->real_escape_string($notes); $promoCode = $_GET['promo_code']; $sanitized_promoCode = $conn->real_escape_string($promoCode); // Create a DateTime object from the AM/PM time // $dateTime = DateTime::createFromFormat('h:i:s A', $timeSlot); $dateTime = $timeSlot; $myBookingTime = date("H:i:s", strtotime($dateTime)); //$myBookingTime = trim(str_replace(' ', '',$timeSlot)); //echo str_replace(" ","",$myBookingTime); //exit(); // Convert to 24-hour format //$myBookingTime = $dateTime->format('H:i A'); $chkMax ="SELECT * FROM `service_bookings` WHERE `dealer_id` ='$dealerID' AND `date` ='$bookingDate' AND `time` ='$myBookingTime' AND `deleted_at` IS NULL AND `cancelled_at` IS NULL AND `deleted_at` IS NULL"; $resultM = $conn->query($chkMax); if($resultM->num_rows > 0) { while($row = $resultM->fetch_assoc()) { $BookCapacity = $BookCapacity + 1; } } $nSlot ="SELECT * FROM `default_service_timeslot_dtls` WHERE `dealership_id` = '$dealerID' AND `time` ='$myBookingTime' AND `enabled`=1"; $resultNS = $conn->query($nSlot); if($resultNS->num_rows > 0) { while($rowS = $resultNS->fetch_assoc()) { $maxCapacity = $rowS['no_of_slots']; } } if($maxCapacity == $BookCapacity){ $stat ="Sorry, the timeslot you selected is already full. Please select new Date or Time to continue. "; $errCode = 99; }else{ $cgkBook ="SELECT * FROM service_bookings WHERE `car_plate`='$vehiclePlate' AND `service_status_id` < 15"; $result = $conn->query($cgkBook); if ($result->num_rows > 0) { $stat="Error: Duplicate Entry, unable to save record. Please contact us via Live Chat Support. Thank YoU!"; $errCode = 1; // Duplicate }else{ $sql = "INSERT INTO service_bookings (`aha_user_id`,`vehicle_id`,`car_plate`,`dealer_id`,`date`,`time`,`service_type_id`,`service_status_id`,`notes`,`created_at`,`promo_code`) VALUES ('$userID','$vehicleID','$vehiclePlate','$dealerID','$bookingDate','$myBookingTime','$serviceID','1','$sanitized_notes','$myTimeStamp','$sanitized_promoCode')"; if ($conn->query($sql) === TRUE) { $stat="Thank you for your booking request! A service representative will contact you shortly with confirmation and details."; $errCode = 0; } else { $stat="Error, unable to save record. Please contact us via Live Chat Support."; $errCode = 3; //SQL error } //TAG PROMO CODE AS USED $sqlPromo = "UPDATE `aha_promo_code` SET `used_code`='YES', `enabled`='0' WHERE `aha_owner_id`='$userID' AND `promo_code`='$promoCode'"; if ($conn->query($sqlPromo) === TRUE) { } } } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode(["status" =>"$stat","errCode" =>$errCode]); } $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings