<?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;

}

.print-start{
    margin-left:30px;
    margin-right:30px;
}
</style>



<?php 

/*$ref_usr=new User_Model;



$user_details=$ref_usr->get_user_info($sale_details['user']);

$inv_name='';

$inv_name=$user_details['invoice_name'];

$inv_user_name=$user_details['user_first_name'];

$discount_enable=false;

/*if($inv_name=='AKAKI TRADING'){

	$discount_enable=false;

}

if($inv_name=='AKAKI HOMES'){

	$discount_enable=true;

}

echo 'dis_enable:'.$discount_enable;

$cr_limit_name='';

if($sale_details['cr_interest']){

get unit cr limit name

$ref_cr_lmt=new Common_Model();

$cr_limit_des=$ref_cr_lmt->get_cr_limit_name_by_val($sale_details['cr_interest']);

print_r($cr_limit_des);

$cr_limit_name=$cr_limit_des[0]['cr_limit_name'];

}*/

?>



<!--https://css-tricks.com/almanac/properties/p/page-break/-->



<!--onLoad="window.print()-->

<?php //print_r($warehouse_details);?>

<body onLoad="window.print()">

<br/>
<br/>
<br/>

<?php $this->load->view("common/report_header.php"); //print_r($user_details);?>


 
<div class="row">

  <div class="col-xs-12">

<div class="col-xs-6">
<?php
//print_r($supplier_details);
?>
<p>Supplier Code: <?php echo $supplier_details['supp_code']; ?></p>

<p><strong>Name: <?php echo $supplier_details['supp_company_name']; ?></strong> </p>

<p><strong>Note: <?php echo $purchase_details['note']; ?></strong> </p>

</div>

<div class="col-xs-6 pull-right" style="padding-left:50px;">
<p>Reference No.<?php echo $purchase_details['reference_no'];?>  </p>

<p>Date: <?php echo display_date_time_format($purchase_details['date']); ?></p>
<p>Supplier Ref. No.<?php echo $purchase_details['supp_invocie_no'];?>  </p>

</div>

</div>

</div>



<div class="print-start">



<?php //print_r($sale_details);?>

  


 <div class="col-xs-12">
<table class="print-table" width="100%" style="border:1px solid #000">

<thead>



<tr class="report_view_th text-center"  style="border:1px solid #000">

<th style="border:1px solid #000; width:40px;" class='width_cus'>No</th>

<th class="col-xs-7" style="border:1px solid #000">Description</th>

<!--<th class="" style="border:1px solid #000">Serial Number(type)</th>-->
<?php if(!isset($print_without_serial)) { ?>
    <th class="" style="border:1px solid #000">Serial Number</th>
<?php } ?>

<th class="width_qty" style="border:1px solid #000";>Qty</th>

<th class="" style="border:1px solid #000">Unit Cost</th>
 <th  style="text-align:right; width:100px; border:1px solid #000;">Min. Sell. Price</th>
									                         <th style="padding-right:0px;">Selling Price</th>
<?php if($purchase_details['discount_cal']){?>
<th class="col-xs-1"  style="border:1px solid #000">Discount</th> <?php }?>

<th class="" align="center"  style="border:1px solid #000"> Subtotal</th>

</tr>

</thead>

