<?php
$PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
//print_r($_GET['itemcode']);
include('includes/session.inc');

if(isset($_GET['itemcode']))
{ 
	  $type=$_GET['itemcode'];
 	  $sql='select StockID from item_master where SubCategoryID="'.$type.'" order by stockid desc limit 1';
	  $result = DB_query($sql,$db);
	  $myrow=DB_Fetch_array($result);
	  $myrow['StockID'];
	  if($myrow['StockID']!='')
	  {
	  		$itemcode=$myrow['StockID'];
			$code_brk1=substr($itemcode,-4);
			//echo $code_brk1;
			$final_num=$code_brk1+1;
			//echo "-".$final_num;
			$final_string=$type.str_pad($final_num,4,"0",STR_PAD_LEFT);
	  }
	  else
	  {
	  		$final_string=$type."0001";
	  }
echo $final_string;	  
}
?>
