<?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">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
    <a href="<?php echo e(route('course.create')); ?>" class="btn btn-success rounded"><i class="fas fa-plus-circle"></i> เพิ่มคอร์ส</a>
    <?php endif; ?>
    <div class="row mt-3">
        <div class="col">
            <div class="card card-outline card-success">
                <div class="card-body">
                    <table class="table" id="course-table">
                        <thead>
                          <tr>
                            <th scope="col" width="3%">#</th>
                            <th scope="col" width="12%">ประเภทรถ</th>
                            <th scope="col" width="10%">เกียร์</th>
                            <th scope="col" width="35%">หลักสูตร</th>
                            <th scope="col" width="10%">ชม. เรียน</th>
                            <th scope="col" width="10%">ชม. อบรม</th>
                            <th scope="col" width="10%">ราคา</th>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
                            <th width="10%"></th>
                            <?php endif; ?>
                          </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hand-hover">
                                <td class="align-middle"><?php echo e($indexKey + 1); ?>.</td>
                                <td class="align-middle"><?php echo e($course->type); ?></td>
                                <td class="align-middle"><?php echo e($course->gear); ?></td>
                                <td class="align-middle"><a href="<?php echo e(route('course.show',$course->id)); ?>" class="course-title-link"><?php echo e($course->name); ?></a></td>
                                <td class="align-middle"><?php echo e($course->hour); ?></td>
                                <td class="align-middle"><?php echo e($course->hour_training); ?></td>
                                <td class="align-middle"><?php echo e(number_format($course->price + $course->optional_price)); ?><input type="hidden" value="<?php echo e($course->price + $course->optional_price); ?>"></td>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
                                <td class="align-middle text-center">
                                    <a href="<?php echo e(route('course.edit',$course->id)); ?>" class="edit-btn ml-2" title="แก้ไขข้อมูล"><i class="far fa-edit"></i></a>
                                    <form id="del-frm<?php echo e($indexKey); ?>" class="d-inline"
                                        method="POST"
                                        action="<?php echo e(route('course.destroy', $course->id )); ?>"
                                        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" title="ลบข้อมูล">
                                            <i class="far fa-trash-alt"></i>
                                        </button>
                                    </form>
                                </td>
                                <?php endif; ?>
                            </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() {
        $('#course-table').DataTable({
            "lengthChange": false,
            "info": false,
            "pageLength": 20,
            "language": {
                "emptyTable":   "ไม่พบข้อมูล",
                "paginate": {
                    "first":    "หน้าแรก",
                    "last":     "หน้าสุดท้าย",
                    "next":     "ถัดไป",
                    "previous": "ก่อนหน้า"
                },
                "search":       "ค้นหา:",
                "lengthMenu":   "จำนวนคอร์สทั้งหมด _MENU_ คอร์ส",
                "info":         "ทั้งหมด _TOTAL_ คอร์ส",
                "infoEmpty":    "ไม่พบคอร์สเรียน",
            }
        });

        $('#course-table tr td:not(:last-child)').click(function () {
            var href = $(this).closest('tr').find('a').attr('href');
            location.href = href;
        });
    });
</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 C:\laragon\www\system.pongpetrdriving.com\resources\views/course/index.blade.php ENDPATH**/ ?>