<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset('css/dataTables.bootstrap4.min.css')); ?>" rel="stylesheet">
<link href="<?php echo e(asset('css/sweetalert2.min.css')); ?>" rel="stylesheet">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-3">
    <a href="<?php echo e(route('user.create')); ?>" class="btn btn-success rounded"><i class="fas fa-plus-circle"></i> เพิ่มผู้ใช้ระบบ</a>
    <div class="row mt-3">
        <div class="col">
            <div class="card card-outline card-success">
                <div class="card-body">
                    <table class="table" id="user-table">
                        <thead>
                          <tr>
                            <th scope="col" width="5%">#</th>
                            <th scope="col" width="15%">ชื่อผู้ใช้</th>
                            <th scope="col" width="20%">ชื่อ - นามสกุล</th>
                            <th scope="col" width="20%">อีเมล์</th>
                            <th scope="col" width="10%">หมายเลขโทรศัพท์</th>
                            <th scope="col" width="15%">สาขา</th>
                            <th scope="col" width="5%">สิทธิ์</th>
                            <th width="10%"></th>
                          </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="align-middle"><?php echo e($indexKey + 1); ?>.</td>
                                <td class="align-middle"><?php echo e($user->username); ?></td>
                                <td class="align-middle"><?php echo e($user->title . $user->firstname ." ". $user->lastname); ?></td>
                                <td class="align-middle"><?php echo e($user->email); ?></td>
                                <td class="align-middle"><?php echo e($user->phone); ?></td>
                                <td class="align-middle"><?php echo e($user->name); ?></td>
                                <td class="align-middle"><?php echo e($user->role); ?></td>
                                <td class="align-middle text-center">
                                    <a href="<?php echo e(route('user.edit',$user->uid)); ?>" class="edit-btn ml-2" data-toggle="tooltip" data-placement="top" title="แก้ไขข้อมูล"><i class="far fa-edit"></i></a>
                                    <a href="<?php echo e(route('user.admin_change_password',$user->uid)); ?>" class="text-info ml-2" data-placement="top" title="เปลี่ยนรหัสผ่าน"><i class="fas fa-key"></i></a>
                                    <form id="del-frm<?php echo e($indexKey); ?>" class="d-inline"
                                        method="POST"
                                        action="<?php echo e(route('user.destroy', $user->uid )); ?>"
                                        onsubmit="confirmalert(event, <?php echo e($indexKey); ?>, 'ผู้ใช้ระบบ')"
                                    >
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn del-btn btn-sm ml-2" data-toggle="tooltip" data-placement="top" title="ลบข้อมูล">
                                            <i class="far fa-trash-alt"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                      </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footerscript'); ?>
<script src="<?php echo e(asset('js/sweetalert2.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/jquery.dataTables.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/dataTables.bootstrap4.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/custom.js')); ?>"></script>
<script>
    $(document).ready(function() {
        $('#user-table').DataTable({
            "lengthChange": false,
            "info": false,
            "pageLength": 20,
            "language": {
                "emptyTable":   "ไม่พบข้อมูล",
                "paginate": {
                    "first":    "หน้าแรก",
                    "last":     "หน้าสุดท้าย",
                    "next":     "ถัดไป",
                    "previous": "ก่อนหน้า"
                },
                "search":       "ค้นหา:",
                "lengthMenu":   "จำนวนผู้ใช้ระบบทั้งหมด _MENU_ คน",
                "info":         "ทั้งหมด _TOTAL_ คน",
                "infoEmpty":    "ไม่พบผู้ใช้ระบบ",
            }
        });

        $('.change-modal').on('hidden.bs.modal', function () {
            $('#changeFrm')[0].reset();
        });
    });
</script>
<?php if(session('feedback')): ?>
<script>
    Swal.fire({
                text: '<?php echo e(session('feedback')); ?>',
                icon: 'success',
                confirmButtonText: 'ตกลง',
                confirmButtonColor: '#62966C'
    })
</script>
<?php endif; ?>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.web', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/admin2/web/system.pongpetrdriving.com/public_html/resources/views/user/index.blade.php ENDPATH**/ ?>