ok
Direktori : /home2/selectio/public_html/subamangala/admin/backups/ |
Current File : /home2/selectio/public_html/subamangala/admin/backups/bookings-create.php |
<?php include "header.php"; $today_date = date('Y-m-d'); $end_date = date('Y-m-d', strtotime($today_date . ' +45 day')); ?> <?php $pickup_city = $_REQUEST['pickup_city']; $drop_city = $_REQUEST['drop_city']; $journey_date = $_REQUEST['journey_date']; $conditions=""; if(isset($pickup_city) && $pickup_city!="" && $drop_city!=""){ $conditions.=" and (t.from_city=".$pickup_city.") and (t.to_city=".$drop_city.")"; } if(isset($journey_date) && $journey_date!=""){ $conditions.=" and (tbl_trips.trip_status=1 OR tbl_trips.trip_status=2 AND tbl_trips.trip_on_start_date <= '".$journey_date."' AND tbl_trips.trip_on_end_date >= '".$journey_date."' ) and ('".$journey_date."' != CURDATE() OR '".$journey_date."' = CURDATE() and CURTIME() < pickup.time)"; } ?> <div class="content-wrapper" style="background:white;"> <div class="col-lg-12 alerts"> <div id="custom-alerts" style="display:none;"> <div class="alert alert-dismissable"> <div class="custom-msg"></div> </div> </div> <?php if ($error) { ?> <div class="alert alert-danger alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-ban"></i> Error</h4> <?= $error; ?> </div> <?php $error=0;} if ($warning) { ?> <div class="alert alert-warning alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-warning"></i> Warning</h4> <?= $warning; ?> </div> <?php $warning=0;} if ($message) { ?> <div class="alert alert-success alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4> <i class="icon fa fa-check"></i> Success</h4> <?= $message; ?> </div> <?php $message=0; } ?> </div> <div class="clearfix"></div> <section class="content"> <div class="row"> <div class="col-xs-12"> <div> <div class="box-header"> <h3 class="box-title"><b>Create Bookings : </b></h3> </div> <div class="box-body"> <div class="col-lg-12"> <form action="bookings-create.php" enctype="multipart/form-data" method="get" accept-charset="utf-8"> <div class="container"> <div class="row" style="margin: 0px 70px 0px 70px; padding: 15px 20px 15px 20px;background: antiquewhite; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;"> <div class="col-sm-3"> <div class="form-group"> <label class="control-label required" for="pickup_city">Pickup</label> <select name="pickup_city" class="form-control select2" style="width:100%" id="pickup_city" onchange="onchange_city(1)" required="required"> <option value="">--- Select From City ---</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_cities` where status=1 ORDER BY name ASC"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { ?> <option value="<?=$result['id']?>" <?php if(isset($_GET['pickup_city']) && $_GET['pickup_city']==$result['id']){echo "selected";}?>><?=$result['name']?></option> <?php }?> </select> </div> </div> <div class="col-sm-3"> <div class="form-group"> <label class="control-label required" for="drop_city">Dropping</label> <select name="drop_city" class="form-control select2" style="width:100%" id="drop_city" onchange="onchange_city(2)" required="required"> <option value="">--- Select To City ---</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_cities` where status=1 ORDER BY name ASC"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { ?> <option value="<?=$result['id']?>" <?php if(isset($_GET['drop_city']) && $_GET['drop_city']==$result['id']){echo "selected";}?>><?=$result['name']?></option> <?php } ?> </select> </div> </div> <div class="col-sm-3"> <div class="form-group"> <label class="control-label required" for="journey_date">Journey Date</label> <input type="date" name="journey_date" min="<?=date('Y-m-d')?>" max="<?=$end_date?>" value="<?php if(isset($_GET['journey_date']) && $_GET['journey_date']){ echo $_GET['journey_date'];}else{ echo date('Y-m-d');}?>" id="journey_date" class="form-control" required="required" > </div> </div> <div class="col-sm-3"> <div class="form-group" style="padding-top: 24px;"> <button type="submit" id="search_bus" style="width: 100%;" class="btn btn-success">Search</button> </div> </div> </div> </div> </form> <?php if(isset($_GET['pickup_city']) && isset($_GET['drop_city']) && isset($_GET['journey_date']) && $_GET['journey_date']>=$today_date && $_GET['journey_date']<=$end_date){ ?> <div id="trips_available_section" class="row"> <?php $statement = $pdo->prepare("SELECT t.*, tbl_trips.trip_on_start_date,tbl_trips.trip_on_end_date,tbl_trips.trip_status, tbl_trips.id as trip_id,tbl_trips.bus_id, pc.name as pickup_city_name, dc.name as drop_city_name, t.trip_id as trip_ids, tbl_bus_details.bus_name, tbl_bus_details.bus_code, pickup.time as pickup_time, dropping.time as drop_time FROM `tbl_trips_details` t LEFT JOIN tbl_trips ON tbl_trips.id=t.trip_id LEFT JOIN tbl_cities pc ON pc.id=t.from_city LEFT JOIN tbl_cities dc ON dc.id=t.to_city LEFT JOIN tbl_bus_details ON tbl_bus_details.id=tbl_trips.bus_id LEFT JOIN tbl_routes pickup ON pickup.trip_id=tbl_trips.id and pickup.city=t.from_city LEFT JOIN tbl_routes dropping ON dropping.trip_id=tbl_trips.id and dropping.city=t.to_city WHERE tbl_trips.trip_status!=3 ".$conditions." ORDER BY pickup.time"); error_log("SELECT t.*, tbl_trips.trip_on_start_date,tbl_trips.trip_on_end_date,tbl_trips.trip_status, tbl_trips.id as trip_id,tbl_trips.bus_id, pc.name as pickup_city_name, dc.name as drop_city_name, t.trip_id as trip_ids, tbl_bus_details.bus_name, tbl_bus_details.bus_code, pickup.time as pickup_time, dropping.time as drop_time FROM `tbl_trips_details` t LEFT JOIN tbl_trips ON tbl_trips.id=t.trip_id LEFT JOIN tbl_cities pc ON pc.id=t.from_city LEFT JOIN tbl_cities dc ON dc.id=t.to_city LEFT JOIN tbl_bus_details ON tbl_bus_details.id=tbl_trips.bus_id LEFT JOIN tbl_routes pickup ON pickup.trip_id=tbl_trips.id and pickup.city=t.from_city LEFT JOIN tbl_routes dropping ON dropping.trip_id=tbl_trips.id and dropping.city=t.to_city WHERE tbl_trips.trip_status!=3 ".$conditions." ORDER BY pickup.time"); $statement->execute(); $emp_data = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); if($totalData>0){ foreach ($emp_data as $data){ if($data['trip_status']=='2'){ }else{ } // Special Dates and Week End Dates Price Here $statement_special_dates = $pdo->prepare("SELECT * FROM `tbl_special_dates` WHERE date='".$_GET['journey_date']."' and bus_code=".$data['bus_id'].""); $statement_special_dates->execute(); $special_dates_data = $statement_special_dates->fetchAll(PDO::FETCH_ASSOC); $_special_Days_totalData = $statement_special_dates->rowCount(); if($_special_Days_totalData>0){ // (Rate Type) 2-Week End Special Day, 3-Special Day Special Holiday $offer_per_seat=""; if($special_dates_data[0]['rate_type']==2){ if($data['offer_type_2']==1){ $price = "<span style='font-size: 18px; font-weight: 600;'>INR</span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['ticket_amount_2'])."</span>"; }else if($data['offer_type_2']==2){ $offer_price = $data['ticket_amount_2']-$data['offer_amount_2']; $offer_per_seat = "<span style='float: right;color: white;font-weight: 500;background: crimson;font-size: 14px;border-radius: 5px;padding: 0px 10px 0px 10px;'>Offer <i class='fa fa-inr'></i> ".$offer_price." Per Seat</span>"; $price = "<span style='font-size: 18px; font-weight: 600;'>INR <s>".number_format($data['ticket_amount_2'])."</s></span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['offer_amount_2'])."</span>"; } }else if($special_dates_data[0]['rate_type']==3){ if($data['offer_type_3']==1){ $price = "<span style='font-size: 18px; font-weight: 600;'>INR</span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['ticket_amount_3'])."</span>"; }else if($data['offer_type_3']==2){ $offer_price = $data['ticket_amount_3']-$data['offer_amount_3']; $offer_per_seat = "<span style='float: right;color: white;font-weight: 500;background: crimson;font-size: 14px;border-radius: 5px;padding: 0px 10px 0px 10px;'>Offer <i class='fa fa-inr'></i> ".$offer_price." Per Seat</span>"; $price = "<span style='font-size: 18px; font-weight: 600;'>INR <s>".number_format($data['ticket_amount_3'])."</s></span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['offer_amount_3'])."</span>"; } } }else{ $offer_per_seat=""; // Offer Type 1=Default, 2=Offer if($data['offer_type']==1){ $price = "<span style='font-size: 18px; font-weight: 600;'>INR</span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['ticket_amount'])."</span>"; }else if($data['offer_type']==2){ $offer_price = $data['ticket_amount']-$data['offer_amount']; $offer_per_seat = "<span style='float: right;color: white;font-weight: 500;background: crimson;font-size: 14px;border-radius: 5px;padding: 0px 10px 0px 10px;'>Offer <i class='fa fa-inr'></i> ".$offer_price." Per Seat</span>"; $price = "<span style='font-size: 18px; font-weight: 600;'>INR <s>".number_format($data['ticket_amount'])."</s></span> <span style='font-size: 27px; font-weight: 900;'>".number_format($data['offer_amount'])."</span>"; } } date_default_timezone_set('Asia/Kolkata'); $start_time = $data['pickup_time']; $end_time = $data['drop_time']; $start_timestamp = strtotime($start_time); $end_timestamp = strtotime($end_time); if ($end_timestamp < $start_timestamp) { $end_timestamp += 86400; } $time_difference = $end_timestamp - $start_timestamp; $hours = floor($time_difference / 3600); $minutes = floor(($time_difference % 3600) / 60); $seconds = $time_difference % 60; $hr = sprintf("%02d", $hours); $min = sprintf("%02d", $minutes); $trip_hours = "".$hr.":".$min.""; ?> <div class="container"> <div class="row" style="padding-top: 6px;"> <div class="col-md-12"> <div class="card_container"> <div class="row"> <div class="col-md-12"> <span style="float: left;color: darkblue;font-weight: 600;font-size: 20px;"><?=$data['bus_name']?> (<?=$data['bus_code']?>)</span> <?=$offer_per_seat?> </div> </div> <?php $statement_route = $pdo->prepare("SELECT *,(SELECT max(order_no) FROM tbl_routes WHERE city=".$drop_city.") last_order_no FROM `tbl_routes` WHERE trip_id=".$data['trip_ids']." and city=".$pickup_city.""); $statement_route->execute(); $statement_route_result = $statement_route->fetchAll(PDO::FETCH_ASSOC); $start_order_no = $statement_route_result[0]['order_no']; $last_order_no = $statement_route_result[0]['last_order_no']; $statement_mid_cities = $pdo->prepare("SELECT * FROM `tbl_routes` WHERE trip_id=".$data['trip_ids']." and order_no>=".$start_order_no." and order_no<".$last_order_no.""); $statement_mid_cities->execute(); $statement_mid_cities_result = $statement_mid_cities->fetchAll(PDO::FETCH_ASSOC); $where = ''; $if_where = ''; $i=1; foreach($statement_mid_cities_result as $mid_city){ if($i==1){ $where.="(GROUP_CONCAT(points) not REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))"; }else{ $where.=" and (GROUP_CONCAT(points) not REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))"; } if($i==1){ $if_where.="(GROUP_CONCAT(points) REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))"; }else{ $if_where.=" or (GROUP_CONCAT(points) REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))"; } $i++; } ?> <?php $statement_tickets = $pdo->prepare("SELECT *,GROUP_CONCAT(points), if(($if_where),'No','Yes') as seat_status FROM `tbl_tickets` WHERE trip_date='".$journey_date."' AND trip_id=".$data['trip_id']." AND bus_id=".$data['bus_id']." GROUP by seat_id"); $statement_tickets->execute(); $ticket_booked_result = $statement_tickets->fetchAll(PDO::FETCH_ASSOC); $booked_countData = $statement_tickets->rowCount(); $booked_Seat_count = 0; foreach($ticket_booked_result as $booked){ if($booked['seat_status']=="No"){ $booked_Seat_count++; } } ?> <div class="row" style="padding-top: 12px;"> <div class="col-md-8"> <div class="row"> <div class="col-md-4 text-center"> <span style="font-weight: 700; color: #3e3e52; font-size: 22px;"> <?=date('h:i A', strtotime($data['pickup_time']))?><br> </span> </div> <div class="col-md-4 text-center" style="border-bottom: 1px dotted;"> <span style=""><?=$trip_hours?> Hrs</span> </div> <div class="col-md-4 text-center"> <span style="font-weight: 700; color: #3e3e52; font-size: 22px;"> <?=date('h:i A', strtotime($data['drop_time']))?><br> </span> </div> </div> <div class="row"> <div class="col-md-4 text-center"> <span style="font-weight: 700; color: #3e3e52; font-size: 18px;"> <?=$data['pickup_city_name']?> </span> </div> <div class="col-md-4 text-center" > <span style="border-bottom: 1px dotted;"></span> </div> <div class="col-md-4 text-center"> <span style="font-weight: 700; color: #3e3e52; font-size: 18px;"> <?=$data['drop_city_name']?> </span> </div> </div> </div> <div class="col-md-4"> <div class="row"> <div class="col-md-6"> Per Seat from<br> <?=$price?> </div> <div class="col-md-6 text-center"> <?php $statement_seats = $pdo->prepare("SELECT COUNT(id) as bus_total_seat_count FROM `tbl_bus_seats` WHERE bus_id=".$data['bus_id']." and seat_no!='' and seat_no!='D'"); $statement_seats->execute(); $seat_Datas = $statement_seats->fetchAll(PDO::FETCH_ASSOC); $seatDatasCount = $statement_seats->rowCount(); $total_seats = $seat_Datas[0]['bus_total_seat_count']; $statement_tickets = $pdo->prepare("SELECT COUNT(tbl_tickets.id) as booked_ticket_count FROM `tbl_tickets` WHERE trip_date='".$journey_date."' AND from_id=".$data['from_city']." AND to_id=".$data['to_city']." AND trip_id=".$data['trip_id']." AND bus_id=".$data['bus_id'].""); $statement_tickets->execute(); $ticket_Datas = $statement_tickets->fetchAll(PDO::FETCH_ASSOC); $ticketDatasCount = $statement_tickets->rowCount(); $booked_tickets = $ticket_Datas[0]['booked_ticket_count']; $available_seats_count = $total_seats-$booked_Seat_count; ?> <span class="btn btn-primary btn-xs"><span id="" style="font-weight: 600;"><?=$available_seats_count?></span> Seats Available</span><br> <span class="btn btn-info " data-tab="tab<?=$data['trip_id']?>" style="margin-top: 5px;" val="<?=$data['trip_id']?>" onclick="view_seats(<?=$data['trip_id']?>,this)">View Seats</span> </div> </div> </div> </div> <div id="seat_append_section_<?=$data['trip_id']?>" class="seat_append_section"></div> </div> </div> </div> </div> <?php } }else{ ?> <div class="text-center"> <h3 style="color: red;">No Trips Available</h3> </div> <?php } ?> </div> <?php } ?> </div> <br><br><br><br> <div class="clearfix"></div> </div> </div> </div> </div> </section> <script> function onchange_city(city_val){ var d=$('#drop_city').val(); var p=$('#pickup_city').val(); if(p==d){ if(city_val==1){ $('#drop_city').val(''); $('#drop_city').trigger('change'); }else{ $('#pickup_city').val(''); $('#pickup_city').trigger('change'); } } } </script> <script> $("#search_bus").click(function () { get_trips_available(); }); function get_trips_available(){ var pickup_city = $("#pickup_city").val(); var drop_city = $("#drop_city").val(); var journey_date = $("#journey_date").val(); if(pickup_city!="" && drop_city!="" && journey_date!=""){ }else{ alert("Please Choose Pickup City and Drop City and Journey Date") } } $(document).ready(function() { $('#seat_details_form').on('submit', function(e){ console.log("Click And Form Working"); e.preventDefault(); $('#loading-div').show(); $('#content-div').hide(); var formData = new FormData(this); formData.append('type', 'seats_selection'); $.ajax({ url: 'apis/bookings.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { console.log(response); if(response['status']==200){ alert(response['message']); $('#seat_details_form').trigger("reset"); /*window.location.href = 'bookings-payment.php';*/ $('#loading-div').hide(); $('#content-div').show(); }else{ alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); } } }); }); }); </script> <?php include "footer.php"; ?> <!-- Style Starts Here --> <style> .card_container { border-radius: 10px; margin: 15px auto; color: black; border: 1px solid #d9c6c6; padding: 10px; background: beige; box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px; } /* .select{ background: #00dbff !important; color: #2f2c2c; font-weight: 700; } .select:hover { background: #00dbff !important; color: #2f2c2c; font-weight: 700; } td{ width: 40px; padding: 1px; text-align: center; } .span{ width: 35px; text-align: center; background: #f3f2f2; color: black; border-color: #d5c3c3; }*/ </style> <!-- Style Endsss Here --> <!-- View Seats Starts Here --> <script> function view_seats(trip_id){ $(".seat_append_section").empty(); var pickup_city = $("#pickup_city").val(); var drop_city = $("#drop_city").val(); var journey_date = $("#journey_date").val(); var content = $('#seat_append_section_'+trip_id).html(); if(content==''){ $.ajax({ type: 'POST', url: 'api/booking_view_seats.php', data: {pickup_city:pickup_city,drop_city:drop_city,journey_date:journey_date,trip_id:trip_id}, success: function(response) { console.log(response); $('#seat_append_section_'+trip_id).append(response); } }); }else{ $('#seat_append_section_'+trip_id).empty(); } } </script> <!-- View Seats Endsss Here --> <script> /*$(document).ready(function() { $(".name_of_seat_numbers").on("change", function() { var checkedCount = $(".name_of_seat_numbers:checked").length; if (checkedCount>5) { $(this).prop("checked", false); } SeatNumbers(); }); }); $(document).ready(function() { $('.span').click(function () { var qty = Number($(this).val()); var span_val = $(".span").text(); console.log("Seat Value: "+$(this).text()); if($(this).hasClass('select')) { var rowCount = $('.select').length; $(this).removeClass("select"); console.log("Selected Seats: "+rowCount); } else { $(this).addClass("select"); var rowCount = $('.select').length; console.log("Selected Seats: "+rowCount); if(rowCount>5){ alert("Maximum No of Seats Allowed is 5") $(this).removeClass("select"); console.log("Selected Seats: "+rowCount); }else{ $(this).addClass("select"); console.log("Selected Seats: "+rowCount); } } SeatNumbers(); SelectCount(); SeatName(); }); }); function SelectCount(){ var rowCount = $('.select').length; $("#total_no_seats").val(rowCount); console.log("Selected Seats: "+rowCount); } function SeatNumbers(){ var checkValues = $('.seat_available:checked').map(function(){ return $(this).val(); }).get(); console.log("Value: " +checkValues); $("#seat_ids").val(checkValues); } function SeatName(){ var SeatValues = $('.select').map(function(){ return $(this).text(); }).get(); console.log("SeatValues Value: " +SeatValues); console.log($(this).text()); $("#name_of_the_seats").text(SeatValues); $("#name_of_seats").val(SeatValues); grand_total(); } function grand_total(){ var ticket_rate = Number($("#ticket_rate").val()); console.log("Ticket Rate: "+ticket_rate); var tot=0; $(".select").each(function(){ var selectedSeats = $('.span').length; console.log("Seat Count: "+selectedSeats); tot+=ticket_rate; }); $("#grand_total").text(tot.toFixed(2)); console.log("Grand Total: "+tot); } $(document).ready(function() { // Disable Female Seats and Checkbox $('.female').prop('disabled', true); // Disable Male Seats and Checkbox $('.male').prop('disabled', true); // Disable Booked Check Box $('.disable').prop('disabled', true); // Available Seat Count var availableSeatCount = $('.span').length; $("#availableSeatCount").text(availableSeatCount); $('.only_show').prop('disabled', true); });*/ </script>