<?php 
ob_start();
$PageSecurity = 4;
$PageName = 'Purchase Requisition';
include('includes/DefinePOClass.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/DefineSuppTransClass.php');
$year=date('y');
$year_after=$year+1;

$str=substr($_REQUEST['site'],0,3);

$prefix_sql=DB_query("Select * from prefix_tbl where prefix_name='".$PageName."'",$db);
$prefix_row=DB_fetch_array($prefix_sql);
$prefix=$prefix_row['prefix_code'];
$x=substr($prefix,6,9);

 $sql="Select MAX(requisitionno) as Reqno from materialrequisitions where sitecode='".$_REQUEST['site']."' order by Reqno desc limit 1";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);

if(DB_num_rows($result)>0)
{
	$Reqno=$myrow['Reqno'];
	 $req_part1=substr($Reqno,-4);
	//echo $req_part1;
	$req_final=$req_part1+1;
	//echo "<br>".$req_final;
}
else
{
	$req_final="1";
}

 $string=$str."/".$x."/".$year.$year_after."/";
$final_string=$string.str_pad($req_final,6,"0",STR_PAD_LEFT);


//echo $final_string;


?>
<div id="reqno"><input name="requisition_no" type="text" id="requisition_no" value="<?php echo $final_string;?>" size="30" readonly="true">
</div>
