Example #1
0
 /**
  * Parse data from interface and return JobVacancy Object
  * @param Array $postArr Array containing POST values
  * @return JobVacancy Job Vacancy object
  */
 public function parseData($postArr)
 {
     $vacancy = new JobVacancy();
     if (isset($postArr['txtId']) && !empty($postArr['txtId'])) {
         $vacancy->setId(trim($postArr['txtId']));
     }
     if (isset($postArr['cmbJobTitle']) && !empty($postArr['cmbJobTitle'])) {
         $vacancy->setJobTitleCode(trim($postArr['cmbJobTitle']));
     }
     if (isset($postArr['cmbHiringManager']) && !empty($postArr['cmbHiringManager'])) {
         $vacancy->setManagerId(trim($postArr['cmbHiringManager']));
     }
     if (isset($postArr['txtDesc']) && !empty($postArr['txtDesc'])) {
         $vacancy->setDescription(trim($postArr['txtDesc']));
     }
     if (isset($postArr['active']) && !empty($postArr['active'])) {
         $vacancy->setActive(true);
     }
     return $vacancy;
 }
 /**
  * Get the role of the given user in relation to the given job application
  *
  * @param authorize $authObj authorize class representing logged in user
  * @param JobApplication Job Application relative to which roles are required
  *
  * @return int One of the ROLE_ constants defined in this class
  */
 public function getRoleForApplication($authObj, $jobApplication)
 {
     if ($authObj->isAdmin()) {
         return self::ROLE_ADMIN;
     }
     if ($authObj->isManager() || $authObj->isOfferer()) {
         // Check if director
         $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SEEK_APPROVAL);
         if (!empty($event) && $event->getOwner() == $authObj->getEmployeeId()) {
             return self::ROLE_DIRECTOR;
         }
         // Check if hiring manager
         $vacancy = JobVacancy::getJobVacancy($jobApplication->getVacancyId());
         if ($authObj->getEmployeeId() == $vacancy->getManagerId()) {
             return self::ROLE_HIRING_MANAGER;
         }
         // Check if interview 2 manager
         $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
         if (!empty($event) && $event->getOwner() == $authObj->getEmployeeId()) {
             return self::ROLE_INTERVIEW2_MANAGER;
         }
         // Check if interview 1 manager
         $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
         if (!empty($event) && $event->getOwner() == $authObj->getEmployeeId()) {
             return self::ROLE_INTERVIEW1_MANAGER;
         }
         return self::ROLE_OTHER_MANAGER;
     }
     if ($authObj->isDirector() || $authObj->isAcceptor()) {
         // Check if director
         $event = $jobApplication->getEventOfType(JobApplicationEvent::EVENT_SEEK_APPROVAL);
         if (!empty($event) && $event->getOwner() == $authObj->getEmployeeId()) {
             return self::ROLE_DIRECTOR;
         }
         return self::ROLE_OTHER_DIRECTOR;
     }
     return self::ROLE_OTHER;
 }
 /**
  * Create an employee based on a job application.
  *
  * @param JobApplication $jobApplication Job Application to create the employee from.
  * @throws RecruitmentControllerException if there is an error when creating employee
  */
 public function createEmployeeFromApplication($jobApplication)
 {
     $empInfo = new EmpInfo();
     // main information
     $employeeId = $empInfo->getLastId();
     $empInfo->setEmployeeId($employeeId);
     $empInfo->setEmpLastName($jobApplication->getLastName());
     $empInfo->setEmpFirstName($jobApplication->getFirstName());
     $empInfo->setEmpMiddleName($jobApplication->getMiddleName());
     $result = $empInfo->addEmpMain();
     // contact information
     $empInfo->setEmpStreet1($jobApplication->getStreet1());
     $empInfo->setEmpStreet2($jobApplication->getStreet2());
     $empInfo->setEmpCity($jobApplication->getCity());
     $empInfo->setEmpProvince($jobApplication->getProvince());
     $empInfo->setEmpCountry($jobApplication->getCountry());
     $empInfo->setEmpZipCode($jobApplication->getZip());
     $empInfo->setEmpHomeTelephone($jobApplication->getPhone());
     $empInfo->setEmpMobile($jobApplication->getMobile());
     $empInfo->setEmpOtherEmail($jobApplication->getEmail());
     $result = $empInfo->updateEmpContact();
     // job information
     $vacancy = JobVacancy::getJobVacancy($jobApplication->getVacancyId());
     $empInfo->setEmpJobTitle($vacancy->getJobTitleCode());
     $empInfo->setEmpStatus(0);
     $empInfo->setEmpEEOCat(0);
     $empInfo->setEmpJoinedDate("null");
     $empInfo->setEmpTerminatedDate("null");
     $result = $empInfo->updateEmpJobInfo();
     return $empInfo->getEmpId();
 }
 /**
  * Send a task to the interviewing manager, giving details of scheduled interview
  *
  * @param JobApplicationEvent $jobApplicationEvent Job Application Event object
  *
  * @return boolean True if mail sent, false otherwise
  */
 public function sendInterviewTaskToManager($jobApplicationEvent)
 {
     /* Get interview details */
     $intManagerId = $jobApplicationEvent->getOwner();
     if (empty($intManagerId)) {
         throw new RecruitmentMailNotifierException("Invalid parameters", RecruitmentMailNotifierException::INVALID_PARAMETER);
     }
     $intManagerEmail = $this->_getEmpAddress($intManagerId);
     if (empty($intManagerEmail)) {
         $this->_log("Interviewing manager {$intManagerId} does not have email address.");
         return false;
     }
     $intManagerName = $this->_getEmpName($intManagerId);
     $jobApplication = JobApplication::getJobApplication($jobApplicationEvent->getApplicationId());
     $applicantName = $jobApplication->getFirstName() . ' ' . $jobApplication->getLastName();
     $applicantEmail = $jobApplication->getEmail();
     $creatorName = $jobApplicationEvent->getCreatorName();
     $creatorEmail = $jobApplicationEvent->getCreatorEmail();
     $interviewTime = $jobApplicationEvent->getEventTime();
     $vacancy = JobVacancy::getJobVacancy($jobApplication->getVacancyId());
     /* Get summary and description from templates */
     $subject = $this->_getTemplate(self::SUBJECT_INTERVIEW_MANAGER_TASK);
     $body = $this->_getTemplate(self::TEMPLATE_INTERVIEW_MANAGER_TASK);
     // Replace placeholders in subject and body
     $search = array(self::VARIABLE_JOB_TITLE, self::VARIABLE_TO, self::VARIABLE_APPLICANT_FIRSTNAME, self::VARIABLE_APPLICANT_MIDDLENAME, self::VARIABLE_APPLICANT_LASTNAME, self::VARIABLE_APPLICANT_STREET1, self::VARIABLE_APPLICANT_STREET2, self::VARIABLE_APPLICANT_CITY, self::VARIABLE_APPLICANT_PROVINCE, self::VARIABLE_APPLICANT_ZIP, self::VARIABLE_APPLICANT_COUNTRY, self::VARIABLE_APPLICANT_PHONE, self::VARIABLE_APPLICANT_MOBILE, self::VARIABLE_APPLICANT_EMAIL, self::VARIABLE_APPLICANT_QUALIFICATIONS, self::VARIABLE_INTERVIEW_NOTES);
     $country = $this->_getCountryName($jobApplication->getCountry());
     $replace = array($vacancy->getJobTitleName(), $intManagerName['first'], $jobApplication->getFirstName(), $jobApplication->getMiddleName(), $jobApplication->getLastName(), $jobApplication->getStreet1(), $jobApplication->getStreet2(), $jobApplication->getCity(), $jobApplication->getProvince(), $jobApplication->getZip(), $country, $jobApplication->getPhone(), $jobApplication->getMobile(), $jobApplication->getEmail(), $jobApplication->getQualifications(), $jobApplicationEvent->getNotes());
     $summary = str_replace($search, $replace, $subject);
     $description = str_replace($search, $replace, $body);
     /* Create task */
     $message = $this->_getTask($summary, $description, $creatorName, $creatorEmail, $applicantName, $applicantEmail, $interviewTime);
     $mailer = $this->_getMailer();
     $attachment = $mailer->createAttachment($message);
     $attachment->type = 'text/calendar';
     $attachment->filename = 'interview.ics';
     /* Send Email with task attached */
     $to = "{$intManagerName['first']} {$intManagerName['last']}<{$intManagerEmail}>";
     $body = '';
     $notificationType = null;
     $attachments = array($attachment);
     $subject = $summary;
     $this->_sendMail($to, $subject, $body, $notificationType, $attachments);
 }
