<x-app-layout>
    <x-slot name="header">
        <div class="row">
            <div class="col-6">
                <h4 class="" title><i class="circular icon fa fa-list"></i> {{ __('Refunds')  }} </h4>
            </div>
        </div>
    </x-slot>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <form method="get">
                        <div class="row">
                            <div class="col-3 form-group">
                                <label class="control-label" for="from">{{ __('From') }}</label>
                                <input type="date"  name="from" for="from" class="form-control date" value={{ old('from', Request::get('from', date('Y-m-d')))}}>
                            </div>
                            <div class="col-3 form-group">
                                <label class="control-label" for="to">{{ __('To') }}</label>
                                <input type="date"  name="to" for="to" class="form-control date" value={{ old('to', Request::get('to', date('Y-m-d')))}}>
                            </div>
                            @if(auth()->user()->isAdmin())
                            <div class="col-3 form-group">
                                <label class="control-label" for="o">{{ __('Office') }}</label>
                                <select name="office_id" for="o" class="form-control">
                                    @foreach(App\Models\Office::all() as $office)
                                        <option value="{{ $office->id }}" @if($office->id ===intval(Request::get('office_id'))) selected @endif>
                                            {{ $office->name }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                            @endif
                            <div class="col-3">
                                <label class="control-label">&nbsp;</label><br>
                                <button class="btn btn-primary" type="submit">{{ __('filter by date') }}</button>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
        </div>  
    </div>
      <div class="card">
        <div class="card-header">
            <a href="{{ route('refunds_export',Request::all()) }}" class="btn btn-primary float-right"> {{ __('Export Excel') }}</a>
        </div>
    
        <div class="card-body">
            <div class="row">
                 <table class="table table-bordered table-hover refund-table">
                     <tr>
                        <th>{{ __('subject') }}</th>
                        <th>{{ __('amount') }}</th>
                        <th>{{ __('created_at') }}</th>
                        <th>{{ __('Status') }}</th>
                        <th>{{ __('Office') }}</th>
                        <th>{{ __('Action') }}</th>

                     </tr>
                   
                        @foreach ($refunds as $refund)
                                    <tr>
                                        <td>{{$refund->ticket->ticket_number }}</td>
                                       <td>{{ formatPrice($refund->amount) }}</td>
                                        <td>{{ $refund->created_at->format('Y/m/d') }}</td>
                                        <td>{{ $refund->status}}</td>
                                        <td>{{ $refund->ticket->segment->booking->office->name}}</td>
                                        <td>
                                                
                                            @if($refund->status ==App\Models\Refund::STATUS_PENDING)
                                                <a  href="{{ route('refunds.update', $refund->id) }}" class="refund-link btn btn-success btn-sm"> <i class="fa fa-dollar-sign"></i> Refund </a>

    
                                            @else
                                                <a  href="{{ route('refunds.show', $refund->id) }}" class="print-link btn btn-info btn-sm"> <i class="fa fa-print"></i> Print </a>


                                            @endif
                                        </td>

                                       
                                    </tr>   
                        @endforeach
                 </table>
                 
            </div>
            <div>
                {{$refunds->withQueryString()->links()}}
            </div>
    
    
    
        </div>
    </div>

    <x-slot name="after_script">
        <script>
                var app = new Vue({
                    el: '#app',
                    mounted:function(){
                        this.$root.load = false;
                    }
                })
        </script>
        
    </x-slot>

</x-app-layout>
