<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset('css/bootstrap-select.min.css')); ?>" rel="stylesheet" />
<link href="<?php echo e(asset('css/bootstrap-datepicker.min.css')); ?>" rel="stylesheet" />
<link href="<?php echo e(asset('css/jquery.Thailand.min.css')); ?>" rel="stylesheet" />
<link href="<?php echo e(asset('css/icheck-bootstrap.min.css')); ?>" rel="stylesheet" />
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-3 pb-3">
    <form action="<?php echo e(route('student.update', $student->id)); ?>"
            novalidate class="<?php echo e(($errors->any()) ? 'was-validated' : 'needs-validation'); ?>"
            method="post"
    >
    <?php echo csrf_field(); ?>
    <?php echo method_field('PUT'); ?>
        <div class="row">
            <div class="col-7">
                <div class="card card-outline card-success">
                    <div class="card-header">
                        <h3 class="card-title">ข้อมูลนักเรียน</h3>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="registerDate">วันที่สมัคร <span class="text-red">*</span></label>
                                    <div class="input-group mb-3">
                                    <input type="text" class="form-control" id="registerDateEdit" name="registerDate" placeholder="วันที่สมัคร" autocomplete="off" value="<?php echo e(formatDateFromDB($student->register_date)); ?>" required>
                                        <div class="input-group-append">
                                            <span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
                                        </div>
                                    </div>
                                    <?php $__errorArgs = ['registerDate'];
$__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 class="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="branch">สาขาที่สมัคร <span class="text-red">*</span></label>
                                    <select id="branch" name="branch" class="selectpicker show-menu-arrow form-control" title="--เลือก--" required>
                                        <?php $__currentLoopData = $branchs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($branch->code); ?>" <?php if($branch->code == $student->code_branch): ?> selected <?php endif; ?>><?php echo e($branch->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?php $__errorArgs = ['branch'];
$__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 class="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="idCard">เลขที่บัตรประชาชน/พาสปอต <span class="text-red">*</span></label>
                                <input type="text" class="form-control" id="idCard" name="idCard" placeholder="เลขที่บัตรประาชาชน 13 หลัก หรือ พาสปอต" value="<?php echo e($student->idcard); ?>" required>
                                    <?php $__errorArgs = ['idCard'];
$__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 class="row">
                            <div class="col-2">
                                <div class="form-group">
                                    <label for="title">คำนำหน้า <span class="text-red">*</span></label>
                                    <select id="title" name="title" class="selectpicker show-menu-arrow form-control" title="--เลือก--" required>
                                      <option value="นาย" <?php if($student->title == "นาย"): ?> selected <?php endif; ?>>นาย</option>
                                      <option value="นาง" <?php if($student->title == "นาง"): ?> selected <?php endif; ?>>นาง</option>
                                      <option value="นางสาว" <?php if($student->title == "นางสาว"): ?> selected <?php endif; ?>>นางสาว</option>
                                    </select>
                                    <?php $__errorArgs = ['title'];
$__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 class="col-4">
                                <div class="form-group">
                                    <label for="firstname">ชื่อ <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="firstname" name="firstname" placeholder="ชื่อ" value="<?php echo e($student->firstname); ?>" required>
                                    <?php $__errorArgs = ['firstname'];
$__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 class="col-4">
                                <div class="form-group">
                                    <label for="lastname">นามสกุล <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="lastname" name="lastname" placeholder="นามสกุล" value="<?php echo e($student->lastname); ?>" required>
                                    <?php $__errorArgs = ['lastname'];
$__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 class="col-2">
                                <div class="form-group">
                                    <label for="nickname">ชื่อเล่น</label>
                                    <input type="text" class="form-control" id="nickname" name="nickname" placeholder="ชื่อเล่น" value="<?php echo e($student->nickname); ?>">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-4">
                                <div class="form-group">
                                    <label for="birthdate">วันเกิด <span class="text-red">*</span></label>
                                    <div class="input-group mb-3">
                                        <input type="text" class="form-control datepiacker" id="birthdate" name="birthdate" placeholder="วันเกิด" autocomplete="off" value="<?php echo e(formatDateFromDB($student->birthdate)); ?>" required>
                                        <div class="input-group-append">
                                            <span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
                                        </div>
                                    </div>
                                    <?php $__errorArgs = ['birthdate'];
