<!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.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready(function(){ 
		$("#fromdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#todate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(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 search_click(){
		form.action ='?page=Data-Stock-BhnBaku&Act=CARI';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function excel_click(){
		form.action ='./transaksi/akuntansi/export_stock_bhnbaku.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function pdf_click(){
		form.action ='./transaksi/akuntansi/pdf_stock_bhnbaku.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
<?php
if(isset($_REQUEST['Act'])=="CARI"){
	 $fromdate	 = isset($_REQUEST['fromdate']) ? $_REQUEST['fromdate'] : $start_date;
	 $todate     = isset($_REQUEST['todate']) ? $_REQUEST['todate'] : $end_date; 	
 }else{
	 $fromdate	 = $start_date;
	 $todate     = $end_date;	
 }
 $month 	= substr($fromdate,5,2);
 $year		= substr($fromdate,0,4);
?>
</head>
<body>
<form action="#" method="post" name="form">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td colspan="10" align="center"><h1><b>DATA TEMPORARY IN & OUT</b></h1></td>
  </tr>
  <tr>
	<td colspan="10">Periode :
	     <!--<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="text" id="fromdate" name="fromdate" size="9" value="<?=$fromdate;?>" style="border-collapse:inherit"  readonly="true">&nbsp;s/d&nbsp;
	      <input type="text" id="todate" name="todate" size="9" value="<?=$todate;?>" style="border-collapse:inheri" readonly="true">
	      <input type="button" name="cari" value="CARI" style="cursor:pointer" onclick="search_click();">
		  <input type="button" name="export" value="Export to Excel" style="cursor:pointer" onClick="excel_click();" />
		  <input type="button" name="pdf" value="Export to PDF" style="cursor:pointer" onClick="pdf_click();"/>
	</td>		
  </tr>
</table>  
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>	
  <tr>
	<th>No</th>
	<th>Jenis</th>
	<th>No. Daftar</th>
	<th>Tgl Daftar</th>
	<th>No. Aju</th>
	<th>Tgl Aju</th>
	<th>Pemasok/Penerima</th>
	<th>Tipe</th>
	<th>Status</th>
  </tr>
  </thead>
	<tbody>
  <?php
	$no=1; $gtprice=0;
	$qd = mysql_query("SELECT a.* FROM (
		SELECT inch_doctype doctype, inch_docno docno, inch_docdate docdate, no_aju, tgl_aju, nm_pemasok nama, 'IN' sts 
		FROM incoming WHERE inch_status=20 AND inch_paytype is null
		UNION
		SELECT outh_doctype doctype, outh_docno docno, outh_docdate docdate, no_aju, tgl_aju, nm_penerima nama, 'OUT' sts  
		FROM outgoing WHERE outh_status=20 AND outh_paytype is null) a
		ORDER BY a.docdate ASC");
	while($dd=mysql_fetch_array($qd)){		
		 if($dd['sts']=="IN"){
		 	$sid = "id IN(3,5)";
		 }else{
		 	$sid = "id IN(4,5)";
		 }
	?> 
	 <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$dd['doctype'];?></td>
		<td align="center"><?=$dd['docno'];?></td>
        <td align="center"><?=$dd['docdate'];?></td>
        <td align="center"><?=$dd['no_aju'];?></td>
        <td align="center"><?=$dd['tgl_aju'];?></td>
        <td align="left"><?=$dd['nama'];?></td>
		<td align="center"><?=$dd['sts'];?></td>
		<td align="center">
		   <input type="hidden" name="pilih['<?=$no;?>']" value="<?=$no;?>" />
		   <select name="type['<?=$no;?>']">
		   <option value="0" selected="selected">PILIH</option> 
			<?php
			  $dataSql = mysql_query("SELECT bbt_tipe FROM buku_besar_tipe WHERE $sid ORDER BY id ASC");
			  while ($dataRow = mysql_fetch_array($dataSql)) {
				if ($dataRow['bbt_tipe']== $bk_tipe) {
					$cek = " selected";
				} else { $cek=""; }
				echo "<option value='$dataRow[bbt_tipe]' $cek>$dataRow[bbt_tipe]</option>";
			  }
			  $sqlData ="";
			?>
		 </select>
		</td>
	  </tr>	  
  <?php $no++; }  ?> 
  </tbody> 
</table>
</form>
</body>
</html>
