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

     $query="Select  * from empmaster where emp_site='".$_GET['q']."' order by emp_name ";
	 $query1=DB_fetch_array(DB_query("Select  MONTH(doj) as month1 from empmaster where emp_site='".$_GET['q']."' order by emp_name ",$db));
	
	
		
	$sql_emp=DB_query($query,$db);
	
	
	
 	if(!$sql_emp){die('Error.'.DB_error());	}
 	?>
	
	<select name="employee_code" onchange="ShowDiv(this.value,'hid_DOJ','EmpDOJ.php')">
	<option value="All">ALL</option>
	<?php 	
	while($rowEmp=DB_fetch_array($sql_emp))
	{?>
	<option value="<?php echo $rowEmp['id'] ?>" <?php echo ($_REQUEST['empcode']==$rowEmp['id']?'selected':'') ?>><?php echo $rowEmp['emp_name'] ?></option>
	 <?php 
	}
	?></select>
<?php 
}
else if(isset($_GET['q']))
{ 
	     $type=$_GET['q'];
		 $emptype=$s->getField('shift_master','id', $_GET['q'],'shift_for');
		 if(strtolower($emptype)=='staff')
		 $prefix_type1='S';
		 else
		 $prefix_type1='W';
		 
/*	$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 empmaster 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';
	  }
	  
	  
  $emp_code=$prefix_type1.$final_string;	  
  ?>
  <input type="text" name="emp_code" class="cap" value="<?php echo $emp_code;?>" size="30">
  <?php 
}
?>