$__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 class="col-2">
                                <div class="form-group">
                                    <label for="age">อายุ</label>
                                    <input type="text" class="form-control" id="age" name="age" value="<?php echo e($age); ?>" disabled>
                                </div>
                            </div>
                            <div class="col-2">
                                <div class="form-group">
                                    <label for="race">เชื้อชาติ</label>
                                    <input type="text" class="form-control" id="race" name="race" placeholder="เชื้อชาติ" value="<?php echo e($student->race); ?>">
                                </div>
                            </div>
                            <div class="col-2">
                                <div class="form-group">
                                    <label for="nationality">สัญชาติ</label>
                                    <input type="text" class="form-control" id="nationality" name="nationality" placeholder="สัญชาติ" value="<?php echo e($student->nationality); ?>">
                                </div>
                            </div>
                            <div class="col-2">
                                <div class="form-group">
                                    <label for="religion">ศาสนา</label>
                                    <input type="text" class="form-control" id="religion" name="religion" placeholder="ศาสนา" value="<?php echo e($student->religion); ?>">
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-12">
                                <div class="form-group">
                                    <label for="address">ที่อยู่ตามบัตรประชาชน <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="address" name="address" placeholder="ที่อยู่" value="<?php echo e($student->address); ?>" required>
                                    <?php $__errorArgs = ['address'];
$__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 class="row">
                            <div class="col-4">
                                <div class="form-group">
                                    <label for="district">ตำบล / แขวง <span class="text-red">*</span></label>
                                    <input type="text" name="district" id="district" class="form-control" placeholder="ตำบล / แขวง" value="<?php echo e($student->district); ?>" required>
                                    <?php $__errorArgs = ['district'];
$__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 class="col-4">
                                <div class="form-group">
                                    <label for="amphoe">อำเภอ / เขต <span class="text-red">*</span></label>
                                    <input type="text" name="amphoe" id="amphoe" class="form-control" placeholder="อำเภอ / เขต" value="<?php echo e($student->amphoe); ?>" required>
                                    <?php $__errorArgs = ['amphoe'];
$__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 class="col-4">
                                <div class="form-group">
                                    <label for="province">จังหวัด <span class="text-red">*</span></label>
                                    <input type="text" name="province" id="province" class="form-control" placeholder="จังหวัด" value="<?php echo e($student->province); ?>" required>
                                    <?php $__errorArgs = ['province'];
$__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 class="row">
                            <div class="col-6">
                                <div class="form-group">
                                    <label for="phone1">หมายเลขโทรศัพท์ 1 <span class="text-red">*</span></label>
                                    <input type="number"
                                            class="form-control"
                                            id="phone1"
                                            name="phone1"
                                            placeholder="หมายเลขโทรศัพท์"
                                            oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
                                            maxlength="10"
                                            value="<?php echo e($student->phone_1); ?>"
                                            required>
                                    <?php $__errorArgs = ['phone1'];
$__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 class="col-6">
                                <div class="form-group">
                                    <label for="phone2">หมายเลขโทรศัพท์ 2</label>
                                    <input type="number"
                                            class="form-control"
                                            id="phone2"
                                            name="phone2"
                                            placeholder="หมายเลขโทรศัพท์"
                                            oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
                                            maxlength="10"
                                            value="<?php echo e($student->phone_2); ?>"
                                            >
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-5">
                <div class="card card-outline card-success">
                    <div class="card-header">
                        <h3 class="card-title">ข้อมูลทั่วไป</h3>
                    </div>
                    <div class="card-body">

                        <div class="row">
                            <div class="col-sm-12 col-md-6">
                                <div class="form-group">
                                    <label for="refName">บุคคลที่ติดต่อได้ในกรณีฉุกเฉิน</label>
                                    <input type="text" class="form-control" id="refName" name="refName" placeholder="ชื่อ - นามสกุล" value="<?php echo e($student->emergency_name); ?>">
                                    <?php $__errorArgs = ['refName'];
