<div>
    @component('common.breadcrumb', ['addBtn' => false, 'permission_create' => 'Company_register_users_index', 'breadcrumb_show' => $breadcrumb_show])
        @slot('breadcrumb_title')
            <h3>{{ $componentName }} | {{ $pageTitle }}</h3>
        @endslot
        <li class="breadcrumb-item">Empresa</li>
        <li class="breadcrumb-item active">Contratos</li>

    @endcomponent

    @include('common.searchbox')
    <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>{{ $company_name }} | Plan: <b>{{ $company_plan_name }}</b></h4>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="card">
                    <div class="table-responsive">
                        <table class="table">
                            <thead class="bg-primary">
                                <tr>
                                    <th scope="col">NOMBRE @include('common.orderby', ['column' => 'name'])</th>
                                    <th scope="col" class="text-center">APELLIDO @include('common.orderby', ['column' => 'last_name'])</th>
                                    <th scope="col" class="text-center">DOCUMENTO @include('common.orderby', ['column' => 'document'])</th>
                                    <th scope="col" class="text-center">ROL</th>
                                    <th scope="col" class="text-center">ESTADO</th>
                                    <th scope="col" class="text-center">FOTO</th>
                                    <th scope="col" class="text-center">ACCIONES</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($users as $item)
                                    <tr>
                                        <td>{{ $item->first_name }}</td>
                                        <td class="text-left">{{ $item->last_name }}</td>
                                        <td class="text-left">{{ $item->document }}</td>
                                        <td>
                                            @if(!empty($item->getRoleNames()))
                                            @foreach($item->getRoleNames() as $val)
                                                <strong class="text-secondary">{{ $val }}</strong>
                                            @endforeach
                                        @endif
                                        </td>
                                        <td class="text-center">
                                            @if ($item->status == "ACTIVO")
                                                <span class="badge badge-success">Activo</span>
                                            @else
                                                <span class="badge badge-danger">Bloqueado</span>
                                            @endif
                                        </td>
                                        <td class="text-center">
                                            @if ($item->imagen != null)
                                                <img src="{{ asset('storage/users/' . $item->imagen) }}"
                                                    alt="imagen" class="card-img-top img-fluid img-h-50">
                                            @endif
                                        </td>
                                        <td class="text-center">
                                            @if(!empty($item->getRoleNames()))
                                                @foreach($item->getRoleNames() as $val)
                                                    @if ($val == 'Empleado')
                                                        @if ($item->status == "ACTIVO")
                                                            @can('Company_employee_profile_index')
                                                                <a href="{{ route('cargo-empleado', $item->id) }}"
                                                                    class="btn btn-outline-primary btn-sm" title="Perfil Empleado / Cargo">
                                                                    <i class="fas fa-briefcase"></i>
                                                                </a>
                                                            @endcan
                                                        @endif
                                                    @endif
                                                @endforeach
                                            @endif
                                            @if ($item->status == "ACTIVO")
                                            @can('Company_contracts_users_create')
                                                <a href="{{ route('contratos-empleados.create', $item->id) }}"
                                                    class="btn btn-outline-secondary" title="Contrato Empleado">
                                                    <i class="fa fa-file-contract"></i>
                                                </a>
                                            @endcan
                                            @can('Company_contracts_users_history')
                                                <a href="{{ route('contratos-empleados.historial', $item->id) }}"
                                                    class="btn btn-outline-secondary" title="Historial Empleado">
                                                    <i class="fa fa-history"></i>
                                                </a>
                                            @endcan
                                            @endif

                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        {{ $users->links() }}
                    </div>

                </div>
            </div>
        </div>
        @include('livewire.company.contracts.form-profile')
    </div>
</div>
@include('common.scriptsCompStandar')
<script>
    document.addEventListener('DOMContentLoaded', function() {
        $('#theModalProfile').on('show.bs.modal', function() {
            $('.modal-body:first *:input[type!=hidden]:first').trigger('focus');
        });
        window.livewire.on('hide-modal-profile', msg => {
            $('#theModalProfile').modal('hide')
        });
        window.livewire.on('show-modal-profile', msg => {
            $('#theModalProfile').modal('show')
        });

    });

</script>
