<?php
if (!isset($PathPrefix)) {
	$PathPrefix='';
}
if (!file_exists($PathPrefix . 'config.php')){
	$rootpath = dirname($_SERVER['PHP_SELF']);
	if ($rootpath == '/' OR $rootpath == "\\") {
		$rootpath = '';
	}
	header('Location:' . $rootpath . '/install/index.php');
}
include($PathPrefix . 'config.php');

if (isset($SessionSavePath)){
	session_save_path($SessionSavePath);
}
session_name('CAKEPHP'); session_start();

include($PathPrefix . 'includes/LanguageSetup.php');
include($PathPrefix . 'includes/ConnectDB.inc');


if(!empty($_REQUEST['q'])){
	 $code_id = $_REQUEST['q'];

	$sql = "select * from stockmaster where description like '$code_id%'";
	//echo $sql;
	$res = DB_query($sql,$db);
	if(DB_num_rows($res)>0){
		while($data = DB_fetch_array($res)){		
			$options[] = $data['description'];			
		}		
		 print(implode("\n", $options));
	}
}

if(isset($_POST)){
	//print_r($_POST);
	$currentId = $_POST['current_id'];
	//echo $currentId;
	$itemDesc = $_POST['item_desc'.$currentId];
	//$item_desc = $itemDesc.;	
	$sql = "select * from stockmaster where description='$itemDesc'";
	//echo $sql;
	$res = DB_query($sql,$db);

	if(DB_num_rows($res)>0){
		while($data = DB_fetch_array($res)){	
		?>		
			<div> <!-- This is empty div and please don't remove this -->
				<div id="sItemCode<?=$currentId;?>">
					<div align="center">
					 <input type="text" size="10" name="item_code<?=$currentId;?>" value="<?=$data['stockid'];?>" readonly style="background-color:#eeeeee" />
					 </div>
				</div>			 
				<div id="sBaseUnit<?=$currentId;?>">
				   <div align="center">
					<input type="text" size="5" name="base_unit<?=$currentId;?>" value="<?=$data['units'];?>" readonly style="background-color:#eeeeee" />
					</div>
				</div>				
			</div>
			<?php
		}				
	}
}
		
			?>