<?php Fun::lang() ?>

@php
    $hr = '<span style="text-align:center">-----------------------------------------------------------------------<span>';
@endphp
<link rel="stylesheet" type="text/css" href="{{asset('assets/css/production.css')}}">

<div class="print_form" style="overflow-y: scroll">
    <div class=" col-sm-12 col-xs-12 form-group text-center">
        <h3>{{__('administrator.return_cut_piece')}}</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('d-m-Y',strtotime($cutting->date))}}</td>
            </tr>
            <tr>
                <td>{{__('administrator.invoice_number')}}</td>
                <td>:</td>
                <td>{{$cutting->invoice_number}}</td>
            </tr>
            <tr>
                <td>{{__('administrator.tailor')}}</td>
                <td>:</td>
                <td>{{findTailor($cutting->tailor_id)->name}}</td>
            </tr>
            <tr>
                <td>{!! $cutting->done_status=='1'?('<span class="label label-success">'.__('administrator.done').'</span>'):'' !!}</td>
            </tr>
        </table>
    </div>
    <hr>
    @php $g_total = 0; @endphp
    @foreach($return as $row)
        <div class=" col-sm-12 col-xs-12 form-group text-left">
            <table class="inv-header" width="100%">
                <tr>
                    <td>{{__('administrator.return_date')}}</td>
                    <td width="2%">:</td>
                    <td>{{date('d-m-Y',strtotime($row->date))}}</td>
                    @if($row->returner)
                        <td>{{__('administrator.returner')}}</td>
                        <td>:</td>
                        <td>{{$row->returner}}</td>
                    @endif
                </tr>
                <tr>
                    <td>{{__('administrator.to_warehouse')}}</td>
                    <td>:</td>
                    <td>{{findWarehouse($row->warehouse_id)->warehouse_name}}</td>
                    @if($row->receiver)
                        <td>{{__('administrator.receiver')}}</td>
                        <td>:</td>
                        <td>{{$row->receiver}}</td>
                    @endif
                </tr>
            </table>
            <br>
            <table class="table">
                <thead>
                <tr>
                    <th>
                        {{__('administrator.barcode')}}
                    </th>
                    <th>
                        {{__('administrator.size')}}
                    </th>
                    <th>
                        {{__('administrator.qty')}}
                    </th>
                </tr>
                </thead>
                @php
                    $return_detail = \App\Model\production\cutting\CuttingReturnDetailModel::where('cutting_return_id',$row->id)->get();
                     $total_return_qty = 0;
                @endphp
                <tbody>
                @foreach($return_detail as $rd)
                    @php  $total_return_qty +=$rd->qty; @endphp
                    <tr>
                        <td>{{$rd->barcode}}</td>
                        <td>{{findSize($rd->size_id)->size}}</td>
                        <td>{{$rd->qty}} {{__('administrator.piece')}}</td>
                    </tr>
                @endforeach
                <tr>
                    <td colspan="2" class="text-right">{{__('administrator.total')}}</td>
                    <td>{{$total_return_qty}} {{__('administrator.piece')}}</td>
                </tr>
                </tbody>
            </table>
        </div>
        @php $g_total+=$total_return_qty;  @endphp
    @endforeach
    @if($return->count()==0)
        <table class="table">
            <thead>
            <tr>
                <th>
                    <h3> {{__('administrator.no_data')}}</h3>
                </th>
            </tr>
            </thead>
        </table>
    @endif
    <table class="table">
        <tr>
            <td class="no-border text-right"> {{__('administrator.total_return_cut_piece')}}</td>
            <td>{{$g_total}} {{__('administrator.piece')}}</td>
        </tr>
    </table>
    <table width="70%" class="" style="margin: 0 auto;">
        <tr>
            <td>
                <button type="button"
                        class="print_jquery_confirm button_info form-control">{{__('administrator.print')}}</button>
            </td>
            <td>
                <button type="button"
                        class="close_jquery_confirm button_warning form-control">{{__('administrator.close')}}</button>
            </td>
        </tr>
    </table>
</div>
<script>
    $(document).ready(function () {

    });
</script>
