<?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 } ?>
        <tr>
          <?php if($delivery_details['vehicle_name']){ ?>
          <td > &nbsp;&nbsp;&nbsp; </td>
          <td >&nbsp;&nbsp;&nbsp;</td>
          <?php } ?>
        </tr>
        <tr>
          <?php if($order_details['invoice_type'] ){ ?>
          <td >&nbsp;&nbsp;&nbsp; </td>
          <td >&nbsp;&nbsp;&nbsp;</td>
          <?php } ?>
        </tr>
         <?php if($order_details['invoice_type'] == 2){ ?>
        <tr>
          <td >&nbsp;&nbsp;&nbsp; </td>
          <td >&nbsp;&nbsp;&nbsp;</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 $order_details['customer_order_date']; ?></td>
        </tr>
        <tr>
          <td style="border:1px solid #000"> Invoice: </td>
          <td style="border:1px solid #000"><strong><?php echo $order_details['cus_order_ref_no']; ?></strong>  </td>
        </tr>
        <tr>
          <?php if($delivery_details['vehicle_name']){ ?>
          <td style="border:1px solid #000"> Lorry: </td>
          <td style="border:1px solid #000"><strong><?php echo $delivery_details['vehicle_name']; ?></strong>&nbsp;&nbsp;&nbsp;(<?php echo $delivery_details['user_first_name'] ;?>)</td>
          <?php } ?>
        </tr>
        <tr>
          <?php if($order_details['user_first_name']){ ?>
          <td style="border:1px solid #000"> Rep Name: </td>
          <td style="border:1px solid #000"><strong><?php echo $order_details['user_first_name']." ".$order_details['user_last_name']."(".$order_details['invoice_name'].")"; ?></strong></td>
          <?php } ?>
        </tr>
         <?php if($order_details['invoice_type'] == 1){ ?>
        <tr>
          <td style="border:1px solid #000"> Due Date: </td>
          <td style="border:1px solid #000"><?php  echo $NewDate=Date('Y-m-d', strtotime("+7 days"));; ?></td>
        </tr>
         <?php }?>
         <?php if($order_details['invoice_type'] == 2){ ?>
         <tr>
          <td style="border:1px solid #000"> Due Date: </td>
          <td style="border:1px solid #000"><?php  echo $NewDate=Date('Y-m-d', strtotime("+40 days"));; ?></td>
        </tr>
         <?php }?>
         
         
      </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 ($cus_order_items_details as $row)

 {

	 $tmpcount++;

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

 ?>
      <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['issue_qty'], 0, '.', ','); ?></strong></td>
        <td style="text-align:right; width:100px; border:none;"><?php echo number_format($row['product_price'], 2, '.', ','); ?></td>
        <?php //if($discount_enable){ ?>
        <td style="width: 100px; text-align:right; vertical-align:middle; border:none"> (<?php echo $row['discount_defualt'] ?><?php if($row['discount']){echo " , ".$row['discount'];}?>) <?php echo number_format($row['default_discount_price']+$row['add_sales_discount_price'], 2, '.', ',') ?></td>
        <?php //}?>
        <td style="text-align:right; width:120px;  border:none"><?php echo $row['total_price']; ?></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($order_details['net_amount'], 2, '.', ',') ?></strong></td>
       </tr>     
      <tr>
         <td>Group Discount(<?php echo $order_details['order_discount'] ?>)</td>
         <td style="text-align:right;"><?php echo number_format($order_details['discount_val'], 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($order_details['total_amount'], 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">
  <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>
