<div wire:ignore.self class="modal fade" tabindex="-1" role="dialog" id="theModalWorkPermit" data-bs-focus="false">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-header bg-primary">
                <h5 class="modal-title">
                <b>Solicitud</b> |
                @if  ($work_permit_id > 0)
                    {{ $first_name }} {{ $last_name }}

                @endif
                </h5>
                <h6 class="text-center text-warning" wire:loading>ESPERE UN MOMENTO POR FAVOR</h6>
            </div>
        <div class="modal-body">
            <span class="b-r-4 m-t-5 m-r-0 py-1 px-2 top-0 end-0 p-absolute m-r-5 {{ $status == 0 ? 'bg-warning' : ($status == 1 ? 'bg-success' : 'bg-danger') }}">
                {{ DataTypeStatusStandard($status) }}
                <i class="fas {{ $status == 0 ? 'fa-clock' : ($status == 1 ? 'fa-check' : 'fa-times') }}"></i>
            </span>
            <span class="b-r-4 m-t-5 m-r-5 py-1 px-2 top-0 start-0 p-absolute">
                <i class="fas fa-calendar-alt"></i>
                {{ \Carbon\Carbon::parse($solicitation_date)->day }} de
                {{ \Carbon\Carbon::parse($solicitation_date)->monthName }} de
                {{ \Carbon\Carbon::parse($solicitation_date)->year }}
            </span>
            <div class="row m-t-30">
                <div class="col-sm-12 col-md-12">
                    <p class="display-6 text-center">
                        <span class="f-w-700"> {{ $type_work_permit_name}}</span>
                    </p>
                    <h5 class="f-w-300 text-center">{{ $register_code}} </h5>
                </div>
            </div><!-- row -->
            <hr>
            <div class="row">
                <div class="col-sm-12 col-md-12">

                </div>
            </div>
            <div class="row">
                <div class="col-sm-12 col-md-6">
                    <div class="row box-support">
                        <div class="col-sm-12 col-md-12 d-flex justify-content-center align-items-center flex-wrap">
                            @if ($support_required == 0)
                                <span class="badge badge-info px-4 py-2 fs-6 text-break">No requiere soporte</span>
                            @else
                                @if ($support_document != NULL)
                                    @switch($status_support_document)
                                        @case(1)
                                            <span class="badge badge-success px-4 py-2 fs-6 text-break">
                                                Documento de soporte Aprobado <i class="fa fa-check"></i>
                                            </span>
                                        @break
                                        @case(2)
                                            <span class="badge badge-danger px-4 py-2 fs-6 text-break">
                                                Documento de soporte Rechazado <i class="fa fa-times"></i>
                                            </span>
                                        @break
                                        @case(3)
                                            <span class="badge badge-warning px-4 py-2 fs-6 text-break">
                                                Esperando correción de documento de soporte <i class="fa fa-clock"></i>
                                            </span>
                                        @break
                                        @default
                                            <span class="badge badge-warning px-4 py-2 fs-6 text-break">
                                                El documento esta pendiente de aprobación <i class="fa fa-clock"></i>
                                            </span>
                                    @endswitch
                                @else
                                    <span class="badge badge-warning px-4 py-2 fs-6 text-break">
                                        Esperando documento de soporte <i class="fa fa-clock"></i>
                                    </span>
                                @endif
                            @endif

                        </div>
                        @if ($support_required == 1)
                            @if ($support_document != null)
                                <a href="{{ asset('storage/users/'.$employee_id.'/work_permits/'.$support_document) }}"
                                target="_blank"
                                class="w-100 text-center btn fs-6 text-primary">
                                    <i class="fas fa-file-download"></i>
                                    Ver documento de soporte
                                </a>

                                <div class="col-sm-12 col-md-12 d-flex justify-content-center align-items-center my-3">
                                    @if ($status_support_document == 3 ||  $status_support_document == 0)
                                        <button wire:click.prevent=SupportDocumentAction('{{ $work_permit_id }}','1') class="btn btn-success btn-sm mx-1">Aprobar</button>
                                        <button onclick="ConfirmWorkPermitAction('{{ $work_permit_id }}','2')" class="btn btn-danger btn-sm mx-1">Rechazar</button>
                                        <button onclick="ConfirmWorkPermitAction('{{ $work_permit_id }}','3')" class="btn btn-warning btn-sm mx-1">Solicitar Correción</button>
                                    @endif
                                </div>
                            @endif
                        @endif
                    </div><!-- row -->
                </div><!-- col-md-6 -->
                <div class="col-sm-12 col-md-6">
                    <label class="fs-6"><span class="f-w-700">Fecha de Salida:<span> {{ \Carbon\Carbon::parse($start_date)->day }} de
                        {{ \Carbon\Carbon::parse($start_date)->monthName }} de
                        {{ \Carbon\Carbon::parse($start_date)->year }} a las
                        {{ \Carbon\Carbon::parse($start_date)->format('g:i A') }} </label>

                    <label class="fs-6"><span class="f-w-700">Fecha de Regreso:<span> {{ \Carbon\Carbon::parse($end_date)->day }} de
                        {{ \Carbon\Carbon::parse($end_date)->monthName }} de
                        {{ \Carbon\Carbon::parse($end_date)->year }} a las
                        {{ \Carbon\Carbon::parse($end_date)->format('g:i A') }} </label>
                    <hr class="m-t-30">
                    @if ($observations != NULL)
                        <label class="fs-6"><span class="f-w-700">Observaciones:<span> {{ $observations }} </label>
                    @else
                        <label class="fs-6"><span class="f-w-700">Observaciones:<span> No hay observaciones </label>
                    @endif

                    @if ($status != 0)
                        <hr class="m-t-30">
                        <label class="fs-6"><span class="f-w-700"><span> {{ DataTypeStatusStandard($status) }} por {{ FullNameUser($reviewed_by) }}</label>
                        @if ($status == 2)
                            <br>
                            <label class="fs-6"><span class="f-w-700">Motivo de rechazo:<span> {{ $rejected_reason == NULL ? 'No hay motivo de rechazo' : $rejected_reason }} </label>
                        @endif
                    @endif
                </div>
            </div><!-- row -->

        </div>
        @include('livewire.loading.component') <!--- component loading ,en targetLoading se coloca el nombre del metodo que se esta cargando --->
        <div class="modal-footer">
            <button type="button" class="btn btn-outline-primary" wire:click.prevent="resetUIWP()" data-bs-dismiss="modal">CERRAR</button>
            @if( $work_permit_id > 0 && $status == 0)
                <button
                    type="button"
                    class="btn btn-danger close-modal"
                    onclick="ConfirmWorkPermitAction('{{ $work_permit_id }}','2','reject')">
                    RECHAZAR SOLICITUD <i class="fas fa-times"></i>
        </button>
                <button type="button"
                    class="btn btn-success close-modal" wire:click.prevent="WorkPermitAction({{ $work_permit_id }},'1')">
                    APROBAR SOLICITUD <i class="fas fa-check"></i>
                </button>
            @endif
        </div>
    </div>
</div>
</div>

