<?php Fun::lang() ?>
<div class="production-request print_this_form">
    <style>
        .tb_info td{
            padding-top: 7px;
        }
    </style>
    <div class="container-fluid">
        <h2>{{__('administrator.packing')}}</h2>
        <hr>
        @php
            $user = findUser($master->user_id);
            $packer = \App\Model\setup\PackerModel::find($master->packer_id);
        @endphp
        <div class="summary-header">
            <table width="100%">
                <tr>
                    <td>
                        <table class="text-left tb_info">
                            <tr>
                                <td>{{__('administrator.date')}}</td>
                                <td> : {{date('d-m-Y',strtotime($master['date']))}} </td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.invoice_number')}}</td>
                                <td> : {{$master->invoice_number}} </td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.user')}}</td>
                                <td> : {{$user?$user->name:''}} </td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.packer')}}</td>
                                <td> : {{$packer?$packer->name:''}} </td>
                            </tr>

                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <div class="wrapper-table">
            <h3>{{__('administrator.items')}}</h3>
            <table class="table table-striped table-hover ">
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{__('administrator.barcode')}}</th>
                    <th>{{__('administrator.items')}}</th>
                    <th>{{__('administrator.size')}}</th>
                    <th>{{__('administrator.color')}}</th>
                    <th>{{__('administrator.packing_qty')}}</th>
                </tr>
                </thead>
                <tbody>
                @php
                    $total_done = 0;
                @endphp
                @foreach($master->detail as $key => $row)
                    @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);
                        $total_done+=$row->qty;
                    @endphp
                    <tr>
                        <td>{{$key+1}}</td>
                        <td>{{$row->barcode}}</td>
                        <td>{{$product->product_name??''}}</td>
                        <td>{{$size->size??''}}</td>
                        <td>{{$color->name??''}}</td>
                        <td>
                            {{$row->qty}}
                        </td>
                    </tr>
                @endforeach
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="5" class="text-right no-border">{{__('administrator.total_item')}}</td>
                    <td>{{$total_done}}</td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
