<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">	
#borderAll {
    border: 1px solid #000;	  	    
}
.p_spacing{
    margin-top:4px;
    margin-bottom:4px;
}
table.tablereport {	
    border: 1px solid #000;	
    border-collapse:collapse;
    margin:5px 0pt 10px;		
    font-size: 9pt;
	width:1120px;
    /*width: 8.27in;	
    height:11.69in;*/
	/*width:11.69in;*/
}
table.tablereport thead tr th{		
    border: 1px solid #000;		
    font-size: 9pt;		
    padding: 4px;
    vertical-align:middle;
}	
table.tablereport tbody tr td {
    border: 1px solid #000;		
    font-size: 9pt;		
    padding: 4px;
    vertical-align:top;
}
table.tablereport tfoot tr td {
    border: 1px solid #000;		
    font-size: 9pt;		
    padding: 4px;
    vertical-align:top;
}
.borderall{
    border:1px #000 solid !important;
}
.noborder{
    border:1px #FFF solid !important;
}
.nobordertlr{
	border-top:hidden !important;
    border-left:hidden !important;
    border-right:hidden !important;    
	border-bottom:1px solid #000 !important;
}

.noborderlrb{
    border-left:hidden !important;
    border-right:hidden !important;
    border-bottom:hidden !important;
}
.nobordertr{
    border-top:hidden !important;
    border-right:hidden !important;
}
.nobordert{
    border-top:hidden !important;	
}
.noborderright{
    border-right:hidden !important;
}
.noborderbtm{
    border-bottom:hidden !important;
}
.noborderrb{
    border-right:hidden !important;
    border-bottom:hidden !important;
}	
</style>
</head>
<body>
<h5>PT.  Corinthian Industries Indonesia</h5>
  <!-- <h5>NPWP : 01.869.309.3-055.000</h5> -->
  <h5><?php echo $this->title ?></h5>
  <h5>  <b>Periode : <?php echo $dtdari .' - '.$dtsampai?></b><br>  </h5>
  <table cellpadding="1" cellspacing="0" class="tablereport">
  <thead>
    <tr>
      <th align="center" width="25"><b>No.</b></th>
      <th align="center" width="80"><b>Kode Barang</b></th>
      <!-- <th align="center" width="150"><b>Size</b></th> -->
      <th align="center" width="80"><b>Nama Barang</b></th>
      <th align="center" width="30"><b>Sat.</b></th>
      <th align="center"><b>Saldo Awal<br><?php echo $dtdari ?></b></th>
      <th align="center"><b>Pemasukan</b></th>
      <th align="center"><b>Pengeluaran</b></th>
      <th align="center"><b>Penyesuaian<br>(Adjustment)</b></th>
      <th align="center"><b>Saldo Akhir<br><?php echo $dtsampai ?></b></th>
      <th align="center"><b>Stock Opname<br><?php echo $dtsampai ?></b></th>
      <th align="center"><b>Selisih</b></th>
      <th width="80"><b>Keterangan</b></th>
    </tr>
  </thead>
  <tbody>
  
    <?php 
    $no = 1;  
    foreach($rs['rows'] as $row){
      $qty_end=$row->qty_beg+$row->qty_in-$row->qty_out+$row->qty_bal;
      $Fqty_end= number_format("$qty_end",2,".",",");
      $qty=$row->qty;
      $Fqty= number_format("$qty",2,".",",");
      $qty_diff= $qty-$qty_end;
      $Fqty_diff= number_format("$qty_diff",2,".",",");
        $qty_beg=$row->qty_beg;
        $qty_beg= number_format("$qty_beg",2,".",",");
        $qty_in=$row->qty_in;
        $qty_in= number_format("$qty_in",2,".",",");
        $qty_out=$row->qty_out;
        $qty_out= number_format("$qty_out",2,".",",");
        $qty_bal=$row->qty_bal;
        $qty_bal= number_format("$qty_bal",2,".",",");

        $total_beg += $row->qty_beg;
        $Format_beg = number_format("$total_beg",2,".",",");
        $total_in += $row->qty_in;
        $Format_in = number_format("$total_in",2,".",",");
        $total_out += $row->qty_out;
        $Format_out = number_format("$total_out",2,".",",");
        $total_bal += $row->qty_bal;
        $Format_bal = number_format("$total_bal",2,".",",");
        $total_end += $row->qty_beg+$row->qty_in-$row->qty_out+$row->qty_bal;
        $Format_end = number_format("$total_end",2,".",",");
        $total_qty += round($row->qty,2);
        $Format_qty = number_format("$total_qty",2,".",",");
        $total_diff += $qty-$qty_end;
        $Format_diff = number_format("$total_diff",2,".",",");

        if ($qty_diff > 0){
          $ket='selisih lebih'; 
        } else if ($qty_diff < 0){
          $ket='selisih kurang';
        } else {
          $ket='sesuai';
        }
      ?>
          
        <tr>
          <td align="center"><?=$no++?></td>
          <td><?=$row->WIP2?></td>
          <!-- <td><?=$row->PartNo?></td> -->
          <td><?=$row->NmBarang?></td>
          <td align="center"><?=$row->Sat?></td>
          <td align="right"><?=$qty_beg?></td>
          <td align="right"><?=$qty_in?></td>
          <td align="right"><?=$qty_out?></td>
          <td align="right"><?=$qty_bal?></td>
          <td align="right"><?=$Fqty_end?></td>
          <td align="right"><?=$Fqty?></td>
          <td align="right"><?=$Fqty_diff?></td>
          <td><?=$ket?></td>
        </tr>
    
    <?php } ?>
      
  </tbody>
  <tfoot>
  <tr>
      <th style=" align=center;"></th>
      <th style=" align=center;"></th>
      <th style=" align=center;"></th>
      <th style=" align=center;"> TOTAL </th>
      <th style=" align=center;  border-right:1px solid black;"></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_beg?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_in?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_out?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_bal?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_end?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_qty?></th>
      <th style=" align=center;  border:1px solid black;"><?=$Format_diff?></th>
      <th style=" align=center;  border:1px solid black;"></th>
    </tr></tfoot>
  </table>
</body>
</html>