<?php 
 

function calEmpLeaveRange($eid,$k)
{
  global $db;
  $s=new db_query();
	 $sql="select * from emp_leave_apply where empid='".$eid."' and approve_status!='C'
	  and '".$k."' BETWEEN approved_date_from AND approved_date_to";
 $r=db_query($sql,$db);
 $rs=DB_fetch_array($r);
 $n=0;
   //echo $rs['approved_date_from']."####".$k;
    //echo $rs['approved_date_from']."####".$rs['approved_date_to'];
  if($rs['approved_date_from']==$k)
  { 
  	 $get_from_half_day=$rs['from_half_day'];
  	if($get_from_half_day!='0')
  	{
  		$n=0;
  	}
  	else
  	{
  		$n=1;
  	}
  	
  }

  else if($rs['approved_date_to']==$k)
  {
  	$get_from_to_day=$rs['to_half_day'];
  	if($get_from_to_day!='0')
  	{
  		$n=0;
  	}
  	else
  	{
  		$n=1;
  	}
  	
  }
  else if($rs['approved_date_from']<=$k && $rs['approved_date_to']>=$k)
  {
  	$n=1;
  }
  else
  {
  	$n=0;
  }
  
//$arr=array();
    //$n=DB_num_rows($r);
  //echo $n;
 return ($n);

}

?>