<?php $__env->startSection('content'); ?>

<?php if( session('status') && session('type') == 'success' ): ?>
    <div class="alert alert-success text-center" role="alert">
        <strong><?php echo e(session('status')); ?></strong>
    </div>
<?php endif; ?>

<?php if( session('status') && session('type') == 'error' ): ?>
    <div class="alert alert-danger text-center" role="alert">
        <strong><?php echo e(session('status')); ?></strong>
    </div>
<?php endif; ?>

<div class="row">
    <div class="col-sm-12 col-md-12 col-lg-12">
        <a role="button" class="btn btn-primary" href="<?php echo e(action('EmployeesController@new')); ?>">
            <i class="fa fa-plus-circle fa-fw"></i>Novo agente
        </a>

         <a role="button" class="btn btn-secondary" href="<?php echo e(action('EmployeeCategoriesController@index')); ?>">
             Categorias
        </a>       
    </div>
</div>

<br />

<table id="employees-table" class="table table-sm table-responsive">
    <thead>
        <tr>
            <th>Status</th>
            <th>Nome</th>
            <th>Matrícula</th>
            <th>Lotação</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <tr>
            <td>
                <strong>
                <?php if( $employee->status === 'A' ): ?>
                    <i style="color: #27AE60">ATIVO</i>
                <?php elseif( $employee->status === 'I' ): ?>
                    <i style="color: #CF000F">INATIVO</i>
                <?php elseif( $employee->status === 'F' ): ?>
                    <i style="color: #65878F">FOLGA</i>
                <?php elseif( $employee->status === 'At' ): ?>
                    <i style="color: #6E5D4B">ATESTADO</i>
                <?php else: ?>
                    <i style="color: #F7BC05">FÉRIAS</i>
                <?php endif; ?>
                </strong>
            </td>
            <td><?php echo e($employee->name); ?></td>
            <td><i><?php echo e($employee->registration_number); ?></i></td>
            <td>
                <?php $__currentLoopData = $employee->getActualWorkPlaces(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php echo e($name); ?><br/> 
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </td>
            <td class="text-right">
                <div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
                    <a role="button" class="btn btn-secondary" href="<?php echo e(action('EmployeesController@view', ['registration_number' => $employee->registration_number])); ?>"><i class="fa fa-eye"></i> ver</a>
                    <a role="button" class="btn btn-secondary" href="<?php echo e(action('EmployeesController@edit', ['registration_number' => $employee->registration_number])); ?>"><i class="fa fa-pencil"></i> editar</a>
                </div>
                <div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
                    <form method="POST" action="<?php echo e(action('EmployeesController@delete', ['registration_number' => $employee->registration_number])); ?>">
                        <?php echo e(csrf_field ()); ?>

                        <input type="hidden" name="_method" value="DELETE">
                        <button id="delete-<?php echo e($employee->id); ?>" type="submit" class="btn btn-danger btn-sm">
                            <i class="fa fa-trash"></i>
                        </button>
                    </form>
                </div>
            </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
</table>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script>
        $('#employees-table').DataTable({
            'language': {
                'url': '//cdn.datatables.net/plug-ins/1.10.16/i18n/Portuguese-Brasil.json'
            },
            'paging'      : true,
            'lengthChange': false,
            'searching'   : true,
            'ordering'    : true,
            'info'        : true,
            'autoWidth'   : true
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.base', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>