<?php
if($xls == 1 ) {
header("Content-Disposition: attachment; filename=\"mutasi_stok.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="1043" border="1" cellpadding="1" cellspacing="1" bordercolor="#000000">
  <tr>
    <th width="117" height="41">POSTING DATE</th>
    <th width="143">NO. DOC.</th>
    <th width="279">SUPPLIER</th>
    <th width="125">MANIFEST</th>
    <th width="74">VEHICLE NUMBER</th>
    <th width="133">IN (L)</th>
    <th width="134">OUT (L)</th>
  </tr>
<?php 
$total = 0;
foreach ($mutasi as $mutasis)
{ 

if(is_numeric($mutasis->idstb) == FALSE)
{
	$nodoc = $mutasis->idstb;
	$in = $mutasis->vol;
	$out = 0;
	
	$stb = $this->db->query("select * FROM t_stb WHERE  idstb = '".$mutasis->idstb."'")->result();
	foreach ($stb as $stbs);
	
	$manifest = $stbs->mnfst; 
	$vnumb =$stbs->vnumb;
	
	$supp = $this->db->query("select * FROM m_supp WHERE  idsupp = '".$stbs->idsupp."'")->result();
	foreach ($supp as $supps);
	
	$suppname = $supps->suppname;
	
}
else
{
	$dn = $this->db->query("select * FROM t_dn WHERE  iddn = '".$mutasis->idstb."'")->result();
	foreach ($dn as $dns);
	
	$nodoc = $dns->dnnumb;
	$in = 0;
	$out = $mutasis->vol;
	$manifest = $dns->mnfst; 
	$vnumb =$dns->vnumb;
	
	$suppname = 'PT. WGI';
}

$total_in = $total_in + $in;
$total_out = $total_out + $out;
if($bg==0)
											   {
											   echo '<tr style=background-color:#eeeeee;>';
											   $bg++;
											   }
											else
												{
												echo '<tr style=background-color:#;>';
												$bg--;
												}		


?>  
      <td><?php echo date("d.m.Y", strtotime($mutasis->posting)); ?></td>
      <td><?php echo $nodoc; ?></td>
    <td><?php echo $suppname; ?></td>
    <td><?php echo $manifest; ?></td>
    <td><?php echo $vnumb; ?></td>
    <td align="right"><?php if($xls == 0 ){ echo number_format($in); } else { echo $in; } ; ?></td>
    <td align="right"><?php if($xls == 0 ){ echo number_format($out); } else { echo $out; } ; ?></td>
  </tr>
<?php 
$total = $cpv_datas->vol + $total;
}
?>
<tr>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00">&nbsp;</td>
    <td bgcolor="#FFFF00"><strong>Total :</strong></td>
    <td align="right" bgcolor="#FFFF00"><strong><?php if($xls == 0 ){ echo number_format($total_in); } else { echo $total_in; } ; ?></strong></td>
    <td bgcolor="#FFFF00" align="right"><strong>
    <?php if($xls == 0 ){ echo number_format($total_out); } else { echo $total_out; } ; ?>
    </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');
	?>
