<html>
<head>
<script type="text/javascript">
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
	$(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 cancel_click(){
		form.action ='?page=Proses-Prod-Out&Act=CLOSE';
		form.method = 'post';
		form.submit();			
		return true;
	}	
	function process_click(){
		form.action ='?page=Proses-Prod-Out&Act=PROCESS';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function inventory_click(){
		form.action ='?page=Proses-Prod-Out&Act=INV';
		form.method = 'post';
		form.submit();			
		return true;
	}	
	function delete_click(){
		form.action ='?page=Proses-Prod-Out&Act=DEL_TEMP';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function deldettemp_click(id){
		form.action ='?page=Proses-Prod-Out&Act=DELDET_TEMP&id_temp='+id;
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
</head>
<form action="#" method="post" name="form" target="_self" enctype="multipart/form-data">
<table>
	<tr>
		<th colspan="2">UPLOAD DATA DARI EXCEL - TRANSFER BARANG JADI/SCRAP</th>
	</tr>	
	<tr>
		<td colspan="2">
			<input name="userfile" type="file">
			<input type="button" name="process" value="PROCESS" style="cursor:pointer" onClick="process_click();">
			<input type="button" name="inventory" value="SEND TO INVENTORY" style="cursor:pointer" onClick="inventory_click();">
			<input type="button" name="delete" value="DELETE ALL" style="cursor:pointer" onClick="delete_click();">
			<input type="button" name="batal" value="CLOSE" style="cursor:pointer" onClick="cancel_click();" />
		</td>
	</tr>
</table>	
<?php
$start_date2 = get_startdate2($inv);
$end_date2   = get_enddate2($inv);
$bulan2    	 = substr($start_date2,5,2);
$tahun2  	 = substr($start_date2,0,4);

if(($Act=="UPL") || ($Act=="PROCESS") || ($Act=="DEL_TEMP") || ($Act=="DELDET_TEMP")){ ?>
	<div class="scroll">
	<table width="100%">
		<tr bgcolor="#CCCCCC">
			<td align="center">No</td>
			<td align="center">Tgl SPB</td>
			<td align="center">Dept</td>
			<td align="center">PIC</td>
			<td align="center">Kode</td>
			<td align="center">Nama Barang</td>
			<td align="center">Satuan</td>
			<td align="center">Jumlah</td>
			<td align="center">Ket.</td>
			<td align="center">Action</td>
		</tr>
	<?php
	$no=1; $tqtyp=0; $tpricep=0;
	$qr=mysql_query("SELECT * FROM transfer_log WHERE trf_status=1000");
    while($d=mysql_fetch_array($qr)){
		$dept = mysql_fetch_array(mysql_query("SELECT dept_name FROM departement WHERE id='$d[trf_deptid]'"));
		$prod = mysql_fetch_array(mysql_query("SELECT id, prod_code, prod_name, prod_sat,prod_cat FROM product WHERE prod_code='$d[trfd_prodcode]'"));
		//$stock = get_stock($start_date2,$end_date2,$bulan2,$tahun2,$prod['id'],$prod['prod_cat'],$inv);	
		$val_date = get_validationdate($d['trf_spbdate']);
		if(empty($prod['id'])){
			$colorp ="#FF0000";
		}else{
			$colorp ="#000000";
		}
		#Stock
		/*if($d['trfd_qty'] > $stock ){
			$colors ="#FF0000";
		}else{
			$colors ="#000000";
		}*/
		if($val_date=="NO"){
			$colord ="#FF0000";
		}else{
			$colord ="#000000";
		}
		$tqtyp = $tqtyp + $d['trfd_qty'];
		#select data
		if(($colorp =="#000000") && ($colord =="#000000") ){
	?>	
		<input type="hidden" name="trf_id[<?=$d['id'];?>]" value="<?=$d['id'];?>">
		<?php } ?>
		<tr onMouseOver="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>			
			<td align="center"><font color="<?=$colord;?>"><?=$d['trf_spbdate'];?></font></td>
			<td><?=$dept['dept_name'];?></td>
			<td><?=$d['trf_pic'];?></td>
			<td><font color="<?=$colorp;?>"><?=$d['trfd_prodcode'];?></font></td>
			<td><?=$prod['prod_name'];?></td>
			<td><?=$prod['prod_sat'];?></td>
			<td align="right"><?=number_format($d['trfd_qty'],2,'.',',');?></td>
			<td align="left"><?=$d['trf_desc'];?></td>
			<td align="center">
				<img src="images/delete.png" title="BATAL" style="cursor:pointer" onClick="deldettemp_click('<?=$d['id'];?>');">	
			</td>
		</tr>		
	<?php $no++; } ?>
	<tr bgcolor="#CCFFFF">
		<td colspan="7">Total</td>
		<td align="right"><?=number_format($tqtyp,2,'.',',');?></td>
		<td colspan="2">&nbsp;</td>	
	</tr>
	</table>
	</div>
<?php } ?>
</form>
</html> 
