<?php $this->load->view("common/header"); ?>
<div style="top:5px;" class="panel-tools open">
  <button data-toggle="dropdown" class="btn btn-blue dropdown-toggle" onClick="window.print()"><i class="fa fa-print"></i></button>
</div>
<style type="text/css">
h3 {
	margin-top: 10px;
}
th {
	text-align: center !important;
}
.report_view_th {
	color: #000 !important;
	text-align: center !important;
}
body {
	background-color: #fff !important;
	font-size: 12px;
}
p {
	margin: 0;
}
.modal-body {
	padding: 2px 15px 15px;
	position: relative;
}
body .modal {
	/* new custom width */

	width: 750px;
	/* must be half of the width, minus scrollbar on the left (30px) */

	margin-left: -375px;
}
.print-table td, th {
	padding: 1px;
	vertical-align: top !important;
}
thead {
	display: table-header-group;
}
tfoot {
	display: table-footer-group;
}
.width_cus {
	width: 100px !important;
}
.width_qty {
	width: 100px !important;
}
</style>

<!--https://css-tricks.com/almanac/properties/p/page-break/-->
<!--onLoad="window.print()-->
<body onLoad="window.print()">
<?php $this->load->view("common/report_header.php"); ?>

<div class="row">
  <div class="col-xs-12">
    <div class="col-xs-5" style="border:solid 1px;">       
        <table class="print-table" width="100%" style="border:none">
        <tr>
          <td > Customer: </td>
          <td ><?php echo $customer_details['cus_name']."(".$customer_details['cus_code'].")"; ?></td>
        </tr> <?php 
		if($customer_details['cus_address']){ ?>
        <tr>
          <td > Address </td>
          <td ><?php echo $customer_details['cus_address']; ?></td>
        </tr>
        <?php } ?>
        
        <?php 
		if($customer_details['cus_phone']){ ?>
        <tr>
          <td > Tel: </td>
          <td ><?php echo $customer_details['cus_phone']; ?></td>
        </tr>
        <?php } ?>
      
       
       
      </table>
        
        

    </div>
    <div class="col-xs-6 pull-right">
      <table class="print-table" width="100%" style="border:none">
        <tr>
          <td style="border:1px solid #000"> Date: </td>
          <td style="border:1px solid #000"><?php echo $sale_details['sale_datetime']; ?></td>
        </tr>
        <tr>
          <td style="border:1px solid #000"> Invoice: </td>
          <td style="border:1px solid #000"><strong><?php echo $sale_details['sale_reference_no']; ?></strong>  </td>
        </tr>
        <tr>
          <?php if($add_sale_details['vehicle_no']){ ?>
          <td style="border:1px solid #000"> Lorry: </td>
          <td style="border:1px solid #000"><strong><?php echo $add_sale_details['vehicle_no']; ?></strong>&nbsp;&nbsp;&nbsp;(<?php echo $add_sale_details['driver_name'] ;?>)</td>
          <?php } ?>
        </tr>
        <tr>
          <?php if($sale_details['user_first_name']){ ?>
          <td style="border:1px solid #000"> Rep Name: </td>
          <td style="border:1px solid #000"><strong><?php echo $sale_details['user_first_name']." ".$sale_details['user_last_name']."(".$sale_details['invoice_name'].")"; ?></strong></td>
          <?php } ?>
        </tr>
         
        <tr>
          <td style="border:1px solid #000"> Due Date: </td>
          <td style="border:1px solid #000"><?php  echo $sale_details['due_date']; ?></td>
        </tr>
        
        
         
         
      </table>
    </div>
  </div>
