<?php $__env->startSection('title','Receive Customer Payment'); ?>
<?php $__env->startSection('crumbs', '<a href="'.route('customer-payments.index').'">Receipts</a> · <b>New</b>'); ?>
<?php $__env->startSection('content'); ?>
<div class="card" style="max-width:860px"><div class="card-h"><h2>Receive payment (posts immediately)</h2><div class="sp"><span class="bdg b-info"><?php echo e($docNo); ?></span></div></div>
<div class="card-b"><form method="POST" action="<?php echo e(route('customer-payments.store')); ?>"><?php echo csrf_field(); ?>
<div class="frow">
<div class="fld c6"><label>Customer *</label><select name="customer_id" required><option value="">—</option><?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($c->id); ?>" data-defcur="<?php echo e($c->default_currency); ?>" <?php echo e($record->customer_id==$c->id?'selected':''); ?>><?php echo e($c->display_name); ?> (<?php echo e(money($c->current_balance)); ?>)</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="fld c6"><label>Against invoice</label><select name="invoice_id"><option value="">— On account —</option><?php $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($i->id); ?>" data-cur="<?php echo e($i->currency_code); ?>" <?php echo e($record->invoice_id==$i->id?'selected':''); ?>><?php echo e($i->invoice_no); ?> (<?php echo e($i->currency_code); ?>) — due <?php echo e(money($i->balance_due)); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="fld c3"><label>Date *</label><input type="date" name="payment_date" value="<?php echo e($record->payment_date?->format('Y-m-d') ?? date('Y-m-d')); ?>" required></div>
<?php echo $__env->make('docs._fxfields', ['record' => $record, 'fx' => $fx, 'isNew' => true, 'lockCur' => !empty($record->invoice_id)], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<script>
(function(){var inv=document.querySelector('select[name=invoice_id]'),cur=document.querySelector('[data-fx-cur]');
if(!inv||!cur)return;
function sync(){var o=inv.options[inv.selectedIndex];var c=o&&o.dataset?o.dataset.cur:'';
var hid=document.querySelector('input[name=currency_code][type=hidden]');
if(c){cur.value=c;cur.dispatchEvent(new Event('change'));cur.disabled=true;
if(hid)hid.value=c;else{var h=document.createElement('input');h.type='hidden';h.name='currency_code';h.value=c;cur.parentNode.appendChild(h);}}
else{cur.disabled=false;if(hid)hid.remove();}}
inv.addEventListener('change',sync);sync();})();
</script>
<div class="fld c3"><label>Amount *</label><input type="number" step="0.01" name="amount" value="<?php echo e($record->amount); ?>" required style="font-weight:800"></div>
<div class="fld c3"><label>Mode *</label><select name="payment_mode"><option value="bank-transfer" <?php echo e($record->payment_mode==='bank-transfer'?'selected':''); ?>>Bank transfer</option><option value="cash" <?php echo e($record->payment_mode==='cash'?'selected':''); ?>>Cash</option><option value="cheque" <?php echo e($record->payment_mode==='cheque'?'selected':''); ?>>Cheque</option><option value="momo" <?php echo e($record->payment_mode==='momo'?'selected':''); ?>>MoMo</option></select></div>
<div class="fld c3"><label>Into bank/cash</label><select name="bank_account_id"><option value="">—</option><?php $__currentLoopData = $banks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($b->id); ?>"><?php echo e($b->display_name); ?> (<?php echo e($b->currency); ?>)</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="fld c4"><label>Cheque no.</label><input type="text" name="cheque_no"></div>
<div class="fld c4"><label>Reference</label><input type="text" name="reference"></div>
<div class="fld c4"><label>Received by</label><input type="text" name="received_by" value="<?php echo e(auth()->user()->name); ?>"></div>
<div class="fld c12"><label>Remarks</label><input type="text" name="remarks"></div>
</div>
<button class="btn btn-pri">💰 Post receipt</button> <a class="btn btn-ghost" href="<?php echo e(route('customer-payments.index')); ?>">Cancel</a>
</form></div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/user/nowills-sqc-erp/resources/views/docs/customer-payment/form.blade.php ENDPATH**/ ?>