<!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>
<link rel="stylesheet" href="function/dataTables/media/css/demo_page.css">
<link rel="stylesheet" href="function/dataTables/media/css/demo_table_jui.css">
<link rel="stylesheet" href="function/dataTables/media/themes/smoothness/jquery-ui-1.8.4.custom.css">
<script type="text/javascript" src="function/dataTables/media/js/jquery.js"></script>
<script type="text/javascript" src="function/dataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready( function () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
	function export_data(month,year)
	{
		form.action ='./transaksi/manual/export_closing.php?month='+month+'&year='+year+'';;
		form.method = 'post';
		form.submit();			
		return true;
	}
	function add_click(){
		form.action ='?page=Proses-Closing&Act=ADD';
		form.method = 'post';
		form.submit();		
		return true;
	}
</script>
<?php
if(isset($_REQUEST['cari'])=="CARI"){
	 $bulan	 = $_REQUEST['bulan'];
	 $tahun  = $_REQUEST['tahun'];	
 }else{
	 $bulan	 = substr($date,5,2);
	 $tahun  = substr($date,0,4);	
 }
 $thnbln ="$tahun$bulan";
?>
<form action="?page=Data-Closing" method="post" name="form">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td colspan="5" align="center"><h1><b>DATA CLOSING</b></h1></td>
  </tr>
  <tr>
	<td colspan="5"><img src="images/btn_add.png" height="30" width="30" title="Tambah" border="0" style="cursor:pointer" onclick="add_click();" /></td>
  </tr>
  <tr>
	  <td colspan="5">Tahun :
	     <select id="bulan" name="bulan">
		   <?php
			$bln = array('','Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember');
			for($n=1; $n<=12; $n++){
			if ($n == $bulan) {
				$cek = " selected";
			} else { $cek=""; }
		   ?>
		   	<option value="<?=$n;?>" <?=$cek;?>><?=$bln[$n];?></option>
		   <?php } ?>
		  </select>
		  <input type="text" id="tahun" name="tahun" size="4" value="<?=$tahun;?>">
	      <input type="submit" name="cari" value="CARI" style="cursor:pointer">
		</td>
	</tr>
</table>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
  <thead>	
  <tr>
	<th>No</th>
	<th>Kode Barang</th>
	<th>Nama Barang</th>
	<th>Satuan</th>
	<th>Jumlah</th>
  </tr>
  </thead>
	<tbody>
  <?php
	$no=0;
	$qd = mysql_query("SELECT MONTH(a.stock_date) cl_month, YEAR(a.stock_date) cl_year, a.stock_qty cl_qty, b.prod_code, b.prod_name, b.prod_sat 
					   FROM stock a INNER JOIN product b ON b.id=a.stock_prodid
					   WHERE MONTH(a.stock_date)='$bulan' AND YEAR(a.stock_date)='$tahun' AND a.stock_status=10 ORDER BY b.prod_code ASC");
	while($dd=mysql_fetch_object($qd)){		
	$no++;
	?> 
	   <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$dd->prod_code;?></td>
		<td align="left"><?=$dd->prod_name;?></td>
		<td align="center"><?=$dd->prod_sat;?></td>
		<td align="right"><?=$dd->cl_qty;?></td>
	  </tr>
  <?php }  ?>
  </tbody>
</table>
</form>