{{-- OLD DELIVERY NOTE TEMPLATE - COMMENTED OUT BUT PRESERVED
<table style="width:100%;">
	<thead>
		<tr>
			<td>

			<p class="text-right color-555 font-30">
              <b>@lang('lang_v1.delivery_note')</b>
			</p>

			</td>
		</tr>
	</thead>

	<tbody>
		<tr>
			<td>

<!-- business information here -->
<div class="row invoice-info">

	<div class="col-md-6 invoice-col width-50 color-555">
		
		<!-- Logo -->
		@if(!empty($receipt_details->logo))
			<img style="max-height: 120px; width: auto;" src="{{$receipt_details->logo}}" class="img">
			<br/>
		@endif

		<!-- Shop & Location Name  -->
		@if(!empty($receipt_details->display_name))
			<p><span style="font-size:24px; font-weight:900; color:black;">
				{{$receipt_details->display_name}}</span>
				@if(!empty($receipt_details->address))
					<br/>{!! $receipt_details->address !!}
				@endif

				@if(!empty($receipt_details->contact))
					<br/>{!! $receipt_details->contact !!}
				@endif

				@if(!empty($receipt_details->website))
					<br/>{{ $receipt_details->website }}
				@endif

				@if(!empty($receipt_details->tax_info1))
					<br/>{{ $receipt_details->tax_label1 }} {{ $receipt_details->tax_info1 }}
				@endif

				@if(!empty($receipt_details->tax_info2))
					<br/>{{ $receipt_details->tax_label2 }} {{ $receipt_details->tax_info2 }}
				@endif

				@if(!empty($receipt_details->location_custom_fields))
					<br/>{{ $receipt_details->location_custom_fields }}
				@endif
			</p>
		@endif
	</div>

	<div class="col-md-6 invoice-col width-50">

		<p class="text-right font-17">
			@if(!empty($receipt_details->invoice_no_prefix))
				<span class="pull-left">{!! $receipt_details->invoice_no_prefix !!}</span>
			@endif

			{{$receipt_details->invoice_no}}
		</p>
		<!-- Date-->
		@if(!empty($receipt_details->date_label))
			<p class="text-right font-17">
				<span class="pull-left">
					{{$receipt_details->date_label}}
				</span>

				{{$receipt_details->invoice_date}}
			</p>
		@endif

		
	</div>
	<div class="col-md-6 invoice-col width-50 word-wrap">
		@if(!empty($receipt_details->customer_label))
			<b>{{ $receipt_details->customer_label }}</b><br/>
		@endif

		@if(!empty($receipt_details->customer_info))
			{!! $receipt_details->customer_info !!}
		@endif
		@if(!empty($receipt_details->client_id_label))
			<br/>
			<strong>{{ $receipt_details->client_id_label }}</strong> {{ $receipt_details->client_id }}
		@endif
		@if(!empty($receipt_details->customer_tax_number))
			<br/>
			<strong>{{ $receipt_details->customer_tax_label }}</strong> {{ $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/>
			<strong>{{ $receipt_details->sales_person_label }}</strong> {{ $receipt_details->sales_person }}
		@endif
	</div>
</div>
<!-- 
<div class="row invoice-info color-555">
	<br/>
	<div class="col-md-6 invoice-col width-50 word-wrap">
		@if(!empty($receipt_details->customer_label))
			<b>{{ $receipt_details->customer_label }}</b><br/>
		@endif

		
		@if(!empty($receipt_details->customer_name))
			{{ $receipt_details->customer_name }}<br>
		@endif
		@if(!empty($receipt_details->customer_info))
			{!! $receipt_details->customer_info !!}
		@endif
		@if(!empty($receipt_details->client_id_label))
			<br/>
			<strong>{{ $receipt_details->client_id_label }}</strong> {{ $receipt_details->client_id }}
		@endif
		@if(!empty($receipt_details->customer_tax_label))
			<br/>
			<strong>{{ $receipt_details->customer_tax_label }}</strong> {{ $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/>
			<strong>{{ $receipt_details->sales_person_label }}</strong> {{ $receipt_details->sales_person }}
		@endif
	</div>
	<div class="col-md-6 invoice-col width-50 word-wrap">
		<strong>@lang('lang_v1.shipping_address'):</strong><br>
		{!! $receipt_details->shipping_address !!}
		@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))
			<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
	</div>
</div>
 -->

<div class="row color-555">
	<div class="col-xs-12">
		<br/>
		<table class="table table-bordered table-no-top-cell-border">
			<thead>
				<tr style="background-color: #357ca5 !important; color: white !important; font-size: 20px !important" class="table-no-side-cell-border table-no-top-cell-border text-center">
					<td style="background-color: #357ca5 !important; color: white !important; width: 5% !important">#</td>
					
					<td style="background-color: #357ca5 !important; color: white !important; width: 65% !important">
						{{$receipt_details->table_product_label}}
					</td>
					
					<td style="background-color: #357ca5 !important; color: white !important; width: 30% !important;">
						{{$receipt_details->table_qty_label}}
					</td>
				</tr>
			</thead>
			<tbody>
				@foreach($receipt_details->lines as $line)
					<tr>
						<td class="text-center">
							{{$loop->iteration}}
						</td>
						<td style="word-break: break-all;">
                            {{$line['name']}} {{$line['product_variation']}} {{$line['variation']}} 
                            @if(!empty($line['sub_sku'])), {{$line['sub_sku']}} @endif @if(!empty($line['brand'])), {{$line['brand']}} @endif
                            @if(!empty($line['product_custom_fields'])), {{$line['product_custom_fields']}} @endif
                            @if(!empty($line['sell_line_note']))({!!$line['sell_line_note']!!}) @endif
                            @if(!empty($line['lot_number']))<br> {{$line['lot_number_label']}}:  {{$line['lot_number']}} @endif 
                            @if(!empty($line['product_expiry'])), {{$line['product_expiry_label']}}:  {{$line['product_expiry']}} @endif 
                        </td>
						<td class="text-right">
							{{$line['quantity']}} {{$line['units']}}
						</td>
					</tr>
					@if(!empty($line['modifiers']))
						@foreach($line['modifiers'] as $modifier)
							<tr>
								<td class="text-center">
									&nbsp;
								</td>
								<td>
		                            {{$modifier['name']}} {{$modifier['variation']}} 
		                            @if(!empty($modifier['sub_sku'])), {{$modifier['sub_sku']}} @endif 
		                            @if(!empty($modifier['sell_line_note']))({!!$modifier['sell_line_note']!!}) @endif 
		                        </td>
								<td class="text-right">
									{{$modifier['quantity']}} {{$modifier['units']}}
								</td>
							</tr>
						@endforeach
					@endif
				@endforeach

				@php
					$lines = count($receipt_details->lines);
				@endphp

				@for ($i = $lines; $i < 1; $i++)
    				<tr>
    					<td>&nbsp;</td>
    					<td>&nbsp;</td>
    					<td>&nbsp;</td>
    				</tr>
				@endfor

			</tbody>
		</table>
	</div>
</div>

<div class="row invoice-info color-555" style="page-break-inside: avoid !important">
	<div class="col-md-6 invoice-col width-50">
		<b class="pull-left">@lang('lang_v1.above_mentioned_items_received_in_good_condition')</b>
	</div>
</div>
</br>
<div class="row invoice-info color-555" style="page-break-inside: avoid !important">
	<div class="col-md-6 invoice-col width-80">
		<b class="pull-left">@lang('lang_v1.received_by') : </b>
	</div>
</div>
</br>
<div class="row invoice-info color-555" style="page-break-inside: avoid !important">
	<div class="col-md-6 invoice-col width-50">
		<b class="pull-left">@lang('lang_v1.date'):</b>
	</div>
</div>
</br>
<div class="row invoice-info color-555" style="page-break-inside: avoid !important">
	<div class="col-md-6 invoice-col width-50">
		<b class="pull-left">@lang('lang_v1.authorized_signatory')</b>
	</div>
</div>

{{-- Barcode --}}
@if($receipt_details->show_barcode)
<br>
<div class="row">
		<div class="col-xs-12">
			<img class="center-block" src="data:image/png;base64,{{DNS1D::getBarcodePNG($receipt_details->invoice_no, 'C128', 2,30,array(39, 48, 54), true)}}">
		</div>
</div>
@endif

@if(!empty($receipt_details->footer_text))
	<div class="row color-555">
		<div class="col-xs-12">
			{!! $receipt_details->footer_text !!}
		</div>
	</div>
@endif

			</td>
		</tr>
	</tbody>
</table>
{{-- END OF OLD TEMPLATE --}}

{{-- NEW DELIVERY CHALLAN TEMPLATE - SIMPLE TRADITIONAL DESIGN --}}
<style>
    .delivery-challan {
        font-family: Arial, sans-serif;
        font-size: 13px;
        margin: 0;
        padding: 20px;
    }
    .delivery-challan h2 {
        text-align: center;
        font-size: 20px;
        margin-bottom: 10px;
        text-decoration: underline;
    }
    .delivery-challan .header-info {
        margin-bottom: 15px;
    }
    .delivery-challan .header-info td {
        padding: 3px 8px;
        vertical-align: top;
    }
    .delivery-challan table.items {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }
    .delivery-challan table.items th, .delivery-challan table.items td {
        border: 1px solid #000;
        padding: 5px;
        text-align: center;
        font-size: 12px;
    }
    .delivery-challan table.items th {
        background: #f0f0f0;
        font-weight: bold;
    }
    .delivery-challan .total-row td {
        font-weight: bold;
    }
    .delivery-challan .section {
        margin: 20px 0;
        font-size: 12px;
    }
    .delivery-challan .signatures {
        margin-top: 40px;
        width: 100%;
    }
    .delivery-challan .signatures td {
        width: 33%;
        text-align: center;
        vertical-align: top;
        font-size: 12px;
    }
    .delivery-challan .line {
        display: block;
        margin: 25px auto 5px;
        border-top: 1px solid #000;
        width: 80%;
    }
</style>

<div class="delivery-challan">
    <h2>Delivery Challan</h2>

    <table class="header-info" width="100%">
        <tr>
            <td><strong>Customer's Name:</strong> 
                @if(!empty($receipt_details->customer_name))
                    {{ $receipt_details->customer_name }}
                @else
                    N/A
                @endif
            </td>
            <td><strong>Purchase Order No:</strong> {{ $receipt_details->sell_custom_field_2_value ?? 'N/A' }}</td>
        </tr>
        <tr>
            <td><strong>Delivery Challan No:</strong> 
                @if(!empty($receipt_details->invoice_no_prefix))
                    {{$receipt_details->invoice_no_prefix}}{{$receipt_details->invoice_no}}
                @else
                    {{$receipt_details->invoice_no}}
                @endif
            </td>
            <td><strong>Purchase Order Date:</strong> {{ $receipt_details->sell_custom_field_3_value ?? 'N/A' }}</td>
        </tr>
        <tr>
            <td><strong>Delivery Challan Date:</strong> {{$receipt_details->invoice_date}}</td>
            <td><strong>Location:</strong> {{ $receipt_details->location_name ?? 'N/A' }}</td>
        </tr>
        <tr>
            <td><strong>Vehicle Number:</strong> {{ $receipt_details->vehicle_number ?? $receipt_details->sell_custom_field_1_value ?? $receipt_details->custom_field_1 ?? 'N/A' }}</td>
            <td><strong>Delivery Person:</strong> {{ $receipt_details->delivery_person ?? 'N/A' }}</td>
        </tr>
    </table>

    <table class="items">
        <thead>
            <tr>
                <th>S.NO</th>
                <th>Item Description</th>
                <th>Batch No</th>
                <th>U.O.M</th>
                <th>Unit Type</th>
                <th>Unit Weight</th>
                <th>No. Of Units</th>
                <th>Quantity</th>
            </tr>
        </thead>
        <tbody>
            @php
                $total_units = 0;
                $total_quantity = 0;
            @endphp
            @foreach($receipt_details->lines as $index => $line)
                @php
                    $total_units += $line['quantity_uf'];
                    $total_quantity += $line['quantity_uf'];
                @endphp
                <tr>
                    <td>{{ $index+1 }}</td>
                    <td>{{$line['name']}} {{$line['product_variation']}} {{$line['variation']}}
                        @if(!empty($line['sub_sku']))
                            <br><small>({{$line['sub_sku']}})</small>
                        @endif
                        @if(!empty($line['brand']))
                            <br><small>Brand: {{$line['brand']}}</small>
                        @endif
                        @if(!empty($line['sell_line_note']))
                            <br><small>Note: {!!$line['sell_line_note']!!}</small>
                        @endif
                    </td>
                    <td>{{$line['lot_number'] ?? ''}}</td>
                    <td>{{$line['units']}}</td>
                    <td>{{$line['product_variation'] ?? ''}}</td>
                    <td>{{$line['unit_weight'] ?? ''}}</td>
                    <td>{{$line['quantity_uf']}}</td>
                    <td>{{$line['quantity_uf']}}</td>
                </tr>
            @endforeach
            <tr class="total-row">
                <td colspan="6" align="right">Total</td>
                <td>{{ $total_units }}</td>
                <td>{{ $total_quantity }}</td>
            </tr>
        </tbody>
    </table>

    <div class="section">
        <strong>Vehicle Number:</strong> {{ $receipt_details->vehicle_number ?? $receipt_details->sell_custom_field_1_value ?? $receipt_details->custom_field_1 ?? 'N/A' }} <br><br>
        All goods are loaded in good condition under my supervision and counting is correct
    </div>

    <table class="signatures" cellspacing="0" cellpadding="0">
        <tr>
            <td>
                <span class="line"></span>
                <strong>Prepared By</strong><br>
                {{ $receipt_details->added_by ?? 'N/A' }}
            </td>
            <td>
                <span class="line"></span>
                <strong>Driver Name & Number</strong><br>
                {{ $receipt_details->shipping_custom_field_2_value ?? 'N/A' }}
            </td>
            <td>
                <span class="line"></span>
                <strong>Checked By</strong><br>
                {{ $receipt_details->shipping_custom_field_3_value ?? '' }}
            </td>
        </tr>
    </table>

    <br><br>

    <table class="signatures">
        <tr>
            <td>
                <span class="line"></span>
                <strong>Receiver's Name</strong>
            </td>
            <td>
                <span class="line"></span>
                <strong>Receiver's Signature & Stamp</strong>
            </td>
            <td>
                <span class="line"></span>
                <strong>Received On</strong>
            </td>
        </tr>
    </table>

    {{-- Barcode Section --}}
    @if($receipt_details->show_barcode)
        <div style="text-align: center; margin-top: 30px;">
            <img src="data:image/png;base64,{{DNS1D::getBarcodePNG($receipt_details->invoice_no, 'C128', 2,30,array(39, 48, 54), true)}}" 
                 alt="Barcode" style="max-width: 100%; height: auto;">
        </div>
    @endif

    {{-- Footer --}}
    @if(!empty($receipt_details->footer_text))
        <div style="margin-top: 30px; text-align: center; font-size: 11px;">
            {!! $receipt_details->footer_text !!}
        </div>
    @endif
</div>