</div>
<!--lorry rep; due date;--> 
<br>
<div class="print-start" style="border:solid 1px; min-height:560px;" >
  <table class="print-table" width="100%" style="border:none">
    <thead>
      <tr class="report_view_th text-center"  style="border:1px solid #000">
        <th style="border:1px solid #000; width:40px;" class='width_cus'><br>
          No</th>
        <th class="col-xs-7" style="border:1px solid #000"><br>
          Description</th>
        <th class="width_qty" style="border:1px solid #000";><br>
          Qty</th>
        <th class="" style="border:1px solid #000">Unit Price<br>
          (Rs.)</th>        
        <th class="col-xs-1"  style="border:1px solid #000">Discount<br>
          (Rs.)</th>
        <th class="" align="center"  style="border:1px solid #000"> Net Amount<br>
          (Rs.)</th>
      </tr>
    </thead>
    <tbody>
      <?php 

 $tmpcount=0;

 $tot_qty=0;

  foreach ($sale_item_list as $row)

 {

	 $tmpcount++;

	 $tot_qty=$tot_qty+$row['quantity'];

 ?>
      <tr style="line-height:18px">
        <td style="text-align:center; vertical-align:middle; border:none"><?php echo $tmpcount ?>)</td>
        <td  style="border:none"><?php echo $row['product_name']; ?>
          <?php //echo $row['product_code']; ?></td>
        <td style="text-align:right; vertical-align:middle; border:none"><strong><?php echo number_format($row['quantity'], 0, '.', ','); ?></strong></td>
        <td style="text-align:right; width:100px; border:none;"><?php echo number_format($row['unit_price'], 2, '.', ','); ?></td>
        <?php //if($discount_enable){ ?>
        <td style="width: 100px; text-align:right; vertical-align:middle; border:none"> (<?php echo $row['discount'] ?><?php if($row['discount']){echo $row['discount_val'];}?>)</td>
        <?php //}?>
        <td style="text-align:right; width:120px;  border:none"><?php echo $row['gross_total']?></td>
      </tr>
      <?php }?>
    </tbody>
  </table>
</div>
<div class="row">

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;No. Items (<?php echo $tmpcount ?>), 

 Total Qty (<?php echo rtrim(str_replace('.00', '', number_format($tot_qty, 2)), ''); ?>)
 <div class="col-xs-12">
  <div class="col-xs-5 pull-right" id="border_print" style="border:1px solid #000;">
     <table width="100%" border="0">
      <tr>
         <td><strong style="font-size:14px;">Sub Total RS</strong></td>
         <td style="text-align:right"><strong style="font-size:14px;"><?php echo number_format($sale_details['sale_inv_total'], 2, '.', ',') ?></strong></td>
       </tr>
        <tr>
         <td>Line Discount</td>
         <td style="text-align:right;"><?php echo number_format($sale_details['total_default_discount_value'], 2, '.', ',') ?></td>
       </tr>      
      <tr>
         <td>Group Discount(<?php echo $sale_details['sale_inv_discount'] ?>)</td>
         <td style="text-align:right;"><?php echo number_format($sale_details['sale_inv_discount_amount'], 2, '.', ',') ?></td>
       </tr>    
      <tr style="border-top:1px solid #000;">
         <td><strong style="font-size:14px;">Total</strong></td>
         <td class="rext-right" style="border-top:1px solid #000; text-align:right"><strong style="font-size:14px;"><?php echo number_format($sale_details['sale_total'], 2, '.', ',') ?></strong></td>
       </tr>
    </table>
   </div>
  <div class="col-xs-6" id="border_print" style="border:1px solid #000; display:none">
     <p class="text-center"><strong>1</strong> Any text </p>
   </div>
</div>
 <!--col-xs-12-->
 <div class="col-xs-12">
      <div class="col-xs-7 pull-left" id="border_print" style=""><br>
        <p style="font-size:14px;">* රිසිට්  පතක් නොමැතිව  කරනු    ලබන  ගෙවීම්    සදහා  අප ආයතනය   වගකියනු නොලැබේ </p>
    </div>
  <p style="font-size:14px;">*සෑම භාණ්ඩයක්ම මිලදීගැනීමේදී හොඳින් පරීක්ෂා කර ලබාගන්න </p>
  <div class="col-xs-2" style="border-top:dashed 1px; margin:50px 5px 0px 25px">
     <center>
      Printed By (<?php echo $this->session->userdata('ss_user_first_name')." ". $this->session->userdata('ss_user_last_name') ?>)
    </center>
   </div>
  <div class="col-xs-2" style="border-top:dashed 1px; margin:50px 5px 0px 25px">
     <center>
      Checked By
    </center>
   </div>
  <div class="col-xs-2" style="border-top:dashed 1px; margin:50px 5px 0px 25px">
     <center>
      Customer Signature
    </center>
   </div>
  <div class="col-xs-2" style="border-top:dashed 1px; margin:50px 5px 0px 25px">
     <center>
      Customer Seal
    </center>
   </div>
</div>
 <div class="col-xs-12">
  <p class="text-center" style="font-size:17px;">
     <strong>Thank You! </strong></p>
</div>

 <!--print-start-->

 </body>
