<!-- Modal -->
<div class="modal fade" id="teacherModal3<?php echo e($vehicle->id.$w.$i); ?>" tabindex="-1" aria-labelledby="teacherModal3<?php echo e($vehicle->id.$w.$i); ?>Label" aria-hidden="true" data-backdrop="static" >
    <div class="modal-dialog modal-dialog-centered">

        <?php if(date('Y-m-d')==$week[$w]): ?>
            <!-- ผู้เรียนมากกว่า 1 คนในเวลาเดียวกัน -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal3<?php echo e($vehicle->id.$w.$i); ?>Label">ระบุผู้สอน</h5>
                </div>
                <div class="modal-body">
                    <div class="row mb-3">
                        <div class="col-12 ">
                            <label id="vehicle-name" class="modal-label-card float-left"><?php echo e($vehicle->type ." คันที่ : ".$vehicle->number . " , " . $vehicle->brand." ".$vehicle->model. " [ ".$vehicle->registration_class." ".$vehicle->registration_number." ]"); ?></label>
                        </div>
                    </div>
                    <?php if(check_cancel_booking($arrSchedule3[$w][$vehicle->id][$i])): ?> <!--เวลาปัจจุบัน(ทำรายยกเลิกได้) ก่อนเรียน > 4 ชม. -->
                        <?php for($n = 0; $n < numberOfStudent($arrValue3[$w][$vehicle->id][$i]); $n++): ?>
                            <form id="frm<?php echo e($vehicle->id.$w.$i.$n); ?>"
                                action="<?php echo e(route('calendar.cancel_booking')); ?>"
                                method="post"
                                
                            >
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('DELETE'); ?>
                                <input type="hidden" name="date" id="date-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($week[$w]); ?>">
                                <div class="row mt-2">
                                    <input type="hidden" name="vehicleBookingID" id="vehicle-booking<?php echo e($vehicle->id.$w.$i.$n); ?>" value="<?php echo e(getVehicleBookingAtN($arrBooking3[$w][$vehicle->id][$i], $n)); ?>">
                                    <div class="col-9">
                                        <label id="student-name<?php echo e($n); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e(getStudentAtN($arrValue3[$w][$vehicle->id][$i], $n)); ?></label>
                                    </div>
                                    <?php if(date('Y-m-d')<$week[$w]): ?>
                                    <div class="col-3">
                                        <button type="submit" id="cancelBtn<?php echo e($vehicle->id.$w.$i.$n); ?>" class="btn btn-sm btn-danger">ยกเลิกนัด</button>
                                    </div>
                                    <?php endif; ?>
                                </div>
                            </form>
                            <hr style="margin-top: -5px;"/>
                        <?php endfor; ?>
                    <?php else: ?> <!-- เลยเวลา 4 ชม. ไม่สามารถยกเลิกนัดได้ ทำได้แค่ book ผู้สอน -->
                        <?php for($n = 0; $n < numberOfStudent($arrValue3[$w][$vehicle->id][$i]); $n++): ?>
                            <div class="row mt-2">
                                <div class="col-9">
                                    <label id="student-name<?php echo e($n); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e(getStudentAtN($arrValue3[$w][$vehicle->id][$i], $n)); ?></label>
                                </div>
                                <hr>
                            </div>
                        <?php endfor; ?>
                    <?php endif; ?>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="module<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">วิชา : <?php echo e($arrModule3[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-12">
                            <label id="drive-time<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">เวลา : <?php echo e(formatTimeFromDB($arrSchedule3[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule3[$w][$vehicle->id][$i], ($arrSpan3[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                    <form action="<?php echo e(route('calendar.booking')); ?>"
                        id="teacherBookFrm32<?php echo e($vehicle->id.$w.$i); ?>"
                        novalidate class="teacherBookFrm <?php echo e(($errors->any()) ? 'was-validated' : 'needs-validation'); ?>"
                        method="post">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" name="vehicleBookingID" id="vehicle-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($arrBooking3[$w][$vehicle->id][$i]); ?>">
                        <input type="hidden" name="purpose" value="เก็บชั่วโมงเพื่อสอบ">
                    <div class="row mt-4">
                        <div class="col-12">
                            <div class="form-group">
                                <label for="teacher" class="modal-label-card float-left mb-2">ผู้สอน <?php if(date('Y-m-d')==$week[$w]): ?><span class="text-red">*</span><?php endif; ?></label>
                                <select id="teacher<?php echo e($vehicle->id.$w.$i); ?>" name="teacher" data-size="10" data-container="body" class="selectpicker show-menu-arrow form-control teacher-select" title="--เลือก--" <?php if(date('Y-m-d')>$week[$w]): ?> disabled <?php endif; ?> required>

                                    <?php $__currentLoopData = $teachers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $teacher): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($teacher->type=='s' || $teacher->type=='a'): ?>
                                        <option value="<?php echo e($teacher->id); ?>" <?php if($teacher->id == $arrTeacher3[$w][$vehicle->id][$i]): ?> selected <?php endif; ?>><?php echo e($teacher->title.$teacher->firstname. " " .$teacher->lastname); ?></option>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <?php $__errorArgs = ['teacher<?php echo e($vehicle->id.$w.$i); ?>'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="text-danger"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">ปิด</button>
                    <button type="submit" id="bookBtn<?php echo e($vehicle->id.$w.$i); ?>" onclick="document.getElementById('teacherBookFrm32<?php echo e($vehicle->id.$w.$i); ?>').submit();" class="btn btn-success">ตกลง</button>
                </div>
                    </form>
            </div>
        <?php elseif(date('Y-m-d') < $week[$w]): ?> <!-- ถ้ายังไม่ถึงวันนัดให้ยกเลิกนัดได้อย่างเดียว -->
            <!-- ผู้เรียนมากกว่า 1 คนในเวลาเดียวกัน -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal3<?php echo e($vehicle->id.$w.$i); ?>Label">ยกเลิกตารางเรียน</h5>
                </div>
                <div class="modal-body">
                    <?php for($n = 0; $n < numberOfStudent($arrValue3[$w][$vehicle->id][$i]); $n++): ?>
                    <form id="frm<?php echo e($vehicle->id.$w.$i.$n); ?>"
                        action="<?php echo e(route('calendar.cancel_booking')); ?>"
                        method="post"
                        
                    >
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <div class="row mt-3">
                            <input type="hidden" name="date" id="date-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($week[$w]); ?>">
                            <input type="hidden" name="vehicleBookingID" id="vehicle-booking<?php echo e($vehicle->id.$w.$i.$n); ?>" value="<?php echo e(getVehicleBookingAtN($arrBooking3[$w][$vehicle->id][$i], $n)); ?>">
                            <div class="col-9">
                                <label id="student-name<?php echo e($n); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e(getStudentAtN($arrValue3[$w][$vehicle->id][$i], $n)); ?></label>
                            </div>
                            <div class="col-3">
                                <button type="submit" id="cancelBtn<?php echo e($vehicle->id.$w.$i.$n); ?>" class="btn btn-sm btn-danger" style="margin-top:-8px;">ยกเลิกนัด</button>
                            </div>
                        </div>
                    </form>
                    <hr style="margin-top: -5px;"/>
                    <?php endfor; ?>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="module<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">วิชา : <?php echo e($arrModule3[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-12">
                            <label id="drive-time<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">เวลา : <?php echo e(formatTimeFromDB($arrSchedule3[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule3[$w][$vehicle->id][$i], ($arrSpan3[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">ปิด</button>
                </div>
            </div>
        <?php else: ?> <!-- รายการของวันที่ผ่านมาแล้ว -->
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row mb-3">
                        <div class="col-12 ">
                            <label class="modal-label-card float-left"><?php echo e($vehicle->type ." คันที่ : ".$vehicle->number . " , " . $vehicle->brand." ".$vehicle->model. " [ ".$vehicle->registration_class." ".$vehicle->registration_number." ]"); ?></label>
                        </div>
                    </div>
                    <?php for($n = 0; $n < numberOfStudent($arrValue3[$w][$vehicle->id][$i]); $n++): ?>
                        <div class="row mt-2">
                            <div class="col-12">
                                <label id="student-name<?php echo e($n); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e(getStudentAtN($arrValue3[$w][$vehicle->id][$i], $n)); ?></label>
                            </div>
                        </div>
                    <?php endfor; ?>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="module<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">วิชา : <?php echo e($arrModule3[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <div class="row mt-2">
                        <div class="col-12">
                            <label class="modal-label-card float-left">เวลา : <?php echo e(formatTimeFromDB($arrSchedule3[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule3[$w][$vehicle->id][$i], ($arrSpan3[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label class="modal-label-card float-left">ผู้สอน : <?php echo e(getTeacherName($teachers, $arrTeacher3[$w][$vehicle->id][$i])); ?></label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">ปิด</button>
                </div>
            </div>
        <?php endif; ?>
    </div>
</div>
<!-- End modal -->
<?php /**PATH /var/www/html/pongpetch/resources/views/calendar/modal_booking_3.blade.php ENDPATH**/ ?>