<?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 entry_slip_no from daily_production_process where branch_id='".$_REQUEST['site']."' order by entry_slip_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['entry_slip_no'],0,10);	
	$en2=substr($enquiry_row['entry_slip_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC/DPE-0001";
}
?>
<input type="text" name="entry_slip" style="width:100%;" id="entry_slip" value="<?php echo $finalString; ?> ">
<?php } ?>

<?php 
if($_REQUEST['site5']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site5']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select job_card_no from job_route_card where branch_id='".$_REQUEST['site5']."' order by job_card_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['job_card_no'],0,8);	
	$en2=substr($enquiry_row['job_card_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC-0001";
}
?>
<input type="text" name="job_ticket" id="job_ticket" style="width:100%" value="<?php echo $finalString; ?> ">
<?php }
?>

<?php 
if($_REQUEST['site6']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site6']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select mat_slip_no from material_slip_against_job_card where branch_id='".$_REQUEST['site6']."' order by mat_slip_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['mat_slip_no'],0,17);	
	$en2=substr($enquiry_row['mat_slip_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC/MAT-SLIP-0001";
}
?>
<input type="text" name="mat_slip_no" id="mat_slip_no" style="width:100%"  value="<?php echo $finalString; ?> ">
<?php }
?>
<?php 
if($_REQUEST['site7']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site7']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select design_prepress_slip from design_prepress_job_card where branch_id='".$_REQUEST['site7']."' order by design_prepress_slip 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['design_prepress_slip'],0,16);	
	$en2=substr($enquiry_row['design_prepress_slip'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC/DES-PRE-0001";
}
?>
<input type="text"  style="width:100%;" name="design_prepress" id="design_prepress"  value="<?php echo $finalString; ?> ">
<?php }
?>

<?php 
if($_REQUEST['site8']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site8']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select hotfoil_slip from tbl_inprocess_audit_hotfoil where branch_id='".$_REQUEST['site8']."' order by hotfoil_slip 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['hotfoil_slip'],0,9);	
	$en2=substr($enquiry_row['hotfoil_slip'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/HFSA-0001";
}
?><input type="text"  name="hot_foil_slip" id="hot_foil_slip" style="width:100%;"  value="<?php echo $finalString; ?> ">

<?php }
?>
<?php 
if($_REQUEST['site9']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site9']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select lamination_slip from tbl_inprocess_audit_laminations where branch_id='".$_REQUEST['site9']."' order by lamination_slip 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['lamination_slip'],0,7);	
	$en2=substr($enquiry_row['lamination_slip'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/LA-0001";
}
?><input type="text"  name="lamination_slip" id="lamination_slip" style="width:100%;"  value="<?php echo $finalString; ?> ">

<?php }
?>
<?php 
if($_REQUEST['site10']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site10']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select die_punching_slip from tbl_inprocess_die_punching where branch_id='".$_REQUEST['site10']."' order by die_punching_slip 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['die_punching_slip'],0,8);	
	$en2=substr($enquiry_row['die_punching_slip'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/DPA-0001";
}
?><input type="text"  name="lamination_slip" id="lamination_slip" style="width:100%;"  value="<?php echo $finalString; ?> ">

<?php }
?>
<?php 
if($_REQUEST['site11']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site11']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select feedback_slip from tbl_inprocess_feed_back_fomat where branch_id='".$_REQUEST['site11']."' order by feedback_slip 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['feedback_slip'],0,8);	
	$en2=substr($enquiry_row['feedback_slip'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/PFB-0001";
}
?><input type="text" id="feedback_slip" name="feedback_slip" style="width:100%;"  value="<?php echo $finalString; ?> ">

<?php }
?>
<?php 
if($_REQUEST['site12']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['site12']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select printing_slip_no from tbl_inprocess_printing_audit where branch_id='".$_REQUEST['site12']."' order by printing_slip_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['printing_slip_no'],0,14);	
	$en2=substr($enquiry_row['printing_slip_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/JC/PRINTA-0001";
}
?><input type="text"  name="printing_slip_no" id="printing_slip_no" style="width:100%;"  value="<?php echo $finalString; ?> ">

<?php }
?>

<?php 
if($_REQUEST['data']!='')
{
$sql="Select id,job_card_no  from job_route_card where sop_no='".$_REQUEST['data']."'";
$result=DB_query($sql,$db);
	?>

<select name="jobcard" id="jobcard" style="width:98%">
				   <option value="0">---Select---</option>
				  <?php 		
		while($row=DB_fetch_array($result))
{?>
				  <option value="<?php echo $row['id'];?><?php echo ($_REQUEST['jobcard']==$row['id']?'selected':'')?>"><?php echo $row['job_card_no'];?></option>
				  <?php } ?>
				</select>

<?php  }
?>
<?php 
if($_REQUEST['bom1']!='')
{
$sql="Select prefix from locations where loccode='".$_REQUEST['bom1']."'";
$result=DB_query($sql,$db);
$row=DB_fetch_array($result);
$prefix=$row['prefix'];
$enquiry_sql="Select Bom_no from bill_material where brach_code='".$_REQUEST['bom1']."' order by Bom_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['Bom_no'],0,9);	
	$en2=substr($enquiry_row['Bom_no'],-2);	
	$next=$en2+1;	
	$finalString=$en1.str_pad($next,4,"0",STR_PAD_LEFT);
}
else
{
	$finalString=$prefix."/BOM-0001";
}
?><input type="text" name="bomno" id="bomno" style="width:100%"  style="width:100%;"  value="<?php echo $finalString; ?>" readonly>

<?php }
?>

