<!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 print_click(id){
		window.open("popup/print_terima_barang.php?inch_id="+id,"mywindow","menubar=1,scrollbars=1,resizable=1,width=700,height=1000");
	}
	function detail_click(id){
		form.action ='?page=Proses-Terima-Barang&Act=DETAIL&inch_id='+id;
		form.method = 'post';
		form.submit();		
		return true;
	}
	function excel_click(){
		form.action ='./transaksi/manual/excel_history_terima_barang.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
<?php
if(isset($_REQUEST['cari'])=="CARI"){
	 $fromdate	 = $_REQUEST['fromdate'];
	 $todate     = $_REQUEST['todate']; 	
 }else{
	 $fromdate	 = $start_date;
	 $todate     = $end_date;	
 }
?>
<form action="?page=Data-Terima-Barang" method="post" name="form" enctype="multipart/form-data">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td colspan="9" align="center"><h1><b>DATA TERIMA BARANG</b></h1></td>
  </tr>
  <tr>
	  <td colspan="9">Periode :
	      <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="submit" name="cari" value="CARI" style="cursor:pointer">
		  <input type="button" name="export" value="EXCEL HISTORY" onClick="excel_click();" style="cursor:pointer" />
		</td>
	</tr>
</table>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>  
  <tr>
	<th>No</th>
	<th>Tanggal Masuk </th>
	<th>Nomor Aju</th>
	<th>Tanggal Aju</th>
	<th>Pemasok </th>
	<th>No. Dokumen</th>
	<th>Tanggal Dokumen</th>
	<th>Jenis Dokumen</th>
	<th>Status</th>
	<th>Action</th>
  </tr>
  </thead>
	<tbody>
  <?php
	$no=1;
	$qd = mysql_query("SELECT a.*, CASE WHEN ifnull(a.inch_supid,0)=0 THEN nm_pemasok ELSE b.sup_name END as pemasok FROM incoming a LEFT JOIN supplier b ON b.id=a.inch_supid 
		  WHERE a.inch_status IN(15,20) AND a.inch_docdate BETWEEN '$fromdate' AND '$todate' AND a.sumber IN('CIESA','MANUAL','UPLOAD','UPL40') ORDER BY a.id DESC");
	while($dd=mysql_fetch_object($qd)){		
	   if($dd->inch_status==10){$status = "Baru";}
	   elseif($dd->inch_status==15){$status = "Posting";}
	   else{$status = "Diterima";}
	?> 
	  <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$dd->inch_bpbdate;?></td>
		<td align="center"><?=$dd->no_aju;?></td>
		<td align="center"><?=$dd->tgl_aju;?></td>
		<td><?=$dd->pemasok;?></td>
		<td align="center"><?=$dd->inch_docno;?></td>
		<td align="center"><?=$dd->inch_docdate;?></td>
		<td align="center"><?=$dd->inch_doctype;?></td>
		<td align="center"><?=$status;?></td>
		<td align="center">
			<?php if ($dd->inch_status==15){ ?>
				<img src="images/btn_edit.png" width="20" height="20" border="0" title="Edit" style="cursor:pointer" onclick="detail_click('<?=$dd->id;?>');" />
			<?php }else { ?>
				<img src="images/btn_print.png" height="20" width="20" title="Print" border="0" style="cursor:pointer" onclick="print_click('<?=$dd->id;?>');" />
			<?php } ?>
		</td>
	  </tr>
  <?php $no++; }  ?>
	</tbody>
</table>
</form>
