
<?php $__env->startSection('title', 'New Loan'); ?>

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

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

<?php $__env->startSection('content'); ?>
<div class="col-md-12">
    <form class="card" action="<?php echo e(route('loans.store')); ?>" method="POST">
        <?php echo csrf_field(); ?>
        <h4 class="card-title fw-400"> Loan 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(key: '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>

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label>Loan Amount<span class="text-danger">*</span></label>
            <input type="number" step="0.01" name="loan_amount"
                class="form-control <?php echo e($errors->has('loan_amount') ? 'is-invalid' : ''); ?>"
                placeholder="Enter Loan Amount" value="<?php echo e(old('loan_amount')); ?>" required>
            <?php if($errors->has('loan_amount')): ?>
            <div class="invalid-feedback"><?php echo e($errors->first('loan_amount')); ?></div>
            <?php endif; ?>
        </div>
    </div>

    <div class="col-md-6">
        <div class="form-group">
            <label>Interest Rate (%)<span class="text-danger">*</span></label>
            <input type="number" step="0.01" name="interest_rate"
                class="form-control <?php echo e($errors->has('interest_rate') ? 'is-invalid' : ''); ?>"
                placeholder="Enter Interest Rate" value="<?php echo e(old('interest_rate')); ?>" required>
            <?php if($errors->has('interest_rate')): ?>
            <div class="invalid-feedback"><?php echo e($errors->first('interest_rate')); ?></div>
            <?php endif; ?>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label>Installment Type<span class="text-danger">*</span></label>
            <select name="installment_type"
                class="form-control <?php echo e($errors->has('installment_type') ? 'is-invalid' : ''); ?>" required>
                <option value="">Select Type</option>
                <option value="daily" <?php echo e(old('installment_type') == 'daily' ? 'selected' : ''); ?>>Daily</option>
                <option value="weekly" <?php echo e(old('installment_type') == 'weekly' ? 'selected' : ''); ?>>Weekly</option>
                <option value="monthly" <?php echo e(old('installment_type') == 'monthly' ? 'selected' : ''); ?>>Monthly</option>
            </select>
            <?php if($errors->has('installment_type')): ?>
            <div class="invalid-feedback"><?php echo e($errors->first('installment_type')); ?></div>
            <?php endif; ?>
        </div>
    </div>

    <div class="col-md-6">
        <div class="form-group">
            <label>Number of Installments<span class="text-danger">*</span></label>
            <input type="number" name="installment_count"
                class="form-control <?php echo e($errors->has('installment_count') ? 'is-invalid' : ''); ?>"
                placeholder="Enter Number of Installments" value="<?php echo e(old('installment_count')); ?>" required>
            <?php if($errors->has('installment_count')): ?>
            <div class="invalid-feedback"><?php echo e($errors->first('installment_count')); ?></div>
            <?php endif; ?>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label>Issue 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="issue_date"
                placeholder="Issue Date" autocomplete="off" value="<?php echo e(request('issue_date', date('Y-m-d'))); ?>" required>
        </div>
    </div>

    <div class="col-md-6">
        <div class="form-group">
            <label>First Installment Date (Optional)</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="first_installment_date" placeholder="First Installment Date (Optional)" autocomplete="off"
                value="<?php echo e(request('first_installment_date')); ?>">
            <small class="form-text text-muted">
                Leave blank to auto-calculate based on installment type
            </small>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label>Bank Account</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>
        </div>
    </div>

    <div class="col-md-6">
        <div class="form-group">
            <label>সঞ্চয় </label>
            <input type="number" step="0.01" name="savings_amount"
                class="form-control <?php echo e($errors->has('savings_amount') ? 'is-invalid' : ''); ?>"
                placeholder="Enter Saving Amount (Optional)" value="<?php echo e(old('savings_amount', 0)); ?>">
            <?php if($errors->has('savings_amount')): ?>
            <div class="invalid-feedback">
                <?php echo e($errors->first('savings_amount')); ?>

            </div>
            <?php endif; ?>
        </div>
    </div>
</div>


</div>

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

<?php $__env->startSection('styles'); ?>
<style>
    /* Custom styles if needed */

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

<?php $__env->startSection('scripts'); ?>
<script>
    /* Optional scripts if needed */

</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/loans/create.blade.php ENDPATH**/ ?>