<?php
$PageSecurity=2;
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/SQL_CommonFunctions.inc');
global $db;
if($_REQUEST['section']!=''){
switch($_REQUEST['section']){


case 'chk_employee' :
$chk_date=$_REQUEST['year']."-".$_REQUEST['month']."-01";
$chk_date1=$_REQUEST['year']."-".$_REQUEST['month']."-31";

if(!empty($_REQUEST['dept'])){
	$con =  "AND `department` ='".$_REQUEST['dept']."'";
}
else{ $con =  '';}
?>
	<?php           $emp_query = "SELECT id,emp_name,emp_code FROM empmaster WHERE CompanyId='".$_SESSION['ACGCompanyId']."' 
	AND emp_site='".$_REQUEST['site']."' AND (dol>='".$chk_date."' OR dol='0000-00-00') AND doj<='".$chk_date1."' ".$con."  ORDER BY emp_name ASC";
			$emp_res = DB_query($emp_query,$db) or die(DB_error());
                        if(DB_num_rows($emp_res)>0){?>
                        <option value="">All</option>
			<?php while($emp_result = DB_fetch_array($emp_res))
				{
			?>
			 <option value="<?php echo $emp_result['id'];?>" <?php if($_REQUEST['employee_code']==$emp_result['id']) { ?> selected="selected" <?php } ?>><?php echo $emp_result['emp_name'].'('. $emp_result['emp_code'].')' ?></option>
                        <?php }} ?>

<?php
break;

case 'chk_employee_all' :

?>
	<?php 
				 $emp_query = "SELECT * FROM empmaster WHERE CompanyId='".$_SESSION['ACGCompanyId']."' 
				AND emp_site='".$_REQUEST['site']."' AND ((YEAR(dol)>='".$_REQUEST['year']."' AND YEAR(doj)<='".$_REQUEST['year']."') OR (YEAR(doj)<='".$_REQUEST['year']."' AND dol='00-00-0000')) ORDER BY emp_code ASC";
				$emp_res = DB_query($emp_query,$db) or die(DB_error());
                                if(DB_num_rows($emp_res)>0){?>
                       <option value="">All</option>
		       <?php while($emp_result = DB_fetch_array($emp_res))
				{
			?>
			 <option value="<?php echo $emp_result['id'];?>" <?php if($_REQUEST['employee_code']==$emp_result['id']) { ?> selected="selected" <?php } ?>><?php echo $emp_result['emp_name'].'('. $emp_result['emp_code'].')' ?></option>
                                <?php }} ?>
<?php
break;

case 'chk_type_employee' :
$chk_date=$_REQUEST['year']."-".$_REQUEST['month']."-01";
$chk_date1=$_REQUEST['year']."-".$_REQUEST['month']."-31";
?>
	<?php       $emp_query = "SELECT id,emp_name FROM empmaster WHERE CompanyId='".$_SESSION['ACGCompanyId']."'
	                               AND emp_site='".$_REQUEST['site']."' AND staff_type='".$_REQUEST['type']."'
	                                AND (dol>='".$chk_date."' OR dol='0000-00-00') AND doj<='".$chk_date1."' 
              ORDER BY emp_name ASC";
		      $emp_res = DB_query($emp_query,$db) or die(DB_error());
                       if(DB_num_rows($emp_res)>0){?>
                       <option value="">All</option>
			<?php while($emp_result = DB_fetch_array($emp_res))
				{
			?>
			 <option value="<?php echo $emp_result['id'];?>" <?php if($_REQUEST['employee_code']==$emp_result['id']) { ?> selected="selected" <?php } ?>><?php echo $emp_result['emp_name'];?></option>
<?php }} ?>
<?php
break;

case 'showcolorCode' :
         $code = DB_query("SELECT color_code FROM qc_color_master WHERE CompanyId='".$_SESSION['ACGCompanyId']."' AND id='".$_REQUEST['str']."'",$db);
         $code_color = DB_fetch_array($code);
         echo $code_color['color_code'];
                 
break;

}}
?>