<?php $__env->startSection('style'); ?>
    <link href="<?php echo e(asset('js/advanced-datatable/css/demo_page.css')); ?>" rel="stylesheet" />
    <link href="<?php echo e(asset('js/advanced-datatable/css/demo_table.css')); ?>" rel="stylesheet" />
    <link rel="stylesheet" href="<?php echo e(asset('js/data-tables/DT_bootstrap.css')); ?>" />
    <?php $__env->stopSection(); ?>

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

            <!--body wrapper start-->
    <div class="wrapper">
        <?php echo $__env->make('partials.message', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="row">
            <div class="col-sm-12">
                <section class="panel">
                    <header class="panel-heading">
                        <?php echo e(trans('ui.user.names')); ?>

                        <span class="tools pull-right">
                <a href="javascript:;" class="fa fa-chevron-down"></a>
             </span>
                    </header>
                    <div class="panel-body">
                        <div class="adv-table">
                           <?php if(Auth::user()->can('create-users')): ?>
                                <a href="<?php echo e(url('auth/user/create')); ?>"><button class="btn btn-primary pull-right" type="button"><i class="fa fa-plus-circle"></i> <?php echo e(trans("ui.user.button_add")); ?></button></a>
                            <?php endif; ?>
                            <table  class="display table table-bordered table-striped" id="dynamic-table">
                                <thead>
                                <tr>
                                    <th><?php echo e(trans('ui.user.firstname')); ?></th>
                                    <th><?php echo e(trans('ui.user.lastname')); ?></th>
                                    <th><?php echo e(trans('ui.user.username')); ?></th>
                                    <th><?php echo e(trans('ui.user.email')); ?></th>
                                    <th><?php echo e(trans('ui.role.names')); ?></th>
                                    <th><?php echo e(trans('ui.procedures.names')); ?></th>

                                <?php if(Auth::user()->can(['update-users', 'delete-users'])): ?>
                                        <th><?php echo e(trans('ui.user.operation_label')); ?></th>
                                    <?php endif; ?>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach($users as $user): ?>

                                    <tr class="gradeX">
                                        <td><?php echo e($user->firstname); ?></td>
                                        <td><?php echo e($user->lastname); ?></td>
                                        <td><?php echo e($user->username); ?></td>
                                        <td><?php echo e($user->email); ?></td>
                                        <td><ul>
                                                <?php foreach($user->roles as $role): ?>
                                                    <li>
                                                        <?php echo e($role->display_name); ?>

                                                    </li>
                                                <?php endforeach; ?>
                                        </ul></td>
                                        <td><ul>
                                                <?php foreach($user->tramites as $tramite): ?>
                                                    <li>
                                                        <?php echo e($tramite-> nombre); ?>

                                                    </li>
                                                <?php endforeach; ?>
                                            </ul></td>
                                        <?php if(Auth::user()->can(['update-users', 'delete-users'])): ?>
                                            <td>

                                                    <?php if(Auth::user()->can('update-users')): ?>
                                                        <a href="<?php echo e(url('auth/user/' . $user->id . '/edit')); ?>">
                                                            <i class="fa fa-refresh"></i>
                                                        </a>
                                                    <?php endif; ?>
 						    <?php if(Auth::user()->can('assign-procedures')): ?>
						       <?php if($user->can('use-api-as-agent')): ?>
                                                        
                                                            <a href="<?php echo e(url('auth/user/' . $user->id . '/assign')); ?>">
                                                                <i class="fa fa-check"></i>
                                                            </a>
                                                      
						       <?php endif; ?>
                                                    <?php endif; ?>												
                                                    <?php if(Auth::user()->can('delete-users')): ?>
                                                        <?php echo Form::open(['url' => 'auth/user/'. $user->id, 'method' => 'delete','style'=>'display:inline-block;']); ?>

                                                            <button class="delete-button" type="submit"><i class="fa fa-times-circle"></i></button>
                                                        <?php echo Form::close(); ?>

                                                    <?php endif; ?>
                                            </td>
                                        <?php endif; ?>
                                    </tr>
                                <?php endforeach; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </section>
            </div>
        </div>
    </div>
    <?php $__env->stopSection(); ?>

    <?php $__env->startSection('script'); ?>
            <!--dynamic table-->
    <script type="text/javascript" language="javascript" src="<?php echo e(asset('js/advanced-datatable/js/jquery.dataTables.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('js/data-tables/DT_bootstrap.js')); ?>"></script>
    <!--dynamic table initialization -->
    <script src="<?php echo e(asset('js/dynamic_table_init.js')); ?>"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>