$__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 class="col-sm-12 col-md-6">
                                <div class="form-group">
                                    <label for="phone1">หมายเลขโทรศัพท์</label>
                                    <input type="number"
                                            class="form-control"
                                            id="refPhone"
                                            name="refPhone"
                                            placeholder="หมายเลขโทรศัพท์"
                                            oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
                                            maxlength="10"
                                            value="<?php echo e($student->emergency_phone); ?>"
                                            >
                                    <?php $__errorArgs = ['refPhone'];
$__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>
                        <hr />
                        <div class="row">
                            <div class="col-sm-12 col-md-12">
                                <div class="form-group">
                                    <label>มีใบอนุญาตขับขี่หรือไม่ <span class="text-red">*</span></label>
                                    <div>
                                        <div class="icheck-nephritis icheck-inline">
                                            <input type="radio" id="noLicense" name="license" value="ไม่มี" <?php if($student->license_status == "ไม่มี"): ?> checked <?php endif; ?>>
                                            <label for="noLicense">ไม่มีใบอนุญาต</label>
                                        </div>
                                        <div class="icheck-nephritis icheck-inline">
                                            <input type="radio" id="noTest" name="license" value="มี" <?php if($student->license_status == "มี"): ?> checked <?php endif; ?>>
                                            <label for="noTest">มีใบอนุญาต</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr />
                        <div class="row">
                            <div class="col-sm-12 col-md-12">
                                <div class="form-group">
                                    <label for="knowSchool">รู้จักโรงเรียนได้อย่างไร</label>
                                    <input type="text" class="form-control" id="knowSchool" name="knowSchool" placeholder="รู้จักโรงเรียนได้อย่างไร จากไหน" value="<?php echo e($student->known_school); ?>">
                                </div>
                            </div>
                        </div>
                        <hr />
                        <div class="row">
                            <div class="col-sm-12 col-md-12">
                                <div class="form-group">
                                    <label for="knowSchool">หมายเหตุ</label>
                                    <input type="text" class="form-control" id="note" name="note" placeholder="หมายเหตุ" value="<?php echo e($student->note); ?>">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-12">
                <div style="float:left">
                    <a href=" <?php if($student->is_active=='1'): ?><?php echo e(route('student.index')); ?> <?php else: ?> <?php echo e(route('student.graduated')); ?> <?php endif; ?> " class="btn btn-outline-secondary"><i class="fas fa-chevron-left"></i> ย้อนกลับ</a>
                </div>
                <div style="float: right">
                    <button type="reset" class="btn btn-outline-secondary" value="reset">คืนค่า</button>
                    <button type="submit" class="btn btn-success ml-2" value="add-course">แก้ไขนักเรียน</button>
                </div>

            </div>
        </div>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footerscript'); ?>
<script src="<?php echo e(asset('js/bootstrap-select.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/JQL.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/typeahead.bundle.js')); ?>"></script>
<script src="<?php echo e(asset('js/jquery.Thailand.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/custom.js')); ?>"></script>
<script>
$(document).ready(function(){
    $('#registerDateEdit').datepicker({
        format: 'dd/mm/yyyy',
        autoclose: true,
        language: 'th',
        orientation: 'bottom',
        //thaiyear: true
    });

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

    $.Thailand({
        $district: $('#district'),
        $amphoe: $('#amphoe'),
        $province: $('#province'),
    });

    $('#birthdate').on('change', function () {
        var bdate = $('#birthdate').val();
        bdate = bdate.split("/");
        bdate = bdate[0]+'/'+bdate[1]+'/'+parseInt(bdate[2]);
        if (isDate(bdate)) {
            var age = calculateAge( parseDate(bdate), new Date() );
              $('#age').val(age);
        } else {
            $('#age').val("");
        }
    });

});
function parseDate(dateStr) {
    var dateParts = dateStr.split("/");
    return (parseInt(dateParts[2]) - 543).toString() + "-" + dateParts[1] + "-" + dateParts[0];
}
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.web', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\tkp-system.bright.in.th\resources\views/student/edit.blade.php ENDPATH**/ ?>