ok

Mini Shell

Direktori : /home2/selectio/www/subamangala/admin/api/
Upload File :
Current File : /home2/selectio/www/subamangala/admin/api/blocking_view_seats.php

<?php 
ob_start();
session_start();
include "../config/config.php";



$pickup_city = $_REQUEST['pickup_city'];
$drop_city = $_REQUEST['drop_city'];
$journey_date = $_REQUEST['journey_date'];
$trip_id = $_REQUEST['trip_id'];
$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)";
}
if(isset($trip_id) && $trip_id!=""){
    $conditions.=" and tbl_trips.id=".$trip_id."";
}


    $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, 
                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){ 
                            
                            
                        // Special Dates and Week End Dates Price Here
                        
                        $statement_special_dates = $pdo->prepare("SELECT * FROM `tbl_special_dates` WHERE date='".$journey_date."'");
                        $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
                            if($special_dates_data[0]['rate_type']==2){
                                if($data['offer_type_2']==1){
                                    
                                    $ticket_amount = $data['ticket_amount_2'];
                                    $offer_amount = $data['offer_amount_2'];
                                    
                                }else if($data['offer_type_2']==2){
                                    
                                    $ticket_amount = $data['ticket_amount_2'];
                                    $offer_amount = $data['offer_amount_2'];
                                    
                                }
                            }else if($special_dates_data[0]['rate_type']==3){
                                if($data['offer_type_3']==1){
                                    
                                    $ticket_amount = $data['ticket_amount_3'];
                                    $offer_amount = $data['offer_amount_3'];
                                    
                                    
                                }else if($data['offer_type_3']==2){
                               
                                     $ticket_amount = $data['ticket_amount_3'];
                                    $offer_amount = $data['offer_amount_3'];
                                    
                                    
                                }
                            }
                            }else{
                            if($data['offer_type']==1){
                                    
                                    $ticket_amount = $data['ticket_amount'];
                                    $offer_amount = $data['offer_amount'];
                                    
                                    
                            }else if($data['offer_type']==2){
                               
                                     $ticket_amount = $data['ticket_amount'];
                                    $offer_amount = $data['offer_amount'];
                                    
                                    
                                }
                        }
                        ?>
                        
                        
                       
                        
                      
                                
                                <form method="post" id="blocking_seats_create" action="">
                                    
                                    
                                    
                        <?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=".$trip_id." 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=".$trip_id." 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); 
                                        $items = array();
                                        foreach($statement_mid_cities_result as $mid_city){
                                            $items[] = $mid_city['city']; 
                                            
                                        }
                                        $points = implode(',', $items);
                            ?>
                                
                         
                                    <div id="seat_append_section_<?=$data['trip_id']?>" >
                                        <div class="row" style="padding-top: 25px;">
                                        
                                        
                                        <div class="col-md-8" style="">
                                    
                                <div class="row">
                                    <div class="col-md-12" style="margin-left: 26%;">
                                      <table>  
                                      
                            <?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=".$trip_id." 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=".$trip_id." 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 = '';
                                        $i=1;
                                        foreach($statement_mid_cities_result as $mid_city){
                                            
                                            $where.= "";
                                            
                                            if($i==1){
                                                $where.="(GROUP_CONCAT(points) REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))";
                                            }else{
                                                $where.=" or (GROUP_CONCAT(points) REGEXP CONCAT('[[:<:]]','".$mid_city['city']."','[[:>:]]'))";
                                            }
                                            
                                       $i++; }
                            ?>
                                        <?php
                                        
                                        $statement_tickets = $pdo->prepare("
                                        SELECT *,GROUP_CONCAT(points),
    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");
    
    error_log("SELECT *,GROUP_CONCAT(points),
    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();
                                        $result = $statement_tickets->fetchAll(PDO::FETCH_ASSOC); 
                                        
                                        
                                        
                                        
                                        
                                        
                                            $statement = $pdo->prepare("SELECT * FROM `tbl_bus_seats` WHERE bus_id=".$data['bus_id']."");
                                            $statement->execute();
                                            $datas = $statement->fetchAll(PDO::FETCH_ASSOC);
                                            $totalData = $statement->rowCount();
                                            $i=1;
                                            foreach($datas as $data_bus){
                                                
                                            $style_class = "span";
                                            $title = "Available";
                                            $disable = "seat_available";
                                            
                                            
                                            
                                            
                                            
                                            foreach($result as $res){
                                                if($res['seat_id']==$data_bus['id']){
                                                    
                                                    
                                                if($res['seat_status']=="No"){
                                                    if($res['gender']=="M"){
                                                        $style_class = "male";
                                                        $title = "Male : Booked";
                                                        $disable = "disable";
                                                    }else if($res['gender']=="F"){
                                                        $style_class = "female";
                                                        $title = "Female : Booked";
                                                        $disable = "disable";
                                                    }
                                                }   
                                                    
                                                    
                                                }
                                            }
                                                
                                                
                                            
                                            if($data_bus['seat_no']==""){
                                                $seat = "<td>&nbsp;</td>";
                                            }else{
                                                $seat = "<td>
                                                        <input class='form-check-input name_of_seat_numbers ".$disable."' type='checkbox' value='".$data_bus['id']."' id='seat_".$data_bus['id']."' style='display: none;'>
        										        <label class='form-check-label' for='seat_".$data_bus['id']."'><span value='".$data_bus['id']."' data-tooltip='".$title."' class='btn btn-xs title ".$style_class."' style=''>".$data_bus['seat_no']."</span></label> 
        										        </td>";
                                            }
                                            if($i==1){
                                                $seat = "<td><img src='icons/steering-wheel.png' style='width: 18px; rotate: -90deg;'></td>";
                                            }
                                            
                                            
                                            if($i%11==1 || $i==1){
                                                echo "<tr>";
                                            }
                                            
                                            echo $seat;
                                            
                                            if($i%11==0){
                                                echo "</tr>";
                                            }
                                            
                                        ?>
                                
                                        <?php $i++; } ?>
                                        </table>
                                    </div>
                                </div>
                                
                                
                                        
                                        
                                        <div class="row" style="padding-top: 10px;">
                                            <div class="col-md-12" style="text-align: center;display: flex;margin-left: 35%;padding-top: 10px;">
                                                
                                                
                                                <span style="display: flex;"><h6 style="background: #f3f2f2; color: #f3f2f2;padding: 0px 10px 20px 10px;height: 0px; border: 1px solid #877a7a;"></h6>&nbsp;<b style="padding-top: 10px;">Available</b></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <span style="display: flex;"><h6 style="background: #00dbff; color: #00dbff; padding: 0px 10px 20px 10px;height: 0px; border: 1px solid #877a7a;"></h6>&nbsp;<b style="padding-top: 10px;">Selected</b></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <span style="display: flex;"><h6 style="background: blue;color: blue;padding: 0px 10px 20px 10px;height: 0px; border: 1px solid #877a7a;"></h6>&nbsp;<b style="padding-top: 10px;">Male</b></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <span style="display: flex;"><h6 style="background: deeppink;color: deeppink;padding: 0px 10px 20px 10px;height: 0px; border: 1px solid #877a7a;"></h6>&nbsp;<b style="padding-top: 10px;">Female</b></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                            </div>
                                        </div>
                                        
                                        
                                        </div>
                                        
                                        
                                        
                                                <!-- General Details Here -->
                                                <input type="hidden" name="passenger_info">
                                                
                                                       <input type="hidden" name="mid_cities" value="<?=$points?>">
                                                <!-------- Trip Journey Date Details Starts Here -------->
                                                 <input type="hidden" name="bus_id" value="<?=$data['bus_id']?>">
                                                 <input type="hidden" name="trip_id" value="<?=$data['trip_id']?>">
                                                 <input type="hidden" name="trip_date" value="<?=$journey_date?>">
                                                 <input type="hidden" name="pickup_city" value="<?=$data['from_city']?>">
                                                 <input type="hidden" name="drop_city" value="<?=$data['to_city']?>">
                                                
                                                <!-- Journey Date Seat Details Here -->
                                                 <input type="hidden" name="seat_ids" id="seat_ids">
                                                 <input type="hidden" name="seat_numbers" id="name_of_seats">
                                                 <input type="hidden" name="seat_amt" id="ticket_rate" value="<?=$ticket_amount?>">
                                                 <input type="hidden" name="total_no_seats" id="total_no_seats">
                                                 <input type="hidden" name="offer_ticket_amt" id="offer_ticket_amt" value="<?=$offer_amount?>"
                                                 
                                                <!-------- Trip Journey Date Details Endsss Here --------> 
                                                 
                                                 
                                                <!-- Trip Return Date Details Here --> 
                                                
                                                
                                                
                                                
                                        <div class="col-md-4" id="points_section" style="display: none;">
                                            <div class="form-group">
                                                <label class="control-label required" for="remarks">Remarks</label>
                                                <textarea class="form-control" name="remarks" rows="6"></textarea>
                                            </div>
                                            <div class="form-group">
                                                <label class="control-label required" for="gender">Gender</label>
                                                <select class="form-control" name="gender">
                                                    <option value="M">Male</option>
                                                    <option value="F">Female</option>
                                                </select>
                                            </div>
                                            
                                            <div class="col-md-6" hidden>
                                                Seat(s):
                                            </div>
                                            <div class="col-md-6" hidden>
                                                <b>&nbsp;<span id="name_of_the_seats"></span></b>
                                            </div>
                                            <!--<div class="col-md-6">
                                                Fare:
                                            </div>
                                            <div class="col-md-6">
                                                <b><i class="fa fa-inr"></i> <span id="grand_total">0.00</span></b>
                                            </div>-->
                                            
                                            
                                            <div class="form-group" style="float: right;padding-top: 10px;">
                                                <button type="sumbit" id="submit" class="btn btn-warning">Submit</button>
                                            </div>
                                            
                                        </div>
                                        
                                        
                                    </div>
                                    </div>
                                        
                                
                                </form>
                                
                 
                        
                        

<?php } }else{   ?>
<?php }  ?>


