<?php $__env->startSection('title','New Credit Note'); ?>
<?php $__env->startSection('crumbs', '<a href="'.route('sales-credit-notes.index').'">Credit Notes</a> · <b>New</b>'); ?>
<?php $__env->startSection('content'); ?>
<div class="card"><div class="card-h"><h2>New sales credit note</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('sales-credit-notes.store')); ?>" data-doc><?php echo csrf_field(); ?>
<div class="frow">
<div class="fld c4"><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($c->display_name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
<div class="fld c4"><label>Against invoice</label><select name="invoice_id"><option value="">—</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($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 c2"><label>Date *</label><input type="date" name="cn_date" value="<?php echo e(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 c2"><label>Reason</label><input type="text" name="reason" placeholder="e.g. Short load"></div>
</div>
<?php echo $__env->make('docs._lines', ['id'=>'cnLines', 'rows'=>[], 'cols'=>[
  ['f'=>'description','l'=>'Description *','t'=>'text','req'=>1],
  ['f'=>'qty','l'=>'Qty','t'=>'number','role'=>'qty','w'=>'110px'],
  ['f'=>'rate','l'=>'Rate','t'=>'number','role'=>'rate','w'=>'130px'],
  ['f'=>'amount','l'=>'Amount','t'=>'number','role'=>'amount','ro'=>1,'w'=>'140px'],
]], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('docs._totals', ['tax'=>null], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<div style="margin-top:12px"><button class="btn btn-pri">Save draft</button> <a class="btn btn-ghost" href="<?php echo e(route('sales-credit-notes.index')); ?>">Cancel</a></div>
</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/credit-note/form.blade.php ENDPATH**/ ?>