 <?php class EmpShift
{
 
 
 
public function getTimeDiff1($dtime,$atime){
 
 
 
 $nextDay=$dtime>$atime?1:0;
 $dep=explode(':',$dtime);
 $arr=explode(':',$atime);
 $diff=abs(mktime($dep[0],$dep[1],0,date('n'),date('j'),date('y'))-mktime($arr[0],$arr[1],0,date('n'),date('j')+$nextDay,date('y')));
 $hours=floor($diff/(60*60));
 $mins=floor(($diff-($hours*60*60))/(60));
 $secs=floor(($diff-(($hours*60*60)+($mins*60))));
 if(strlen($hours)<2){$hours="0".$hours;}
 if(strlen($mins)<2){$mins="0".$mins;}
 if(strlen($secs)<2){$secs="0".$secs;}
 return $hours.':'.$mins;

// return $hours.':'.$mins.':'.$secs;
}



 public function EmpShift_Calculation($empid , $stime,$type)
 {
	 global $db;	
 	$Sintime=$stime[0];
	$Souttime=$stime[1];
	$Eintime=$stime[2];
	$Eouttime=$stime[3];	
	$OfficeHour=$stime[4];	
 	$WorkingHours=$stime[5];	 
	//	echo strtotime($OfficeHour).'+++'. strtotime($WorkingHours);
 	  if($type=='latearr'&& strtotime($Eintime)>strtotime($Sintime))
     echo $this->getTimeDiff1($Sintime,$Eintime);
	 if($type=='early' && strtotime($Sintime)>strtotime($Eintime)){
 	  //   strtotime($Sintime).'==='.strtotime($Eintime);
	  echo  $this->getTimeDiff1($Eintime,$Sintime);
	 }
	 if($type=='latedept' && strtotime($Eouttime)>strtotime($Souttime))
	echo  $this->getTimeDiff1($Souttime,$Eouttime );
	 if($type=='earlydept' && strtotime($Eouttime)<strtotime($Souttime))
	echo  $this->getTimeDiff1($Eouttime ,$Souttime);
	 
	 
 }
 
 function ConvertTimeINTO_Mins($times)
 {
    $tt=explode(':',$times);
    if($tt[1]!=0)
		$mins=$tt[0]*60+$tt[1];
	else
		$mins = $tt[0]*60;
	return($mins);
 }
 
 
  
 }
$OBJ_EMPSHIFT=new EmpShift();
 ?>