<!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 () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	$(document).ready(function(){ 
		$("#start_date").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){ 
		$("#end_date").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});	
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
	function post_click(id,flag,sumber,idheader,no_aju,jenis,no_dokpab){
		var a = confirm("Apakah anda yakin akan unposting data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST&id='+id+'&flag='+flag+'&sumber='+sumber+'&idheader='+idheader+'&no_aju='+no_aju+'&jenis_dokpab='+jenis+'&no_dokpab='+no_dokpab;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function post2_click(id,spbno){
		var a = confirm("Apakah anda yakin akan unposting data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST2&id='+id+'&trf_spbno='+spbno;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function post3_click(id,spbno,tipe){
		var a = confirm("Apakah anda yakin akan unposting data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST2&id='+id+'&trf_spbno='+spbno+'&jtipe='+tipe;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function post4_click(id,spbno,tipe){
		var a = confirm("Apakah anda yakin akan complete data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST3&id='+id+'&trf_spbno='+spbno+'&jtipe='+tipe;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function post5_click(id,spbno){
		var a = confirm("Apakah anda yakin akan unposting data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST5&id='+id+'&trf_spbno='+spbno;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function post6_click(id,spbno){
		var a = confirm("Apakah anda yakin akan unposting data ini?");
		if (a == true){
			form.action ='?page=Proses-Unposting&Act=UNPOST6&id='+id+'&trf_spbno='+spbno;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function search_click(){
		form.action ='?page=Data-Unposting&Act=SEARCH';
		form.method = 'post';
		form.submit();		
		return true;
	}	
	function type_click(){
		form.action ='?page=Data-Unposting';
		form.method = 'post';
		form.submit();		
		return true;
	}
</script>
<?php
	$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';	
	if(isset($_REQUEST['Act'])=="SEARCH"){
		$start_date = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : $start_date;
		$end_date   = isset($_REQUEST['end_date']) ? $_REQUEST['end_date'] : $end_date;
	}else{
		$start_date = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : $start_date;
		$end_date   = isset($_REQUEST['end_date']) ? $_REQUEST['end_date'] : $end_date;
	}
?>
<form name="form" method="post" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="8">PROSES UNPOSTING</th>
	</tr>
	<tr>
		<td colspan="8">&nbsp;</td>		
	</tr>
	<tr>
		<td colspan="8">
			Tipe Unposting :
			<select name="type" onChange="type_click(this.value);">
			  <option value="BLANK">PILIH</option> 
				<?php
				  $dataSql = mysql_query("SELECT * FROM maintenance WHERE m_status=3 ORDER BY id ASC");
				  while ($dataRow = mysql_fetch_array($dataSql)) {
					if ($dataRow['id']== $type) {
						$cek = " selected";
					} else { $cek=""; }
					echo "<option value='$dataRow[id]' $cek>$dataRow[m_desc]</option>";
				  }
				  $sqlData ="";
				?>
			 </select>	 
		</td>		
	</tr>
	<?php if($type==20 || $type==21 || $type==22 || $type==23 || $type==24 || $type==25 || $type==28 || $type==29 || $type==31){ ?>
	<tr>
		<td colspan="8">
			Tanggal Transaksi :  
			<input type="text" name="start_date" size="9" value="<?=$start_date;?>" style="border-collapse:inherit"  readonly="true">
            <input type="text" name="end_date" size="9" value="<?=$end_date;?>" style="border-collapse:inherit"  readonly="true">
			<input type="button" name="search" value="CARI" style="cursor:pointer" onclick="search_click();" />
		</td>
	</tr>
	<?php }elseif($type==26){ ?>
	<tr>
		<td colspan="8">
			Periode Aktif : 
			<input type="text" name="thn_acct" size="4" value="<?=$thn_acct;?>" style="border-collapse:inherit"  readonly="true">
		</td>
	</tr>
	<?php }elseif($type==27){ ?>
	<tr>
		<td colspan="8">
			Tanggal Transaksi : 
			<input type="text" id="start_date" name="start_date" size="9" value="<?=$start_date;?>" style="border-collapse:inherit">
            <input type="text" id="end_date" name="end_date" size="9" value="<?=$end_date;?>" style="border-collapse:inherit">
			<input type="button" name="search" value="CARI" style="cursor:pointer" onclick="search_click();" />
		</td>
	</tr>
	<?php }else{ ?>
	<tr>
		<td colspan="8">&nbsp;</td>		
	</tr>
	<?php }?>	
</table>	
<?php if($type==20){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No Aju</th>
		<th>Tgl Aju</th>
		<th>Jenis Dok.</th>
		<th>No Dok.</th>
		<th>Tgl Dok.</th>
		<th>Supp. / Cust.</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT * FROM 
		(SELECT id, no_aju, tgl_aju, inch_doctype jenis_dokpab, inch_docno no_dokpab, inch_docdate tgl_dokpab, nm_pemasok nm_sc, 10 flag,sumber,id_header
		FROM incoming WHERE inch_status=20
		UNION ALL
		SELECT id, no_aju, tgl_aju, outh_doctype jenis_dokpab, outh_docno no_dokpab, outh_docdate tgl_dokpab, nm_penerima nm_sc, 20 flag,sumber,id_header
		FROM outgoing WHERE outh_status=20) a
		WHERE a.tgl_dokpab BETWEEN '$start_date' AND '$end_date'");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->no_aju;?></td>
			<td align="center"><?=$dd->tgl_aju;?></td>
			<td align="center"><?=$dd->jenis_dokpab;?></td>
			<td align="center"><?=$dd->no_dokpab;?></td>
			<td align="center"><?=$dd->tgl_dokpab;?></td>
			<td align="left"><?=$dd->nm_sc;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post_click('<?=$dd->id;?>','<?=$dd->flag;?>','<?=$dd->sumber;?>','<?=$dd->id_header;?>','<?=$dd->no_aju;?>','<?=$dd->jenis_dokpab;?>','<?=$dd->no_dokpab;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==21){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No SPB</th>
		<th>Tgl SPB</th>
		<th>Dept.</th>
		<th>PIC</th>
		<th>Keterangan</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*,b.dept_name FROM transfer a
		  INNER JOIN departement b ON b.id=a.trf_deptid
		  WHERE trf_spbdate BETWEEN '$start_date' AND '$end_date' AND a.trf_status=20 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->trf_spbno;?></td>
			<td align="center"><?=$dd->trf_spbdate;?></td>
			<td align="left"><?=$dd->dept_name;?></td>
			<td align="left"><?=$dd->trf_pic;?></td>
			<td align="left"><?=$dd->trf_desc;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->trf_spbno;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==22){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No WO</th>
		<th>Tgl WO</th>
		<th>Dept.</th>
		<th>No. Lot</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*,b.dept_name FROM workorder a
		  INNER JOIN departement b ON b.id=a.wo_deptid
		  WHERE wo_date BETWEEN '$start_date' AND '$end_date' AND a.wo_status=20 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->wo_no;?></td>
			<td align="center"><?=$dd->wo_date;?></td>
			<td align="left"><?=$dd->dept_name;?></td>
			<td align="left"><?=$dd->wo_lotno;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->wo_no;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==23){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No Lap</th>
		<th>Tgl Lap</th>
		<th>Dept.</th>
		<th>PIC</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*,b.dept_name FROM finishgoods a
		  INNER JOIN departement b ON b.id=a.fgh_deptid
		  WHERE fgh_lpdate BETWEEN '$start_date' AND '$end_date' AND a.fgh_status=20 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->fgh_lpno;?></td>
			<td align="center"><?=$dd->fgh_lpdate;?></td>
			<td align="left"><?=$dd->dept_name;?></td>
			<td align="left"><?=$dd->fgh_pic;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->fgh_lpno;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==24){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No Lap</th>
		<th>Tgl Lap</th>
		<th>PIC</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.* FROM scrap a
		  WHERE scrh_lpdate BETWEEN '$start_date' AND '$end_date' AND a.scrh_status=20 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->scrh_lpno;?></td>
			<td align="center"><?=$dd->scrh_lpdate;?></td>
			<td align="left"><?=$dd->scrh_pic;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->scrh_lpno;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==25){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No</th>
		<th>Kode Konversi</th>	
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Jumlah</th>
		<th>Satuan</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*, b.prod_code,b.prod_name,b.prod_sat FROM konversi a
			     INNER JOIN product b ON b.id=a.kv_prodid 
			     WHERE a.kv_status=20 AND kv_date BETWEEN '$start_date' AND '$end_date'  
				 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		 <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->kv_no;?></td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="right"><?=$dd->kv_qty;?></td>
			<td><?=$dd->prod_sat;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->kv_no;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==26){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No</th>
		<th>No Jurnal</th>
		<th>Tanggal</th>
		<th>Tipe</th>
		<th>No Invoice</th>
		<th>Currency</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT * FROM jurnal WHERE jurnal_status=20 AND YEAR(jurnal_date)='$thn_acct' ORDER BY id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		 <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->jurnal_no;?></td>
			<td align="center"><?=$dd->jurnal_date;?></td>
			<td align="center"><?=$dd->jurnal_type;?></td>
			<td><?=$dd->jurnal_invno;?></td>
			<td align="center"><?=$dd->jurnal_currency;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post3_click('<?=$dd->id;?>','<?=$dd->jurnal_no;?>','<?=$dd->jurnal_type;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==27){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No</th>
		<th>Tipe PO</th>
		<th>No PO</th>
		<th>Tanggal PO</th>
		<th>Nama</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*, b.sup_name, c.cust_name FROM purchase_order a LEFT JOIN supplier b ON b.id=a.po_idsupp
		  LEFT JOIN customer c ON c.id=a.po_idcust
		  WHERE a.po_status = 20 AND a.po_date BETWEEN '$start_date' AND '$end_date' ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
			if($dd->po_type=="Purchasing"){$names = $dd->sup_name;}else{$names = $dd->cust_name;}
		?> 
		 <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="left"><?=$dd->po_type;?></td>
			<td align="center"><?=$dd->po_no;?></td>
			<td align="center"><?=$dd->po_date;?></td>
			<td align="left"><?=$names;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post3_click('<?=$dd->id;?>','<?=$dd->po_no;?>','<?=$dd->po_type;?>');" />
				<img src="images/logout.png" width="25" height="25" title="Completed" style="cursor:pointer" onclick="post4_click('<?=$dd->id;?>','<?=$dd->po_no;?>','<?=$dd->po_type;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==28){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No</th>
		<th>Kode Konversi</th>	
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Jumlah</th>
		<th>Satuan</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.*, b.prod_code,b.prod_name,b.prod_sat FROM konversi2 a
			     INNER JOIN product b ON b.id=a.kv_prodid 
			     WHERE a.kv_status=20 AND kv_date BETWEEN '$start_date' AND '$end_date'  
				 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		 <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->kv_no;?></td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="right"><?=$dd->kv_qty;?></td>
			<td><?=$dd->prod_sat;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post2_click('<?=$dd->id;?>','<?=$dd->kv_no;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==29){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No</th>
		<th>Nomor</th>	
		<th>Tanggal</th>		
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT * FROM adjusment WHERE adjh_status=20 AND adjh_date BETWEEN '$start_date' AND '$end_date' ORDER BY id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		 <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->adjh_no;?></td>
			<td align="center"><?=$dd->adjh_date;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post5_click('<?=$dd->id;?>','<?=$dd->adjh_no;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php }elseif($type==31){ ?>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>No WO</th>
		<th>Tgl WO</th>
		<th>Dept.</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$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 '$start_date' AND '$end_date' AND a.wonb_status=20 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
		?> 
		  <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="left"><?=$dd->dept_name;?></td>
			<td align="center">
				<img src="images/unpost.png" width="25" height="25" title="Unposting" style="cursor:pointer" onclick="post6_click('<?=$dd->id;?>','<?=$dd->wonb_no;?>');" />
			</td>			
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
<?php } ?>
</form>