<?php $this->load->view( "common/header" );
?>
<body>
	<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 $sale_details['user_first_name'] ?>
						</p>
						<?php if(isset($is_dublicated)){?>
						<p style="margin-bottom:0px;">Reprinted : 
							<?php echo $this->session->userdata('ss_user_first_name');?>  (<?php echo date("Y-m-d H:i:s"); ?> )
						</p>
						<?php } ?>
					</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>
						Delivery 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_items_discount = 0;
  foreach ($sale_item_list as $row)
 {
	 $tmpcount++;
	 $tot_qty=$tot_qty+$row['quantity'];	 
	 $g_total += $row['gross_total'];
	 $total_items_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']; ?>  <?php if($row['is_free_issue']==1){ echo " ( FREE )";} ?>
							</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 
									$n = $row['quantity'];
									$whole = floor($n);
									$fraction = $n - $whole;
									$fraction;
									if($fraction==0){
									   echo number_format($row['quantity'], 0, '.', ','); 
									}else{
									  echo number_format($row['quantity'], 3, '.', ',');  
									}
									 ?>
								</strong>
							</td>
							<td style="text-align:right; width:100px; ">
								<?php if($row['is_free_issue']==0){  echo number_format($row['unit_price'], 2, '.', ','); }?>
							</td>
							<td style="width: 100px; text-align:right; vertical-align:middle; padding-right:10px;">
								<?php if($row['is_free_issue']==0){ echo number_format($row['discount_val'], 2, '.', ',');} ?>
							</td>
							<td style="text-align:right; width:120px; ">
								<?php if($row['is_free_issue']==0){ 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;" id="td_order_discount">
								<?php echo number_format($sale_details['delivery_charge'], 2, '.', ',') ?>
							</td>
						</tr>
						<?php } ?>
						
							<?php if($sale_details['cr_interest_amt']>0) {?>
						<tr>
							<td style="text-align:left;" colspan="5">Credit/Debit Card Charges (<?php echo $sale_details['cr_interest'] ?>%)</td>
							<td style="text-align:right; " id="td_cc_charg">
								<?php echo number_format($sale_details['cr_interest_amt'], 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']+$sale_details['cr_interest_amt'], 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']+$sale_details['cr_interest_amt']), 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_items_discount>0){?>
                        <tr style="">
                          <td style="font-size:16px;" colspan="5">Total Item Discount </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($total_items_discount, 2, '.', ',') ?></p></td>
                        </tr>
                        
                        <?php } ?>


					</tbody>
				</table>
				<br/>
			</div>
			<?php if($sale_details['price_type']== "retail_credit"){ ?>
        
        
			<!--start carrier details-->
			<div class="col-xs-12 row">
			<div style="text-align: left;" class="carrier_details">
            Driver
            <div class="row">
              <div class="col-xs-3"> On cash:</div>
              <div class="col-xs-9" style="border-bottom:dashed;min-height: 20px;"></div>
            </div>
            <div class="row">
              <div class="col-xs-3"> Name:</div>
              <div class="col-xs-9" style="border-bottom:dashed;min-height: 20px;"></div>
            </div><br />
            <span style="text-align:center">Carrier Details</span>
            <div class="col-md-12">
              <div class="col-xs-2"> Name:</div>
              <div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>

              <!--<div class="col-xs-2"> NIC:</div>-->
              <!--<div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>-->

              <div class="col-xs-2"> Mobile:</div>
              <div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>

              <div class="col-xs-2"> Signature:</div>
              <div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>

              <!--<div class="col-xs-2"> Driver Name:</div>-->
              <!--<div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>-->

              <!--<div class="col-xs-2"> Driver On Cash:</div>-->
              <!--<div class="col-xs-10" style="border-bottom:dashed;min-height: 20px;"></div>-->
            </div>
          </div>
          </div>
			<?php } ?>
			<div style="text-align: center; font-size: 12px;">භාන්ඩයක් මාරු කරන විට දින 7ක් තුල බිල රැගෙන ඒම අනිවාර්ය වේ.(ආපසු මුදල් ගෙවීමක් සිදු නොකෙරේ) <br/>
          </div>
			<div style="text-align: center">
		
				<h4 style="margin-top: 1px">~~~Thank You~~~</h4>
				
			</div>
		</div>
	</div>
	<script>
        window.onafterprint = window.close;
        window.print();
	</script>
</body>