ok
Direktori : /home2/selectio/www/subamangala/admin/api/ |
Current File : /home2/selectio/www/subamangala/admin/api/dashboard_get_bus_details.php |
<?php ob_start(); session_start(); include "../config/config.php"; date_default_timezone_set("Asia/Kolkata"); //India time (GMT +5:30) $date = date('Y-m-d'); $response = array(); $conditions = ""; $conditions1 = ""; if(isset($_POST['bus_id']) && $_POST['bus_id']!=0 && $_POST['bus_id']!=''){ $conditions.=" and tbl_tickets.bus_id=".$_POST['bus_id']; } if(isset($_POST['trip_date']) && $_POST['trip_date']!=0 && $_POST['trip_date']!=''){ $conditions.=" and tbl_tickets.trip_date='".$_POST['trip_date']."'"; } if(isset($_POST['bus_id']) && $_POST['bus_id']!="" && $_POST['bus_id']!=0){ $conditions1.=" and tbl_bus_details.id=".$_POST['bus_id']; $statement_bus_seats = $pdo->prepare("SELECT * FROM `tbl_bus_details` WHERE status=1 $conditions1"); $statement_bus_seats->execute(); $bus_seats_query = $statement_bus_seats->fetchAll(PDO::FETCH_ASSOC); $bus_seats_totalFiltered = $statement_bus_seats->rowCount(); $total_bus_seats_count = $bus_seats_query[0]['bus_seats']; }else{ $total_bus_seats_count = 0; } $statement = $pdo->prepare("SELECT * FROM `tbl_tickets` WHERE status=1 and block_seats=0 $conditions GROUP BY seat_no"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalFiltered = $statement->rowCount(); $blocked_seats = $pdo->prepare("SELECT * FROM `tbl_tickets` WHERE status=1 and block_seats=1 $conditions"); $blocked_seats->execute(); $blocked_query = $blocked_seats->fetchAll(PDO::FETCH_ASSOC); $blocked_row_count = $blocked_seats->rowCount(); if($totalFiltered>0) { $total_booked_seats = $totalFiltered; }else{ $total_booked_seats = 0; } $available_seats_count = $total_bus_seats_count - $total_booked_seats; $datas[] = array('total_bus_seats_count'=>$total_bus_seats_count,'total_booked_seats'=>$total_booked_seats,'total_available_seats'=>$available_seats_count,'total_blocked_seats'=>$blocked_row_count); echo json_encode($datas); ?>