@extends('layouts.jform')
@section('content')
    <?php Fun::lang() ?>
    <?php
    $user = findUser($master->user_id);
    $export_to = findWarehouse($master->export_to);
    $date = date('d-m-Y', strtotime($master->date));
    ?>
    <div class="print_form" style="overflow-y: scroll">
        <div class=" col-sm-12 col-xs-12 form-group text-center">
            <h3>{{__('administrator.return_item')}}</h3>
        </div>
        <div class=" col-sm-12 col-xs-12 form-group">
            <table class="inv-header">
                <tr>
                    <td>{{__('administrator.start_date')}}</td>
                    <td width="2%">:</td>
                    <td>{{$date}}</td>
                </tr>
                <tr>
                    <td>{{__('administrator.invoice_number')}}</td>
                    <td>:</td>
                    <td>{{$master->invoice_number}}</td>
                </tr>
                <tr>
                    <td>{{__('administrator.user')}}</td>
                    <td>:</td>
                    <td>{{$user->name??''}}</td>
                </tr>
            </table>
        </div>
        <hr>
        <div class=" col-sm-12 col-xs-12 form-group text-left">
            <table class="table" width="100%">
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{__('administrator.items')}}</th>
                    <th>{{__('administrator.barcode')}}</th>
                    <th>{{__('administrator.return_qty')}}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($detail as $key=> $row)
                    @php
                        $total = $row->qty*$row->template_qty;
                        $product_unit = findProductUnitByCode($row->barcode);
                        if($product_unit){
                                 $product = getProductById($product_unit->product_id);
                                 $product = $product->product_name??'';
                                 $size = findSize($product_unit->size_code);
                                 $color = findColor($product_unit->color_code);
                                 $size = $size->size??'';
                                 $color = $color->name??'';
                        }else{
                            $product = '';
                            $size = '';
                            $color = '';
                        }
                    @endphp
                    <tr>
                        <td>{{$key+1}}</td>
                        <td>{{"$product ($size , $color)"}}{!! Form::hidden('barcode[]', $row->barcode) !!}</td>
                        <td>{{$row->barcode}}</td>
                        <td>{{$row->qty}}</td>
                    </tr>
                @endforeach
                </tbody>
                <tfoot>
                </tfoot>
            </table>
            <br>
        </div>
    </div>
@endsection

