<?php $__env->startSection('css'); ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">
<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">
    <form action="<?php echo e(route('vehicle.store')); ?>" 
            novalidate class="<?php echo e(($errors->any()) ? 'was-validated' : 'needs-validation'); ?>" 
            method="post"
    >
    <?php echo csrf_field(); ?>
        <div class="row">
            <div class="col-12">
                <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-2">
                                <div class="form-group">
                                    <label for="type">ประเภทยานพาหนะ <span class="text-red">*</span></label>
                                    <select id="type" name="type" class="form-control selectpicker show-menu-arrow" title="--เลือกประเภท--" required>
                                      <option value="รถยนต์" >รถยนต์</option>
                                      <option value="รถจักรยานยนต์" >รถจักรยานยนต์</option>
                                    </select>
                                    <?php $__errorArgs = ['type'];
$__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-2">
                                <div class="form-group gear">
                                    <label for="gear">ประเภทเกียร์ <span class="text-red">*</span></label>
                                    <select id="gear" name="gear" class="form-control dan selectpicker show-menu-arrow" title="--เลือกเกียร์--" required >
                                      <option value="ธรรมดา" >ธรรมดา</option>
                                      <option value="ออโต้" >ออโต้</option>
                                    </select>
                                    <?php $__errorArgs = ['gear'];
$__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-1">
                                <div class="form-group">
                                    <label for="vehicleNo">คันที่ <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="vehicleNo" name="vehicleNo" placeholder="คันที่" required>
                                    <?php $__errorArgs = ['vehicleNo'];
$__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-3">
                                <div class="form-group">
                                    <label for="brand">ยี่ห้อ <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="brand" name="brand" placeholder="ชื่อยี่ห้อ" required>
                                    <?php $__errorArgs = ['brand'];
$__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="model">รุ่น <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="model" name="model" placeholder="ชื่อรุ่น" required>
                                    <?php $__errorArgs = ['model'];
$__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-sm-4 col-md-3">
                                <div class="form-group">
                                    <label for="bodySerial">เลขตัวถัง <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="bodySerial" name="bodySerial" placeholder="เลขตัวถัง" required>
                                    <?php $__errorArgs = ['bodySerial'];
$__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-8 col-md-3">
                                <div class="form-group">
                                    <label for="engineSerial">เลขเครื่องยนต์ <span class="text-red">*</span></label>
                                    <input type="text" class="form-control" id="engineSerial" name="engineSerial" placeholder="เลขเครื่องยนต์" required>
                                    <?php $__errorArgs = ['engineSerial'];
$__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="characteristic">ลักษณะ / มาตรฐานรถ</label>
                                    <input type="text" class="form-control" id="characteristic" name="characteristic" placeholder="ลักษณะ / มาตรฐานรถ">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="registration">เลขทะเบียน <span class="text-red">*</span></label>
                                    <div class="row">
                                        <div class="col-sm-12 col-md-4">
                                            <input type="text" class="form-control" id="registrationClass" name="registrationClass" placeholder="หมวด" required>
                                            <?php $__errorArgs = ['registrationClass'];
$__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 class="col-sm-12 col-md-6">
                                            <input type="number" class="form-control" id="registrationNum" name="registrationNum" placeholder="เลขทะเบียน" required>
                                            <?php $__errorArgs = ['registrationNum'];
$__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="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="province">จังหวัด <span class="text-red">*</span></label>
                                    <select class="form-control selectpicker show-menu-arrow" id="province" name="province" data-live-search="true" title="--เลือกจังหวัด--" required>
                                        <?php $__currentLoopData = $provinces; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $province): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($province->name); ?>"><?php echo e($province->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    <?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 class="col-sm-12 col-md-4">
                                <div class="form-group">
                                    <label for="taxExpire">วันหมดอายุภาษี <span class="text-red">*</span></label>
                                    <div class="input-group mb-3">
                                        <input type="text" class="form-control" id="taxExpire" name="taxExpire" placeholder="วันหมดอายุภาษี" autocomplete="off"  required>
                                        <div class="input-group-append">
                                            <span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
                                        </div>
                                    </div>
                                    <?php $__errorArgs = ['taxExpire'];
$__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 card body -->

                </div>
                <div class="row mt-3">
                    <div class="col-12">
                        <div style="float:left">
                            <a href="<?php echo e(route('vehicle.index')); ?>" 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>
            </div>
        </div>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footerscript'); ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/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/custom.js')); ?>"></script>
<script>
    $(document).ready(function(){
        $('.selectpicker').selectpicker();

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

        $('#type').on('change', function () {  
            if( $('#type').val() == 'รถยนต์' ) {
                $('#vehicleNo').val('<?php echo $car_no; ?>');
            }
            if( $('#type').val() == 'รถจักรยานยนต์' ) {
                $('#vehicleNo').val('<?php echo $motobike_no; ?>');
            }
        });
    });
</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\system.pongpetrdriving.com\resources\views/vehicle/create.blade.php ENDPATH**/ ?>