<tbody>

 <?php 

 $tmpcount=0;

 $tot_qty=0;

  foreach ($purchase_item_list as $row)

 {

	 $tmpcount++;

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

 ?>  

<tr>

<td style="text-align:center; vertical-align:middle; border:1px solid #000;"><?php echo $tmpcount ?></td>

<td  style="border:1px solid #000">

  <?php echo $row['product_name_c']; ?> (<?php echo $row['product_id']; ?>)</td>
  
  
  <?php if(!isset($print_without_serial)) { ?>
<?php $pur_ord_mod=new purchases_model();
$sn_list=$pur_ord_mod->get_purchese_serial_by_id($purchase_id,$row['id']);
?>

<td  style="text-align:center; vertical-align:middle; border:1px solid #000;"><table><?php foreach ($sn_list as $sn){ 

 $pis_cash_price=$sn->pis_cash_price;
   // echo "pis_min_cash_price:".  
    $pis_min_cash_price=$sn->pis_min_cash_price;
    $pieces = explode("_", $sn->pis_number);
    
?><tr  style="vertical-align:text-top"><td style="text-align:left"><?php echo $pieces[0]; //echo "$sn->pis_number ";?></td></tr><?php }?></table></td>

<?php }?>

<td style="text-align:center; vertical-align:middle; border:1px solid #000;"><strong><?php echo number_format($row['quantity'], 0, '.', ','); ?></strong></td>

<td style="text-align:right; width:100px; border:1px solid #000;"><?php echo number_format($row['unit_price'], 2, '.', ','); ?></td>
<td style="text-align:right; width:100px; border:1px solid #000;"><?php echo $pis_min_cash_price; ?></td>
<td style="text-align:right; width:100px; border:1px solid #000;"><?php echo $pis_cash_price; ?></td>

<?php if($row['discount_cal']){?>
<td style="width: 100px; text-align:right; vertical-align:middle; border:1px solid #000">

 <?php echo number_format($row['discount_cal'], 2, '.', ',') ?></td><?php }?>



 <td style="text-align:right; width:120px;  border:1px solid #000""><?php echo $row['sub_total']; ?></td>

</tr>

<?php }?>









</tbody>

</table>

</div>







                 

 <div class="row">
<div class="col-xs-12">
 <br>

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

 Total Qty (<?php echo $tot_qty; //echo rtrim(str_replace('.00', '', number_format($tot_qty, 2)), '0'); ?>)



</div>
</div>











 <div class="col-xs-7" 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($purchase_details['total'], 2, '.', ',') ?></strong></td>

  </tr>

  
<?php if($purchase_details['discount']){?>
<tr>

  <td>Deduction</td>

  <td style="text-align:right;">
  
  <?php 
  echo number_format($purchase_details['discount'], 2, '.', ',');
  //echo number_format($purchase_details['discount'], 2, '.', ',') ?></td>

</tr><?php } ?>

<?php if($purchase_details['poaddition']){?>
<tr>

  <td>Addition</td>

  <td style="text-align:right;">
  
  <?php 
  echo number_format($purchase_details['poaddition'], 2, '.', ',');
  //echo number_format($purchase_details['discount'], 2, '.', ',') ?></td>

</tr><?php } ?>


<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($purchase_details['grand_total'], 2, '.', ',') ?></strong></td>

  </tr>
   <?php 
													$pur_rtn_mod=new Purchase_Return_Model();
													$tmp_grn_id=$this->input->get('purchase_id');
													//echo "purchase_id:".$tmp_grn_id;
													$pur_return_des=$pur_rtn_mod->get_purchase_return_list_by_purchase_id($tmp_grn_id);
														//print_r($po_header[0]);
														//echo $this->uri->segment(3);
													//print_r($pur_return_des);
													$grn_rtn_tot=0;
													foreach ($pur_return_des as $item) 
													{
														$grn_rtn_tot=$grn_rtn_tot+$item->pur_rtn_inv_total;
													?>
<tr>

  <td style="text-align:left;">GRN Return Amount (<?php echo $item->pur_rtn_reference_no ?> : <?php echo site_date($item->pur_rtn_datetime) ?>)</td>
  <td style="text-align:right;"><?php echo number_format($item->pur_rtn_inv_total,2,'.',','); ?></td>
</tr>
<?php }?>
 <?php if ($grn_rtn_tot){ ?>
<tr>
  <td><strong>Grand Total</strong></td>
  <td style="text-align:right;"><strong><?php 
									                     echo number_format($purchase_details['grand_total'] - $grn_rtn_tot,2,'.',',');
									                     ?></strong></td>
</tr>
<?php }?>
<tr>

  <td>Paid</td>

<?php if($po_paid_total[0]->grn_paid_total){ ?>
  <td style="text-align:right;"><?php echo number_format($po_paid_total[0]->grn_paid_total, 2, '.', ',') ?></td>
<?php } else {?>
 <td style="text-align:right;"><?php echo number_format(0, 2, '.', ',') ?></td>
<?php } ?> 
</tr>
<tr style="border-top:1px solid #000;">

    <td><strong style="font-size:14px;">Balance</strong></td>

    <td class="rext-right" style="border-top:1px solid #000; text-align:right"><strong style="font-size:14px;"><?php echo number_format($purchase_details['grand_total']-$grn_rtn_tot - $po_paid_total[0]->grn_paid_total, 2, '.', ',') ?></strong></td>

  </tr>

</table>

</div>

</div>



    <!--<div class="col-xs-6" id="border_print" style="border:1px solid #000;">

 <p class="text-center"><strong>1</strong> Year Warranty for Electrical & Electronic Items <strong>6</strong> month warranty for Lantern/torch No Warrant for physical Damage.

   <strong>3</strong> Years Warranty for TV. </p>

 </div>-->



</div><!--col-xs-12-->









<div class="col-xs-12">

 <p class="text-center" style="font-size:17px;"><br>



<strong>Thank You! </strong></p>

 </div>

<!--print-start-->   



 </body>

