<?php $PageSecurity = 11;
include('includes/session.inc');
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
if($_REQUEST['site']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select vouchar_no from job_production_card where branch_id='".$_REQUEST['site']."' order by vouchar_no DESC limit 1";
$enquiry_result=DB_query($enquiry_sql,$db);

if(DB_num_rows($enquiry_result)>0)
{
	$enquiry_row=DB_fetch_array($enquiry_result);	
	$en1=substr($enquiry_row['vouchar_no'],0,10);	
	$en2=substr($enquiry_row['vouchar_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC/PP-0001";
}
?>
<input type="text" name="vouchar_no" style="width:100%;" id="vouchar_no" value="<?php echo $finalString; ?> ">
<?php } ?>