<style>
    @page {
  size: auto; 
  margin: 0mm 5mm 0mm 5mm;  
}
</style>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <!-- <link rel="stylesheet" href="style.css"> -->
        <title>Receipt-{{$receipt_details->invoice_no}}</title>
    </head>
    <body>
        
        <?php //print_r($receipt_details); ?>
        <div class="ticket">
        	@if(!empty($receipt_details->logo))
        		<div class="text-box centered">
        			<img style="max-height: 100px; width: auto;" src="{{$receipt_details->logo}}" alt="Logo">
        		</div>
        	@endif
        	<div class="text-box">
        	<!-- Logo -->
            <p class="centered" style="font-size:12px;">
                
            	<!-- Header text -->
            	@if(!empty($receipt_details->header_text))
            		<span class="headings">{!! $receipt_details->header_text !!}</span>
					<br/>
				@endif
				<!-- business information here -->
				@if(!empty($receipt_details->display_name))
					<span class="headings" style="font-size:14px;">
						{{$receipt_details->display_name}}</span>
					<br/>
				@endif
				@if(!empty($receipt_details->sub_heading_line1))
					<span style="font-size:12px;">({{ $receipt_details->sub_heading_line1 }})<br/></span>
				@endif
				
				@if(!empty($receipt_details->address))
					<span >{!! $receipt_details->address !!}
					
					
					</span>
					<br/>
				@endif

				@if(!empty($receipt_details->contact))
					{!! $receipt_details->contact !!}
				@endif
				@if(!empty($receipt_details->contact) && !empty($receipt_details->website))
					, 
				@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->sub_heading_line2))
					{{ $receipt_details->sub_heading_line2 }}<br/>
				@endif
				@if(!empty($receipt_details->sub_heading_line3))
					{{ $receipt_details->sub_heading_line3 }}<br/>
				@endif
				@if(!empty($receipt_details->sub_heading_line4))
					{{ $receipt_details->sub_heading_line4 }}<br/>
				@endif		
				@if(!empty($receipt_details->sub_heading_line5))
					{{ $receipt_details->sub_heading_line5 }}<br/>
				@endif

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

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

				<!-- Title of receipt -->
				@if(!empty($receipt_details->invoice_heading))
					<br><span class="sub-headings">{!! $receipt_details->invoice_heading !!}</span>
				@endif
			</p>
			</div>
			
			
	<div class="textbox-info border-top">
				<p class="f-left"><strong>Name</strong> :{{$receipt_detailsmrp
					->customer_name}}</p>
				<p class="f-right">
					<strong>{!! $receipt_details->invoice_no_prefix !!}</strong> :{{$receipt_details->invoice_no}}
				</p>
			</div>
			
			<?php $old_date_timestamp = strtotime($receipt_details->invoice_date); ?>
			<div class="textbox-info">
				<p class="f-left"><strong>Mobile</strong> :{{$receipt_details->customer_mobile}}</p>
				<p class="f-right">
					<strong>{!! $receipt_details->date_label !!}</strong> :{{date('d-m-Y', $old_date_timestamp)}}
				</p>
			</div>
			@if(!empty($receipt_details->customer_rp_label))
			<div class="textbox-info">
				<!--<p class="f-left"><strong>Mobile</strong> :{{$receipt_details->customer_mobile}}</p>-->
				<p class="f-left">
					<strong>{{ $receipt_details->customer_rp_label }} :</strong> {{ $receipt_details->customer_total_rp }}
				</p>
			</div>
			@endif
			
				<br/>
				
			
			<div class="textbox-info">
				<p class="f-left"><strong>{{$receipt_details->sales_person_label}}</strong> :{{$receipt_details->sales_person}}</p>
				<p class="f-right">
					<strong>Time</strong> :{{date('h:i A', $old_date_timestamp)}}
				</p>
			</div>
			
			
			@php $dis=0; @endphp
                @foreach($receipt_details->lines as $line)
                    <?php if($line['total_line_discount']!='0.00') $dis=1;  ?>
                @endforeach
            <table style="margin-top: 5px !important;" class="width-100 table-f-7">
                <thead class=" border-top-dotted  border-bottom-dotted">
                    <tr>
                        <th >
                        	{{$receipt_details->table_product_label}}
                        </th>
                        <th class="unit_price text-center" >
                        	MRP
                        </th>
                        <th class="quantity text-center" >
                        	{{$receipt_details->table_qty_label}}
                        </th>
                        
                        <!-- <th class="unit_price text-center" >
                        	Sub.Tot
                        </th> -->
						<th class="text-center" >Disc</th>
						
                        <th class="price text-center" >{{$receipt_details->table_subtotal_label}}</th>
                    </tr>
                </thead>
			<tbody>
				<?php $line_subtotal=0;
                $pro_qty=0;
                $rate =0;
                $disc = 0;
                $net_rate =0;
                $tax_saving=0; ?>

				@forelse($receipt_details->lines as $line)
				<?php 
                       $pro_qty = $pro_qty + $line['quantity'];
                       $rate = $rate + $line['unit_price_before_discount_uf']*$line['quantity'];
                       $disc = $disc + $line['line_discount_uf'];
                       $net_rate = $net_rate + $line['unit_price_inc_tax_uf']*$line['quantity'];
                       $line_subtotal=$line_subtotal+$line['quantity_uf']*$line['sell_price_inc_tax_uf'];
                    ?>
					<!-- <tr>
						<td colspan="5"> <?php  //print_r($line);
								$li=45;
								if(strlen($line['name'])<$li){
								    echo $line['name'];
								}else{
								    echo substr($line['name'], 0, $li)."...";
								}?>
						</td>
					</tr> -->
					<tr>
					   <!-- <td></td> -->
					   <td > <?php  //print_r($line);
								$li=7;
								if(strlen($line['name'])<$li){
								    echo $line['name'];
								}else{
								    echo substr($line['name'], 0, $li)."...";
								}?>
						</td>
					
						
						<td class="text-center"><?=number_format($line['unit_price_before_discount_uf'],2);?></td>
						<td class="text-center">{{$line['quantity']}}</td>
						
						<!-- <td class="text-right">{{number_format($line['unit_price_before_discount_uf']*$line['quantity_uf'],2)}}</td> -->
						<td class="text-center">{{$line['total_line_discount'] ?? '0.00'}}</td>
						<td class="text-center">{{$line['line_total']}}</td>
					</tr>
				@endforeach

				<tr class="border-top-dotted">
                        <td class="text-right">&nbsp;Total Item</td>
                        <td class="quantity text-center"><?=$pro_qty?></td>
                        <td class="text-right">&nbsp;</td>
                        <td class="text-right">&nbsp;</td>
                        <td class="unit_price text-center"><?=number_format($rate,2);?></td>
                        <!-- <td class="text-center"> {{($receipt_details->total_line_discount_unformat+$tax_saving)}}</td> 
                        <td class="price text-center"><?=number_format($net_rate,2);?></td>-->
                </tr>   
            </table>
			@if(!empty($receipt_details->total_quantity_label))
				<div class="flex-box">
					<p class="left text-right">
						{!! $receipt_details->total_quantity_label !!}
					</p>
					<p class="width-50 text-right">
						({{$receipt_details->total_quantity}})
					</p>
				</div>
			@endif
			@if(empty($receipt_details->hide_price))
                <div class="flex-box border-top-dotted" >
                    <p class="left text-right sub-headings">
                    	{!! $receipt_details->subtotal_label !!}
                    </p>
                    <p class="width-50 text-right sub-headings">
                    	<!-- {{$receipt_details->subtotal}} -->{{number_format((float)$rate, 2, '.', '')}}
                    </p>
                </div>

                <!-- Shipping Charges -->
				@if(!empty($receipt_details->shipping_charges))
					<div class="flex-box">
						<p class="left text-right">
							{!! $receipt_details->shipping_charges_label !!}
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->shipping_charges}}
						</p>
					</div>
				@endif

				@if(!empty($receipt_details->packing_charge))
					<div class="flex-box">
						<p class="left text-right">
							{!! $receipt_details->packing_charge_label !!}
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->packing_charge}}
						</p>
					</div>
				@endif

				<!-- Discount -->
				@if( !empty($receipt_details->discount) )
					<div class="flex-box">
						<p class="width-50 text-right sub-headings">
							<!--{!! $receipt_details->discount_label !!}-->Round Off Amt
						</p>

						<p class="width-50 text-right sub-headings">
							(-) {{$receipt_details->discount}}
						</p>
					</div>
				@endif

				@if( !empty($receipt_details->total_line_discount) )
					<div class="flex-box">
						<p class="width-50 text-right main-headings">
							{!! $receipt_details->line_discount_label !!}
						</p>

						<p class="width-50 text-right main-headings">
							(-) {{number_format($receipt_details->total_line_discount_unformat+$tax_saving,2)}}
						</p>
					</div>
				@endif

				@if( !empty($receipt_details->additional_expenses) )
					@foreach($receipt_details->additional_expenses as $key => $val)
						<div class="flex-box">
							<p class="width-50 text-right">
								{{$key}}:
							</p>

							<p class="width-50 text-right">
								(+) {{$val}}
							</p>
						</div>
					@endforeach
				@endif

			

