<?php $__env->startSection('content'); ?>
    <div class="template-pdf-invoice">
        <div class="row">
            <div class="col-xs-6 invoice-number">
                <h5>Invoice Number: #<?php echo $invoice->invoice_no; ?></h5>
            </div>

            <?php if(isset($invoice->image_url) && $invoice->image_url != ''): ?>
                <div class="col-xs-6">
                    <div class="logo" style="background-image: url( <?php echo $invoice->image_url; ?> );"></div>
                </div>
            <?php endif; ?>
        </div>

        <div class="row">
            <div class="col-xs-6 invoice-to">
                <h5>To:</h5>

                <?php if($invoice->customer): ?>
                    <?php if($invoice->customer->contact): ?>
                        <p><?php echo $invoice->customer->contact; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->company_name): ?>
                        <p><?php echo $invoice->customer->company_name; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->address): ?>
                        <p><?php echo $invoice->customer->address; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->address_line1): ?>
                        <p><?php echo $invoice->customer->address_line1; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->address_line2): ?>
                        <p><?php echo $invoice->customer->address_line2; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->city): ?>
                        <p><?php echo $invoice->customer->city; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->postcode): ?>
                        <p><?php echo $invoice->customer->postcode; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->telephone): ?>
                        <p><?php echo $invoice->customer->telephone; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->customer->email): ?>
                        <p><?php echo $invoice->customer->email; ?></p>
                    <?php endif; ?>
                <?php endif; ?>
            </div>

            <div class="col-xs-6 invoice-from">
                <h5>From: </h5>

                <?php if($invoice->invoice_template && $invoice->invoice_template->business): ?>
                    <?php if($invoice->invoice_template->business->name): ?>
                        <p><?php echo $invoice->invoice_template->business->name; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->business->address_line1): ?>
                        <p><?php echo $invoice->invoice_template->business->address_line1; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->business->address_line2): ?>
                        <p><?php echo $invoice->invoice_template->business->address_line2; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->business->city): ?>
                        <p><?php echo $invoice->invoice_template->business->city; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->business->postcode): ?>
                        <p><?php echo $invoice->invoice_template->business->postcode; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->telephone &&
                        strlen($invoice->invoice_template->telephone) >= 6 &&
                        strlen($invoice->invoice_template->telephone) <= 18): ?>
                        <p><?php echo $invoice->invoice_template->telephone; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->email): ?>
                        <p><?php echo $invoice->invoice_template->email; ?></p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->with_vat && $invoice->invoice_template->vat): ?>
                        <p>VAT Number: <?php echo $invoice->invoice_template->vat; ?></p>
                    <?php endif; ?>
                <?php endif; ?>
            </div>
        </div>

        <div class="row" style="margin-top: 20px;">
            <div class="col-md-12">
                <p>Invoice Date: <?php echo Helper::formatDate($invoice->date);; ?></p>

                <?php if($invoice->due_selection == 'Paid'): ?>
                    <p>Paid with thanks</p>
                <?php else: ?>
                    <p>Due Date: <?php echo Helper::formatDate($invoice->due_on); ?></p>
                <?php endif; ?>
            </div>
        </div>

        <div class="invoice-middle">
            <table class="table">
                <thead>
                <tr>
                    <th>Product Name</th>
                    <th>Description</th>
                    <th class="text-center">Quantity</th>
                    <th class="text-right">Unit Price</th>
                    <?php if($invoice->invoice_template->with_vat): ?>
                        <th class="text-right">VAT(%)</th>
                    <?php endif; ?>
                    <th class="text-right">Amount</th>
                </tr>
                </thead>
                <tbody>
                <?php if($invoice->invoice_details == null || count($invoice->invoice_details) == 0): ?>
                    <tr>
                        <td>Empty Product</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                <?php endif; ?>

                <?php /*Invoice details begin*/ ?>
                <?php if($invoice->invoice_details): ?>
                    <?php foreach($invoice->invoice_details as $detail ): ?>
                        <tr>
                            <td><?php echo $detail->name; ?></td>
                            <td><?php echo $detail->description; ?></td>
                            <td class='text-center'><?php echo $detail->quantity; ?></td>
                            <td class="text-right"><?php echo Helper::formatAmount($detail->unit_price); ?></td>
                            <?php if($invoice->invoice_template->with_vat): ?>
                                <td class="text-right"><?php echo $detail->tax_rate; ?>%</td>
                            <?php endif; ?>
                            <td class="text-right">
                                ₤<?php echo Helper::formatAmount($detail->amount); ?>

                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
                <?php /*Invoice details end*/ ?>
                </tbody>
                <tfoot>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td class="text-right">Sub-total:</td>
                    <?php if($invoice->invoice_template->with_vat): ?>
                        <td></td>
                    <?php endif; ?>
                    <td class="text-right">₤<?php echo Helper::formatAmount($invoice->amount);; ?></td>
                </tr>
                <?php if($invoice->invoice_template->with_vat): ?>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td class="text-right">VAT:</td>
                        <td></td>
                        <td class="text-right">₤<?php echo Helper::formatAmount($invoice->vat);; ?></td>
                    </tr>
                <?php endif; ?>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td class="text-right">Total:</td>
                    <?php if($invoice->invoice_template->with_vat): ?>
                        <td></td>
                    <?php endif; ?>
                    <td class="text-right">₤<?php echo Helper::formatAmount($invoice->total);; ?></td>
                </tr>
                </tfoot>
            </table>
        </div>

        <div class="">
            <div class="row">
                <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
                    <p>
                        <b>Bank Detail:</b>
                    </p>

                    <?php if(!!$invoice->invoice_template->bank_name): ?>
                        <p>
                            Bank Name:
                            <?php echo $invoice->invoice_template->bank_name;; ?>

                        </p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->sort_code): ?>
                        <p>Sort-code:
                            <?php echo $invoice->invoice_template->sort_code; ?>

                        </p>
                    <?php endif; ?>

                    <?php if($invoice->invoice_template->account_number): ?>
                        <p>Account Number:
                            <?php echo $invoice->invoice_template->account_number;; ?>

                        </p>
                    <?php endif; ?>
                </div>

                <div class="col-xs-4">
                    <p><b>Note</b></p>

                    <p><?php echo $invoice->notes;; ?></p>
                </div>

            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.report', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>