<?php $__env->startSection('title','EMI / Installment'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1 class="page-title">EMI / Installment</h1><div class="page-subtitle">Installment sale, schedule and collection</div></div></div>

<form method="POST" action="<?php echo e(route('admin.installments.store')); ?>" class="card panel-tight grid-4"><?php echo csrf_field(); ?><div><label>Invoice No</label><input name="sale_invoice_no"></div><div><label>Customer</label><select name="customer_id" required><?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($customer->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div><label>Branch</label><select name="branch_id"><option value="">Select</option><?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($branch->id); ?>"><?php echo e($branch->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div><label>Status</label><select name="status"><option>Active</option><option>Closed</option><option>Defaulted</option></select></div><div><label>Principal</label><input type="number" step="0.01" name="principal_amount" required></div><div><label>Down Payment</label><input type="number" step="0.01" name="down_payment"></div><div><label>Installment Amount</label><input type="number" step="0.01" name="installment_amount" required></div><div><label>Installment Count</label><input type="number" name="installment_count" value="6"></div><div><label>Interval Days</label><input type="number" name="interval_days" value="30"></div><div><label>Start Date</label><input type="date" name="start_date" value="<?php echo e(date('Y-m-d')); ?>"></div><div><label>Penalty / Late Day</label><input type="number" step="0.01" name="penalty_per_late_day" value="0"></div><div><label>Notes</label><input name="notes"></div><div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Create EMI Plan</button><a class="btn" href="<?php echo e(route('admin.installments.defaulters')); ?>">Defaulters</a></div></form>
<div class="card panel-tight table-wrap"><table class="table"><thead><tr><th>ID</th><th>Invoice</th><th>Customer</th><th>Principal</th><th>Inst.</th><th>Status</th><th>Action</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $plans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $plan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><?php echo e($plan->id); ?></td><td><?php echo e($plan->sale_invoice_no ?: '—'); ?></td><td><?php echo e($plan->customer_id); ?></td><td><?php echo e($plan->principal_amount); ?></td><td><?php echo e($plan->installment_count); ?> x <?php echo e($plan->installment_amount); ?></td><td><?php echo e($plan->status); ?></td><td><details><summary class="btn">Collect</summary><form method="POST" action="<?php echo e(route('admin.installments.collect',$plan)); ?>" class="grid-2" style="margin-top:10px"><?php echo csrf_field(); ?><div><label>Payment ID</label><select name="payment_id"><?php $__currentLoopData = \App\Models\InstallmentPayment::where('installment_sale_id',$plan->id)->where('status','!=','Paid')->get(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($payment->id); ?>">#<?php echo e($payment->id); ?> - <?php echo e($payment->scheduled_date); ?> - <?php echo e($payment->amount_due); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div><label>Amount Paid</label><input type="number" step="0.01" name="amount_paid" required></div><div><label>Paid Date</label><input type="date" name="paid_date" value="<?php echo e(date('Y-m-d')); ?>"></div><div><label>Late Fee</label><input type="number" step="0.01" name="late_fee"></div><div style="grid-column:1/-1"><label>Notes</label><input name="notes"></div><div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Save Collection</button></div></form></details></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="7">No EMI plans found.</td></tr><?php endif; ?></tbody></table><?php echo e($plans->links()); ?></div>

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

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH J:\xampp\htdocs\pos\resources\views/admin/installments/index.blade.php ENDPATH**/ ?>