<script>
$(document).ready(function() {
$(".name_of_seat_numbers").on("change", function() {
    
    
    var checkedCount = $(".name_of_seat_numbers:checked").length;
    
    if(checkedCount!=0){
        $("#points_section").css({
          'display': 'block'
        });
    }else if(checkedCount==0){
        $("#points_section").css({
          'display': 'none'
        });
    }
    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);
  
  $('.only_show').prop('disabled', true);
});
</script>




<style>
.title::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: black;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.3s ease-in-out;
}

.title:hover::after {
  visibility: visible;
  opacity: 1;
}
.male{
    cursor: default;
    background: blue;
    color: white;
    font-weight: 600;
    width: 35px;
    text-align: center;
}
.male:hover{
    cursor: default;
    background: blue;
    color: white;
    font-weight: 600;
}
.female{
    background: deeppink;
    color: white;
    font-weight: 600;
    cursor: default;
    width: 35px;
    text-align: center;
}
.female:hover{
    background: deeppink;
    color: white;
    font-weight: 600;
    cursor: default;
}
li{
    text-decoration: none;
}
    .select{
        background: #00dbff !important;
        color: #2f2c2c;
        font-weight: 700;
    }
    .select:hover {
    background: #00dbff !important;
    color: #2f2c2c;
    font-weight: 700;
    }
