public function save() { $file = $this->getValue('resume'); $resume = new JobCandidateAttachment(); $candidate = new JobCandidate(); $vacnacyId = $this->getValue('vacancyList'); $resultArray = array(); if (!$this->isValidResume($file)) { $resultArray['messageType'] = 'warning'; $resultArray['message'] = __(TopLevelMessages::FILE_TYPE_SAVE_FAILURE); return $resultArray; } else { $this->candidateId = $this->_getNewlySavedCandidateId($candidate); $resultArray['candidateId'] = $this->candidateId; $resumeId = $this->_saveResume($file, $resume, $this->candidateId); } $this->_saveCandidateVacancies($vacnacyId, $this->candidateId); //Now send mail to HR admin and Hiring manager $empNumber = sfContext::getInstance()->getUser()->getEmployeeNumber(); $addCandidateMailer = new AddCandidateMailer($empNumber, $this->candidateId, $vacnacyId); $addCandidateMailer->send(); return $resultArray; }
/** * * @return string */ public function save() { $file = $this->getValue('resume'); $resumeUpdate = $this->getValue('resumeUpdate'); $resume = new JobCandidateAttachment(); $resumeId = ""; $candidate = new JobCandidate(); $vacancy = $this->getValue('vacancy'); $existingVacancyList = array(); $empNumber = sfContext::getInstance()->getUser()->getEmployeeNumber(); if ($empNumber == 0) { $empNumber = null; } $this->addedBy = $empNumber; if (!empty($file)) { if (!$this->isValidResume($file)) { $resultArray['messageType'] = 'warning'; $resultArray['message'] = __(TopLevelMessages::FILE_TYPE_SAVE_FAILURE); return $resultArray; } } if ($this->candidateId != null) { $candidate = $this->getCandidateService()->getCandidateById($this->candidateId); $storedResume = $candidate->getJobCandidateAttachment(); if ($storedResume != "") { $resume = $storedResume; } $existingVacancyList = $candidate->getJobCandidateVacancy(); $candidateVacancy = $existingVacancyList[0]; $id = $candidateVacancy->getVacancyId(); if (!empty($id)) { if ($id != $vacancy) { $interviews = $this->getInterviewService()->getInterviewsByCandidateVacancyId($candidateVacancy); foreach ($interviews as $interview) { $interviewers = $interview->getJobInterviewInterviewer(); foreach ($interviewers as $interviewer) { $interviewer->delete(); } } $candidateVacancy->delete(); $vacancyName = $candidateVacancy->getVacancyName(); $this->removedHistory = new CandidateHistory(); $this->removedHistory->candidateId = $this->candidateId; $this->removedHistory->action = CandidateHistory::RECRUITMENT_CANDIDATE_ACTION_REMOVE; $this->removedHistory->performedBy = $this->addedBy; $date = date('Y-m-d'); $this->removedHistory->performedDate = $date . " " . date('H:i:s'); $this->removedHistory->candidateVacancyName = $vacancyName; $this->removedHistory->vacancyId = $id; $this->_saveCandidateVacancies($vacancy, $this->candidateId); } } else { $this->_saveCandidateVacancies($vacancy, $this->candidateId); } } if ($resumeUpdate == self::CONTRACT_DELETE) { $resume->delete(); } $candidateId = $this->_getNewlySavedCandidateId($candidate); $resultArray = array(); $resultArray['candidateId'] = $candidateId; if (!empty($file)) { $resumeId = $this->_saveResume($file, $resume, $candidateId); } if ($this->candidateId == "") { $this->_saveCandidateVacancies($vacancy, $candidateId); } if (!empty($this->addedHistory)) { $this->getCandidateService()->saveCandidateHistory($this->addedHistory); } if (!empty($this->removedHistory)) { $this->getCandidateService()->saveCandidateHistory($this->removedHistory); } //Now send mail to HR admin and Hiring manager if (empty($this->candidateId)) { $addCandidateMailer = new AddCandidateMailer($empNumber, $candidateId, $vacancy); $addCandidateMailer->send(); } return $resultArray; }