<?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('UsersController@new')); ?>">
                <i class="fa fa-plus-circle fa-fw"></i>Novo usuário
            </a>
        </div>
    </div>

    <br />

    <table id="users-table" class="table table-sm">
        <thead>
            <tr>
                <th>Nome</th>
                <th>Email</th>
                <th>Tipo</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
                <td><?php echo e($user->name); ?></td>
                <td><?php echo e($user->email); ?></td>
                <td>
                    <?php if($user->category == 'A'): ?>
                        ADMINISTRADOR
                    <?php elseif($user->category == 'C'): ?>
                        COORDENADOR
                    <?php elseif($user->category == 'P'): ?>
                        PLANTONISTA
                    <?php else: ?>
                        AGENTE
                    <?php endif; ?>
                </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('UsersController@view', ['id' => $user->id])); ?>"><i class="fa fa-eye"></i> ver</a>
                        <a role="button" class="btn btn-secondary" href="<?php echo e(action('UsersController@edit', ['id' => $user->id])); ?>"><i class="fa fa-pencil"></i> editar</a>
                    </div>
                    <div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
                        <form id="delete-user-form" method="POST" action="<?php echo e(action('UsersController@delete', ['id' => $user->id])); ?>">
                            <?php echo e(csrf_field ()); ?>

                            <?php echo e(method_field('DELETE')); ?>

                            <button 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>
        $('#users-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(); ?>