
<?php Fun::lang() ?>
@php
    $fwarehouse = findWarehouse($tran->from_warehouse_id);
    $tailor = findTailor($tran->tailor_id);
    $cur = findCurrency($tran->currency_id);
@endphp
<div class="page-purchases">
    <div class="container-fluid">
        <div class="top-content">
            <div class="row1">
                <div class="col-sm-12 col-xs-12">
                    {{--<h2 class="show-product">{{__('administrator.transfer_stock')}} </h2>--}}
                    <img src="{{headerlogo()}}" alt="">
                    <hr>
                </div>
            </div>
        </div>
        <hr>
        <hr>
        <div class="summary-header">
            <table>
                <tr>
                    <td>
                        <table class="text-left">
                            <tr>
                                <td>{{__('administrator.invoice_number')}}</td>
                                <td> : {{$tran->invoice_number}} </td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.from_warehouse')}}</td>
                                <td> :  {{$fwarehouse->warehouse_name}}</td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.tailor')}}</td>
                                <td> :  {{$tailor->name}}</td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.created_at')}}</td>
                                <td> : {{date('d-m-Y',strtotime($tran['date']))}} </td>
                            </tr>
                            <tr>
                                <td>{{__('administrator.description')}}</td>
                                <td> : {{$tran->note}} </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <div class="wrapper-table">
            <table class="table table-striped table-hover ">
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{__('administrator.barcode')}}</th>
                    <th>{{__('administrator.material')}}</th>
                    <th>{{__('administrator.qty')}}</th>
                    <th>{{__('administrator.price')}}</th>
                    <th>{{__('administrator.total')}}</th>
                </tr>
                </thead>
                <tbody>
                @php $grand_total = 0; @endphp
                    @foreach($tran_detail as $key => $value)
                        @php
                            $product = getProductById($value->product_id);
                            $unit = findUnit($value->unit_id);
                            $total = $value->price*$value->qty;
                            $grand_total += $total;
                        @endphp
                        <tr>
                            <td>{{$key+=1}}</td>
                            <td>{{$product->barcode}} </td>
                            <td>{{$product->product_name}} </td>
                            <td>{{$value->qty}} {{$unit->unit}}</td>
                            <td>{{$cur->symbol??''}}{{$value->price}}</td>
                            <td>{{$cur->symbol??''}}{{$total}}</td>
                        </tr>
                    @endforeach
                    @php
                        $total_row = 8;
                        $total_data = count($tran_detail);
                        $left_row = $total_row-$total_data;
                    @endphp
                    @for ($i=0;$i<$left_row;$i++)
                        <tr>
                            <td>{{ $key ++}}</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    @endfor
                </tbody>
                @php
                    $symbol = findCurrency($tran->currency_id);
                @endphp
                <tfoot>
                <tr>
                    <td colspan="5" class="text-right no-border">{{__('administrator.total_amount')}}</td>
                    <td>{{$grand_total.' '.($symbol->symbol??'')}}</td>
                </tr>
                <tr>
                    <td colspan="5" class="text-right no-border">{{__('administrator.account_receivable')}}</td>
                    <td>{{$tran->account_receivable.' '.($symbol->symbol??'')}}</td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