.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;
}
td{
        width: 40px;
        padding: 1px;
        text-align: center;
    }
    .span{
        width: 35px;
        text-align: center;
        background: #f3f2f2;
        color: black;
        border-color: #d5c3c3;
    }
</style>

<style>
.limited-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    
  }
    .custom-select-b {
  position: relative;
  width: 100%;
}

.select-styled-b {
    padding: 8px 5px 5px 12px;
    background-color: white;
    font-size: 12px;
    font-weight: 500;
    font-family: sans-serif;
    border: 1px solid #ccc;
    cursor: pointer;
}

.select-options-b {
  position: absolute;
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: #f1f1f1;
  border: 1px solid #ccc;
  display: none;
  width: 100%;
  max-height: 150px;
  /*overflow-y: auto;*/
  overflow-x: hidden;
}

.select-option-b {
  padding: 8px;
}

.select-option-b:hover {
  background-color: #ddd;
}


.custom-select-d {
  position: relative;
  width: 100%;
}

.select-styled-d {
    padding: 8px 5px 5px 12px;
    background-color: white;
    font-size: 12px;
    font-weight: 500;
    font-family: sans-serif;
    border: 1px solid #ccc;
    cursor: pointer;
}

.select-options-d {
  position: absolute;
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: #f1f1f1;
  border: 1px solid #ccc;
  display: none;
  width: 100%;
  max-height: 150px;
  overflow-x: hidden;
}

