Exemplo n.º 1
0
 /**
  * Saves Leave Request and Sends Notification
  * 
  * @param LeaveParameterObject $leaveAssignmentData 
  * 
  */
 protected function saveLeaveRequest(LeaveParameterObject $leaveAssignmentData)
 {
     $leaveRequest = $this->generateLeaveRequest($leaveAssignmentData);
     $leaveType = $this->getLeaveTypeService()->readLeaveType($leaveAssignmentData->getLeaveType());
     $leaveRequest->setLeaveTypeName($leaveType->getLeaveTypeName());
     if (is_null($leaveRequest->getLeavePeriodId())) {
         if ($this->getLeavePeriodService()->isWithinNextLeavePeriod(strtotime($leaveRequest->getDateApplied()))) {
             $nextLeavePeriod = $this->getLeavePeriodService()->createNextLeavePeriod($leaveRequest->getDateApplied());
             $leaveRequest->setLeavePeriodId($nextLeavePeriod->getLeavePeriodId());
         }
     }
     $leaves = $this->createLeaveObjectListForAppliedRange($leaveAssignmentData);
     if ($this->isEmployeeAllowedToApply($leaveType)) {
         if ($this->isValidLeaveRequest($leaveRequest, $leaves)) {
             try {
                 $this->getLeaveRequestService()->saveLeaveRequest($leaveRequest, $leaves);
                 if ($this->isOverlapLeaveRequest($leaveAssignmentData)) {
                     $this->getLeaveRequestService()->modifyOverlapLeaveRequest($leaveRequest, $leaves);
                 }
                 //sending leave apply notification
                 $leaveApplicationMailer = new LeaveApplicationMailer($this->getLoggedInEmployee(), $leaveRequest, $leaves);
                 $leaveApplicationMailer->send();
                 return true;
             } catch (Exception $e) {
                 throw new LeaveAllocationServiceException('Leave Quota will Exceed');
             }
         }
     }
 }
Exemplo n.º 2
0
 protected function sendEmail($loggedInEmployee, $leaveRequest, $leaves)
 {
     $leaveApplicationMailer = new LeaveApplicationMailer($loggedInEmployee, $leaveRequest, $leaves);
     $leaveApplicationMailer->send();
 }