Skip to content

Commit

Permalink
get employee leave query corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
go-faustino committed Mar 18, 2018
1 parent 67ed67b commit 7c7f2fc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions application/modules/timemanagement/models/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ public function getEmployeeHolidaysNWeekends($empId,$year,$month,$calWeek="") {
$where .= " and WEEK(holidaydate,2) = '".$calWeek."'";
} else
$where .= " and MONTH(holidaydate) = '".$month."'";

$select = $this->select()
->setIntegrityCheck(false)
->from(array('s'=>'main_employees_summary'),
array('date_of_joining','m.weekend_startday','m.weekend_endday','holiday_names'=>'GROUP_CONCAT(h.holidayname)' ,
'holiday_dates'=>'GROUP_CONCAT(h.holidaydate)'))
'holiday_dates'=>'GROUP_CONCAT(h.holidaydate)'))
->joinInner(array('m'=>'main_leavemanagement'),"m.department_id = s.department_id and m.isactive=1",array())
->joinLeft(array('h'=>'main_holidaydates'),"h.groupid = s.holiday_group and h.isactive=1 and YEAR(holidaydate) = '".$year."' ".$where." ",array())
->where(" s.user_id = '".$empId."'");
//echo $select;
//echo $select;
$result = $this->fetchAll($select)->toArray();

return $result;
Expand Down Expand Up @@ -141,12 +141,12 @@ public function checkweekdaysdatacron($hidstartweek_date,$hidendweek_date,$hidem

$calWeekVal = strftime('%U',strtotime($loopDate));
$dateYearVal = strftime('%Y',strtotime($loopDate));

if($calWeekVal == "00") {
$prevYear = $dateYearVal - 1;
$calWeekVal = strftime('%U',strtotime($prevYear.'-12-31'));
}
}

if(!in_array($calWeekVal,$cal_weekArray)){
$cal_weekArray[] = $calWeekVal;
$yearCalWeekArray[$calWeekVal][] = $dateYearVal;
Expand Down Expand Up @@ -333,8 +333,8 @@ public function getEmpLeaves($empid,$startday,$endday,$flag='')
->from(array('el' => 'main_leaverequest'),
array('from_date'=>'date_format(el.from_date,"%Y-%m-%d")','to_date'=>'date_format(el.to_date,"%Y-%m-%d")','leavetypeid'=>'el.leavetypeid','leavestatus'=>'el.leavestatus','leaveday'=>'el.leaveday','leave_req_id'=>'el.id'))
// ->where("el.isactive=1 AND el.user_id=".$empid." AND el.leavestatus IN ('Approved','Pending for approval') AND ((el.from_date >= '".$startday."' AND el.from_date <= '".$endday."') OR (el.to_date >= '".$startday."' AND el.to_date <= '".$endday."')) ");
->where("$where el.isactive=1 AND el.user_id=".$empid." AND el.leavestatus IN ('Approved','Pending for approval') AND ((el.from_date >= '".$startday."' AND el.from_date <= '".$endday."') OR (el.to_date >= '".$startday."' AND el.to_date <= '".$endday."')) ");
//echo $select;
->where("$where el.isactive=1 AND el.user_id=".$empid." AND el.leavestatus IN ('Approved','Pending for approval') AND (el.from_date <= '".$endday."' AND el.to_date >= '".$startday."') ");
//echo $select;
return $this->fetchAll($select)->toArray();
}

Expand All @@ -348,7 +348,7 @@ public function getEmpOncalls($empid,$startday,$endday,$flag='')
array('from_date'=>'date_format(el.from_date,"%Y-%m-%d")','to_date'=>'date_format(el.to_date,"%Y-%m-%d")','oncalltypeid'=>'el.oncalltypeid','oncallstatus'=>'el.oncallstatus','oncallday'=>'el.oncallday','oncall_req_id'=>'el.id'))
// ->where("el.isactive=1 AND el.user_id=".$empid." AND el.oncallstatus IN ('Approved','Pending for approval') AND ((el.from_date >= '".$startday."' AND el.from_date <= '".$endday."') OR (el.to_date >= '".$startday."' AND el.to_date <= '".$endday."')) ");
->where("$where el.isactive=1 AND el.user_id=".$empid." AND el.oncallstatus IN ('Approved','Pending for approval') AND ((el.from_date >= '".$startday."' AND el.from_date <= '".$endday."') OR (el.to_date >= '".$startday."' AND el.to_date <= '".$endday."')) ");
//echo $select;
//echo $select;
return $this->fetchAll($select)->toArray();
}

Expand All @@ -369,7 +369,7 @@ public function getManagers()

return $this->fetchAll($select)->toArray();
}

public function getManagement()
{
$select = $this->select()
Expand Down

0 comments on commit 7c7f2fc

Please sign in to comment.