<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="{{asset('images/INB.png')}}" rel="shortcut icon" type="image/x-icon"/>
     <!-- Bootstrap -->
    <link href="{{asset('backend/vendors/bootstrap/dist/css/bootstrap.min.css')}}" rel="stylesheet">
    <style type="text/css">
      /* th span {
        background: #337ab7;
        color: #fff;
        font-weight: bold;
        padding: 1px;
    }*/
    </style>
</head>
<body>
    <div class="container body-section">
        <div class="toolbar hidden-print">
            <div class="">
                <a href="{{ url('sales-list') }}" class="btn btn-primary" > <<< Back</a>
            </div>
            <div class="text-right">
                <button id="printInvoice" class="btn btn-info" onclick="printDiv('printableArea')" >
                    <i class="fa fa-print"></i> Print
                </button>
                <!--<button class="btn btn-info"><i class="fa fa-file-pdf-o"></i> Export as PDF</button>-->
            </div>
            <hr>
        </div>
        <div id="printableArea">
                <header>
                    <div class="row">
                        <div class="col-sm-2 col-xs-2">
                                <img src="{{ asset('storage/about/'.about()->logo)}}" data-holder-rendered="true" class="img-responsive" width="85px" height="75px" />
                        </div>
                        <div class="col-sm-8 col-xs-8">
                            <div class="text-center">
                                <h4>{{about()->english_name}}</h4>
                                <p>Phone:  {{about()->phone}}, Email: {{about()->email}}</p>
                                <p>Address: {{about()->address }} </p>
                                <h4>Sales Details Report</h4>
                            </div>
                        </div>
                        <div class="col-sm-2 col-xs-2">
                    </div>
                </header>
                <main class="">
                    <div class="row">
                        <div class="col-sm-3 col-xs-3">
                            <b>INVOICE NO: {{$sale->invoice_no}}</b>
                        </div>
                        <div class="col-sm-6 col-xs-6"></div>
                        <div class="col-sm-3 col-xs-3">
                             <b>Sale Date: {{date('d-m-Y',strtotime($sale->sale_date))}}</b>
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-sm-12 col-xs-12">
                            <table class="table table-bordered table-condensed">
                                <tr class="customer-detail">
                                    <td><b> Name: </b> {{$sale->customer->name}}</td>
                                    <td><b>Customer Phone: </b> {{$sale->customer->phone}}</td>
                                </tr>
                                <tr class="customer-detail">
                                    <td colspan="2"><b>Address: </b>{{$sale->customer->address}} </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="row"> 
                        <div class="col-sm-12 col-xs-12">
                            <table class="table table-bordered table-condensed" cellspacing="0" cellpadding="0">
                                <thead>
                                    <tr class="bg-primary">
                                        <th>SL</th>
                                        <th>DESCRIPTION</th>
                                        <th>UNIT PRICE</th>
                                        <th>SIZE</th>
                                        <th>QUANTITY</th>
                                        <th>TSQF</th>
                                        <th>TOTAL</th>
                                    </tr>
                                </thead>
                                <tbody>
                                @foreach($sale->details as $i=>$detail)
                                    <tr>
                                        <td class="no">{{$i+1}}</td>
                                        <td class="text-left">
                                            {{$detail->product->product_name}}
                                            ( {{$detail->height}}x{{$detail->width}})
                                           
                                        </td>
                                        <td class="unit">{{$detail->unit_price}}</td>
                                        <td class="qty">{{$detail->size}}</td>
                                        <td class="qty">{{$detail->quantity}}</td>
                                        <td class="qty">{{$detail->tsqf}}</td>
                                        <td class="total">{{$detail->tsqf *  $detail->unit_price}}</td>
                                    </tr>
                                @endforeach
                                @if($sale->other_cost != '')
                                <tr>
                                    <td class="no">{{$i+2}}</td>
                                    <td colspan="3">{{$sale->note}}</td>
                                    <td >Other Cost</td>
                                    <td >{{$sale->other_cost}}</td>
                                </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                        <div class="col-sm-12 col-xs-12">
                            <table class="table table-bordered table-condensed" style="max-width: 30%;float:right">
                                <tfoot>
                                    <tr>    
                                        <td colspan="2"><b>Sub Total:</b></td>
                                        <td>{{$sale->total_price}}</td>
                                    </tr>
                                     <tr>    
                                        <td colspan="2"><b>Other Cost:</b></td>
                                        <td>{{$sale->other_cost}}</td>
                                    </tr>
                                    <tr>   
                                        <td colspan="2"><b>Discount:</b></td>
                                        <td>{{$sale->discount}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><b>Grand Total:</b></td>
                                        <td>{{$sale->grand_total_price}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><b>Payment:</b></td>
                                        <td>{{$sale->payment}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><b>Due Amount:</b></td>
                                        <td>{{$sale->due_amount}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><b>Previous Due:</b></td>
                                        <td>{{$sale->customer->sales->sum('due_amount') -  $sale->due_amount}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><b>Total Due:</b></td>
                                        <td>{{$sale->customer->sales->sum('due_amount')}}</td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                    <div style="clear: both;"></div>
                    <div class="row">
                        <div class="2">............................</div>
                        <div class="2">Authorize Signature</div>
                    </div>
                    <p>Note: {{$sale->note}}</p>
                    <div class="thanks">Thank you!</div>
                    <div class="notices">
                        <div>NOTICE:</div>
                        <div class="notice">80% price of total have to paid before print.</div>
                    </div>
                </main>
                <footer>
                    Invoice was created on a computer and is valid without the signature and seal.
                </footer>
            </div>
            <!--DO NOT DELETE THIS div. IT is responsible for showing footer always at the bottom-->
            <div></div>
        </div>
    </div>
    <script type="text/javascript">
        function printDiv(divName) {
            var printContents = document.getElementById(divName).innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;
            window.print();
            document.body.innerHTML = originalContents;
        }
    </script>
</body>
</html>