@extends('layouts.jform')
@section('content')
    <?php Fun::lang() ?>
    <div class="page-purchases">
        <div class="container-fluid">

            <hr>
            <div class="summary-header">
                <table>
                    <tr>
                        <td>
                            <table class="text-left">
                                <tr>
                                    <td>{{__('administrator.invoice_number')}}</td>
                                    <td> : {{$item->invoice_number}} </td>
                                </tr>
                                <tr>
                                    <td>{{__('administrator.request_by')}}</td>
                                    <td> : {{findUser($item->request_by)->name}}</td>
                                </tr>
                                <tr>
                                    <td>{{__('administrator.request_to')}}</td>
                                    <td> : {{findBranch($item->branch_id)->name}}</td>
                                </tr>
                                <tr>
                                    <td>{{__('administrator.created_at')}}</td>
                                    <td> : {{date('d-m-Y',strtotime($item['date']))}} </td>
                                </tr>
                                <tr>
                                    <td>{{__('administrator.note')}}</td>
                                    <td> : {{$item->note}} </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
            <?php
            $readonly = '';
            $status = 3;
            if($item->status===3&&$item->request_to==Auth::user()->branch_id){
                $readonly = 'readonly';
                $status = 4;
            }

            ?>
            <div class="wrapper-table">
                {!! Form::open(array('route' => ['request-stock-update-status',$status],'method'=>'GET','class'=>'jform')) !!}

                <input type="hidden" name="id" value="{{$item->id}}">
                <table class="table table-striped table-hover ">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>{{__('administrator.barcode')}}</th>
                        <th>{{__('administrator.item')}}</th>
                        <th>{{__('administrator.size')}}</th>
                        <th>{{__('administrator.qty')}}</th>
                        <th>{{__('administrator.return_qty')}}</th>
                    </tr>
                    </thead>
                    <tbody>

                        @foreach($item_detail as $key => $value)

                            <tr>
                                <td>{{$key+=1}}
                                    <input type="hidden" name="detail_id[]" value="{{$value->id}}">

                                </td>
                                <td>{{$value->barcode}} </td>
                                <td>{{optional($value->getItem)->product_name}} </td>
                                <td>{{optional($value->getSize)->size}}</td>
                                <td>{{$value->qty}} {{optional($value->getUnit)->unit}}</td>
                                <td>{!! Form::text('return_qty[]',$value->return_qty, ['placeholder'=>__('administrator.return_qty'),'class' => 'form-control number-only','max'=>$value->qty,$readonly]) !!}</td>
                            </tr>
                        @endforeach

                    </tbody>
                </table>
                {!! Form::submit('Submit', ['class' => 'hidden']) !!}

                {!! Form::close() !!}

            </div>
        </div>
    </div>
@endsection