@if(!empty($receipt_details->group_tax_details))
					@foreach($receipt_details->group_tax_details as $key => $value)
					<div class="flex-box">
							<p class="width-50 text-right">
								{!! $key !!}
							</p>
						<p class="width-50 text-right">
								(+) {{$value}}
						</p>
					</div>
					@endforeach
@endif
				@if( !empty($receipt_details->tax) )
					<div class="flex-box">
						<p class="width-50 text-right">
							{!! $receipt_details->tax_label !!}
						</p>
						<p class="width-50 text-right">
							(+) {{$receipt_details->tax}}
						</p>
					</div>
				@endif

				@if( $receipt_details->round_off_amount > 0)
					<div class="flex-box">
						<p class="width-50 text-right">
							{!! $receipt_details->round_off_label !!} 
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->round_off}}
						</p>
					</div>
				@endif
	
				<div class="flex-box">
					<p class="width-50 text-right sub-headings">
						{!! $receipt_details->total_label !!}
					</p>
					<p class="width-50 text-right sub-headings">
						{{$receipt_details->total}}
					</p>
				</div>
			      @if(!empty($receipt_details->total_in_words)) 
			       <div class="flex-box">
					<p class="width-50 text-right main-headings">
						Amount in Words:
					</p>
					<p class="width-50 text-right main-headings">
							{{ ucwords($receipt_details->total_in_words) }} Rupees Only /-
					</p>
						@endif
				</div>
				
				<p colspan="2" class="text-right mb-0">
					
				
					
				</p>
			
				

				<!-- Total Paid-->
				@if(!empty($receipt_details->total_paid))
					<!--<div class="flex-box border-bottom-dotted">
						<p class="width-50 text-right">
							{!! $receipt_details->total_paid_label !!}
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->total_paid}}
						</p>
					</div>-->
				@endif

				<!-- Total Due-->
				@if(!empty($receipt_details->total_due) && !empty($receipt_details->total_due_label))
					<div class="flex-box">
						<p class="width-50 text-right">
							{!! $receipt_details->total_due_label !!}
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->total_due}}
						</p>
					</div>
				@endif

				@if(!empty($receipt_details->all_due))
					<div class="flex-box">
						<p class="width-50 text-right">
							{!! $receipt_details->all_bal_label !!}
						</p>
						<p class="width-50 text-right">
							{{$receipt_details->all_due}}
						</p>
					</div>
				@endif
			@endif
           

            @if(!empty($receipt_details->additional_notes))
	            <p class="centered">
	                
	            	{!! nl2br($receipt_details->additional_notes) !!}
	            </p>
            @endif
            
             @if(!empty($receipt_details->payments))
                        <div class="flex-box border-top-dotted">
							<p class="width-100 text-left"><b><u style="text-decoration: underline dotted black;text-underline-offset: 4px;">Payment Details:</u></b><br>
							 @if(!empty($receipt_details->payments))
            					@foreach($receipt_details->payments as $payment)

            							<span class="width-50 text-left">{{$payment['method']}} : {{$payment['amount']}} </span>
            					@endforeach
            @endif
							
							</p>
						
						</div>
             @endif  

            @if(!empty($receipt_details->footer_text))
				<p class="centered">
					{!! $receipt_details->footer_text !!}
				</p>
			@endif
           

			@if($receipt_details->show_qr_code && !empty($receipt_details->qr_code_text))
				<img class="center-block mt-5" src="data:image/png;base64,{{DNS2D::getBarcodePNG($receipt_details->qr_code_text, 'QRCODE')}}">
			@endif
			
			
			 {{-- Barcode --}}
			@if($receipt_details->show_barcode)
				<img class="center-block" src="data:image/png;base64,{{DNS1D::getBarcodePNG($receipt_details->invoice_no, 'C128', 2,30,array(39, 48, 54), true)}}">
			@endif
			
			<div class="centered border-bottom-dotted">
			</div>
			
			
	
    </body>
