
<?php $__env->startSection('title', 'Add Savings'); ?>

<?php $__env->startSection('page-header'); ?>
<header class="header bg-ui-general">
    <div class="header-info">
        <h1 class="header-title">
            <strong>New Savings</strong>
        </h1>
    </div>

    <div class="header-action">
        <nav class="nav">
            <a class="nav-link" href="<?php echo e(route('savings.index')); ?>">
                Savings List
            </a>
            <a class="nav-link active" href="<?php echo e(route('savings.create')); ?>">
                <i class="fa fa-plus"></i>
                New Savings
            </a>
        </nav>
    </div>
</header>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="col-md-12">
    <form class="card" action="<?php echo e(route('savings.store')); ?>" method="POST">
        <?php echo csrf_field(); ?>
        <h4 class="card-title fw-400">Savings Information</h4>

        <div class="card-body">

            
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Customer <span class="text-danger">*</span></label>
                        <select name="customer_id"
                            class="form-control <?php echo e($errors->has('customer_id') ? 'is-invalid' : ''); ?>"
                            data-provide="selectpicker" data-live-search="true" data-size="10" required>
                            <option value="">Select Customer</option>
                            <?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($customer->id); ?>"
                                <?php echo e(old('customer_id') == $customer->id ? 'selected' : ''); ?>>
                                <?php echo e($customer->name); ?> (<?php echo e($customer->mobile_no); ?>) <?php echo e($customer->account_no); ?>

                            </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php if($errors->has('customer_id')): ?>
                        <div class="invalid-feedback"><?php echo e($errors->first('customer_id')); ?></div>
                        <?php endif; ?>
                    </div>
                </div>
                
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Total Savings</label>
                        <input type="text" id="total_savings" class="form-control" value="0.00" disabled>
                    </div>
                </div>


                
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Bank Account <span class="text-danger">*</span></label>
                        <select name="bank_account_id" class="form-control" required>
                            <?php $__currentLoopData = App\BankAccount::all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($account->id); ?>"><?php echo e($account->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php $__errorArgs = ['bank_account_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <div class="invalid-feedback"><?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-md-6">
                    <div class="form-group">
                        <label>Amount <span class="text-danger">*</span></label>
                        <input type="number" step="0.01" name="amount"
                            class="form-control <?php echo e($errors->has('amount') ? 'is-invalid' : ''); ?>"
                            placeholder="Enter Amount" value="<?php echo e(old('amount')); ?>" 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="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="form-group">
                        <label>Deposit Date <span class="text-danger">*</span></label>
                        <input type="text" data-provide="datepicker" data-date-today-highlight="true"
                            data-orientation="bottom" data-date-format="yyyy-mm-dd" data-date-autoclose="true"
                            class="form-control" name="deposit_date" placeholder="Deposit Date"
                            value="<?php echo e(old('deposit_date', date('Y-m-d'))); ?>" required>
                        <?php $__errorArgs = ['deposit_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                </div>
            </div>

        </div>

        <footer class="card-footer text-right">
            <button type="submit" class="btn btn-primary">
                <i class="fa fa-save"></i> Add Savings
            </button>
        </footer>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
<style>
    /* Optional custom styles */

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

<?php $__env->startSection('scripts'); ?>
<script>
$(document).ready(function() {
    // When customer select changes
    $('select[name="customer_id"]').change(function() {
        var customerId = $(this).val();
        if(customerId) {
            $.get('/back/savings/customer-savings/' + customerId, function(data) {
                // data should return total_savings
                var total = parseFloat(data.total_savings) || 0;
                $('#total_savings').val(total.toFixed(2));
            });
        } else {
            $('#total_savings').val('0.00');
        }
    });
});
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/demosoftghor/sm.demo.softghor.com/resources/views/pages/savings/create.blade.php ENDPATH**/ ?>