File manager - Edit - /home/autoph/public_html/api/aha/validate_booking_date.php
Back
<?php include '../../../cfg/ahaconn.php'; $mykey = $_GET['keyID']; //########################################################################### //########################################################################### if($mykey =="6e59e008b5348b452b615a3033729daae383"){ $userID = $_GET['userID']; $branchID = $_GET['branchID']; $bookingDate = $_GET['bookingDate']; // SQL query $sql = "SELECT * FROM `aha_blocked_dates` WHERE `enabled` = 1 AND `dealer_id`='$branchID' AND `blocked_date`='$bookingDate'"; $count = 0; $result = $conn->query($sql); if ($result->num_rows > 0) { // Array to hold the results $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $count = $count + 1; if($count > 0){ $isVisible = ''; }else{ $isVisible = 'true'; } $rows[] = $row; } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } else { echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } } //########################################################################### //########################################################################### //check custom blocking date if($mykey =="6e59e008b5348b452b615a3033729daae383custom"){ $userID = $_GET['userID']; $branchID = $_GET['branchID']; $bookingDate = $_GET['bookingDate']; // SQL query $sql = "SELECT * FROM `aha_custom_date_blocking` WHERE `enabled` = 1 AND `dealer_id`='$branchID' AND `custom_date`='$bookingDate'"; $count = 0; $result = $conn->query($sql); if ($result->num_rows > 0) { // Array to hold the results $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $count = $count + 1; if($count > 0){ $isVisible = 'true'; }else{ $isVisible = ''; } $dateTimeX = DateTime::createFromFormat('H:i:s', $row['time_slot']); $amTimepm = $dateTimeX->format('h:i A'); $rows[] = [ "dealer_id" => $row['dealer_id'], "custom_date" => $amTimepm, "time_slot" => $amTimepm, "max_capacity" => $row['max_capacity'], "gj_capacity" => $row['gj_capacity'], "qs_capacity" => $row['qs_capacity'], "enabled" => $row['enabled'] ]; } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } else { echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } } //########################################################################### //########################################################################### //check standard time slot setup if not in the blocked dates, and no custom blocking found //check custom blocking date if($mykey =="6e59e008b5348b452b615a3033729daae383standard"){ $userID = $_GET['userID']; $branchID = $_GET['branchID']; $bookingDate = $_GET['bookingDate']; $tStamp = strtotime($bookingDate); $dayName = date('l', $tStamp); // VALIDATE BOOKING DATES AND TIME $date1 = new DateTime($bookingDate); $date2 = new DateTime($currentDate); $currentTime = new DateTime(); // Calculate the difference $diff = $date1->diff($date2); $daysDiff =$diff->days; //ADDED NEXT DAY VALIDATION if($daysDiff == 0){ $fourPM = new DateTime(); $fourPM->setTime(15, 30, 0); // Set the time to 16:00 (4:00 PM) if ($currentTime >= $fourPM) { echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } else { //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ $sql="SELECT t1.* FROM default_service_timeslot_dtls t1 LEFT JOIN ( SELECT dealer_id, time, date, COUNT(*) AS count_times FROM service_bookings WHERE dealer_id = $branchID AND date='$bookingDate' GROUP BY dealer_id, time, date ) t2 ON t1.time = t2.time AND t1.dealership_id = t2.dealer_id AND t2.count_times >= t1.no_of_slots WHERE t2.time IS NULL AND t1.dealership_id = $branchID AND `no_of_slots` > 0 AND `exclude_days` NOT LIKE '%$dayName%'"; $count = 0; $bookSlot = 0; $result = $conn->query($sql); if ($result->num_rows > 0) { // Array to hold the results $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $count = $count + 1; if($count > 0){ $isVisible = 'true'; }else{ $isVisible = ''; } $dateTime = DateTime::createFromFormat('H:i:s', $row['time']); $ampmTime = $dateTime->format('h:i A'); if($row['custom_days'] == null){ $rows[] = [ 'id' => $row['dealership_id'], 'maxSlot' => $row['no_of_slots'], 'qss' => $row['qs_capacity'], 'gJob' => $row['gj_capacity'], 'time' => $ampmTime ]; }else{ $rows[] = [ 'id' => $row['dealership_id'], 'maxSlot' => $row['custom_no_of_slots'], 'qss' => $row['qs_capacity'], 'gJob' => $row['gj_capacity'], 'time' => $ampmTime ]; } } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } else { echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ } }else{ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ $sql="SELECT t1.* FROM default_service_timeslot_dtls t1 LEFT JOIN ( SELECT dealer_id, time, date, COUNT(*) AS count_times FROM service_bookings WHERE dealer_id = $branchID AND date='$bookingDate' GROUP BY dealer_id, time, date ) t2 ON t1.time = t2.time AND t1.dealership_id = t2.dealer_id AND t2.count_times >= t1.no_of_slots WHERE t2.time IS NULL AND t1.dealership_id = $branchID AND `no_of_slots` > 0 AND `exclude_days` NOT LIKE '%$dayName%'"; $count = 0; $bookSlot = 0; $result = $conn->query($sql); if ($result->num_rows > 0) { // Array to hold the results $rows = array(); // Fetch data from each row and add it to the array while($row = $result->fetch_assoc()) { $count = $count + 1; if($count > 0){ $isVisible = 'true'; }else{ $isVisible = ''; } $dateTime = DateTime::createFromFormat('H:i:s', $row['time']); $ampmTime = $dateTime->format('h:i A'); if($row['custom_days'] == null){ $rows[] = [ 'id' => $row['dealership_id'], 'maxSlot' => $row['no_of_slots'], 'qss' => $row['qs_capacity'], 'gJob' => $row['gj_capacity'], 'time' => $ampmTime ]; }else{ $rows[] = [ 'id' => $row['dealership_id'], 'maxSlot' => $row['custom_no_of_slots'], 'qss' => $row['qs_capacity'], 'gJob' => $row['gj_capacity'], 'time' => $ampmTime ]; } } // Output the result in JSON format header('Content-Type: application/json'); echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } else { echo json_encode([$rows,"Count" => "$count","isVisible" => "$isVisible"]); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++ } } $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings