@extends('layouts.app')

@section('scripts')
<script src="{{ asset('js/appointments.js') }}"></script>
@endsection

@section('content')


<div class="page-title">
    <div class="row">
        <div class="col-12 col-md-6 order-md-1 order-last">
            <h3>Appointments</h3>
        </div>
    </div>
</div>
<section class="section">
    <div class="card">
        <div class="card-header">
            <h4 class="card-title">Appointments</h4>
        </div>
        <div class="card-body">

            <form onsubmit="showSpinner();">

                <div class="row">
                    <div class="form-group col-md-6">
                        <label>Start Date</label>
                        <input id="startDate" name="startDate" class="form-control datepicker" value="{{ ($filters['oStartDate'] ?? null) }}" required  readonly />
                    </div>
                    <div class="form-group col-md-6">
                        <label>End Date</label>
                        <input id="endDate" name="endDate" class="form-control datepicker"  value="{{ ($filters['oEndDate'] ?? null) }}"  required  readonly />
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-6">
                        <label>Service Type *</label>
                        <select id="serviceType" class="choices multiple-remove form-select" multiple name="serviceTypes[]" required>
                            <option value="">-- Select Service</option>
                            @php $filters['serviceTypes'] = $filters['serviceTypes'] ?? array(); @endphp
                            @foreach($serviceTypes as $serviceType)

                            <option value="{{ $serviceType->typeID }}" {{ in_array($serviceType->typeID,$filters['serviceTypes']) ? 'selected':'' }}>{{ $serviceType->typeID }} - {{ $serviceType->description }}</option>

                            @endforeach
                        </select>
                    </div>

                    <div class="form-group col-md-6">
                        <label>Techinician</label>
                        <select id="employee" class="choices  multiple-remove form-select" multiple name="employee[]">
                            <option value="">-- Select Technician</option>
                            @foreach($employees as $employee)

                            <option value="{{ $employee->employeeID }}" {{ in_array($employee->employeeID,($filters['employee'] ?? array()))  ? 'selected':'' }}>{{ $employee->employeeID }} - {{ $employee->fname }} {{ $employee->lname }}</option>

                            @endforeach
                        </select>
                    </div>
                </div>

                <button class="btn btn-primary" >Search</button>
                <a class="btn btn-dark" href="{{ route('appointments') }}">Clear Filters</a>
                <a id="linkExport" target="_blank" class="btn btn-light" onclick="exportExcel();" ohref="{{ route('appointments') }}?exportPDF=1" >Export to pdf</a><br /><br />

            </form>
            <br />

            @include('reports.appointmentData')
        </div>
    </div>
</section>

@endsection
