<?php
if($xls == 1 ) {

header("Content-Disposition: attachment; filename=\"branch_po_credit.xls\"");
header("Content-Type: application/vnd.ms-excel");	

}
$this->load->view('includes/header.php');

			/* 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
echo '<font class="title">'.$menu_path.'</font>';
?>
<br />
<?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 } ?>
<?php
echo '<br>';
echo '<br>';
echo '<h2>'.$nama_vendor.'</h2>';
echo '<h4>Unit Pembelian : '.$uom.'</h4>';
if($tax==1)
{
echo '<h4>Harga sudah termasuk PPN</h4>';
}
else
{
echo '<h4>Harga belum termasuk PPN</h4>';	
}
echo '<br>';
?>

<table width="91%" border="1">
  <tr>
    <th width="3%">No.</th>
    <th width="7%">No. PO</th>
    <th width="6%">Tgl Input</th>
    <th width="12%">Cabang</th>
    <th width="27%">Pengambilan</th>
    <th width="9%">Quantity</th>
    <th width="9%">Satuan</th>
    <th width="9%">Harga Satuan</th>
    <th width="7%">PPN</th>
    <th width="11%">Total</th>
  </tr>
 <?php 
$no = 0;
$bg = 0;
$total_all = 0;
$total_vol = 0; 
foreach ($po as $row)
{ 
$tot_po = round((($row->quantity * $row->net_price) - $row->disc) + $row->tax);
if($bg==0)
											   {
											   echo '<tr style=background-color:#eeeeee;>';
											   $bg++;
											   }
											else
												{
												echo '<tr style=background-color:#;>';
												$bg--;
												}	
?>
    <td><?php echo ++$no; ?></td>
    <td><?php echo $row->ebeln; ?></td>
    <td><?php echo date("d.m.Y", strtotime($row->postdate)); ?></td>
    <td><?php echo $row->cabname; ?></td>
    <td><?php echo $row->vendor_name; ?></td>
    <td align="center"><?php if($uom=='DR')
	{
		$vol = $row->quantity / 200;
	}
	else
	{
	$vol = $row->quantity;	
	}
	if($xls == 0 ) {
	echo number_format($vol);
	}
	else
	{
		echo $vol;
	}?></td>
    <td align="center"><?php echo $uom; ?></td>
    <td align="right"><?php if($tax==1)
		{
			
			$price = $tot_po / $vol;
		}
		else
		{
			$price = $row->net_price;
		}
if($xls == 0 ) {
	echo $this->fungsi->format_idr($price);
}
else
{
	echo round($price);
}?></td>
    <td align="right"><?php if($tax==1)
		{
			
			$ppn = 0;
		}
		else
		{
			$ppn = $row->tax;
		}
		if($xls == 0 ) {
			echo $this->fungsi->format_idr($ppn);
		}
		else
		{
			echo round($ppn);
		}
	?></td>
    <td align="right"><?php if($tax==1)
		{
			
			$total =  round($price) * $vol;
		}
		else
		{
			$total =  $tot_po;
		}
	if($xls == 0 ) {
	echo $this->fungsi->format_idr($total);
	}
	else
	{
		echo $total;
	}?></td>
  </tr>
<?php
$total_all = $total  + $total_all ;
$total_vol = $total_vol  + $vol ;
}
?>
  <tr>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66" align="center"><b><?php
	if($xls == 0 ) { echo number_format($total_vol); } else { echo $total_vol;  } ?></b></td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td bgcolor="#FFFF66">&nbsp;</td>
    <td align="right" bgcolor="#FFFF66"><b><?php if($xls == 0 ) { echo $this->fungsi->format_idr($total_all); } else { echo $total_all; } ?></b></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');
	?>
