<div>
    @component('common.breadcrumb', ['addBtn' => false, 'permission_create' => 'Employee_contracts_index',
        'breadcrumb_show' => $breadcrumb_show])
        @slot('breadcrumb_title')
            <h3>{{ $componentName }} | {{ $pageTitle }}</h3>
        @endslot
        <li class="breadcrumb-item">Empleado</li>
        <li class="breadcrumb-item active">Contratos</li>
    @endcomponent
    <div class="container-fluid">
        <div class="row layout-top-spacing">
            <div class="col-sm-12">
                <div class="card">
                    <div class="card-body">
                        <div class="card-header">
                            <h4>Contratos <b> | {{ $first_name }} {{ $last_name }}</b></h4>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row justify-content-between file-content mb-2">
            <div class="col-lg-4 col-md-4 col-sm-12">
                <div class="form-inline">
                    <div class="form-group d-flex mb-0"><i class="fa fa-search"></i>
                        <input class="form-control-plaintext" type="text" wire:model="search" placeholder="Buscar...">
                    </div>
                </div>
            </div>
            @if (isset($count_reg))
                <div class="col-lg-4 col-md-4 col-sm-12">
                    <p class="p-l-20">Total Contratos: {{ $count_reg }}</p>
                </div>
            @endif

        </div>
    </div><!-- container-fluid -->
    <div class="container-fluid">
        <div class="row layout-top-spacing">
            <div class="col-sm-12">
                @if ($count_reg > 0)
                    @foreach ($contracts_user as $item)
                        <div class="card">
                            <div class="card-body">
                                <div class="card-title">
                                    <h6 class="d-inline">Nombre del Contrato: </h6>
                                    <p class="d-inline float-right">{{ $item->name }}</p>
                                </div>
                                <div class="card-subtitle mb-2 text-muted">
                                    <h6 class="d-inline">Tipo de Contrato: </h6>
                                    <p class="d-inline float-right">{{ DataTypeContract($item->type) }}</p>
                                    <h6 class="d-inline"> - | - </h6>
                                    <h6 class="d-inline">Subtipo de Contrato: </h6>
                                    <p class="d-inline float-right">{{ DataSubTypeContract($item->sub_type) }}</p>
                                </div>
                                <div class="card-content">
                                    <h6 class="d-inline">Descripción: </h6>
                                    <p class="d-inline float-right">{{ $item->description }}</p>
                                    <hr class="my-2">
                                    <h6 class="d-inline">Fecha de Inicio: </h6>
                                    <p class="d-inline float-right">
                                        {{ \Carbon\Carbon::parse($item->start_date)->day }} de
                                        {{ \Carbon\Carbon::parse($item->start_date)->monthName }} de
                                        {{ \Carbon\Carbon::parse($item->start_date)->year }}</p>
                                    <h6 class="d-inline"> || </h6>
                                    <h6 class="d-inline">Fecha de Finalización: </h6>
                                    <p class="d-inline float-right">{{ \Carbon\Carbon::parse($item->end_date)->day }}
                                        de {{ \Carbon\Carbon::parse($item->end_date)->monthName }} de
                                        {{ \Carbon\Carbon::parse($item->end_date)->year }}</p>
                                    <hr class="my-2">
                                    <h6 class="d-inline">Fecha de Creación: </h6>
                                    <p class="d-inline float-right">
                                        {{ \Carbon\Carbon::parse($item->created_at)->day }} de
                                        {{ \Carbon\Carbon::parse($item->created_at)->monthName }} del
                                        {{ \Carbon\Carbon::parse($item->created_at)->year }}</p>
                                    @if ($item->status_contract == '3')
                                        <hr class="my-2">
                                        <h6 class="d-inline text-danger">Razón de la terminacion: </h6> {{ $item->ref_reason_termination }} <br>
                                        <h6 class="d-inline text-danger">Fecha de Terminación: </h6> {{ \Carbon\Carbon::parse($item->date_termination)->day }} de
                                        {{ \Carbon\Carbon::parse($item->date_termination)->monthName }} de
                                        {{ \Carbon\Carbon::parse($item->date_termination)->year }}<br>
                                        <h6 class="d-inline text-danger">Terminado por: </h6> {{ FullNameUser($item->user_termination) }} <br>
                                    @endif
                                    <hr class="my-2">
                                    @if(getAnnexesContractUser($item->id, $user_id, $company_id)['count'] > 0)
                                        <h6 class="d-inline">Anexos: </h6>
                                        <ul class="class="list-group">
                                            @foreach (getAnnexesContractUser($item->id, $user_id, $company_id)['annexes'] as $annex)
                                                <li class="list-group-item">
                                                        {{ $annex->name }}
                                                </li>
                                            @endforeach
                                        </ul>
                                    @endif
                                    <hr class="my-2">
                                    <div class="row">
                                        @if ($item->status_contract != '3')
                                        <div class="col-lg-8 col-md-8 col-sm-12">
                                            <div class="form-group">
                                                @if ($item->signature_employee == null)
                                                    <a href="{{ url('/contrato-empleado/pdf/' . $item->id_contract_user) }}"
                                                        target="_blank" class="btn btn-outline-primary m-2"
                                                        title="Imprimir">
                                                        <i class="far fa-file-pdf"></i> Ver Contrato
                                                    </a>
                                                @endif
                                                    @if ($item->signature_company == null)
                                                        <span class="border-2 bg-info rounded p-2 m-2"><i class="fas fa-hourglass-end"></i> Contrato sin firma del empleador</span>
                                                    @else
                                                        <span class="border-2 bg-success m-2 p-2">
                                                            <i class="fas fa-check"></i> Contrato Firmado por el empleador
                                                        </span>
                                                    @endif
                                                <label class="d-inline">
                                                        @if ($item->active_signature_employee == 1)
                                                            @if ($item->signature_employee == null)
                                                            <a href="{{ route('empleado-contrato-firmar', $item->id_contract_user) }}"
                                                                class="btn btn-outline-primary m-2" title="Firmar">
                                                                <i class="fas fa-pen"></i> Firmar Contrato
                                                            </a>
                                                            @else
                                                                <span class="border-2 bg-success m-2 p-2">
                                                                    <i class="fas fa-check"></i> Contrato Firmado por el trabajador
                                                                </span>
                                                            @endif
                                                        @else
                                                            <span class="border-2 bg-info m-2 p-2 rounded"><i class="fas fa-hourglass-end"></i> Aún no se encuentra disponible para firmar</span>
                                                        @endif
                                                </label>
                                            </div>
                                        </div>
                                        @endif
                                        <div class="col-lg-4 col-md-4 col-sm-12">
                                            <span
                                                class="border-2 f-right m-2 p-2 {{ ColorStatusContract($item->status_contract) }}"
                                                title="Aprobado / Pendiente"><i
                                                    class="fas {{ IconStatusContract($item->status_contract) }}"></i>
                                                {{ DataTypeStatusContract($item->status_contract) }}
                                            </span>

                                        </div>
                                    </div><!-- row -->

                                </div><!-- card-content -->
                            </div><!-- card-body -->
                        </div><!-- card -->
                    @endforeach
                @else
                    <div class="card">
                        <div class="card-header text-center">
                            <h5 class="text-danger">No hay Contratos registrados para este Empleado</h5>
                        </div>
                    </div>
                @endif
                {{ $contracts_user->links() }}
            </div><!-- col-sm-12 -->
        </div><!-- row -->
    </div><!-- container-fluid -->
</div>

@include('common.scriptsCompStandar')
