<?php
$PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
//print_r($_GET['itemcode']);
include('includes/session.inc');
include('includes/function_lib.php');
if(isset($_GET['q']))
{ 
	    $type=$_GET['q'];
	$idx=explode(' ',$type);
	for($i=0;$i<count($idx);$i++)
	{
	     $prefix_type[$i]=substr($idx[$i], 0, 3);
	}
	 
	 $prefix_type1=implode("-",$prefix_type);
//echo 	 $prefix_type=	 $s->GetFieldValue('stockcategory',"id='".$type."'" ,'item_prefix');

 	  $sql='select id from suppliers where 1=1 order by id desc limit 1';
	  $result = DB_query($sql,$db);
	  $myrow=DB_Fetch_array($result);
	  $myrow['id'];
	  if($myrow['id']!='')
	  {
	  		$itemcode=$myrow['id'];
 			$final_num=$myrow['id']+1;
 			$final_string= str_pad($final_num,4,"0",STR_PAD_LEFT);
	  }
	  else
	  {
	  		$final_string='0001';
	  }
	  
	  
  $vendor_code=$prefix_type1.'-'.$final_string;	  
}
?>
<input type="text" name="vendor_code" class="cap" value="<?php echo $vendor_code;?>" size="30">