<!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_won.php?wonb_id="+id,"mywindow","menubar=1,scrollbars=1,resizable=1,width=700,height=1000");
	}
	function add_click(){
		form.action ='?page=Proses-Work-Order-Non-Bom&Act=ADD';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function import_click(){
		form.action ='?page=Proses-Work-Order-Non-Bom&Act=UPL';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function template_click(){
		form.action ='./transaksi/manual/template_inc_prod.php';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function posting_click(id,code){
		form.action ='?page=Proses-Work-Order-Non-Bom&Act=POSTING&wonb_id='+id+'&wonb_no='+code;
		form.method = 'post';
		form.submit();		
		return true;
	}
	function detail_click(id){
		form.action ='?page=Proses-Work-Order-Non-Bom&Act=DETAIL&wonb_id='+id;
		form.method = 'post';
		form.submit();		
		return true;
	}
	function delete_click(id,code){
		var a = confirm("Apakah anda yakin akan menghapus data?");
		if (a == true){
			form.action ='?page=Proses-Work-Order-Non-Bom&Act=DELETE&wonb_id='+id+'&wonb_no='+code;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function excel_click(){
		form.action ='./transaksi/manual/excel_workordernonbom.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;	
 }
?>
</head>
<body>
<form action="?page=Data-Work-Order-Non-Bom" method="post" name="form">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td colspan="9" align="center"><h1><b>DATA WORK ORDER NON BOM</b></h1></td>
  </tr>
  <tr>
	<td colspan="9">
		<img src="images/btn_add.png" height="30" width="30" title="Tambah Manual" border="0" style="cursor:pointer" onclick="add_click();" />
		<!--<img src="images/btn_import.png" height="30" width="30" title="Import Excel" border="0" style="cursor:pointer" onclick="import_click();" />
		<img src="images/template_excel.png" height="30" width="30" title="Template Excel" border="0" style="cursor:pointer" onclick="template_click();" />-->
	</td>
  </tr>
  <tr>
	<td colspan="9">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="submit" name="cari" value="CARI" style="cursor:pointer">
		  <input type="button" name="export" value="EXCEL" onClick="excel_click();" style="cursor:pointer" />
	</td>		
  </tr>
</table>  
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>	
  <tr>
	<th>No</th>
	<th>No.WO Non BOM</th>
	<th>Tanggal</th>
	<!--<th>Warehouse</th>-->
	<th>Departemen </th>
	<th>PIC</th>
	<th>Keterangan</th>
	<th>Action</th>
  </tr>
  </thead>
	<tbody>
  <?php
	$no=0;
	
	//SELECT a.*,b.dept_name, c.prod_code, c.prod_name FROM workorder_nonbom a
		//  INNER JOIN departement b ON b.id=a.wonb_deptid
		  //INNER JOIN product c ON c.id=a.wonb_prodid
		  //WHERE wo_date BETWEEN '$fromdate' AND '$todate' AND a.wo_status <> 100 AND wo_level='Level FG' ORDER BY a.id DESC
	
	$qd = mysql_query("SELECT a.*,b.dept_name FROM workorder_nonbom a
		  INNER JOIN departement b ON b.id=a.wonb_deptid
		  WHERE wonb_date BETWEEN '$fromdate' AND '$todate' AND a.wonb_status <> 100 ORDER BY a.id DESC");
	while($dd=mysql_fetch_object($qd)){		
	$no++;
	?> 
	 <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$dd->wonb_no;?></td>
		<td align="center"><?=$dd->wonb_date;?></td>
		<!--<td align="center"><?=$dd->wonb_whid;?></td>-->
		<td><?=$dd->dept_name;?></td>
		<td><?=$dd->wonb_pic;?></td>
		<td align="left"><?=$dd->wonb_desc;?></td>
		<td align="center">
			<?php if ($dd->wonb_status==10){ ?>
	<img src="images/btn_posting.png" width="20" height="20" border="0" title="Posting" style="cursor:pointer" onclick="posting_click('<?=$dd->id;?>','<?=$dd->wonb_no;?>');" />
	<img src="images/btn_edit.png" width="20" height="20" border="0" title="Edit" style="cursor:pointer" onclick="detail_click('<?=$dd->id;?>');" />
	<img src="images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" style="cursor:pointer" onclick="delete_click('<?=$dd->id;?>','<?=$dd->wonb_no;?>');" />
			<?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 }  ?> 
  </tbody> 
</table>
</form>
</body>
</html>
