<?php $__env->startSection('section-title', 'Account'); ?>
<?php $__env->startSection('page-title', 'Withdraw'); ?>

<?php if(check_permission('accounting.transaction-history')): ?>
    <?php $__env->startSection('action-button'); ?>
        <a href="<?php echo e(url('transaction-history')); ?>" class="btn add_list_btn">
            <i class="mr-2 feather icon-list"></i>
            Transaction History
        </a>
    <?php $__env->stopSection(); ?>
<?php endif; ?>

<?php $__env->startSection('content'); ?>
    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card card_style">
                <div class="card-body">
                    <div class="">
                        <form class="row g-3 needs-validation" method="POST" action="<?php echo e(route('withdraw-store')); ?>" enctype="multipart/form-data">
                            <?php echo csrf_field(); ?>
                            
                            <div class="mt-2 col-md-6">
                                <label class="form-label font-weight-bold">Date</label>
                                <input type="date" class="form-control" value="<?php echo e(date('Y-m-d')); ?>" name="date" required>
                                <div class="error"><?php echo e(($errors->has('date'))?$errors->first('date'):''); ?></div>
                            </div>

                            
                            <div class="mt-2 col-md-6">
                                <label class="form-label fw-bold">Bank Account *</label>
                                <select class="select2 bank_id" name="bank_id" required>
                                    <option selected value="">Select Bank Account</option>
                                    <?php $__currentLoopData = $bank_accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bank_account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($bank_account->id); ?>">
                                            <?php echo e($bank_account->bank_name); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <div class="error"><b id="amount"></b></div>
                                <input type="hidden" name="from_amount" class="from_amount">
                                <div class="error"><?php echo e(($errors->has('bank_id'))?$errors->first('bank_id'):''); ?></div>
                            </div>

                            
                            <div class="mt-2 col-md-12">
                                <label for="amount" class="form-label fw-bold">Withdraw Amount *</label>
                                <input type="number" class="form-control" min="1" step="any" placeholder="Enter Withdraw Amount" name="withdraw_amount" required>
                                <div class="error"><?php echo e(($errors->has('withdraw_amount'))?$errors->first('withdraw_amount'):''); ?></div>
                            </div>

                            
                            <div class="mt-2 col-md-12">
                                <label for="details" class="form-label fw-bold">Note</label>
                                <textarea name="note" class="form-control" rows="2"></textarea>
                            </div>

                            
                            <div class="mt-2 text-center col-md-12">
                                <?php if(check_permission('withdraw-store')): ?>
                                    <button class="btn save_btn" type="submit">Save</button>
                                <?php endif; ?>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
    <script type="text/javascript">
        $(function(){
            $(document).on('change', '.bank_id', function(){
            var bank_id = $(this).val();
            if (bank_id != '') {
                $.ajax({
                    url:"<?php echo e(route('get-account-balance')); ?>",
                    type:"GET",
                    data:{bank_id:bank_id},
                    success:function(data){
                        var balance = 'Current Balance : '+data.balance+' TK';
                        $('#amount').text(balance);
                        $('.from_amount').val(data.balance);
                    }
                });
            }
            });
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\new demo\resources\views/backend/pages/account/withdraw.blade.php ENDPATH**/ ?>