<?php Fun::lang() ?>
<?php $total = 0 ?>
<?php $total_discount = 0 ?>

<div class="print_this_form">
    <div class="row">
        <div class="col-sm-12">
            <table class="text-left">
                <tr>
                    <td>{{__('administrator.supplier_name')}}</td>
                    <td width="10px"> :</td>
                    <td><strong>{{$supplier->supplier_name}}</strong></td>
                </tr>
                <tr>
                    <td>{{__('administrator.supplier_phone')}}</td>
                    <td> :</td>
                    <td>{{$supplier->supplier_phone}}</td>
                </tr>
                <tr>
                    <td>{{__('administrator.supplier_email')}}</td>
                    <td> :</td>
                    <td>{{$supplier->supplier_email}}</td>
                </tr>
                <tr>
                    <td>{{__('administrator.supplier_address')}}</td>
                    <td> :</td>
                    <td>{{$supplier->supplier_address}}</td>
                </tr>
                <tr>
                    <td>{{__('administrator.created_at')}}</td>
                    <td> :</td>
                    <td>{{date('d-m-Y', strtotime($supplier->created_at)) }}</td>
                </tr>
            </table>
        </div>
        <h4 style="margin-top: 10px;margin-bottom: 10px">{{__('administrator.purchase_history')}}</h4>
        <div class="col-sm-12">
            <table class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>#</th>
                    <th>{{__('administrator.purchase_date')}}</th>
                    <th>{{__('administrator.invoice_number')}}</th>
                    <th>{{__('administrator.paid')}}</th>
                    <th>{{__('administrator.total')}}</th>
                    <th>{{__('administrator.remain')}}</th>
                    <th>{{__('administrator.payment_status')}}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($history as $key =>$row)
                    <?php
                    $total_paid = $row->paid;
                    $total_paid = findCurrency($row->currency_id)->symbol . number_format($total_paid, 2);
                    $total = getPurchaseTotal($row);
                    $remain = $total - $row->paid;
                    $remain = findCurrency($row->currency_id)->symbol . number_format(($remain > 0 ? $remain : 0), 2);
                    ?>
                    <tr>
                        <td>{{$key+1}}</td>
                        <td>{{date('d-m-Y',strtotime($row->purchase_date))}}</td>
                        <td><a class="under-line cursor text-primary btn_purchase_invoice_public" data-href="{{route("purchases.show", $row->id)}}">{{$row->invoice_number}}</a></td>
                        <td>{{$total_paid}}</td>
                        <td>{{$total}}</td>
                        <td>{{$remain}}</td>
                        <td>{!! checkPaymentStatus($row->payment_status) !!}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {!! Form::hidden('supplier_id_hide', @$supplier?$supplier->supplier_id:'') !!}
            @if(@$history)
                {!! $history->render() !!}
            @endif
        </div>
    </div>
</div>





