<?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>
<?php $this->load->view("common/report_header.php"); ?>
<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()">


<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">
            <tbody>
        <tr>
          <td > Customer: </td>
          <td ><?php echo $details['cus_name']."(".$details['cus_code'].")"; ?></td>
        </tr> <?php 
		if($details['cus_address']){ ?>
        <tr>
          <td > Address </td>
          <td ><?php echo $details['cus_address']; ?></td>
        </tr>
        <?php } ?>
        
        <?php 
		if($details['cus_phone']){ ?>
        <tr>
          <td > Tel: </td>
          <td ><?php echo $details['cus_phone']; ?></td>
        </tr>
        <?php } ?>
        </tbody>
      </table>
    </div>
    <div class="col-xs-6 pull-right">
      <table class="print-table" width="100%" style="border:none">
          <tbody>
        <tr>
          <td style="border:1px solid #000"> Date: </td>
          <td style="border:1px solid #000"><?php echo $details['added_date_time']; ?></td>
        </tr>
        <tr>
          <td style="border:1px solid #000"> Invoice: </td>
          <td style="border:1px solid #000"><strong><?php echo $details['dpn_ref_no']; ?></strong>  </td>
        </tr>
         <tr>
          <td style="border:1px solid #000"> Dispatch No: </td>
          <td style="border:1px solid #000"><strong><?php echo $details['dpn_manual_ref_no']; ?></strong>  </td>
        </tr>
        <tr>
          <?php if($details['user_first_name']){ ?>
          <td style="border:1px solid #000"> Rep Name: </td>
          <td style="border:1px solid #000"><strong><?php echo $details['user_first_name']." ".$details['user_last_name']; ?></strong></td>
          <?php } ?>
        </tr>
         </tbody>
      </table>
    </div>
  </div>
</div>
<!--lorry rep; due date;--> 
<br>
<div class="print-start" style="border:solid 1px; min-height:100px;" >
  <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="" align="center"  style="border:1px solid #000"> Net Amount<br>
          (Rs.)</th>
      </tr>
    </thead>
    <tbody>
      <?php 
 $tmpcount=0;
 $tot_qty=0;
  foreach ($item_list as $row){
	 $tmpcount++;
	 $tot_qty=$tot_qty+$row['issued_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['issued_qty'], 0, '.', ','); ?></strong></td>
        <td style="text-align:right; width:100px; border:none;"><?php echo number_format($row['uom_price'], 2, '.', ','); ?></td>
       
        <td style="text-align:right; width:120px;  border:none"><?php echo number_format($row['total_price'], 2, '.', ',')?></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">
         <tbody>
      <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($details['total_dpn_price'], 2, '.', ',') ?></strong></td>
       </tr>
        <tr>
         <td>Loading Charge</td>
         <td style="text-align:right;"><?php echo number_format($details['loading_unloading_charge'], 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($details['total_dpn_value'], 2, '.', ',') ?></strong></td>
       </tr>
       </tbody>
    </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-12">
<?php foreach($return_note_master as $row_m){ ?>
<h5 class="text-center"><strong>RETURN NOTE</strong> (<?php echo $row_m['rtn_ref_no'];  ?>) </h5>

 <table width="100%" border="0">
  <tbody>
      <tr><th>CODE</th><th>NAME</th><th>UOM</th><th>QTY</th><th>TOTAL</th></tr>
      <?php foreach($return_note_items as $row_i){  
    if($row_m['rtn_id']!=$row_i['rtn_id']){continue;}else{?>
      <tr class="text-center">
          <td>
            <?php echo $row_i['product_code'];  ?>  
          </td>
          <td>
           <?php echo $row_i['product_name'];  ?>   
          </td>
          <td>
             <?php echo $row_i['unit_code'];  ?>  
          </td>
          <td >
             <?php echo $row_i['rtn_request_qty'];  ?>  
          </td>
          <td class="text-right">
             <?php echo $row_i['rtn_total_value'];  ?>  
          </td>
      </tr>
      <?php  } ?> 
      <tr class="text-right">
          <td colspan="1">
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
              TOTAL
          </td>
          <td>
             <?php echo $row_m['rtn_total_value'];  ?>  
          </td>
      </tr>
      
      <tr class="text-right">
          <td colspan="1">
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
              DELIVERY CHARGE
          </td>
          <td>
             <?php echo $row_m['rtn_delivery_charge'];  ?>  
          </td>
      </tr>
      
       <tr class="text-center">
          <td colspan="1">
          </td>
          <td>
          </td>
          <td>
          </td>
          <td class="text-right">
              <strong>RETURN AMOUNT</strong>
          </td>
          <td class="text-right">
            <strong><?php echo $row_m['return_note_amount'];  ?>  </strong> 
          </td>
      </tr>
      
<?php } ?>

  </tbody>
  </table>

 
<?php } ?>
  
  </div>
  <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>
 </html>
