IceHrm v18.0

This commit is contained in:
Thilina Hasantha
2016-08-04 14:27:59 +05:30
parent 9e243073df
commit a10fbba14a
882 changed files with 90619 additions and 2546 deletions

View File

@@ -134,5 +134,45 @@ class AttendanceActionManager extends SubActionManager{
return new IceResponse(IceResponse::SUCCESS,$openPunch);
}
public function createPreviousAttendnaceSheet($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$timeSheet = new EmployeeAttendanceSheet();
$timeSheet->Load("id = ?",array($req->id));
if($timeSheet->id != $req->id){
return new IceResponse(IceResponse::ERROR,"Attendance Sheet not found");
}
if($timeSheet->employee != $employee->id){
return new IceResponse(IceResponse::ERROR,"You don't have permissions to add this Attendance Sheet");
}
$end = date("Y-m-d", strtotime("last Saturday", strtotime($timeSheet->date_start)));
$start = date("Y-m-d", strtotime("last Sunday", strtotime($end)));
$tempTimeSheet = new EmployeeTimeSheet();
$tempTimeSheet->Load("employee = ? and date_start = ?",array($employee->id, $start));
if($employee->id == $tempTimeSheet->employee){
return new IceResponse(IceResponse::ERROR,"Attendance Sheet already exists");
}
$newTimeSheet = new EmployeeTimeSheet();
$newTimeSheet->employee = $employee->id;
$newTimeSheet->date_start = $start;
$newTimeSheet->date_end = $end;
$newTimeSheet->status = "Pending";
$ok = $newTimeSheet->Save();
if(!$ok){
LogManager::getInstance()->info("Error creating time sheet : ".$newTimeSheet->ErrorMsg());
return new IceResponse(IceResponse::ERROR,"Error creating Attendance Sheet");
}
return new IceResponse(IceResponse::SUCCESS,"");
}
}
}