Upgrade to v15.0.OS

This commit is contained in:
Thilina Hasantha
2016-02-08 04:25:58 +05:30
parent b99b6f6f77
commit 078396d5d7
91 changed files with 3332 additions and 1720 deletions

View File

@@ -21,49 +21,82 @@ Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
include (APP_BASE_PATH."modules/leaves/api/LeavesActionManager.php");
class DashboardActionManager extends SubActionManager{
public function getPendingLeaves($req){
return new IceResponse(IceResponse::SUCCESS,0);
}
public function getLastTimeSheetHours($req){
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("employee = ? order by date_end desc limit 1",array($this->getCurrentProfileId()));
if(empty($timeSheet->employee)){
return new IceResponse(IceResponse::SUCCESS,"0:00");
}
$timeSheetEntry = new EmployeeTimeEntry();
$list = $timeSheetEntry->Find("timesheet = ?",array($timeSheet->id));
$seconds = 0;
foreach($list as $entry){
$seconds += (strtotime($entry->date_end) - strtotime($entry->date_start));
}
$minutes = (int)($seconds/60);
$rem = $minutes % 60;
$hours = ($minutes - $rem)/60;
if($rem < 10){
$rem ="0".$rem;
}
return new IceResponse(IceResponse::SUCCESS,$hours.":".$rem);
}
public function getEmployeeActiveProjects($req){
$project = new EmployeeProject();
$projects = $project->Find("employee = ? and status =?",array($this->getCurrentProfileId(),'Current'));
return new IceResponse(IceResponse::SUCCESS,count($projects));
}
public function getPendingLeaves($req){
$lam = new LeavesActionManager();
$leavePeriod = $lam->getCurrentLeavePeriod(date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
$leave = new EmployeeLeave();
$pendingLeaves = $leave->Find("status = ? and employee = ?",array("Pending", $this->getCurrentProfileId()));
return new IceResponse(IceResponse::SUCCESS,count($pendingLeaves));
}
public function getInitData($req){
$data = array();
$emp = new Employee();
$data['numberOfEmployees'] = $emp->Count("status = 'Active' and supervisor = ?",array($this->getCurrentProfileId()));
$data['lastTimeSheetHours'] = $this->getLastTimeSheetHours($req)->getData();
$data['activeProjects'] = $this->getEmployeeActiveProjects($req)->getData();
$data['pendingLeaves'] = $this->getPendingLeaves($req)->getData();
$candidate = new Candidate();
$data['numberOfCandidates'] = $candidate->Count("1 = 1");
$job = new Job();
$data['numberOfJobs'] = $job->Count("status = 'Active'");
$attendance = new Attendance();
$data['numberOfAttendanceLastWeek'] = $attendance->Count("in_time > '".date("Y-m-d H:i:s",strtotime("-1 week"))."'");
$course = new Course();
$data['numberOfCourses'] = $course->Count("1 = 1");
return new IceResponse(IceResponse::SUCCESS,$data);
}
public function getLastTimeSheetHours($req){
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("employee = ? order by date_end desc limit 1",array($this->getCurrentProfileId()));
if(empty($timeSheet->employee)){
return new IceResponse(IceResponse::SUCCESS,"0:00");
}
$timeSheetEntry = new EmployeeTimeEntry();
$list = $timeSheetEntry->Find("timesheet = ?",array($timeSheet->id));
$seconds = 0;
foreach($list as $entry){
$seconds += (strtotime($entry->date_end) - strtotime($entry->date_start));
}
$minutes = (int)($seconds/60);
$rem = $minutes % 60;
$hours = ($minutes - $rem)/60;
if($rem < 10){
$rem ="0".$rem;
}
return new IceResponse(IceResponse::SUCCESS,$hours.":".$rem);
}
public function getEmployeeActiveProjects($req){
$project = new EmployeeProject();
$projects = $project->Find("employee = ? and status =?",array($this->getCurrentProfileId(),'Current'));
return new IceResponse(IceResponse::SUCCESS,count($projects));
}
}