<?php
if($xls == 1 ) {
header("Content-Disposition: attachment; filename=\"po_periode.xls\"");
header("Content-Type: application/vnd.ms-excel");	
}
$this->load->view('includes/header.php');
echo '<font class="title">'.$menu_path.'</font>';
echo '<br>';
echo '<br>';
			/* Display system message */
			$this->fungsi->disp_sys_msg();
			echo validation_errors('<p class="field_error">', '</p>');
			
			//foreach ($cpv_pus  as $cpv_puss)
?>
<style type="text/css" media="print">
.no-print		{ display:none; }
</style>
<script language="Javascript1.2">
  <!--
  function printpage() {
  window.print();
  }
  //-->
</script>
<?php
if($xls == 0 ) {
	?>
<input type="button" class="no-print" value="Print this Page" onclick="window.print();">
<form name="form1" method="post" action="<?php echo $form_action ?>">
  <input type="submit" name="button" class="no-print" id="button" value="Export To Excel" />
</form>
<?php } ?>
<br />
<table width="1295" border="1" cellpadding="1" cellspacing="1" bordercolor="#000000">
  <tr>
    <th width="97">NO. PO</th>
    <th width="97">TOP</th>
    <th width="97">NO. MIGO</th>
    <th width="97">MIRO</th>
    <th width="97">NO. CPV</th>
    <th width="97">NO. CPDU</th>
    <th width="97">NO. PP</th>
    <th width="97">VENDOR ID</th>
    <th width="97" height="41">POST DATE</th>
    <th width="111">POST BY</th>
    <th width="123">PRICE/Ltr</th>
    <th width="123">QUANTITY</th>
    <th width="123">R. Disc</th>
    <th width="123">TOTAL BEFORE PPN</th>
    <th width="123">PPN</th>
    <th width="123">TOTAL</th>
  </tr>
  <?php 
$total = 0;
$total_amt = 0;
$bg = 0;
foreach ($po as $pos)
{ 
											if($bg==0)
											   {
											   echo '<tr style=background-color:#eeeeee;>';
											   $bg++;
											   }
											else
												{
												echo '<tr style=background-color:#;>';
												$bg--;
												}		
?>
       
        
          
            
                 
                    <td><?php echo $pos->ebeln; ?></td>
                    <td><?php echo $pos->desc; ?></td>
                  <td><?php echo $pos->mblnr; ?></td>
              <td align="center"><?php
			  
			  if($this->fungsi_sap->fm_check_po_miro($pos->ebeln) == '')
				{
					 echo '<font color="#FF0000"><b>NOT OK</b></font>';
				}
				else
				{
					echo '<font color="#00CC00"><b>OK</b></font>';
				}
			   ?></td>
            <td><?php echo $pos->nocpvform; ?></td>
            <td><?php 
if($pos->nocpvform != '')
{
$query_cpdu = $this->db->query("SELECT nocpdu FROM t_cpv WHERE nocpvform = '".$pos->nocpvform."'")->result();
foreach ($query_cpdu  as $query_cpdus);
echo $query_cpdus->nocpdu;
}?></td>
        <td><?php echo $pos->preq_no; ?></td>
      <td><?php echo $pos->vendor; ?></td>
      <td><?php echo  date("d.m.Y", strtotime($pos->postdate)) ; ?></td>
    <td><?php echo $pos->addby; ?></td>
<?php if($xls == 0 ) { ?>
    <td align="right"><?php echo $this->fungsi->format_idr($pos->net_price); ?></td>
    <td align="right"><?php echo number_format($pos->quantity); ?></td>
    <td align="right"><?php echo $this->fungsi->format_idr($pos->disc); ?></td>
    <td align="right"><?php echo  $this->fungsi->format_idr((($pos->quantity * $pos->net_price) - $pos->disc)); ?></td>
    <td align="right"><?php echo $this->fungsi->format_idr($pos->tax); ?></td>
    <td align="right"><?php echo  $this->fungsi->format_idr((($pos->quantity * $pos->net_price) - $pos->disc) + $pos->tax); ?></td>
<?php }
else
{
 ?>
 <td align="right"><?php echo $pos->net_price; ?></td>
    <td align="right"><?php echo $pos->quantity; ?></td>
    <td align="right"><?php echo $pos->disc; ?></td>
    <td align="right"><?php echo  (($pos->quantity * $pos->net_price) - $pos->disc); ?></td>
    <td align="right"><?php echo $pos->tax; ?></td>
    <td align="right"><?php echo  (($pos->quantity * $pos->net_price) - $pos->disc) + $pos->tax; ?></td>
<?php } ?>
  </tr>
  <?php 
$total = $pos->quantity + $total;
$total_amt = $total_amt + (($pos->quantity * $pos->net_price) - $pos->disc) + $pos->tax;
}
?>
  <tr>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
  <td bgcolor="#FFFF00">&nbsp;</td>
  <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td align="right" bgcolor="#FFFF00">&nbsp;</td>
    <td align="right" bgcolor="#FFFF00"><strong><?php if($xls == 0 ) { echo number_format($total);  } else { echo $total; }?></strong></td>
    <td align="right" bgcolor="#FFFF00">&nbsp;</td>
    <td align="right" bgcolor="#FFFF00">&nbsp;</td>
    <td align="right" bgcolor="#FFFF00">&nbsp;</td>
    <td align="right" bgcolor="#FFFF00"><strong><?php if($xls == 0 ) { echo $this->fungsi->format_idr($total_amt); } else { echo $total_amt; } ?></strong></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00">&nbsp;</td>
    <td align="center" bgcolor="#FFFF00"><strong>AVERAGE PRICE :</strong></td>
    <td align="right" bgcolor="#FFFF00"><strong>
      <?php if($xls == 0 ) { echo $this->fungsi->format_idr($total_amt / $total);  } else { echo round($total_amt / $total); }?>
    </strong></td>
  </tr>
</table>
<?php
if ( ! empty($link))
	{
		echo '<p id="bottom_link" class="no-print">';
		foreach($link as $links)
		{
			echo $links . ' ';
		}
		echo '</p>';
	}
$this->load->view('includes/footer.php');
	?>
