@if(session()->has('admin_userid'))
   
@else 
 <script>window.location.href="admin";</script>
@endif

@extends('backend.header')
@section('content')

    <div class="container-fluid">
        <div class="row bg-title">
            <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                <h4 class="page-title">Booking Confirmation List</h4> </div>
        </div>
            @php
                $get_booking =DB::table('booking_now')->get();
                $count = 1;
            @endphp
        <div class="col-sm-12">
            <div class="white-box">
                <div style="display: flex; margin-bottom: 2%;">
                    <h3 class="box-title m-b-0">Parking Providers Details</h3>
                    {{-- <a href="{{'add_parking'}}" class="btn btn-primary" style="margin-left: 77%; z-index:999;" ><i class="fa fa-plus"></i>&nbsp; Add</a> --}}
                </div>
                <div class="table-responsive">
                    <table id="myTable" class="table table-striped">
                        <thead>
                            <tr>
                                <th>S.No</th>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Mobile</th>
                                <th>Address</th>
                                <th>Vehicle</th>
                                <th>Vehicle Reg No</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($get_booking as $booking)
                            <tr>
                                <td>{{$count}}</td>
                                <td>{{$booking->fname}} &nbsp; {{$booking->lname}}</td>
                                <td>{{$booking->email}}</td>
                                <td>{{$booking->mobile}}</td>
                                <td>{{$booking->address}}</td>
                                <td>{{$booking->vehicle}}</td>
                                <td>{{$booking->vehicle_reg}}</td>
                                <td>
                                    <!-- <button class="btn view_booking" id="{{$booking->bookingid}}" data-toggle="modal" data-traget="#view_booking"><i class="fa fa-eye"></i></button> -->

                                    <button class="btn view_booking" id="{{$booking->bookingid}}" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa fa-eye"></i></button>

                                    
                                    <button class="btn" onclick="window.location.href='delete_booking&id={{$booking->bookingid}}'"><i class="fa fa-trash-o"></i></button>
                                </td>
                            </tr>
                            @php
                             $count++   
                            @endphp
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
</div>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myLargeModalLabel">Booking List</h4> </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Postal Code</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="postalcode" name="postalcode">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">SMS Service</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="sms_service" name="sms_service">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Travel</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="travel" name="travel">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Terminal</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="terminal" name="terminal">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Return Terminal</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="return_terminal" name="return_terminal">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Return Flight</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="return_flight" name="return_flight">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Vehicle Make</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="vehicle_make" name="vehicle_make">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Vehicle Model</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="vehicle_model" name="vehicle_model">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Vehicle Color</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="vehicle_color" name="vehicle_color">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Cancel</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="cancel" name="cancel">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Card Name</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="card_name" name="card_name">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Card Number</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="card_number" name="card_number">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Expiry Date</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="expiry_date" name="expiry_date">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">CVC</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="cvc" name="cvc">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                    <div class="col-md-6">
                            <div class="form-group row">
                                <label for="example-text-input" class="col-4 col-form-label">Making Payment</label>
                                <div class="col-8">
                                    <input class="form-control form-control-line" type="text" id="making_payment" name="making_payment">
                                </div>
                            </div>
                        </div>
                    <div class="clear"></div>
                </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger waves-effect text-left" data-dismiss="modal">Close</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->


<button  class="btn btn-primary add-btn" data-toggle="modal" data-target="#view_booking" id="view_booking_modal" style="display:none;"><i class="fa fa-plus"></i></button>

    <script src="assets/plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="assets/plugins/bower_components/datatables/jquery.dataTables.min.js"></script>
    <!-- start - This is for export functionality only -->
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
    <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
    <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>

    <link href="assets/plugins/bower_components/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
    <link href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />
    <script>
        $(document).ready(function() {
            $('#myTable').DataTable();
            $(document).ready(function() {
                var table = $('#example').DataTable({
                    "columnDefs": [{
                        "visible": false,
                        "targets": 2
                    }],
                    "order": [
                        [2, 'asc']
                    ],
                    "displayLength": 25,
                    "drawCallback": function(settings) {
                        var api = this.api();
                        var rows = api.rows({
                            page: 'current'
                        }).nodes();
                        var last = null;
    
                        api.column(2, {
                            page: 'current'
                        }).data().each(function(group, i) {
                            if (last !== group) {
                                $(rows).eq(i).before(
                                    '<tr class="group"><td colspan="5">' + group + '</td></tr>'
                                );
    
                                last = group;
                            }
                        });
                    }
                });
    
                // Order by the grouping
                $('#example tbody').on('click', 'tr.group', function() {
                    var currentOrder = table.order()[0];
                    if (currentOrder[0] === 2 && currentOrder[1] === 'asc') {
                        table.order([2, 'desc']).draw();
                    } else {
                        table.order([2, 'asc']).draw();
                    }
                });
            });
        });
        $('#example23').DataTable({
            dom: 'Bfrtip',
            buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
            ]
        });
        </script>
        <script>
            $('.view_booking').click(function(){
              var id = this.id;
              $.ajax({
                url: 'get_booking_details',
                method: "post",
                data: {bookingid: id,
                _token: '{{ csrf_token() }}'},
                dataType: "json",
                success: function (response) { 
                    var detail = response.details[0];
					
					$('#postalcode').val(detail.postalcode);
                    // alert(detail.postalcode);
					$('#travel').val(detail.travel);

                    if(detail.terminal == 1)
                    {
                        $('#terminal').val("South Terminal");

                    } else if(detail.terminal == 2) {

                        $('#terminal').val("North Terminal");

                    } else{

                        $('#terminal').val("TBC");
                    }

                    if(detail.return_terminal == 1)
                    {
                        $('#return_terminal').val("South Terminal");

                    } else if(detail.return_terminal == 2) {

                        $('#return_terminal').val("North Terminal");

                    } else {

                        $('#return_terminal').val("TBC");
                    }

					$('#return_flight').val(detail.return_flight);
					$('#postalcode').val(detail.postalcode);
					$('#vehicle_model').val(detail.vehicle_model);
					$('#vehicle_color').val(detail.vehicle_color);

                    if(detail.cancel == 1)
                    {
                        $('#cancel').val("Yes");

                    } else{

                        $('#cancel').val("No");

                    }
                    $('#vehicle_make').val(detail.vehicle_make);
                    $('#sms_service').val(detail.sms_service);
                    $('#card_name').val(detail.card_name);
                    $('#card_number').val(detail.card_number);
                    $('#expiry_date').val(detail.expiry_date);
                    $('#cvc').val(detail.cvc);
                    $('#making_payment').val(detail.making_payment);
                    

                    $('#view_booking_modal').click();
                }
            });
          });
       </script>
@endsection