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

<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-3">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
    <div class="row">
        <div class="col-12">
            <a href="#withdrawModal" data-toggle="modal" data-target="#withdrawModal" class="btn btn-success rounded"><i class="fas fa-plus-circle"></i> เพิ่มรายการเบิกเงิน</a>
            <!-- Modal -->
            <div class="modal fade" id="withdrawModal" tabindex="-1" aria-labelledby="withdrawModalLabel" aria-hidden="true" data-backdrop="static" >
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title-card" id="withdrawModalLabel">เพิ่มรายการเบิกเงิน</h5>
                        </div>
                        <form action="<?php echo e(route('withdraw.withdraw')); ?>"
                            id="withdrawFrm"
                            novalidate class="<?php echo e(($errors->any()) ? 'was-validated' : 'needs-validation'); ?>"
                            method="post">
                            <?php echo csrf_field(); ?>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-12">
                                    <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->id); ?>" <?php if(auth()->user()->branch_id == $branch->id): ?> 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>
                            <div class="row">
                                <div class="col-12">
                                    <div class="form-group">
                                        <label for="wtype">รายการเบิก <span class="text-red">*</span></label>
                                        <select id="wtype" name="wtype" class="selectpicker show-menu-arrow form-control" title="--เลือก--" required>
                                            <option value="ค่าสอน">ค่าสอน</option>
                                            <option value="ค่าน้ำมัน">ค่าน้ำมัน</option>
                                            <option value="อื่นๆ">อื่นๆ</option>
                                        </select>
                                        <?php $__errorArgs = ['wtype'];
$__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 mt-2" id="other" style="display: none;">
                                <!-- เบิกอื่นๆ -->
                                <div class="col-12" id="wnameDiv" style="display: none;">
                                    <div class="form-group">
                                        <label for="wname" class="modal-label-card float-left mb-2">รายละเอียด <span class="text-red">*</span></label>
                                        <input type="text" class="form-control" id="wname" name="wname" placeholder="รายการเบิก" required>
                                        <?php $__errorArgs = ['wname'];
$__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-12" id="teachDateDiv" style="display: none;">
                                    <div class="row">
                                        <div class="col-5">
                                            <div class="form-group">
                                                <label for="teachDate">เดือนที่สอน <span class="text-red">*</span></label>
                                                <div class="input-group mb-3">
                                                    <input type="text" class="form-control" id="teachDate" name="teachDate" 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 = ['teachDate'];
$__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-7">
                                            <div class="form-group">
                                                <label for="teacher" class="modal-label-card float-left mb-2">ผู้สอน <span class="text-red">*</span></label>
                                                <select id="teacher" name="teacher" class="selectpicker show-menu-arrow form-control" title="--เลือก--" required>
                                                </select>
                                                <?php $__errorArgs = ['teacher'];
$__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-12" id="oilDiv" style="display: none;">
                                    <div class="row">
                                        <div class="col-12">
                                            <div class="form-group">
                                                <label for="teacherOil" class="modal-label-card float-left mb-2">ผู้เบิก <span class="text-red">*</span></label>
                                                <select id="teacherOil" name="teacherOil" class="selectpicker show-menu-arrow form-control" title="--เลือก--" required>
                                                    <?php $__currentLoopData = $teachers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $teacher): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($teacher->id); ?>"><?php echo e($teacher->title.$teacher->firstname. " " .$teacher->lastname); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                                <?php $__errorArgs = ['teacher'];
$__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>
                            <div class="row mt-2">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label>รูปแบบการจ่ายเงิน <span class="text-red">*</span></label>
                                        <div>
                                            <div class="icheck-nephritis icheck-inline">
                                                <input class="purpose" type="radio" id="cash" name="method" value="เงินสด" required>
                                                <label for="cash">เงินสด</label>
                                            </div>
                                            <div class="icheck-nephritis icheck-inline">
                                                <input class="purpose" type="radio" id="transfer" name="method" value="โอน">
                                                <label for="transfer">โอนผ่านบัญชี</label>
                                            </div>
                                        </div>
                                        <?php $__errorArgs = ['method'];
$__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="amount" class="modal-label-card float-left mb-2">จำนวนเงิน <span class="text-red">*</span></label>
                                        <input type="text" class="form-control" id="amount" name="amount" placeholder="จำนวนเงิน (บาท)" required>
                                        <?php $__errorArgs = ['amount'];
