public function testSaveReview() { $dao = new PerformanceReviewDao(); $review = new PerformanceReview(); $review->setId(1); $review->setEmployeeNumber(1); $review = $dao->saveReview($review); $this->assertEquals(1, $review->getId()); }
/** * * @return type */ public function saveForm($postData) { $formValues = $this->getValues(); $isSupervisorValid = true; $reviewers = array(); if ($postData['saveReview360Form']['supervisorReviewerId']) { $reviewers['supervisors'] = array($postData['saveReview360Form']['supervisorReviewerId']); } if ($formValues['reviewId'] > 0) { $review = $this->getPerformanceReviewService()->searchReview(array('id' => $formValues['reviewId'])); } else { $review = new PerformanceReview(); $isSupervisorValid = $this->isSupervisorValid($formValues['employeeId'], $postData['saveReview360Form']['supervisorReviewerId']); } if ($isSupervisorValid) { $review->setEmployeeNumber($formValues['employeeId']); $review->setWorkPeriodStart(date("Y-m-d", strtotime($formValues['workPeriodStartDate']))); $review->setWorkPeriodEnd(date("Y-m-d", strtotime($formValues['workPeriodEndDate']))); $review->setDueDate(date("Y-m-d", strtotime($formValues['dueDate']))); $employee = $this->getEmployeeService()->getEmployee($formValues['employeeId']); $review->setJobTitleCode($employee->getJobTitleCode()); $review->setDepartmentId($employee->getWorkStation()); $review->save(); $postData['reviewers'] = $reviewers; $review = $this->createReviewers($postData['reviewers'], $review); $review->save(); $this->setReview($review); if ($formValues['formAction'] == 'save') { $review->setStatusId(ReviewStatusInactive::getInstance()->getStatusId()); $review->save(); } else { if ($formValues['formAction'] == 'activate') { $review = $this->createRatings($review); $review->save(); $errorMessages = array(); $employee = $this->getEmployeeService()->getEmployee($this->getValue('employeeId')); if ($employee->getJobTitle()->getId() == null && $employee->getSubDivision()->getId() == null) { $errorMessages[] = __("Cannot activate review for employees who doesn't have Job Title and/or Sub-Division"); } if (!isset($postData['reviewers'])) { $errorMessages[] = __("Cannot activate review without reviewers"); } else { if (sizeof($review->getReviewerRating()) == 0) { $errorMessages[] = __("Cannot activate review without KPIs"); } } if (sizeof($errorMessages) == 0) { $review->setStatusId(ReviewStatusActivated::getInstance()->getStatusId()); $review->setActivatedDate(date("Y-m-d H:i:s")); $review->save(); return true; } else { $this->setTemplateMessage(implode("<br/>", $errorMessages)); $review->setStatusId(ReviewStatusInactive::getInstance()->getStatusId()); $review->save(); return false; } } } return true; } else { $errorMessages = array(); $errorMessages[] = __("Invalid Supervisor"); $this->setTemplateMessage(implode("<br/>", $errorMessages)); } }