Example #5
0
 /**
  * Retrieve vacancy list
  * @returns doctrine collection
  * @throws DaoException
  */
 public function saveJobVacancy(JobVacancy $jobVacancy)
 {
     try {
         if ($jobVacancy->getId() == '') {
             $idGenService = new IDGeneratorService();
             $idGenService->setEntity($jobVacancy);
             $jobVacancy->setId($idGenService->getNextID());
         }
         $jobVacancy->save();
         return true;
     } catch (Exception $e) {
         throw new DaoException($e->getMessage());
     }
 }
 /**
  * test the parseData function
  */
 public function testParseData()
 {
     $extractor = new EXTRACTOR_JobVacancy();
     // No parameters - default settings
     $post = array();
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $this->assertEquals($expected, $vacancy);
     // All parameters
     $post = array('txtId' => '2', 'cmbJobTitle' => '3', 'cmbHiringManager' => '2', 'txtDesc' => 'XYZ', 'active' => '1');
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $expected->setId(2);
     $expected->setJobTitleCode(3);
     $expected->setManagerId(2);
     $expected->setDescription('XYZ');
     $expected->setActive(true);
     $this->assertEquals($expected, $vacancy);
     // Without ID
     $post = array('cmbJobTitle' => '3', 'cmbHiringManager' => '2', 'txtDesc' => 'XYZ', 'active' => '1');
     $vacancy = $extractor->parseData($post);
     $expected = new JobVacancy();
     $expected->setJobTitleCode(3);
     $expected->setManagerId(2);
     $expected->setDescription('XYZ');
     $expected->setActive(true);
     $this->assertEquals($expected, $vacancy);
 }
 /**
  * Test case for createEmployeeFromApplication
  */
 public function testCreateEmployeeFromApplication()
 {
     $jobApplication = JobApplication::getJobApplication(1);
     $empInfo = new EmpInfo();
     $before = $empInfo->countEmployee();
     $recController = new RecruitmentController();
     $empNum = $recController->createEmployeeFromApplication($jobApplication);
     $this->assertNotNull($empNum);
     // check employee count increased by 1
     $after = $empInfo->countEmployee();
     $this->assertEquals($before + 1, $after);
     // verify employee main details
     $empMain = $empInfo->filterEmpMain($empNum);
     $this->assertTrue(isset($empMain[0]));
     $this->assertEquals($empNum, $empMain[0][0]);
     $this->assertEquals($jobApplication->getLastName(), $empMain[0][1]);
     $this->assertEquals($jobApplication->getFirstName(), $empMain[0][2]);
     $this->assertEquals($jobApplication->getMiddleName(), $empMain[0][3]);
     // check that empId saved as well.
     $employeeId = str_pad($empNum, $empInfo->getEmployeeIdLength(), "0", STR_PAD_LEFT);
     $this->assertEquals($employeeId, $empMain[0][5]);
     // verify employee contact details
     $empContact = $empInfo->filterEmpContact($empNum);
     $this->assertTrue(isset($empContact[0]));
     $this->assertEquals($empNum, $empMain[0][0]);
     $this->assertEquals($jobApplication->getStreet1(), $empContact[0][1]);
     $this->assertEquals($jobApplication->getStreet2(), $empContact[0][2]);
     $this->assertEquals($jobApplication->getCity(), $empContact[0][3]);
     $this->assertEquals($jobApplication->getCountry(), $empContact[0][4]);
     $this->assertEquals($jobApplication->getProvince(), $empContact[0][5]);
     $this->assertEquals($jobApplication->getZip(), $empContact[0][6]);
     // Phone saved as home telephone
     $this->assertEquals($jobApplication->getPhone(), $empContact[0][7]);
     $this->assertEquals($jobApplication->getMobile(), $empContact[0][8]);
     // Email stored as other email.
     $this->assertEquals($jobApplication->getEmail(), $empContact[0][11]);
     // Job title
     $empJobInfo = $empInfo->filterEmpJobInfo($empNum);
     $this->assertTrue(isset($empJobInfo[0]));
     $this->assertEquals($empNum, $empJobInfo[0][0]);
     $vacancy = JobVacancy::getJobVacancy($jobApplication->getVacancyId());
     $this->assertEquals($vacancy->getJobTitleCode(), $empJobInfo[0][2]);
 }
