<?php $this->load->view( "common/header" );
?>
<body onLoad="window.print()">
	<div class="col-xs-12">
		<div style="page-break-after:always;">
			<div class=" text-center">
			    <?php /* ?>
				<br>
				<img src="<?php echo base_url('thems/images/golden_lanka.png'); ?>" width="100px" style="margin-top:-6px;" height="60px"/><br>
				 <?php */ ?>
				<h4>
					<?php $inv_name=$warehouse_details['name']; echo $inv_name; ?>
				</h4>
				<!-- 
            <img alt="logo" src="<?php //echo asset_url(); ?>images/logo_print.png" style="margin-top: 1px;width: 100px;"> -->
				<p style="font-size:13px ; margin: 0px">
					<?php echo  $warehouse_details['address'] ?>
				</p>
				<?php  //if($get_warehouse[0]->email) echo $get_warehouse[0]->email."<br>"; ?>
				<?php if($warehouse_details['phone']) echo "<span style=\"font-weight:bold; font-size:15px\">".$warehouse_details['phone']."</span><br>"; ?>
			</div>

			<!--col-xs-12-->

			<div>
				<div class="row">
					<div class="col-md-12"> <?php /* ?>
						<p style="margin-bottom: 0px">Reg.No :
							<?php echo $warehouse_details['reg_no'] ?> </p><?php */ ?>
						<p id="bill_date" style="margin-bottom: 0px">Date:
							<?php echo display_date_time_format($sale_details['sale_datetime']); ?> </p>
					</div>
					<div class="col-md-6">

					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<p id="bill_no" style="font-weight:bold; margin-bottom: 0px">Bill No: <?php echo $sale_details['sale_reference_no']; ?> </p>
						<p style="margin-bottom:0px;">Cashier :
							<?php echo $this->session->userdata['ss_user_first_name'] ?>
						</p>
					</div>
					<div class="col-md-7">

					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<p style="" id="bill_customer">Customer:
							<?php echo $customer_details['cus_name'] ?>
							| <?php echo $customer_details['cus_phone'] ?>
						<br>
						Delevery Address:<?php echo $sale_details['sale_shipping'] ?>
						</p>
					</div>
				</div>
			</div>
			<div>
				<!--class="col-md-12"-->
				<table id="bill_table" class="print-table" style="width:100%">
					<thead style="">
						<tr class="report_view_th text-center" style="border-bottom: dashed 1px">
							<th style="width:5%" class="text-center">*</th>
							<th style="width:40%">Item</th>
							<th style="width:15%" class="text-right">Qty</th>
							<th style="width:15%" class="text-right">Price</th>
							<th style="width:15%" class="text-center">Discount</th>
							<th style="text-align:right"> Amount</th>
						</tr>
					</thead>
					<tbody>

						<?php 
 $tmpcount=0;
 $tot_qty=0;
 $g_total = 0;
 $total_item_discount=0;
  foreach ($sale_item_list as $row)
 {
	 $tmpcount++;
	 $tot_qty=$tot_qty+$row['quantity'];	 
	 $g_total += $row['gross_total'];
	 $total_item_discount+=$row['discount_val'];
 ?>
<!--any exchange should be done within seven days-->
						<tr style="border-top: dashed;">
							<td style="text-align:center; vertical-align:middle; ">
								<?php echo $tmpcount ?>
							</td>
							<td style="" colspan="5">
								<?php echo $row['product_name']; ?>
							</td>
						</tr>
						<tr style="border-bottom: dashed;">
							<td colspan="3" style="text-align:right; vertical-align:middle; padding-right:10px; ">
								<strong style="font-size:16px">
									<?php echo number_format($row['quantity'], 0, '.', ','); ?>
								</strong>
							</td>
							<td style="text-align:right; width:100px; ">
								<?php echo number_format($row['unit_price'], 2, '.', ','); ?>
							</td>
							<td style="width: 100px; text-align:right; vertical-align:middle; padding-right:10px;">
								<?php echo number_format($row['discount_val'], 2, '.', ',') ?>
							</td>
							<td style="text-align:right; width:120px; ">
								<?php echo $row['gross_total']; ?> </td>
						</tr>

						<?php }?>




						<tr style="display:none">
							<td style="text-align:center; width:40px; vertical-align:middle;font-weight:bold; font-size:16px">*</td>
							<td style="vertical-align:middle;font-weight:bold; font-size:15px">&nbsp;</td>
							<td style="width: 80px; text-align:center; vertical-align:middle;font-weight:bold; font-size:15px">&nbsp;</td>
							<td style="text-align:right; width:100px;">&nbsp;</td>
							<td style="text-align:right; width:120px; padding-right:10px;">&nbsp;</td>
						</tr>
						<tr style="border-top: dashed 1px">
							<td style="" colspan="5">SubTotal</td>
							<td style="text-align:right; " class="td_sub_total">
								<?php echo number_format($g_total, 2, '.', ',') ?>
							</td>
						</tr>
						<tr>
							<td style="text-align:left; font-weight:bold;" colspan="5">Order Discount</td>
							<td style="text-align:right;  border-bottom:solid 1px #000000" id="td_order_discount">
								<?php echo number_format($sale_details['sale_inv_discount_amount'], 2, '.', ',') ?>
							</td>
						</tr>
						
						<?php if($sale_details['delivery_charge']> 0){ ?>
						<tr>
							<td style="text-align:left;" colspan="5">Delivery Charges</td>
							<td style="text-align:right;  border-bottom:solid 1px #000000" id="td_order_discount">
								<?php echo number_format($sale_details['delivery_charge'], 2, '.', ',') ?>
							</td>
						</tr>
						
						<?php } ?>
						<tr>
							<td style="  font-size:16px" colspan="5">Total:</td>
							<td style="text-align:right;  font-size:16px;  border-bottom:4px double #000;" id="print_bill_total">
								<?php echo number_format($g_total-$sale_details['sale_inv_discount_amount']+$sale_details['delivery_charge'], 2, '.', ',') ?>
							</td>
						</tr>
						<?php if($sale_details['sale_given_amount'] > 0){ ?>
						<tr>
                          <td style="font-size:16px;" colspan="5">Paying </td>
                          <td style="  border-bottom:0px double #000;text-align:right;"><p style="font-size:16px;margin: 0px;" id="td_balance_amount"><?php echo number_format($sale_details['sale_given_amount'], 2, '.', ',') ?></p></td>
                        </tr>
                        <tr style="">
                          <td style="font-size:16px;" colspan="5">Balance </td>
                          <td style="  border-bottom:0px double #000;text-align:right;"><p style="font-size:16px;margin: 0px;" id="td_balance_amount"><?php echo number_format($sale_details['sale_given_amount']-($g_total-$sale_details['sale_inv_discount_amount']+$sale_details['delivery_charge']), 2, '.', ',') ?></p></td>
                        </tr>
                        <?php }else{?>
                        
                        <tr style="">
                          <td style="font-size:16px;" colspan="5">Payment Balance </td>
                          <td style="  border-bottom:0px double #000;text-align:right;"><p style="font-size:16px;margin: 0px;" id="td_balance_amount"><?php echo number_format($g_total+$sale_details['delivery_charge']-$sale_details['sale_given_amount']-$sale_details['sale_inv_discount_amount'], 2, '.', ',') ?></p></td>
                        </tr>
                        <?php } ?>
                        
                        <?php if($total_item_discount> 0){ ?>
                        <tr style="">
                          <td style="font-size:16px;" colspan="5">Total Item discount </td>
                          <td style="  border-top:1px double #000;text-align:right;"><p style="font-size:16px;margin: 0px;" id="td_tt_iTdis"><?php echo number_format($total_item_discount, 2, '.', ',') ?></p></td>
                        </tr>
                        <?php } ?>
					</tbody>
				</table>
				<br/>
			</div>
			<div style="text-align: center">
		
				<h4 style="margin-top: 1px">~~~Thank You~~~</h4>
				
			</div>

		</div>
	</div>
</body>