</html>

<style type="text/css">
.f-8 {
	font-size: 8px !important;
}
body {
	color: #000000;
}
@media print {
	* {
    	font-size: 12px;
    	font-weight:600;
    	font-family: 'Times New Roman';
	}
	.f-8 {
		font-size: 12px !important;
	}
	
.headings{
	font-size: 20px;
	font-weight: 700;
	text-transform: uppercase;
	white-space: nowrap;
}

.sub-headings{
	font-size: 14px !important;
	font-weight: 700 !important;
}
.main-headings{
	font-size: 16px !important;
	font-weight: 800 !important;
}


.border-top{
    border-top: 1px solid black;
}
.border-bottom{
	border-bottom: 1px solid black;
}

.border-bottom-dotted{
	border-bottom: 1px dotted black;
}
.border-top-dotted{
	border-top: 1px dotted black;
}

td.serial_number, th.serial_number{
	width: 5%;
    max-width: 5%;
}

td.description,
th.description {
}

td.quantity,
th.quantity {
    word-break: break-all;
}
td.unit_price, th.unit_price{
    word-break: break-all;
}

td.price,
th.price {
    word-break: break-all;
}

.centered {
    text-align: center;
    align-content: center;
}

.ticket {
    width: 100%;
    max-width: 100%;
}

img {
    max-width: inherit;
    width: auto;
}

    .hidden-print,
    .hidden-print * {
        display: none !important;
    }
}
.table-info {
	width: 100%;
}
.table-info tr:first-child td, .table-info tr:first-child th {
	padding-top: 8px;
}
.table-info th {
	text-align: left;
}
.table-info td {
	text-align: right;
}
.logo {
	float: left;
	width:35%;
	padding: 10px;
}

.text-with-image {
	float: left;
	width:65%;
}
.text-box {
	width: 100%;
	height: auto;
}

.textbox-info {
	clear: both;
}
.textbox-info p {
	margin-bottom: 0px
}
.flex-box {
	display: flex;
	width: 100%;
	padding-right:15px;
}
.flex-box p {
	width: 50%;
	margin-bottom: 0px;
	white-space: nowrap
	padding-right:15px;
}

.table-f-12 th, .table-f-12 td {
	font-size: 12px;
	word-break: break-word;
}

.bw {
	word-break: break-word;
}
</style> 