<?php Fun::lang()?>
        <!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>NSO POS</title>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/css/pos-invoice.css')); ?>">
</head>

<body>
<?php
    $customer = findCustomer($master->customer_id);
?>
<div class="print_invoice_wholesale">
    <h3>Sale Return</h3>
    <hr width="40%">
    <table>
        <tr style="text-align: left;">
            <td>
                <table>

                    <tr class="font_12">
                        <td  class="width-20"><?php echo e(__('administrator.invoice')); ?></td>
                        <td>: <?php echo e($master->invoice_number); ?></td>
                    </tr>
                    <tr class="font_12">
                        <?php if($master->user_id): ?>
                            <td><?php echo e(__('administrator.request_by')); ?></td>
                            <td>: <?php echo e(findUser($master->user_id)->name); ?></td>
                        <?php endif; ?>
                    </tr>
                    <tr class="font_12">
                        <td><?php echo e(__('administrator.request_to')); ?></td>
                        <td>: <?php echo e(findBranch($master->branch_id)->name); ?></td>
                    </tr>
                </table>
            </td>
            <td>
                <?php if($master->customer_id): ?>
                    <table class="table-right-side">
                        <tr class="font_12">
                            <td><?php echo e(__('administrator.date')); ?></td>
                            <td  width="40%" >: <?php echo e(date('d-m-Y',strtotime($master->sale_date))); ?></td>
                        </tr>
                        <tr class="font_12">
                            <td><?php echo e(__('administrator.customer')); ?></td>
                            <td > : <?php echo e($customer?$customer->customer_name:''); ?></td>
                        </tr>

                    </table>
                <?php endif; ?>
            </td>
        </tr>
    </table>
    <?php
        $hide=0;
            foreach($detail as $key => $row){
                if($row->dis==0){
                    $hide ++;
                }
            }
    ?>
    <form class="return_form_stock">
        <input type="text"class="hidden" value="<?php echo e($master->id); ?>" name="sale_id">
        <table class="table m-top-30">
            <thead>
            <tr>
                <th width="6%">#</th>
                <th><?php echo e(__('administrator.code')); ?></th>
                <th><?php echo e(__('administrator.products')); ?></th>
                <th><?php echo e(__('administrator.qty')); ?></th>
                <th><?php echo e(__('administrator.size')); ?></th>
                <th><?php echo e(__('administrator.price')); ?></th>
                <th><?php echo e(__('administrator.discount')); ?>(%)</th>
                <th width="10%"><?php echo e(__('administrator.total')); ?></th>
                <th width="10%"><?php echo e(__('administrator.return_qty')); ?></th>

            </tr>
            </thead>
            <tbody>
            <?php
            $subtotal = 0;
            $key = 0;
            ?>
            <?php if($detail): ?>
                <?php $__currentLoopData = $detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                    $product = getProductById($row->product_id);
                    $unit = (findUnit($row->unit_id));
                    if (\App\Fun\Fun::lang() == 'km') {
                        $unit = $unit->unit_name_km;
                    } else {
                        $unit = $unit->unit_name_en;
                    }
                    ?>
                    <tr role="row">
                        <td><?php echo e($key+=1); ?></td>
                        <td><?php echo e($row->barcode); ?><input type="text"class="hidden" value="<?php echo e($row->id); ?>" name="sale_detail_id[]"></td>
                        <td><?php echo e($product->product_name); ?></td>
                        <td><?php echo e($row->qty.' '.$unit); ?></td>
                        <td><?php echo e(findSize($row->size_id)->size); ?></td>
                        <td><?php echo e(findCurrency($master->currency_id)->symbol.$row->sale_price); ?></td>
                        <td ><?php echo e(number_format($row->dis)); ?>%</td>
                        <td><?php echo e(findCurrency($master->currency_id)->symbol.generateTotal($row)); ?></td>
                        <td><input class="form-control return_qty" type="text" name="return_qty[]" data-max="<?php echo e($row->qty); ?>" value="0"></td>

                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                <?php
                    $total_row = 10;
                    $total_data = count($detail);
                    $left_row = $total_row-$total_data;
                ?>
                <?php if($total_row>$total_data): ?>
                    <?php for($i=0;$i<$left_row; $i++): ?>
                        <tr>
                            <td><?php echo e($key += 1); ?></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    <?php endfor; ?>
                <?php endif; ?>
            <?php endif; ?>
            </tbody>
        </table>
    </form>
</div>
<script>
    $(document).ready(function () {
        $('.return_qty').on('keyup',function () {
            let $qty = $(this).data('max');
            let $return_qty = $(this).val();
            $qty = $qty?parseFloat($qty):0;
            $return_qty = $return_qty?parseFloat($return_qty):0;
            if($qty<$return_qty){
                $(this).val($qty);
            }
        });
    })
</script>
</body>
</html>

<?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/pos/sale-request/return.blade.php ENDPATH**/ ?>