.select-option-d {
  padding: 8px;
}

.select-option-d:hover {
  background-color: #ddd;
}

</style>
<script>
$('#go_to_payment').click(function() {
    var boarding_point = $('#boarding_point').val();
    var dropping_point = $('#dropping_point').val();
    
    if(boarding_point=='' || dropping_point==''){
        alert("Please Choose Boarding && Dropping Points")
    }
    
  });

$(document).ready(function() {
  $('#boarding_point').hide();
  $('#dropping_point').hide();



// Boarding Points Here
  $('#boarding_point option').each(function() {
    var value = $(this).val();
    var text = $(this).text();
    var quick_address = $(this).data('address');
    var row = `<div class="row select-option-b" data-value="` + value + `" style="border-bottom: 1px solid #dbd1d1;">
                <div class="col-md-12" style="margin-left: 15px;">
                <b>`+ text + `</b>
                </div>
                <div class="col-md-12" style="margin-left: 18px;">
               <span style="font-size: 11px; font-weight: 500; font-family: 'Source Sans Pro';"> `+ quick_address +`</span>
                </div>
            </div>`;                
    $('.select-options-b').append(row);
  });

$('.select-styled-b').click(function(e) {
    e.stopPropagation();
    $('.select-options-b').toggle();
  });

$('.select-option-b').click(function() {
    var value = $(this).data('value');
    var text = $(this).text();
    $('#boarding_point').val(value);
    $('.select-styled-b').text(text);
    $('.select-options-b').hide();
  });

$(document).click(function() {
    $('.select-options-b').hide();
  });
  
// Dropping Points Here
  $('#dropping_point option').each(function() {
    var value = $(this).val();
    var text = $(this).text();
    var quick_address = $(this).data('address');
    var row = `<div class="row select-option-d" data-value="` + value + `" style="border-bottom: 1px solid #dbd1d1;">
                <div class="col-md-12" style="margin-left: 15px;">
                <b>`+ text + `</b>
                </div>
                <div class="col-md-12" style="margin-left: 18px;">
               <span style="font-size: 11px; font-weight: 500; font-family: 'Source Sans Pro';"> `+ quick_address +`</span>
                </div>
            </div>`;                
    $('.select-options-d').append(row);
  });

$('.select-styled-d').click(function(e) {
    e.stopPropagation();
    $('.select-options-d').toggle();
  });

$('.select-option-d').click(function() {
    var value = $(this).data('value');
    var text = $(this).text();
    $('#dropping_point').val(value);
    $('.select-styled-d').text(text);
    $('.select-options-d').hide();
  });

$(document).click(function() {
    $('.select-options-d').hide();
  });
});
</script>
<script>
    $(document).ready(function() {
   $('#blocking_seats_create').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', 'blocking_seats');
                    $.ajax({
                            url: 'apis/blocking_seats.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']);
                                     $('#blocking_seats_create').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 $pdo = null; ?>

Zerion Mini Shell 1.0