<x-app-layout>

<div class="row mt-2">
    <div class="col">
        <div class="card">
            <div class="card-header">
                <h3 class="page-title">{{ __('Manifest') }}</h3>
            </div>
            <div class="card-body">
                <form method="get">
                    <div class="row">
                        <div class="col-3 form-group">
                            <label class="control-label" for="o">{{ __('Cruise') }}</label>
                            <select name="cruise_id" for="o" class="form-control">
                                @foreach(App\Models\Cruise::all() as $item)
                                    <option value="{{ $item->id }}" @if($item->id == intval(Request::get('cruise_id'))) selected @endif>
                                        {{ $item->name.'-'.$item->cruise_number }}
                                    </option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-3 form-group">
                            <label class="control-label" for="o1">{{ __('Status') }}</label>
                            <select name="status" for="o" class="form-control">
                                    <option value="U" @if(Request::get('status') == "U") selected @endif>
                                                Used
                                    </option>
                                    <option value="O" @if(Request::get('status') == "O") selected @endif>
                                        Open
                                    </option>
                                    
                                    <option value="D" @if(Request::get('status') == "D") selected @endif>
                                        today
                                    </option>
                                    
                            </select>
                        </div>
                        <div class="col-3">
                            <label class="control-label">&nbsp;</label><br>
                            <button class="btn btn-primary" type="submit">{{ __('search') }}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>

<div class="card">
    <div class="card-header">
        <a href="{{ route('cars_reports_export') }}?cruise_id={{$cruise->id}}" class="btn btn-primary float-right mx-2"> {{ __('Export Cars') }}</a>
        <a href="{{ route('image') }}?cruise_id={{$cruise->id}}&status={{Request::get('status')}}" class="btn btn-primary float-right"> export image</a>
        <a href="{{ route('passengers_reports_export') }}?cruise_id={{$cruise->id}}&status={{Request::get('status')}}" class="btn btn-primary float-right"> {{ __('Export Passengers') }}</a>
    </div>


    <div class="card-body">
        <div class="row">
<div class="table-responsive">
             <table class="table table-bordered table-hover">
                 <tr><th>{{ __('Count') }}</th>
                    <th>{{ __('Ticket Number') }}</th>
                    <th>{{ __('Price') }}</th>
                    <th>{{ __('Price_Bags') }}</th>
                    <th>{{ __('Surname') }}</th>
                    <th>{{ __('Full Name') }}</th>
                    <th>{{ __('Gender') }}</th>
                    <th>{{ __('Date of birth') }}</th>
                    <th>{{ __('Place of birth') }}</th>
                    <th>{{ __('Nationality') }}</th>
                    <th>{{ __('Passport No') }}</th>
                    <th>{{ __('Expiry') }}</th>
                    <th>{{ __('NEG PCR YES/NO') }}</th>
                    <th>{{ __('VACC 1ST DOSE/Date') }}</th>
                    <th>{{ __('VACC 2ND DOSE/Date') }}</th>
                    <th>{{ __('DAILY TEMPRATURE LIST') }}</th>
                    <th>{{ __('Phone Number') }}</th>
                    <th>{{ __('Dep Date') }}</th>
                    <th>{{ __('Arv Date') }}</th>
                    <th>{{ __('With Car') }}</th>
                    <th>{{ __('Plate Number') }}</th>
                    <th>{{ __('Chassis Number') }}</th>
                    <th>{{ __('Engine Number') }}</th>
                    <th>{{ __('Green.in.NO') }}</th>
                    <th>{{ __('Room') }}</th>
                    <th>{{ __('Number bags') }}</th>
                    <th>{{ __('Weight bags') }}</th>
                 </tr>
                 @foreach ($tickets as $ticket)
                 <tr>
                    <td></td>
                    <td>{{ $ticket->ticket_number }}</td>
                    <td>{{ FormatPrice($ticket->price) }}</td>
                    <td>{{FormatPrice(optional($ticket->boardingPass)->amount) }}</td>
                    <td>{{ $ticket->lastName }}</td>
                    <td>{{ $ticket->firstName }}</td>
                    <td>{{ $ticket->gender }}</td>
                    <td>{{ $ticket->birth_date }}</td>
                    <td>{{ $ticket->place_of }}</td>
                    <td >{{ $ticket->nationality }}</td>
                    <td>{{ $ticket->passport }}</td>
                    <td>{{ $ticket->expiry_date }}</td>
                    <td></td>
                    <td >{{ $ticket->vacc1n_name }}<br>{{ $ticket->vacc1n_date}}</td>
                    <td>{{ $ticket->vacc2n_name }}<br>{{ $ticket->vacc2n_date}}</td>
                    <td></td>
                    <td dir="ltr">{{ $ticket->phone }}</td>
                    <td>{{ $ticket->segment->cruise->name.' '.$ticket->segment->cruise->departure_date_time  }}</td>
                    <td>{{ $ticket->segment->cruise->name.' '.$ticket->segment->cruise->arrival_date_time  }}</td>
                    <td>{{ $ticket->car? 'Yes': 'No' }}</td>
                   
                    <td>{{$ticket->car?$ticket->car->details['car_number']:'--'}}</td>
    
                    <td>{{$ticket->car?$ticket->car->details['chassis_number']:'--'}}</td>
                    <td>{{$ticket->car &&isset($ticket->car->details['engine_number'])?$ticket->car->details['engine_number']:'--'}}</td>
                    <td>{{$ticket->car&&isset($ticket->car->details['green_insurance_number'])?$ticket->car->details['green_insurance_number']:'--'}}</td>
                    <td>{{$ticket->boardingPass&&$ticket->boardingPass->room?$ticket->boardingPass->room->code:'' }} </td>
                    <td>{{$ticket->boardingPass?$ticket->boardingPass->number_bags:'' }} </td>
                    <td>{{ $ticket->boardingPass?$ticket->boardingPass->weight_bags:''}} </td>
                 </tr>
                 @endforeach
             </table>
             </div>
        </div>
        <div>
            {{$tickets->withQueryString()->links()}}
        </div>



    </div>

</div>
<x-slot name="after_script">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.4.5/jquery-ui-timepicker-addon.min.js"></script>
<script>
                    var app = new Vue({
                    el: '#app',
                    mounted:function(){
                       this.$root.load = false;
                    }
                })
    $('.date').datepicker({
        autoclose: true,
        dateFormat: "{{ config('panel.date_format_js') }}"
      })
</script>
</x-slot>
</x-app-layout>