芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/rentandbuyrealty.com/ProZigzagbus Web Admin 1.2/getbus.php
fetchData($query); $vendor_id = $_POST['vendor_id']; $fromCity = $_POST['fromCity']; $toCity = $_POST['toCity']; $trip_date = $_POST['journeyDate']; $trip_day_of_week_numeric = date('w', strtotime($trip_date)); // Define an array to map numeric day of the week to its name $days_of_week = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); // Get the day of the week as its name $trip_day_of_week = $days_of_week[$trip_day_of_week_numeric]; $offday_check = "AND FIND_IN_SET('" . $trip_day_of_week . "', bus.offday) = 0"; $currentTimestamp = strtotime(date("H:i:s")); $twoHoursAgoTimestamp = $currentTimestamp + (2 * 60 * 60); // Subtract 2 hours in seconds $twoHoursAgo = date("H:i:s", $twoHoursAgoTimestamp); $sql = " SELECT bp.bus_id, bus.operator_id, bp.bpoint, bp.id AS id_pickup_drop, bp.dpoint, bp.btime AS pick_time, bp.dtime AS drop_time, bp.differncetime As Difference_pick_drop, bus.title, bus.bno, bus.bus_img, bus.bstatus, bus.rate, bus.tick_price, bus.decker, bus.driver_direction, bus.totl_seat, bus.seat_limit, bus.bac, bus.is_sleeper, bus.seat_layout, bus.offday, ( SELECT CASE WHEN COUNT(*) != 0 THEN FORMAT(SUM(total_rate) / COUNT(*), IF(SUM(total_rate) % COUNT(*) > 0, 2, 0)) ELSE bus.rate END FROM tbl_book WHERE bus_id = bp.bus_id AND book_status = 'Completed' AND is_rate = 1 ) AS bus_rate, ( SELECT GROUP_CONCAT(title) FROM tbl_facility WHERE FIND_IN_SET(tbl_facility.id, bus.bus_facility) ) AS bus_facilities, ( SELECT GROUP_CONCAT(img) FROM tbl_facility WHERE FIND_IN_SET(tbl_facility.id, bus.bus_facility) ) AS facility_imgs, IF('" . $trip_date . "' = CURDATE(), bp.btime >= '" . $twoHoursAgo . "', 1) as apply_time_filter, boarding_city.title as boarding_city, drop_city.title as drop_city FROM tbl_board_drop_points as bp JOIN tbl_bus as bus ON bp.bus_id = bus.id JOIN (SELECT title FROM tbl_city WHERE id = " . $fromCity . ") as boarding_city JOIN (SELECT title FROM tbl_city WHERE id = " . $toCity . ") as drop_city WHERE bp.bpoint = " . $fromCity . " AND bus.bstatus = 1 AND bp.dpoint = " . $toCity . " AND bus.operator_id=".$vendor_id." " . $offday_check . ""; $busfetch = $h->queryfire($sql); while($row = $busfetch->fetch_assoc()) { $busId = $row['bus_id']; $query = "SELECT * FROM tbl_book_pessenger WHERE bus_id = $busId AND book_date = '$trip_date'"; $count = $h->executeQuery($query); $lft =$row['totl_seat'] - $count; $pick_datetime = new DateTime($trip_date . ' ' . $row['pick_time']); $drop_datetime = new DateTime($trip_date . ' ' . $row['drop_time']); // Check if the drop time is on the next date if ($drop_datetime < $pick_datetime) { // Drop time is on the next date $pick_date = $pick_datetime->format('Y-m-d'); $next_date = $drop_datetime->modify('+1 day'); $dropdate = $next_date->format('Y-m-d'); } else { // Drop time is on the same date $dropdate = $drop_datetime->format('Y-m-d'); $pick_date = $pick_datetime->format('Y-m-d'); } $bac = $bdata['bac']; $is_sleeper = $bdata['is_sleeper']; if($is_sleeper == 1 && $bac == 1) { $bus_type = 'A/c Sleeper'; } else if($is_sleeper == 1 && $bac == 0) { $bus_type = 'Non A/c Sleeper'; } else if($is_sleeper == 0 && $bac == 1) { $bus_type = 'A/c Seater'; } else { $bus_type = 'Non A/c Seater'; } ?>