<!-- Modal -->
<div class="modal fade" id="teacherModal1<?php echo e($vehicle->id.$w.$i); ?>" tabindex="-1" aria-labelledby="teacherModal1<?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]): ?>
            <?php if(numberOfStudent($arrValue1[$w][$vehicle->id][$i])==1): ?> <!-- มีผู้เรียนแค่ 1 คนในช่วงเวลา -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal1<?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>

                    <div class="row mt-2">
                        <div class="col-12 ">
                            <label id="student-name<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e($arrValue1[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <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($arrModule1[$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($arrSchedule1[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule1[$w][$vehicle->id][$i], ($arrSpan1[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="note<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <form action="<?php echo e(route('calendar.booking')); ?>"
                            id="teacherBookFrm1<?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($arrBooking1[$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" title="--เลือก--" class="selectpicker show-menu-arrow form-control" required>
                                    <?php $__currentLoopData = $teachers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $teacher): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($teacher->type=='t' || $teacher->type=='a'): ?>
                                        <option value="<?php echo e($teacher->id); ?>" <?php if($teacher->id == $arrTeacher1[$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> <!-- modal-body -->
                <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); ?>" class="btn btn-success" onclick="document.getElementById('teacherBookFrm1<?php echo e($vehicle->id.$w.$i); ?>').submit();">ตกลง</button>
                    </form>
                        <?php if(check_cancel_booking($arrSchedule1[$w][$vehicle->id][$i])): ?> <!--เวลาปัจจุบัน(ทำรายยกเลิกได้) ก่อนเรียน > 4 ชม. -->
                            <form action="<?php echo e(route('calendar.cancel_booking')); ?>"
                                method="post"
                                
                            >
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <input type="hidden" name="vehicleBookingID" id="vehicle-cancle-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($arrBooking1[$w][$vehicle->id][$i]); ?>">
                                <div class="clearfix float-right" >
                                    <button type="submit" id="cancelBtn<?php echo e($vehicle->id.$w.$i); ?>" class="btn btn-danger" >ยกเลิกนัด</button>
                                </div>
                            </form>
                        <?php endif; ?>
                </div>
            </div>
            <?php else: ?>   <!-- ผู้เรียนมากกว่า 1 คนในเวลาเดียวกัน -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal1<?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($arrSchedule1[$w][$vehicle->id][$i])): ?> <!--เวลาปัจจุบัน(ทำรายยกเลิกได้) ก่อนเรียน > 4 ชม. -->
                        <?php for($n = 0; $n < numberOfStudent($arrValue1[$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($arrBooking1[$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($arrValue1[$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>
                                <div class="row mt-2">
                                    <div class="col-12">
                                        <label id="note<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                                    </div>
                                </div>
                            </form>
                            <hr style="margin-top: -5px;"/>
                        <?php endfor; ?>
                    <?php else: ?> <!-- เลยเวลา 4 ชม. ไม่สามารถยกเลิกนัดได้ ทำได้แค่ book ผู้สอน -->
                        <?php for($n = 0; $n < numberOfStudent($arrValue1[$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($arrValue1[$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($arrModule1[$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($arrSchedule1[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule2[$w][$vehicle->id][$i], ($arrSpan2[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="note<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <form action="<?php echo e(route('calendar.booking')); ?>"
                        id="teacherBookFrm12<?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($arrBooking1[$w][$vehicle->id][$i]); ?>">
                    <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_teach; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $teacher): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($teacher->type=='t' || $teacher->type=='a'): ?>
                                        <option value="<?php echo e($teacher->id); ?>" <?php if($teacher->id == $arrTeacher1[$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('teacherBookFrm12<?php echo e($vehicle->id.$w.$i); ?>').submit();" class="btn btn-success">ตกลง</button>
                </div>
                    </form>
            </div>
            <?php endif; ?>
        <?php elseif(date('Y-m-d') < $week[$w]): ?> <!-- ถ้ายังไม่ถึงวันนัดให้ยกเลิกนัดได้อย่างเดียว -->
            <?php if(numberOfStudent($arrValue1[$w][$vehicle->id][$i])==1): ?> <!-- มีผู้เรียนแค่ 1 คนในช่วงเวลา -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal1<?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>
                    <div class="row mt-2">
                        <input type="hidden" name="vehicleBookingID" id="vehicle-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($arrBooking1[$w][$vehicle->id][$i]); ?>">
                        <div class="col-12 ">
                            <label id="student-name<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">ผู้เรียน : <?php echo e($arrValue1[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                    <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($arrModule1[$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($arrSchedule1[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule1[$w][$vehicle->id][$i], ($arrSpan1[$w][$vehicle->id][$i])/2 ) ." น."); ?></label>
                        </div>
                    </div>
                    <div class="row mt-4">
                        <div class="col-12">
                            <label id="note<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <form id="frm<?php echo e($vehicle->id.$w.$i); ?>"
                        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]); ?>">
                        <input type="hidden" name="vehicleBookingID" id="vehicle-booking<?php echo e($vehicle->id.$w.$i); ?>" value="<?php echo e($arrBooking1[$w][$vehicle->id][$i]); ?>">
                        <button type="button" class="btn btn-outline-secondary mr-2" data-dismiss="modal">ปิด</button>
                        <div class="clearfix float-right" >
                            <button type="submit" id="cancelBtn<?php echo e($vehicle->id.$w.$i); ?>" class="btn btn-danger" >ยกเลิกนัด</button>
                        </div>
                    </form>
                </div>
            </div>
            <?php else: ?> <!-- ผู้เรียนมากกว่า 1 คนในเวลาเดียวกัน -->
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title-card" id="teacherModal1<?php echo e($vehicle->id.$w.$i); ?>Label">ยกเลิกตารางเรียน</h5>
                </div>
                <div class="modal-body">
                    <?php for($n = 0; $n < numberOfStudent($arrValue1[$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($arrBooking1[$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($arrValue1[$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>
                        <div class="row mt-2">
                            <div class="col-12">
                                <label id="note<?php echo e($vehicle->id.$w.$i); ?>" class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                            </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($arrModule1[$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($arrSchedule1[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule1[$w][$vehicle->id][$i], ($arrSpan1[$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 endif; ?>
        <?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 if(numberOfStudent($arrValue1[$w][$vehicle->id][$i])==1): ?> <!-- มีผู้เรียนแค่ 1 คนในช่วงเวลา -->
                        <div class="row mt-2">
                            <div class="col-12 ">
                                <label class="modal-label-card float-left">ผู้เรียน : <?php echo e($arrValue1[$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($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                            </div>
                        </div>
                    <?php else: ?>
                        <?php for($n = 0; $n < numberOfStudent($arrValue1[$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($arrValue1[$w][$vehicle->id][$i], $n)); ?></label>
                                </div>
                            </div>
                            <div class="row mt-2">
                                <div class="col-12">
                                    <label class="modal-label-card float-left">หมายเหตุ : <?php echo e($arrStuNote1[$w][$vehicle->id][$i]); ?></label>
                                </div>
                            </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($arrModule1[$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($arrSchedule1[$w][$vehicle->id][$i]) . " ถึง " . getEndTimeFromHour($arrSchedule1[$w][$vehicle->id][$i], ($arrSpan1[$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, $arrTeacher1[$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 /home/admin2/web/system.pongpetrdriving.com/public_html/resources/views/calendar/modal_booking_1.blade.php ENDPATH**/ ?>