$__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 mt-2">
                                <div class="col-6">
                                    <div class="form-group">
                                        <label for="payDate">วันที่เบิก <span class="text-red">*</span></label>
                                        <div class="input-group mb-3">
                                            <input type="text" class="form-control" id="payDate" name="payDate" 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 = ['payDate'];
$__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="payTime" class="modal-label-card float-left mb-2">เวลาที่เบิก <span class="text-red">*</span></label>
                                        <div class="input-group mb-3">
                                            <input type="text" class="form-control" id="payTime" name="payTime" placeholder="เวลาที่เบิก" autocomplete="off" required>
                                            <div class="input-group-append">
                                                <span class="input-group-text"><i class="far fa-clock"></i></span>
                                            </div>
                                        </div>
                                        <?php $__errorArgs = ['payTime'];
$__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 mt-2">
                            <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">ปิด</button>
                            <button type="submit" id="payBtn" class="btn btn-success">ตกลง</button>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- End modal -->
        </div>
    </div>
    <div class="row mt-3">
        <div class="col-4">
            <form action="<?php echo e(route('withdraw.submit')); ?>"
            novalidate class="<?php echo e(($errors->any()) ? 'was-validated' : 'needs-validation'); ?>"
            method="post"
            >
            <?php echo csrf_field(); ?>
                <div class="form-group">
                    <label for="date">รายการเบิก ประจำเดือน <span class="text-red">*</span></label>
                    <div class="input-group mb-3">
                        <input type="text" class="form-control datepiacker" id="date" name="date" placeholder="เดือน/ปี" autocomplete="off" value="<?php echo e($date); ?>" required>
                        <div class="input-group-append">
                            <span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
                        </div>
                        <button type="submit" class="btn btn-outline-success show-outline-btn ml-2" value="search">แสดง</button>
                    </div>
                    <?php $__errorArgs = ['date'];
$__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>
            </form>
        </div>
    </div>
    <?php endif; ?>
    <div class="row mt-2">
        <div class="col">
            <div class="card card-outline card-success">
                <div class="card-body">
                    <table class="table" id="teacher-table">
                        <thead>
                          <tr>
                            <th scope="col" width="5%">ลำดับ</th>
                            <th scope="col" width="12%">วัน เวลา</th>
                            <th scope="col" width="25%">รายการ</th>
                            <th scope="col" width="20%">ผู้เบิก</th>
                            <th scope="col" width="8%">จำนวน</th>
                            <th scope="col" width="10%">ช่องทาง</th>
                            <th scope="col" width="10%">สาขาที่เบิก</th>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
                            <th width="10%"></th>
                            <?php endif; ?>
                          </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $withdraws; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indexKey => $withdraw): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hand-hover">
                                <td><?php echo e($indexKey+1); ?></td>
                                <td><?php echo e($withdraw->date . " ". $withdraw->time); ?></td>
                                <td><?php echo e($withdraw->wtitle); ?></td>
                                <td><?php echo e($withdraw->ttitle ." ". $withdraw->firstname . " " .$withdraw->lastname); ?></td>
                                <td><?php echo e($withdraw->amount); ?></td>
                                <td><?php echo e($withdraw->method); ?></td>
                                <td><?php echo e($withdraw->name); ?></td>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperadminOrAdmin')): ?>
                                <td class="align-middle text-center">
                                    <form id="del-frm<?php echo e($indexKey); ?>" class="d-inline"
                                        method="POST"
                                        action="<?php echo e(route('withdraw.destroy', $withdraw->id )); ?>"
                                        onsubmit="confirmalert(event, <?php echo e($indexKey); ?>, 'รายการเบิก')"
                                    >
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="btn del-btn btn-sm ml-2" data-toggle="tooltip" data-placement="top" title="ลบข้อมูล">
                                            <i class="far fa-trash-alt"></i>
                                        </button>
                                    </form>
                                </td>
                                <?php endif; ?>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                      </table>
                </div>
            </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/bootstrap-select.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/bootstrap-timepicker.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/custom.js')); ?>"></script>
<script src="<?php echo e(asset('js/withdraw.js')); ?>"></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('layouts.web', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\system.pongpetrdriving.com\resources\views/withdraw/index.blade.php ENDPATH**/ ?>