
@extends('layouts.guest')
@section('content')
<style>
    page[size="A4"] {
        width: 21cm;
        height: 29.7cm;
    }

    page[size="A4"][layout="landscape"] {
        width: 29.7cm;
        height: 21cm;
    }

    .header {
        position: fixed;
        left: 0px;
        top: -100px;
        right: 0px;
        height: 0px;
        text-align: center;
    }

    .footer {
        position: fixed;
        left: 0px;
        bottom: -50px;
        right: 0px;
        height: 50px;
    }

    .header .pagenum:before {
        content: counter(page);
    }

    table {
        page-break-inside: auto
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    table {
        width: 100%;
    }

    table,
    th,
    td {
        border: 0px solid #000;
        border-collapse: collapse;
        padding: 2px;
        color: #060606 !important;
    }

    td .tdclass {
        color: #060606 !important;
    }

    p {
        color: #060606 !important;
    }

    body {
        font-family: "Poppins", sans-serif;
        font-size: 12px;
        padding: 0px;
        margin: 0px;
        line-height: 16px;
    }

    .vl {
        border-left: 3px solid black;
        height: 50px;
    }

</style>
<div class="container">
    <div class="spacer"></div>
    <div class="row">
        <div class="col-md-12 text-right" >
            <button type="button" class="btn btn-primary no-print" id="print_invoice" 
                 aria-label="Print"><i class="fas fa-print"></i> @lang( 'messages.print' )
            </button>
            @auth
                <a href="{{action('SellController@index')}}" class="btn btn-success no-print" ><i class="fas fa-backward"></i>
                </a>
            @endauth
        </div>
    </div>
    <div class="row">
        <div class="col-md-8 col-md-offset-2 col-sm-12" style="border: 1px solid #ccc;">
            <div class="spacer"></div>
            <div id="invoice_content">
<div style="padding: 3px 10px;">
    <table style="width: 100%;border: none;">
        <tr>
            <td style="border: none;">
                <table style="width: 100%;border: none;">
                    <tr>
                        <td colspan="" style="text-align: right;vertical-align: top;border: none;">
                            <table style="border: none;width:100%">
                                <tr>
                                    <td style="border: none;width:50%;text-align: left;">

                                        <h2
                                            style="margin-bottom:3px;margin-top:8px;font-size: 30px; color: #000000; font-weight: 600;">
                                            @lang('lang_v1.packing_slip')
                                        </h2>
                                        <h3
                                            style="margin-bottom:3px;margin-top:8px;font-size: 30px; color: #000000; font-weight: 600;">
                                           Smoxy
                                        </h3>
                                        <table>
                                            <tr>
                                                <td style="width: 130px;font-size: 13px;font-weight: bold;">
                                                    @if (!empty($receipt_details->address))
                                                        {!! $receipt_details->address !!}
                                                    @endif
                                                   
                                                </td>
                                                <td>
                                                    <div class="vl"></div>
                                                </td>
                                                <td style="width: -1px;font-size: 13px;font-weight: bold;">
                                                    @if (!empty($receipt_details->contact))
                                                        {!! $receipt_details->contact !!}
                                                    @endif
                                                    @if (!empty($receipt_details->contact) && !empty($receipt_details->website))
                                                        <br>
                                                    @endif
                                                    @if (!empty($receipt_details->website))
                                                        {{ $receipt_details->website }}
                                                    @endif
                                                    @if (!empty($receipt_details->location_custom_fields))
                                                        <br>{{ $receipt_details->location_custom_fields }}
                                                    @endif
                                                    @if (!empty($receipt_details->tax_info1))
                                                        <b>{{ $receipt_details->tax_label1 }}</b>
                                                        {{ $receipt_details->tax_info1 }}
                                                    @endif

                                                    @if (!empty($receipt_details->tax_info2))
                                                        <b>{{ $receipt_details->tax_label2 }}</b>
                                                        {{ $receipt_details->tax_info2 }}
                                                    @endif
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="border: none;vertical-align: top;padding-left: 95px;">
                                        <!-- Header text -->
                                        @if (!empty($receipt_details->logo))
                                            <img src="{{ $receipt_details->logo }}"
                                                class="img img-responsive center-block" style="width: 100%;">
                                        @endif
                                        <div class="col-xs-12">
                                        </div>
                                        <h2
                                            style="text-transform: uppercase; margin-bottom:3px;margin-top:8px;font-size: 25px; font-weight: 600; text-align: left;color: #060606">
                                            <!-- Shop & Location Name  -->
                                        </h2>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                    </tr>
                    <tr>
                        <td colspan="" style="text-align: center; border:none;">
                            <table style="border: none; background-color: #c3c3c3 !important;margin-top: 15px;">
                                <tr>
                                    <td style="vertical-align: top;width: 36%;border: none;padding: 5px">
                                        <table style="width: 75%;">
                                            <tr>
                                                <td style="vertical-align: top;padding-left: 5px;text-align: left; ">
                                                    <!-- Table information-->
                                                    <span class="pull-left text-left">
                                                        <!-- Waiter info -->
                                                    </span>
                                                    <!-- customer info -->
                                                    <span style="font-weight: 600;font-size: 16px;">Bill To</span>
                                                    <br>
                                                    <b>
                                                        <span style="font-weight: 700; font-size: 12px;">
                                                    </b></span>
                                                    <span style="color: #000;">
                                                        @if (!empty($receipt_details->table_label) || !empty($receipt_details->table))
                                                            <br />
                                                            <span class="pull-left text-left">
                                                                @if (!empty($receipt_details->table_label))
                                                                    <b>{!! $receipt_details->table_label !!}</b>
                                                                @endif
                                                                {{ $receipt_details->table }}

                                                                <!-- Waiter info -->
                                                            </span>
                                                        @endif

                                                        <!-- customer info -->
                                                        @if (!empty($receipt_details->customer_info))

                                                            {!! $receipt_details->customer_info !!}
                                                        @endif
                                                        @if (!empty($receipt_details->client_id_label))
                                                            <br />
                                                            <b>{{ $receipt_details->client_id_label }}</b>
                                                            {{ $receipt_details->client_id }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_tax_label))
                                                            <br />
                                                            <b>{{ $receipt_details->customer_tax_label }}</b>
                                                            {{ $receipt_details->customer_tax_number }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_custom_fields))
                                                            <br />{!! $receipt_details->customer_custom_fields !!}
                                                        @endif
                                                        @if (!empty($receipt_details->sales_person_label))
                                                            <br />
                                                            <b>{{ $receipt_details->sales_person_label }}</b>
                                                            {{ $receipt_details->sales_person }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_rp_label))
                                                            <br />
                                                            <strong>{{ $receipt_details->customer_rp_label }}</strong>
                                                            {{ $receipt_details->customer_total_rp }}
                                                        @endif
                                                    </span>

                                                    <br>

                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 36%;vertical-align: top;border: none ;padding: 5px">
                                        <table style="width: 75%;">
                                            <tr>
                                                <td style="vertical-align: top;padding-left: 5px;text-align: left; ">
                                                    <!-- Table information-->

                                                    <!-- customer info -->
                                                    <span style="font-weight: 600;font-size: 16px;">Ship To</span>
                                                    <br>

                                                    <span style="color: #000;">
                                                        @if (!empty($receipt_details->table_label) || !empty($receipt_details->table))
                                                            <br />
                                                            <span class="pull-left text-left">
                                                                @if (!empty($receipt_details->table_label))
                                                                    <b>{!! $receipt_details->table_label !!}</b>
                                                                @endif
                                                                {{ $receipt_details->table }}

                                                                <!-- Waiter info -->
                                                            </span>
                                                        @endif

                                                        <!-- customer info -->
                                                        @if (!empty($receipt_details->customer_info))
                                                            {!! $receipt_details->customer_info !!} <br>
                                                        @endif
                                                        @if (!empty($receipt_details->client_id_label))
                                                            <br />
                                                            <b>{{ $receipt_details->client_id_label }}</b>
                                                            {{ $receipt_details->client_id }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_tax_label))
                                                            <br />
                                                            <b>{{ $receipt_details->customer_tax_label }}</b>
                                                            {{ $receipt_details->customer_tax_number }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_custom_fields))
                                                            <br />{!! $receipt_details->customer_custom_fields !!}
                                                        @endif
                                                        @if (!empty($receipt_details->sales_person_label))
                                                            <br />
                                                            <b>{{ $receipt_details->sales_person_label }}</b>
                                                            {{ $receipt_details->sales_person }}
                                                        @endif
                                                        @if (!empty($receipt_details->customer_rp_label))
                                                            <br />
                                                            <strong>{{ $receipt_details->customer_rp_label }}</strong>
                                                            {{ $receipt_details->customer_total_rp }}
                                                        @endif
                                                    </span>

                                                    <br>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 33%;vertical-align: top;border: none ;padding: 5px">
                                        <table style="width: 90%;">
                                            <tr>
                                                <td style="vertical-align: top;padding-left: 5px;text-align: left; ">
                                                    <!-- Table information-->
                                                    <!-- customer info -->
                                                    <span style="font-weight: 600;font-size: 16px;">Invoice
                                                        Details</span>
                                                    <br>
                                                    <br>
                                                    <span>
                                                        @if (!empty($receipt_details->invoice_no_prefix))
                                                            <b>{!! $receipt_details->invoice_no_prefix !!}</b>
                                                        @endif
                                                        {{ $receipt_details->invoice_no }}
                                                        <br>
                                                    </span>
                                                    <span style="font-weight:600;font-size: 12px;">Term:</span>
                                                    <br>
                                                    <span style="font-size: 13px;font-weight: 400;">
                                                        <b>{{ $receipt_details->date_label }}</b>
                                                        {{ $receipt_details->invoice_date }}
                                                        @if (!empty($receipt_details->due_date_label))
                                                            <br><b>{{ $receipt_details->due_date_label }}</b>
                                                            {{ $receipt_details->due_date ?? '' }}
                                                        @endif
                                                        @if (!empty($receipt_details->due_date_label))
                                                            <br><b>{{ $receipt_details->due_date_label }}</b>
                                                            {{ $receipt_details->due_date ?? '' }}
                                                        @endif
                                                    </span>
                                                    @if (!empty($receipt_details->brand_label) || !empty($receipt_details->repair_brand))
                                                        <br>
                                                        @if (!empty($receipt_details->brand_label))
                                                            <b>{!! $receipt_details->brand_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_brand }}
                                                    @endif

                                                    @if (!empty($receipt_details->device_label) || !empty($receipt_details->repair_device))
                                                        <br>
                                                        @if (!empty($receipt_details->device_label))
                                                            <b>{!! $receipt_details->device_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_device }}
                                                    @endif

                                                    @if (!empty($receipt_details->model_no_label) || !empty($receipt_details->repair_model_no))
                                                        <br>
                                                        @if (!empty($receipt_details->model_no_label))
                                                            <b>{!! $receipt_details->model_no_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_model_no }}
                                                    @endif

                                                    @if (!empty($receipt_details->serial_no_label) || !empty($receipt_details->repair_serial_no))
                                                        <br>
                                                        @if (!empty($receipt_details->serial_no_label))
                                                            <b>{!! $receipt_details->serial_no_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_serial_no }}<br>
                                                    @endif
                                                    @if (!empty($receipt_details->repair_status_label) || !empty($receipt_details->repair_status))
                                                        @if (!empty($receipt_details->repair_status_label))
                                                            <b>{!! $receipt_details->repair_status_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_status }}<br>
                                                    @endif

                                                    @if (!empty($receipt_details->repair_warranty_label) || !empty($receipt_details->repair_warranty))
                                                        @if (!empty($receipt_details->repair_warranty_label))
                                                            <b>{!! $receipt_details->repair_warranty_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->repair_warranty }}
                                                        <br>
                                                    @endif

                                                    <!-- Waiter info -->
                                                    @if (!empty($receipt_details->service_staff_label) || !empty($receipt_details->service_staff))
                                                        <br />
                                                        @if (!empty($receipt_details->service_staff_label))
                                                            <b>{!! $receipt_details->service_staff_label !!}</b>
                                                        @endif
                                                        {{ $receipt_details->service_staff }}
                                                    @endif
                                                    @if (!empty($receipt_details->shipping_custom_field_1_label))
                                                        <br><strong>{!! $receipt_details->shipping_custom_field_1_label !!} :</strong>
                                                        {!! $receipt_details->shipping_custom_field_1_value ?? '' !!}
                                                    @endif

                                                    @if (!empty($receipt_details->shipping_custom_field_2_label) && $receipt_details->shipping_custom_field_2_label != 0)
                                                        <br><strong>{!! $receipt_details->shipping_custom_field_2_label !!}:</strong>
                                                        {!! $receipt_details->shipping_custom_field_2_value ?? '' !!}
                                                    @endif

                                                    @if (!empty($receipt_details->shipping_custom_field_3_label))
                                                        <br><strong>{!! $receipt_details->shipping_custom_field_3_label !!}:</strong>
                                                        {!! $receipt_details->shipping_custom_field_3_value ?? '' !!}
                                                    @endif

                                                    @if (!empty($receipt_details->shipping_custom_field_4_label))
                                                        <br><strong>{!! $receipt_details->shipping_custom_field_4_label !!}:</strong>
                                                        {!! $receipt_details->shipping_custom_field_4_value ?? '' !!}
                                                    @endif

                                                    @if (!empty($receipt_details->shipping_custom_field_5_label))
                                                        <br><strong>{!! $receipt_details->shipping_custom_field_2_label !!}:</strong>
                                                        {!! $receipt_details->shipping_custom_field_5_value ?? '' !!}
                                                    @endif

                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <div class="row">
                    @includeIf('sale_pos.receipts.partial.common_repair_invoice')
                </div>


                @php
                    $p_width = 40;
                @endphp
                @if (!empty($receipt_details->item_discount_label))
                    @php
                        $p_width -= 15;
                    @endphp
                @endif
                <table style="width: 100%;padding:2px; margin-top: 10px;" class="table table-responsive table-slim">
                    <thead style="background-color: #c3c3c3 !important;">
                        <tr>

                            <td
                                style="font-weight: 700;text-align: left;vertical-align:top;border: 1px solid #808080; border-left: none; width:18%;background-color: #c3c3c3 !important;">
                                Quantity</td>
                            <td
                                style="font-weight: 700;vertical-align:top;border: 1px solid #808080; border-left: none;background-color: #c3c3c3 !important;">
                                Description</td>
                            <td
                                style="font-weight: 700;text-align: left;vertical-align:top;border: 1px solid #808080; border-left: none; width: 125px;background-color: #c3c3c3 !important;">
                                Item Code</td>
                     
                        </tr>
                    </thead>

                    <tbody>
                        @forelse($receipt_details->lines as $line)
                            <tr>
                                <td>{{ $line['quantity'] }} {{ $line['units'] }} </td>
                                <td>
                                    @if (!empty($line['image']))
                                        <img src="{{ $line['image'] }}" alt="Image" width="50"
                                            style="float: left; margin-right: 8px;">
                                    @endif
                                    {{ $line['name'] }}  {{ $line['variation'] }}
                                    @if (!empty($line['brand'])), {{ $line['brand'] }}
                                        @endif @if (!empty($line['cat_code'])),
                                            {{ $line['cat_code'] }}@endif
                                        @if (!empty($line['product_custom_fields'])),
                                            {{ $line['product_custom_fields'] }} @endif
                                        @if (!empty($line['sell_line_note']))
                                            <br>
                                            <small>
                                                {{ $line['sell_line_note'] }}
                                            </small>
                                        @endif

                                </td>
                                <td>
                                    @if (!empty($line['sub_sku']))
                                        {{ $line['sub_sku'] }} @endif
                                </td>
                                <td style="display:none">
                                    $ {{ $line['unit_price_inc_tax'] }}
                                </td>
                                <td style="display:none">$ {{ $line['line_total'] }}</td>
                            </tr>
                            @if (!empty($line['modifiers']))
                                @foreach ($line['modifiers'] as $modifier)
                                    <tr>
                                        <td>
                                            {{ $modifier['name'] }} {{ $modifier['variation'] }}
                                            @if (!empty($modifier['sub_sku'])),
                                                {{ $modifier['sub_sku'] }} @endif @if (!empty($modifier['cat_code'])),
                                                    {{ $modifier['cat_code'] }}@endif
                                                @if (!empty($modifier['sell_line_note']))
                                                    ({{ $modifier['sell_line_note'] }}) @endif
                                        </td>
                                        <td class="text-right">{{ $modifier['quantity'] }} {{ $modifier['units'] }}
                                        </td>
                                        <td class="text-right" style="display:none">{{ $modifier['unit_price_inc_tax'] }}</td>
                                        @if (!empty($receipt_details->item_discount_label))
                                            <td class="text-right">0.00</td>
                                        @endif
                                        <td class="text-right" style="display:none">{{ $modifier['line_total'] }}</td>
                                    </tr>
                                @endforeach
                            @endif
                            @empty
                                <tr>
                                    <td colspan="4">&nbsp;</td>
                                </tr>
                            @endforelse
                        </tbody>

                    </table>
                </td>
                
                </td>
            </tr>
        </table>
        </tr>
        </table><br><br>
        <footer>
           <!--  <table class="table table-slim">
                <tr>
                    <td class="text-right" style="font-size: 15px;font-weight: 600;">
                        {!! $receipt_details->subtotal_label !!}
                    </td>
                    <td class="text-right" style="width: 155px;">

                        {{ $receipt_details->subtotal }}
                    </td>
                </tr>

              
                <tr>
                    <td class="text-right" style="font-size: 15px;font-weight: 600;">
                        {!! $receipt_details->total_label !!}
                    </td>
                    <td class="text-right" style="width: 155px;">

                        {{ $receipt_details->total }}
                        @if (!empty($receipt_details->total_in_words))
                            <br>
                            <small>({{ $receipt_details->total_in_words }})</small>
                        @endif
                    </td>
                </tr>
                {{-- @if (!empty($receipt_details->payments))
                    @foreach ($receipt_details->payments as $payment)
                        <tr>
                            <td class="text-right" style="font-size: 15px;font-weight: 600;">{{ $payment['method'] }} :
                            </td>
                            <td class="text-right" style="width: 155px;">{{ $payment['amount'] }} {{ $payment['date'] }}
                            </td>
                        </tr>
                    @endforeach
                @endif --}}

              
                @if (!empty($receipt_details->total_paid))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->total_paid_label !!} :
                        </td>
                        <td class="text-right" style="width: 155px;">
                            {{ $receipt_details->total_paid }}
                        </td>
                    </tr>
                @endif

             
                @if (!empty($receipt_details->total_due))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->total_due_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->total_due }}
                        </td>
                    </tr>
                @endif

                @if (!empty($receipt_details->all_due))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->all_bal_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->all_due }}
                        </td>
                    </tr>
                @endif

                @if (!empty($receipt_details->total_quantity_label))
                    <tr class="color-555">
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->total_quantity_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->total_quantity }}
                        </td>
                    </tr>
                @endif

                @if (!empty($receipt_details->total_exempt_uf))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            @lang('lang_v1.exempt')
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->total_exempt }}
                        </td>
                    </tr>
                @endif
               
                @if (!empty($receipt_details->shipping_charges))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->shipping_charges_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->shipping_charges }}
                        </td>
                    </tr>
                @endif

                @if (!empty($receipt_details->packing_charge))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->packing_charge_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->packing_charge }}
                        </td>
                    </tr>
                @endif

                
                @if (!empty($receipt_details->discount))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->discount_label !!}
                        </td>

                        <td class="text-right" style="width: 155px;">

                            (-) {{ $receipt_details->discount }}
                        </td>
                    </tr>
                @endif

                @if (!empty($receipt_details->reward_point_label))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->reward_point_label !!}
                        </td>

                        <td class="text-right" style="width: 155px;">

                            (-) {{ $receipt_details->reward_point_amount }}
                        </td>
                    </tr>
                @endif

                
                @if (!empty($receipt_details->tax))
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->tax_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            (+) {{ $receipt_details->tax }}
                        </td>
                    </tr>
                @endif

                @if ($receipt_details->round_off_amount > 0)
                    <tr>
                        <td class="text-right" style="font-size: 15px;font-weight: 600;">
                            {!! $receipt_details->round_off_label !!}
                        </td>
                        <td class="text-right" style="width: 155px;">

                            {{ $receipt_details->round_off }}
                        </td>
                    </tr>
                @endif
            </table> -->
        </footer>
        

		     <table width="100%" class="row" style="margin-top:50px;border:none;">
                <tr class="col-12">
                    <th class="col-4"><hr style="width:120px;"></th>
                    <th class="col-4"><hr style="width:120px;"></th>
                    <th class="col-4"><hr style="width:120px;"></th>
                </tr>
                <tr  class="col-12">
                    <td  class="col-4" style="text-align: center;">Box Count</td>
                    <td  class="col-4" style="text-align: center;">Pallet Count</td>
                    <td  class="col-4" style="text-align: center;">Packed By</td>
                </tr>
            </table>
    </div>
            </div>
            <div class="spacer"></div>
        </div>
    </div>
    <div class="spacer"></div>
</div>
@stop
@section('javascript')
<script type="text/javascript">
    $(document).ready(function(){
        $(document).on('click', '#print_invoice', function(){
            $('#invoice_content').printThis();
        });
    });
    @if(!empty(request()->input('print_on_load')))
        $(window).on('load', function(){
            $('#invoice_content').printThis();
        });
    @endif
</script>
@endsection