<?php
$PageSecurity = 2;
include('includes/session.inc');
$title = _('View/Search Items') ;
include('includes/SQL_CommonFunctions.inc');

 if($_REQUEST['type']=='basic')
 {
  $sql_basic="select basic_salary from emp_grade where id='".$_REQUEST['id']."' ";
  $result_basic=DB_query($sql_basic,$db);
  $rs_basic=DB_fetch_array($result_basic);
  $basic=$rs_basic[0];

  $sql_allowance="select * from allowmaster where allowcode in('DA','HRA') ";
  $result_allowance=DB_query($sql_allowance,$db);
  while($rs_allowance=DB_fetch_array($result_allowance))
  {
      $sql_allow_amount="select sum(percentage_value) from emp_salary_grade where emp_grade_id='".$_REQUEST['id']."' and allowance_deduction='".$rs_allowance['id']."' and all_ded_prefix='A' ";
      $result_allow_amount=DB_query($sql_allow_amount,$db);
      $rs_allow_amount=DB_fetch_array($result_allow_amount);
      $hra=$rs_allow_amount[0];
  }

  $total=$basic+$hra;
  echo $total;
 }
 else if($_REQUEST['type']=='employee_count')
 {
 	$count12=0;
 	$sql_att="select distinct employee from daily_attendance where month(attendance_date)='".$_REQUEST['month']."' and year(attendance_date)='".$_REQUEST['year']."' and employee in(select id from empmaster where grade='".$_REQUEST['id']."'  ) group by employee ";
 	$result_att=DB_query($sql_att,$db);
 	while($rs_att=DB_fetch_array($result_att))
 	{
            $sql_count_att="select count(*) from daily_attendance where month(attendance_date)='".$_REQUEST['month']."' and year(attendance_date)='".$_REQUEST['year']."' and employee='".$rs_att[0]."' and pres_abs in('P','WL') ";
            $result_count_att=DB_query($sql_count_att,$db);
            while($rs_count_att=DB_fetch_array($result_count_att))
            {
            	 if($rs_count_att[0]>=25)
            	 {
            	 	$count12+=1;
            	 }
            	
                  
            } 
     }	
     echo $count12;	
 }
?>