<?php 
$PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
if($_REQUEST['q']!=''){
$sql=DB_query("Select * from storetype where Store_Site='".$_REQUEST['q']."'",$db);
?>
<select name="fromStore" id="fromStore" style="width:100%;height:20px">
    	<?php 
		while($myrow=DB_fetch_array($sql))
		{?>
			<option value="<?php echo $myrow['StoreCode'];?>"><?php echo $myrow['StoreName'];?></option>
		<?php 	
		}
    	?>
</select>
<?php } 
else if($_REQUEST['p']!='')
{
	$sql=DB_query("Select * from storetype where Store_Site='".$_REQUEST['p']."'",$db);
?>
<select name="toStore" id="toStore" style="width:100%;height:20px">
    	<?php 
		while($myrow=DB_fetch_array($sql))
		{?>
			<option value="<?php echo $myrow['StoreCode'];?>"><?php echo $myrow['StoreName'];?></option>
		<?php 	
		}
    	?>
</select>
<?php 
}
else if($_REQUEST['r']!='')
{
	$prefixSql="SELECT prefix FROM locations where loccode='".$_REQUEST['r']."'";
	$query= DB_query($prefixSql,$db);
	
	$row=DB_fetch_array($query);
	
	//echo $lastId=DB_Last_Insert_Id($db,"stock_transfer","id");
	
	$stockid="SELECT id FROM stock_transfer ORDER BY id DESC limit 1";
	$stockids= DB_query($stockid,$db);
	$rowstock=DB_fetch_array($stockids);
	
	//$row1[id];
	$lastId=$rowstock['id']+1;
	if(strlen($lastId)==2){
		$add="/ST-000".$lastId;
	}
	else if(strlen($lastId)==3){
		$add="/ST-00".$lastId;
	}
	else if(strlen($lastId)==4){
		$add="/ST-0".$lastId;
	}
	else if(strlen($lastId)==5){
		$add="/ST-".$lastId;
	}
	else
	{
		$add="/ST-0000".$lastId;
	}
	echo $row['prefix'].$add;
	
}
?>