<?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" />
<link href="<?php echo e(asset('css/bootstrap-datepicker.min.css')); ?>" rel="stylesheet" />
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-3">
    <div class="row mt-3">
        <div class="col">
            <div class="card card-outline card-success">
                <div class="card-body">
                    <table class="table" id="student-table">
                        <thead>
                          <tr>
                            <th scope="col" width="2%">#</th>
                            <th scope="col" width="5%">เลขที่</th>
                            <th scope="col" width="12%">ชื่อ-สกุล</th>
                            <th scope="col" width="7%">เลขที่บัตรประชาชน</th>
                            <th scope="col" width="28%">หลักสูตร</th>
                            <th scope="col" width="7%">วันสอบ</th>
                            <th scope="col" width="5%">คงค้าง</th>
                            <th width="9%">เลื่อนวันสอบ</th>
                          </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $students; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $student): $__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($student->code_no."/".$student->code_month."/".$student->code_branch); ?></td>
                                <td class="align-middle">
                                    <a class="course-title-link <?php if(alertPayment($student->exam_date, ($student->course_cost - $student->discount - $student->paid))): ?> <?php echo e('text-danger font-weight-bold'); ?> <?php endif; ?>"
                                        href="<?php echo e(route('student.show',$student->sid)); ?>"
                                    >
                                        <?php echo e($student->firstname ." ". $student->lastname); ?>

                                    </a>
                                </td>
                                <td class="align-middle"><?php echo e($student->idcard); ?></td>
                                <td class="align-middle"><?php echo e("(".$student->type .") ". $student->name); ?></td>
                                <td class="align-middle"><?php echo e(($student->exam_date != "") ? formatDateFromDB($student->exam_date) : " "); ?></td>
                                <td class="align-middle <?php if( ($student->course_cost - $student->discount - $student->paid) > '0'): ?> text-danger" <?php else: ?> " <?php endif; ?>><?php echo e(number_format( $student->course_cost - $student->discount - $student->paid)); ?></td>
                                <td class="align-middle text-center">
                                    <a href="#" data-toggle="modal"
                                        data-target="#examModal"
                                        data-studentID="<?php echo e($student->sid); ?>"
                                        data-student="<?php echo e($student->title.$student->firstname ." ". $student->lastname); ?>"
                                        data-enroll="<?php echo e($student->eid); ?>"
                                        data-date="<?php echo e($student->exam_date); ?>">
                                        <i class="fas fa-calendar-alt"></i>
                                    </a>
                                    
                                    
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                      </table>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div style="float:left">
                <a href="<?php echo e(route('home.index')); ?>" class="btn btn-outline-secondary"><i class="fas fa-chevron-left"></i> ย้อนกลับ</a>
            </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/bootstrap-datepicker.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/bootstrap-datepicker.th.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/custom.js')); ?>"></script>
<script>
    $(document).ready(function() {
        $('#student-table').DataTable({
            "lengthChange": false,
            "info": false,
            "pageLength": 20,
            "language": {
                "emptyTable":   "ไม่พบข้อมูล",
                "paginate": {
                    "first":    "หน้าแรก",
                    "last":     "หน้าสุดท้าย",
                    "next":     "ถัดไป",
                    "previous": "ก่อนหน้า"
                },
                "search":       "ค้นหา:",
                "lengthMenu":   "จำนวนนักเรียนทั้งหมด _MENU_ คน",
                "info":         "ทั้งหมด _TOTAL_ คน",
                "infoEmpty":    "ไม่พบนักเรียน",
            }
        });

        $('#student-table tr td:not(:last-child)').click(function () {
            var href = $(this).closest('tr').find('a').attr('href');
            location.href = href;
        });

        $('#examDate').datepicker({
            format: 'dd/mm/yyyy',
            autoclose: true,
            language: 'th',
            orientation: 'bottom',
            thaiyear: true,
        });

        $('#examModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget);
            var studentID = button.data('studentID');
            var student = button.data('student');
            var enroll = button.data('enroll');
            var date = button.data('date');
            var spanDate = date.split("-");
            spanDate = spanDate[2] + "/" + spanDate[1] + "/" + spanDate[0];
            var modal = $(this);
            modal.find('#student').text(student);
            modal.find('#studentID').val(studentID);
            modal.find('#enrollID').val(enroll);
            modal.find('#examDate').val(spanDate);
        });
    });
</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('home.modal_exam', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?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/home/show_exam.blade.php ENDPATH**/ ?>