/** * get Leave Request * @return LeaveRequest */ public function getLeaveRequest() { $posts = $this->getValues(); $leaveRequest = new LeaveRequest(); $leaveRequest->setLeaveTypeId($posts['txtLeaveType']); $leaveRequest->setDateApplied($posts['txtFromDate']); $leaveRequest->setLeavePeriodId($this->getLeavePeriod($posts['txtFromDate'])); $leaveRequest->setEmpNumber($posts['txtEmpID']); $leaveRequest->setLeaveComments($posts['txtComment']); return $leaveRequest; }
/** * * @param LeaveParameterObject $leaveAssignmentData * @return LeaveRequest */ protected function generateLeaveRequest(LeaveParameterObject $leaveAssignmentData) { $leavePeriodId = null; $leavePeriod = $this->getLeavePeriodService()->getLeavePeriod(strtotime($leaveAssignmentData->getFromDate())); if (!is_null($leavePeriod) && $leavePeriod instanceof LeavePeriod) { $leavePeriodId = $leavePeriod->getLeavePeriodId(); } $leaveRequest = new LeaveRequest(); $leaveRequest->setLeaveTypeId($leaveAssignmentData->getLeaveType()); $leaveRequest->setDateApplied($leaveAssignmentData->getFromDate()); $leaveRequest->setLeavePeriodId($leavePeriodId); $leaveRequest->setEmpNumber($leaveAssignmentData->getEmployeeNumber()); $leaveRequest->setLeaveComments($leaveAssignmentData->getComment()); return $leaveRequest; }
/** * Modify Overlap leave request * @param LeaveRequest $leaveRequest * @return boolean */ public function xmodifyOverlapLeaveRequest(LeaveRequest $leaveRequest, $leaveList, $leavePeriod = null) { try { $nextLeavePeriod = false; $nextLeaveRequest = false; if ($leavePeriod == null) { $leavePeriod = Doctrine::getTable('LeavePeriod')->find($leaveRequest->getLeavePeriodId()); } foreach ($leaveList as $leave) { if ($leave->getLeaveDate() > $leavePeriod->getEndDate()) { if (!$nextLeavePeriod instanceof LeavePeriod) { $leavePeriodService = new LeavePeriodService(); $leavePeriodService->setLeavePeriodDao(new LeavePeriodDao()); $nextLeavePeriod = $leavePeriodService->createNextLeavePeriod($leave->getLeaveDate()); $nextLeaveRequest = new LeaveRequest(); $idGenService = new IDGeneratorService(); $idGenService->setEntity($leaveRequest); $nextLeaveRequest->setLeaveRequestId($idGenService->getNextID()); $nextLeaveRequest->setLeaveTypeId($leaveRequest->getLeaveTypeId()); $nextLeaveRequest->setDateApplied($leaveRequest->getDateApplied()); $nextLeaveRequest->setLeavePeriodId($nextLeavePeriod->getLeavePeriodId()); $nextLeaveRequest->setLeaveTypeName($leaveRequest->getLeaveTypeName()); $nextLeaveRequest->setEmpNumber($leaveRequest->getEmpNumber()); $nextLeaveRequest->setLeaveComments($leaveRequest->getLeaveComments()); $nextLeaveRequest->save(); } $q = Doctrine_Query::create()->update('Leave l')->set('l.leave_request_id=', $nextLeaveRequest->getLeaveRequestId())->where('l.leave_id = ?', $leave->getLeaveId()); $q->execute(); } } return true; } catch (Exception $e) { throw new DaoException($e->getMessage()); } }
private function _getLeaveRequestData() { $leaveRequest = new LeaveRequest(); $leaveRequest->setLeavePeriodId(1); $leaveRequest->setLeaveTypeId('LTY001'); $leaveRequest->setLeaveTypeName('Casual'); $leaveRequest->setDateApplied('2010-09-01'); $leaveRequest->setEmpNumber(1); $leaveRequest->setLeaveComments("Testing comment i add"); $leave1 = new Leave(); $leave1->setLeaveLengthHours(8); $leave1->setLeaveLengthDays(1); $leave1->setLeaveDate('2010-12-01'); $leave1->setLeaveStatus(1); $leave2 = new Leave(); $leave2->setLeaveLengthHours(6); $leave2->setLeaveLengthDays(0.75); $leave2->setLeaveDate('2010-12-02'); $leave2->setLeaveStatus(1); return array($leaveRequest, array($leave1, $leave2)); }