Example #8
0
 /**
  * Creates a JobVacancy object from a resultset row
  *
  * @param array $row Resultset row from the database.
  * @return JobVacancy JobVacancy object.
  */
 private static function _createFromRow($row)
 {
     $vacancy = new JobVacancy($row[self::DB_FIELD_VACANCY_ID]);
     $vacancy->setJobTitleCode($row[self::DB_FIELD_JOBTITLE_CODE]);
     $vacancy->setManagerId($row[self::DB_FIELD_MANAGER_ID]);
     $vacancy->setActive((bool) $row[self::DB_FIELD_ACTIVE]);
     $vacancy->setDescription($row[self::DB_FIELD_DESCRIPTION]);
     if (isset($row[self::FIELD_JOB_TITLE_NAME])) {
         $vacancy->setJobTitleName($row[self::FIELD_JOB_TITLE_NAME]);
     }
     if (isset($row[self::FIELD_MANAGER_NAME])) {
         $vacancy->setManagerName($row[self::FIELD_MANAGER_NAME]);
     }
     return $vacancy;
 }
 /**
  * Create a JobVacancy object with the passed parameters
  */
 private function _getJobVacancy($id, $jobTitleCode, $managerId, $active, $description)
 {
     $vacancy = new JobVacancy($id);
     $vacancy->setJobTitleCode($jobTitleCode);
     $vacancy->setManagerId($managerId);
     $vacancy->setActive($active);
     $vacancy->setDescription($description);
     return $vacancy;
 }