<script language="javascript">
	$(document).ready(function(){
		$("#docdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	function save_click(){
		if(form.prodcode.value==""){
			alert("Silakan isi kode barang.");
			form.prodcode.focus();
			return false;
		}else if(form.stock_qty.value==""){
			alert("Silakan jumlah.");
			form.stock_qty.focus();
			return false;
		}else{
			var a = confirm("Apakah anda yakin akan menyimpan data?");
			if (a == true){
				form.action ='?page=Proses-Stock-Awal&Act=SAVE';
				form.method = 'post';
				form.submit();			
				return true;
			}
		}
	}
	function close_click(){
		form.action ='?page=Proses-Stock-Awal&Act=CLOSE'
		form.method = 'post';
		form.submit();		
		return true;
	}
	function popup_item(){
		window.open("popup/popup_item2.php?","mywindow","menubar=1,scrollbars=1,resizable=1,width=650,height=250");
	}
</script>
<form action="#" method="post" name="form" target="_self" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="4">INPUT DATA SALDO AWAL</th>
	</tr>	
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
		
	<tr>
		<td width="15%">Kode Barang</td>
		<td width="35%">: 
			<input type="hidden" name="stock_id" id="stock_id" size="27" value="<?php echo $stock_id; ?>">
			<input type="hidden" name="prodid" id="prodid" size="27" value="<?php echo $prodid; ?>">
            <input type="hidden" name="prod_cat" id="prod_cat" size="27" value="<?php echo $prod_cat; ?>">
			<input type="text" name="prodcode" id="prodcode" size="50" value="<?php echo $prodcode; ?>" readonly="true">
			<img src="images/popup.png" height="15" width="15" title="Popup Item Master" style="cursor:pointer" border="0" onClick="popup_item();" />
		</td>
		<td width="15%">&nbsp;</td>
		<td width="35%">&nbsp;</td>
	</tr>
	<tr>
		<td>Satuan</td>
		<td>: <input type="text" name="prodsat" id="prodsat" size="10" value="<?php echo $prodsat; ?>" readonly="true"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>Tanggal saldo awal</td>
		<td>: <input type="text" name="stock_date" size="10" value="<?php echo $start_date; ?>" readonly="true"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>Jumlah</td>
		<td>: <input type="text" name="stock_qty" size="10" value="<?php echo $stock_qty; ?>" style="text-align:right"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td>Lokasi</td>
		<td>: <select name="stock_loc"> 
			<?php if($stock_loc==1){ ?>
			<option value="0">PILIH</option>
			<option value="1" selected="selected">Gudang Bahan Baku</option>
			<option value="2">Gudang Produksi</option>	
            <option value="3">Gudang Finishgoods</option>
            <option value="4">Gudang Asset/Mesin</option>
			<?php }elseif($stock_loc==2){ ?>
			<option value="0">PILIH</option>
			<option value="1">Gudang Bahan Baku</option>
			<option value="2" selected="selected">Gudang Produksi</option>	
            <option value="3">Gudang Finishgoods</option>
            <option value="4">Gudang Asset/Mesin</option>
			<?php }elseif($stock_loc==3){ ?>
			<option value="0">PILIH</option>
			<option value="1">Gudang Bahan Baku</option>
			<option value="2">Gudang Produksi</option>	
            <option value="3" selected="selected">Gudang Finishgoods</option>
            <option value="4">Gudang Asset/Mesin</option>
			<?php }elseif($stock_loc==4){ ?>
			<option value="0">PILIH</option>
			<option value="1">Gudang Bahan Baku</option>
			<option value="2">Gudang Produksi</option>	
            <option value="3">Gudang Finishgoods</option>
            <option value="4" selected="selected">Gudang Asset/Mesin</option>
			<?php }else{ ?>
			<option value="0" selected="selected">PILIH</option>
			<option value="1">Gudang Bahan Baku</option>
			<option value="2">Gudang Produksi</option>	
            <option value="3">Gudang Finishgoods</option>
            <option value="4">Gudang Asset/Mesin</option>
			<?php } ?>
		</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<?php if($prod_cat==1 || $prod_cat==6 || $prod_cat==7){ ?>
	<tr>
		<td>Jenis Dokumen</td>
		<td colspan="3">: <select name="stock_doctype">
        				<option value="BLANK" selected>PILIH</option>
				<?php
				  $dataSql = mysql_query("SELECT doc_type FROM document_type WHERE doc_status=1 ORDER BY  id ASC");
				  while ($dataRow = mysql_fetch_array($dataSql)) {
					if ($dataRow['doc_type']== $stock_doctype) {
						$cek = " selected";
					} else { $cek=""; }
					echo "<option value='$dataRow[doc_type]' $cek>$dataRow[doc_type]</option>";
				  }
				  $sqlData ="";
				?>
			 </select>&nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong dan barang sparepart*/</font></td>
	</tr>
	<tr>
		<td>Nomor Dokumen</td>
		<td colspan="3">: <input type="text" name="stock_docno" size="6" value="<?php echo $stock_docno; ?>" maxlength="6">
		&nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong  dan barang sparepart*/</font></td>
	</tr>
	<tr>
		<td>Tanggal Dokumen</td>
		<td colspan="3">: <input type="text" name="stock_docdate" value="<?php if(empty($stock_docdate)){$stock_docdate=$date;} echo $stock_docdate; ?>" size="12" id="docdate" 
				  readonly="true" style="background-color:#CCFFFF " />
				  &nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong  dan barang sparepart*/</font></td>
	</tr>
	<tr>
		<td>Valuta</td>
		<td colspan="3">: <select name="stock_currency">
					<option value="BLANK" selected>PILIH</option>
					<?php
					  $dataSql = mysql_query("SELECT currency FROM currency ORDER BY id ASC");
					  while ($dataRow = mysql_fetch_array($dataSql)) {	
					  	if ($dataRow['currency']== $stock_currency) {
							$cek = " selected";
						} else { $cek=""; }								
						echo "<option value='$dataRow[currency]' $cek>$dataRow[currency]</option>";
					  }
					  $sqlData =""; 
					?>
			 </select>&nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong  dan barang sparepart*/</font></td>
	</tr>
	<tr>
		<td>Total Harga</td>
		<td colspan="3">: <input type="text" name="stock_price" size="20" value="<?php echo $stock_price; ?>" style="text-align:right">
		&nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong  dan barang sparepart*/</font></td>
	</tr>
	<tr>
		<td>Detail Lokasi (Gudang)</td>
		<td colspan="3">: <select name="stock_whid">
                           <option value="0" selected="selected">PILIH</option> 
                            <?php
                              $dataSql = mysql_query("SELECT id, mw_name FROM master_warehouse WHERE mw_status=10 ORDER BY id ASC");
                              while ($dataRow = mysql_fetch_array($dataSql)){
								  if ($dataRow['id']== $stock_whid) {
										$cek = " selected";
									} else { $cek=""; }	
                                echo "<option value='$dataRow[id]' $cek>$dataRow[mw_name]</option>";
                              }
                              $sqlData ="";
                            ?>
                        </select>
		&nbsp;<font color="#FF0000">/*kolom ini khusus untuk saldo awal bahan baku dan bahan penolong  dan barang sparepart*/</font></td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="4" align="center">
			<input type="button" name="btnSave" value="SIMPAN" onclick="save_click();" style="cursor:pointer">
			<input type="button" value="BATAL" onclick="close_click();"  style="cursor:pointer" />
		</td>
	</tr>
</table>
</form>