<?php Fun::lang() ?>
<div class="production-request">
    <div class="container-fluid">
        <hr>
        <?php
            $user = findUser($production->user_id);
            $tailor =  \App\Model\people\TailorModel::find($production->tailor_id);
        ?>
        <div class="summary-header">
            <table width="100%">
                <tr>
                    <td>
                        <table class="text-left">
                            <tr>
                                <td><?php echo e(__('administrator.invoice_number')); ?></td>
                                <td> : <?php echo e($production->invoice_number); ?> </td>
                            </tr>
                            <tr>
                                <td><?php echo e(__('administrator.user')); ?></td>
                                <td> : <?php echo e($user?$user->name:''); ?> </td>
                            </tr>
                            <tr>
                                <td><?php echo e(__('administrator.tailor')); ?></td>
                                <td> : <?php echo e($tailor?$tailor->name:''); ?> </td>
                            </tr>
                            <tr>
                                <td><?php echo e(__('administrator.date')); ?></td>
                                <td> : <?php echo e(date('d-m-Y',strtotime($production['date']))); ?> </td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <table class="pull-right">
                            <tr>
                                <td><?php echo e(__('administrator.packer')); ?><i class="text-danger">*</i> &nbsp;&nbsp;</td>
                                <td><?php echo Form::select('packer_id',\App\Model\setup\PackerModel::pluck('name','id'),null,['class'=>'form-control','placeholder'=>__('administrator.please_select')]); ?></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <?php
            $cur = findCurrency($production->currency_id);
            $symbol = $cur->symbol??'';
        ?>
        <div class="wrapper-table">
            <h3><?php echo e(__('administrator.items')); ?></h3>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>#</th>
                    <th><?php echo e(__('administrator.barcode')); ?></th>
                    <th><?php echo e(__('administrator.items')); ?></th>
                    <th><?php echo e(__('administrator.size')); ?></th>
                    <th><?php echo e(__('administrator.color')); ?></th>
                    <th><?php echo e(__('administrator.production_qty')); ?></th>
                    <th><?php echo e(__('administrator.packing')); ?></th>
                    <th><?php echo e(__('administrator.remain')); ?></th>
                    <th><?php echo e(__('administrator.packing_qty')); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php
                    $total_packing = 0;
                    $total_remain = 0;
                ?>
                <?php $__currentLoopData = $detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        $product_unit = findProductUnitByCode($row->barcode,'product');
                        $product = getProductById($product_unit->product_id);
                        $size = findSize($product_unit->size_code);
                        $color = findColor($product_unit->color_code);
                        $unit = findUnit($product_unit->unit_id);

                        $remain = $row->return_qty-$row->packing_qty;
                    ?>
                    <tr>
                        <td><?php echo e($key++); ?></td>
                        <td><?php echo e($row->barcode); ?></td>
                        <td><?php echo e($product->product_name??''); ?></td>
                        <td><?php echo e($size->size??''); ?></td>
                        <td><?php echo e($color->name??''); ?></td>
                        <td><?php echo e($row->return_qty); ?></td>
                        <td><?php echo e($row->packing_qty); ?></td>
                        <td><?php echo e($remain); ?></td>
                        <td>
                            <?php echo Form::text('qty[]', $remain, ['class' => 'form-control number-only packing_qty','data-max'=>$remain]); ?>

                            
                            <?php echo Form::hidden('detail_id[]', $row->id); ?>

                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="5" class="text-right no-border"><?php echo e(__('administrator.total_item')); ?></td>
                    <td><?php echo e($production->return_qty); ?></td>
                    <td><?php echo e($production->packing_qty); ?></td>
                    <td><?php echo e($production->return_qty-$production->packing_qty); ?></td>
                    <td></td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<?php echo Form::hidden('production_id', $production->id); ?>

<?php echo Form::submit('Submit', ['class' => 'hidden']); ?>

<script>
    $(document).ready(function (){
        $('.packing_qty').on('keyup',function () {
            let max = $(this).data('max')
            max = max?parseFloat(max):0;
            let qty = $(this).val()
            qty = qty?parseFloat(qty):0;
            if(max<qty){
                $(this).val(max)
            }
        })
    })
</script>
<?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/administrator/production-packing/form.blade.php ENDPATH**/ ?>