private function onEdit() { if ($this->_accessLevel < ACCESS_LEVEL_EDIT) { $this->listByView('Invalid user level for action.'); return; } $companies = new Companies($this->_siteID); /* Bail out if we don't have a valid company ID. */ if (!$this->isRequiredIDValid('companyID', $_POST)) { $this->listByView('Invalid company ID.'); return; } /* Bail out if we don't have a valid owner user ID. */ if (!$this->isOptionalIDValid('owner', $_POST)) { $this->listByView('Invalid owner user ID.'); return; } /* Bail out if we don't have a valid billing contact ID. */ if (!$this->isOptionalIDValid('billingContact', $_POST)) { $this->listByView('Invalid billing contact ID.'); return; } $formattedPhone1 = StringUtility::extractPhoneNumber($this->getTrimmedInput('phone1', $_POST)); if (!empty($formattedPhone1)) { $phone1 = $formattedPhone1; } else { $phone1 = $this->getTrimmedInput('phone1', $_POST); } $formattedPhone2 = StringUtility::extractPhoneNumber($this->getTrimmedInput('phone2', $_POST)); if (!empty($formattedPhone2)) { $phone2 = $formattedPhone2; } else { $phone2 = $this->getTrimmedInput('phone2', $_POST); } $formattedFaxNumber = StringUtility::extractPhoneNumber($this->getTrimmedInput('faxNumber', $_POST)); if (!empty($formattedFaxNumber)) { $faxNumber = $formattedFaxNumber; } else { $faxNumber = $this->getTrimmedInput('faxNumber', $_POST); } $url = $this->getTrimmedInput('url', $_POST); if (!empty($url)) { $formattedURL = StringUtility::extractURL($url); if (!empty($formattedURL)) { $url = $formattedURL; } } /* Hot company? */ $isHot = $this->isChecked('isHot', $_POST); $companyID = $_POST['companyID']; $owner = $_POST['owner']; $billingContact = $_POST['billingContact']; /* Change ownership email? */ if ($this->isChecked('ownershipChange', $_POST) && $owner > 0) { $companyDetails = $companies->get($companyID); $users = new Users($this->_siteID); $ownerDetails = $users->get($_POST['owner']); if (!empty($ownerDetails)) { $emailAddress = $ownerDetails['email']; /* Get the change status email template. */ $emailTemplates = new EmailTemplates($this->_siteID); $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_OWNERSHIPASSIGNCLIENT'); if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) { $statusChangeTemplate = ''; } else { $statusChangeTemplate = $statusChangeTemplateRS['textReplaced']; } /* Replace e-mail template variables. */ $stringsToFind = array('%CLNTOWNER%', '%CLNTNAME%', '%CLNTCATSURL%'); $replacementStrings = array($ownerDetails['fullName'], $companyDetails['name'], '<a href="http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=companies&a=show&companyID=' . $companyID . '">' . 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=companies&a=show&companyID=' . $companyID . '</a>'); $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate); $email = $statusChangeTemplate; } else { $email = ''; $emailAddress = ''; } } else { $email = ''; $emailAddress = ''; } $name = $this->getTrimmedInput('name', $_POST); $address = $this->getTrimmedInput('address', $_POST); $city = $this->getTrimmedInput('city', $_POST); $state = $this->getTrimmedInput('state', $_POST); $zip = $this->getTrimmedInput('zip', $_POST); $keyTechnologies = $this->getTrimmedInput('keyTechnologies', $_POST); $notes = $this->getTrimmedInput('notes', $_POST); /* Departments list editor. */ $departmentsCSV = $this->getTrimmedInput('departmentsCSV', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($name)) { $this->listByView('Required fields are missing.'); return; } if (!eval(Hooks::get('CLIENTS_ON_EDIT_PRE'))) { return; } $departments = $companies->getDepartments($companyID); $departmentsDifferences = ListEditor::getDifferencesFromList($departments, 'name', 'departmentID', $departmentsCSV); $companies->updateDepartments($companyID, $departmentsDifferences); if (!$companies->update($companyID, $name, $address, $city, $state, $zip, $phone1, $phone2, $faxNumber, $url, $keyTechnologies, $isHot, $notes, $owner, $billingContact, $email, $emailAddress)) { CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to update company.'); } if (!eval(Hooks::get('CLIENTS_ON_EDIT_POST'))) { return; } /* Update extra fields. */ $companies->extraFields->setValuesOnEdit($companyID); /* Update contacts? */ if (isset($_POST['updateContacts'])) { if ($_POST['updateContacts'] == 'yes') { $contacts = new Contacts($this->_siteID); $contacts->updateByCompany($companyID, $address, $city, $state, $zip); } } CATSUtility::transferRelativeURI('m=companies&a=show&companyID=' . $companyID); }
private function onEdit() { if ($this->_accessLevel < ACCESS_LEVEL_EDIT) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Invalid user level for action.'); } /* Bail out if we don't have a valid contact ID. */ if (!$this->isRequiredIDValid('contactID', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.'); } /* Bail out if we don't have a valid company ID. */ if (!$this->isRequiredIDValid('companyID', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid company ID.'); } /* Bail out if we don't have a valid owner user ID. */ if (!$this->isOptionalIDValid('owner', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid owner user ID.'); } $contactID = $_POST['contactID']; $companyID = $_POST['companyID']; $owner = $_POST['owner']; $formattedPhoneWork = StringUtility::extractPhoneNumber($this->getTrimmedInput('phoneWork', $_POST)); if (!empty($formattedPhoneWork)) { $phoneWork = $formattedPhoneWork; } else { $phoneWork = $this->getTrimmedInput('phoneWork', $_POST); } $formattedPhoneCell = StringUtility::extractPhoneNumber($this->getTrimmedInput('phoneCell', $_POST)); if (!empty($formattedPhoneCell)) { $phoneCell = $formattedPhoneCell; } else { $phoneCell = $this->getTrimmedInput('phoneCell', $_POST); } $formattedPhoneOther = StringUtility::extractPhoneNumber($this->getTrimmedInput('phoneOther', $_POST)); if (!empty($formattedPhoneOther)) { $phoneOther = $formattedPhoneOther; } else { $phoneOther = $this->getTrimmedInput('phoneOther', $_POST); } $contacts = new Contacts($this->_siteID); if ($this->isChecked('ownershipChange', $_POST) && $owner > 0) { $contactDetails = $contacts->get($contactID); $users = new Users($this->_siteID); $ownerDetails = $users->get($owner); if (!empty($ownerDetails)) { $emailAddress = $ownerDetails['email']; /* Get the change status email template. */ $emailTemplates = new EmailTemplates($this->_siteID); $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_OWNERSHIPASSIGNCONTACT'); if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) { $statusChangeTemplate = ''; } else { $statusChangeTemplate = $statusChangeTemplateRS['textReplaced']; } /* Replace e-mail template variables. */ $stringsToFind = array('%CONTOWNER%', '%CONTFIRSTNAME%', '%CONTFULLNAME%', '%CONTCLIENTNAME%', '%CONTCATSURL%'); $replacementStrings = array($ownerDetails['fullName'], $contactDetails['firstName'], $contactDetails['firstName'] . ' ' . $contactDetails['lastName'], $contactDetails['companyName'], '<a href="http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=contacts&a=show&contactID=' . $contactID . '">' . 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=contacts&a=show&contactID=' . $contactID . '</a>'); $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate); $email = $statusChangeTemplate; } else { $email = ''; $emailAddress = ''; } } else { $email = ''; $emailAddress = ''; } $firstName = $this->getTrimmedInput('firstName', $_POST); $lastName = $this->getTrimmedInput('lastName', $_POST); $title = $this->getTrimmedInput('title', $_POST); $department = $this->getTrimmedInput('department', $_POST); $reportsTo = $this->getTrimmedInput('reportsTo', $_POST); $email1 = $this->getTrimmedInput('email1', $_POST); $email2 = $this->getTrimmedInput('email2', $_POST); $address = $this->getTrimmedInput('address', $_POST); $city = $this->getTrimmedInput('city', $_POST); $state = $this->getTrimmedInput('state', $_POST); $zip = $this->getTrimmedInput('zip', $_POST); $notes = $this->getTrimmedInput('notes', $_POST); $isHot = $this->isChecked('isHot', $_POST); $leftCompany = $this->isChecked('leftCompany', $_POST); /* Departments list editor. */ $departmentsCSV = $this->getTrimmedInput('departmentsCSV', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($firstName) || empty($lastName) || empty($title)) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.'); } if (!eval(Hooks::get('CONTACTS_ON_EDIT_PRE'))) { return; } /* Update departments. */ $companies = new Companies($this->_siteID); $departments = $companies->getDepartments($companyID); $departmentsDifferences = ListEditor::getDifferencesFromList($departments, 'name', 'departmentID', $departmentsCSV); $companies->updateDepartments($companyID, $departmentsDifferences); if (!$contacts->update($contactID, $companyID, $firstName, $lastName, $title, $department, $reportsTo, $email1, $email2, $phoneWork, $phoneCell, $phoneOther, $address, $city, $state, $zip, $isHot, $leftCompany, $notes, $owner, $email, $emailAddress)) { CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to update contact.'); } /* Update extra fields. */ $contacts->extraFields->setValuesOnEdit($contactID); if (!eval(Hooks::get('CONTACTS_ON_EDIT_POST'))) { return; } CATSUtility::transferRelativeURI('m=contacts&a=show&contactID=' . $contactID); }
private function addActivityChangeStatus() { /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('candidateID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); } /* Bail out if we don't have a valid job order ID. */ if (!$this->isRequiredIDValid('jobOrderID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid job order ID.'); } $candidateID = $_GET['candidateID']; $jobOrderID = $_GET['jobOrderID']; $candidates = new Candidates($this->_siteID); $candidateData = $candidates->get($candidateID); /* Bail out if we got an empty result set. */ if (empty($candidateData)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified candidate ID could not be found.'); } $pipelines = new Pipelines($this->_siteID); $pipelineData = $pipelines->get($candidateID, $jobOrderID); /* Bail out if we got an empty result set. */ if (empty($pipelineData)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified pipeline entry could not be found.'); } $statusRS = $pipelines->getStatusesForPicking(); $selectedStatusID = $pipelineData['statusID']; /* Override default send email behavior with site specific send email behavior. */ $mailerSettings = new MailerSettings($this->_siteID); $mailerSettingsRS = $mailerSettings->getAll(); $candidateJoborderStatusSendsMessage = unserialize($mailerSettingsRS['candidateJoborderStatusSendsMessage']); foreach ($statusRS as $index => $status) { $statusRS[$index]['triggersEmail'] = $candidateJoborderStatusSendsMessage[$status['statusID']]; } /* Get the change status email template. */ $emailTemplates = new EmailTemplates($this->_siteID); $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_STATUSCHANGE'); if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) { $statusChangeTemplate = ''; $emailDisabled = $statusChangeTemplateRS['disabled']; } else { $statusChangeTemplate = $statusChangeTemplateRS['textReplaced']; $emailDisabled = $statusChangeTemplateRS['disabled']; } /* Replace e-mail template variables. '%CANDSTATUS%', '%JBODTITLE%', * '%JBODCLIENT%' are replaced by JavaScript. */ $stringsToFind = array('%CANDOWNER%', '%CANDFIRSTNAME%', '%CANDFULLNAME%'); $replacementStrings = array($candidateData['ownerFullName'], $candidateData['firstName'], $candidateData['firstName'] . ' ' . $candidateData['lastName']); $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) { $allowEventReminders = true; } else { $allowEventReminders = false; } $this->_template->assign('candidateID', $candidateID); $this->_template->assign('pipelineData', $pipelineData); $this->_template->assign('statusRS', $statusRS); $this->_template->assign('selectedJobOrderID', $jobOrderID); $this->_template->assign('selectedStatusID', $selectedStatusID); $this->_template->assign('calendarEventTypes', $calendarEventTypes); $this->_template->assign('allowEventReminders', $allowEventReminders); $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail()); $this->_template->assign('onlyScheduleEvent', false); $this->_template->assign('statusChangeTemplate', $statusChangeTemplate); $this->_template->assign('emailDisabled', $emailDisabled); $this->_template->assign('isFinishedMode', false); $this->_template->assign('isJobOrdersMode', true); if (!eval(Hooks::get('JO_ADD_ACTIVITY_CHANGE_STATUS'))) { return; } $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl'); }
public function onApplyToJobOrder($siteID, $candidateID = false) { $jobOrders = new JobOrders($siteID); $careerPortalSettings = new CareerPortalSettings($siteID); if (!$this->isRequiredIDValid('ID', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid job order ID.'); return; } $jobOrderID = $_POST['ID']; $jobOrderData = $jobOrders->get($jobOrderID); if (!isset($jobOrderData['public']) || $jobOrderData['public'] == 0) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified job order could not be found.'); return; } $lastName = $this->getTrimmedInput('lastName', $_POST); $middleName = $this->getTrimmedInput('middleName', $_POST); $firstName = $this->getTrimmedInput('firstName', $_POST); $email = $this->getTrimmedInput('email', $_POST); $email2 = $this->getTrimmedInput('email2', $_POST); $address = $this->getTrimmedInput('address', $_POST); $city = $this->getTrimmedInput('city', $_POST); $state = $this->getTrimmedInput('state', $_POST); $zip = $this->getTrimmedInput('zip', $_POST); $source = $this->getTrimmedInput('source', $_POST); $phone = $this->getTrimmedInput('phone', $_POST); $phoneHome = $this->getTrimmedInput('phoneHome', $_POST); $phoneCell = $this->getTrimmedInput('phoneCell', $_POST); $bestTimeToCall = $this->getTrimmedInput('bestTimeToCall', $_POST); $keySkills = $this->getTrimmedInput('keySkills', $_POST); $extraNotes = $this->getTrimmedInput('extraNotes', $_POST); $employer = $this->getTrimmedInput('employer', $_POST); $gender = $this->getTrimmedInput('eeogender', $_POST); $race = $this->getTrimmedInput('eeorace', $_POST); $veteran = $this->getTrimmedInput('eeoveteran', $_POST); $disability = $this->getTrimmedInput('eeodisability', $_POST); if (empty($firstName)) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'First Name is a required field - please have your administrator edit your templates to include the first name field.'); } if (empty($lastName)) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Last Name is a required field - please have your administrator edit your templates to include the last name field.'); } if (empty($email)) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'E-Mail address is a required field - please have your administrator edit your templates to include the email field.'); } if (empty($source)) { $source = 'Online Careers Website'; } $users = new Users(CATS_ADMIN_SITE); $automatedUser = $users->getAutomatedUser(); /* Find if another user with same e-mail exists. If so, update the user * to contain the new information. */ $candidates = new Candidates($siteID); /** * Save basic information in a cookie in case the site is using registration to * process repeated postings, etc. */ $fields = array('firstName', 'lastName', 'email', 'address', 'city', 'state', 'zip', 'phone', 'phoneHome', 'phoneCell' ); $storedVal = ''; foreach ($fields as $field) { eval('$tmp = sprintf(\'"%s"="%s"\', $field, urlencode($' . $field . '));'); $storedVal .= $tmp; } // Store their information for an hour only (about 1 session), if they return they can log in again and // specify "remember me" which stores it for 2 weeks. @setcookie($this->getCareerPortalCookieName($siteID), $storedVal, time()+60*60); if ($candidateID !== false) { $candidate = $candidates->get($candidateID); // Candidate exists and registered. Update their profile with new values (if provided) $candidates->update( $candidateID, $candidate['isActive'] ? true : false, $firstName, $middleName, $lastName, $email, $email2, $phoneHome, $phoneCell, $phone, $address, $city, $state, $zip, $source, $keySkills, '', $employer, '', '', '', $candidate['notes'], '', $bestTimeToCall, $automatedUser['userID'], $automatedUser['userID'], $gender, $race, $veteran, $disability ); /* Update extra feilds */ $candidates->extraFields->setValuesOnEdit($candidateID); } else { // Lookup the candidate by e-mail, use that candidate instead if found (but don't update profile) $candidateID = $candidates->getIDByEmail($email); } if ($candidateID === false || $candidateID < 0) { /* New candidate. */ $candidateID = $candidates->add( $firstName, $middleName, $lastName, $email, $email2, $phoneHome, $phoneCell, $phone, $address, $city, $state, $zip, $source, $keySkills, '', $employer, '', '', '', 'Candidate submitted these notes with first application: ' . "\n\n" . $extraNotes, '', $bestTimeToCall, $automatedUser['userID'], $automatedUser['userID'], $gender, $race, $veteran, $disability ); /* Update extra fields. */ $candidates->extraFields->setValuesOnEdit($candidateID); } // If the candidate was added and a questionnaire exists for the job order if ($candidateID > 0 && ($questionnaireID = $jobOrderData['questionnaireID'])) { $questionnaireLib = new Questionnaire($siteID); // Perform any actions specified by the questionnaire $questionnaireLib->doActions($questionnaireID, $candidateID, $_POST); } $fileUploaded = false; /* Upload resume (no questionnaire) */ if (isset($_FILES['file']) && !empty($_FILES['file']['name'])) { $attachmentCreator = new AttachmentCreator($siteID); $attachmentCreator->createFromUpload( DATA_ITEM_CANDIDATE, $candidateID, 'file', false, true ); if ($attachmentCreator->isError()) { CommonErrors::fatal(COMMONERROR_FILEERROR, $this, $attachmentCreator->getError()); return; } $duplicatesOccurred = $attachmentCreator->duplicatesOccurred(); $isTextExtractionError = $attachmentCreator->isTextExtractionError(); $textExtractionErrorMessage = $attachmentCreator->getTextExtractionError(); // FIXME: Show parse errors! $fileUploaded = true; $resumePath = $attachmentCreator->getNewFilePath(); } /* Upload resume (with questionnaire) */ else if (isset($_POST['file']) && !empty($_POST['file'])) { $resumePath = ''; $newFilePath = FileUtility::getUploadFilePath($siteID, 'careerportaladd', $_POST['file']); if ($newFilePath !== false) { $attachmentCreator = new AttachmentCreator($siteID); $attachmentCreator->createFromFile( DATA_ITEM_CANDIDATE, $candidateID, $newFilePath, false, '', true, true ); if ($attachmentCreator->isError()) { CommonErrors::fatal(COMMONERROR_FILEERROR, $this, $attachmentCreator->getError()); return; } $duplicatesOccurred = $attachmentCreator->duplicatesOccurred(); $isTextExtractionError = $attachmentCreator->isTextExtractionError(); $textExtractionErrorMessage = $attachmentCreator->getTextExtractionError(); // FIXME: Show parse errors! $fileUploaded = true; $resumePath = $attachmentCreator->getNewFilePath(); } } $pipelines = new Pipelines($siteID); $activityEntries = new ActivityEntries($siteID); /* Is the candidate already in the pipeline for this job order? */ $rs = $pipelines->get($candidateID, $jobOrderID); if (count($rs) == 0) { /* Attempt to add the candidate to the pipeline. */ if (!$pipelines->add($candidateID, $jobOrderID)) { CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to add candidate to pipeline.'); } // FIXME: For some reason, pipeline entries like to disappear between // the above add() and this get(). WTF? $rs = $pipelines->get($candidateID, $jobOrderID); if (isset($rs['candidateJobOrderID'])) $pipelines->updateRatingValue($rs['candidateJobOrderID'], -1); $newApplication = true; } else { $newApplication = false; } /* Build activity note. */ if (!$newApplication) { $activityNote = 'User re-applied through candidate portal'; } else { $activityNote = 'User applied through candidate portal'; } if ($fileUploaded) { if (!$duplicatesOccurred) { $activityNote .= ' <span style="font-weight: bold;">and' . ' attached a new resume (<a href="' . $resumePath . '">Download</a>)</span>'; } else { $activityNote .= ' and attached an existing resume (<a href="' . $resumePath . '">Download</a>)'; } } if (!empty($extraNotes)) { $activityNote .= '; added these notes: ' . $extraNotes; } /* Add the activity note. */ $activityID = $activityEntries->add( $candidateID, DATA_ITEM_CANDIDATE, ACTIVITY_OTHER, $activityNote, $automatedUser['userID'], $jobOrderID ); /* Send an E-Mail describing what happened. */ $emailTemplates = new EmailTemplates($siteID); $candidatesEmailTemplateRS = $emailTemplates->getByTag( 'EMAIL_TEMPLATE_CANDIDATEAPPLY' ); if (!isset($candidatesEmailTemplateRS['textReplaced']) || empty($candidatesEmailTemplateRS['textReplaced']) || $candidatesEmailTemplateRS['disabled'] == 1) { $candidatesEmailTemplate = ''; } else { $candidatesEmailTemplate = $candidatesEmailTemplateRS['textReplaced']; } /* Replace e-mail template variables. */ /* E-Mail #1 - to candidate */ $stringsToFind = array( '%CANDFIRSTNAME%', '%CANDFULLNAME%', '%JBODOWNER%', '%JBODTITLE%', '%JBODCLIENT%' ); $replacementStrings = array( $firstName, $firstName . ' ' . $lastName, $jobOrderData['ownerFullName'], $jobOrderData['title'], $jobOrderData['companyName'] //'<a href="http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=candidates&a=show&candidateID=' . $candidateID . '">'. // 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=candidates&a=show&candidateID=' . $candidateID . '</a>' ); $candidatesEmailTemplate = str_replace( $stringsToFind, $replacementStrings, $candidatesEmailTemplate ); $emailContents = $candidatesEmailTemplate; if (!empty($emailContents)) { if(!$candidates->isLoaded()) { $candidates->load($candidateID); } $candidates->sendEMail( $automatedUser['userID'], $email, CAREERS_CANDIDATEAPPLY_SUBJECT, $emailContents ); } /* E-Mail #2 - to owner */ $candidatesEmailTemplateRS = $emailTemplates->getByTag( 'EMAIL_TEMPLATE_CANDIDATEPORTALNEW' ); if (!isset($candidatesEmailTemplateRS['textReplaced']) || empty($candidatesEmailTemplateRS['textReplaced']) || $candidatesEmailTemplateRS['disabled'] == 1) { $candidatesEmailTemplate = ''; } else { $candidatesEmailTemplate = $candidatesEmailTemplateRS['textReplaced']; } // FIXME: This will break if 'http' is elsewhere in the URL. $uri = str_replace('employment', '', $_SERVER['REQUEST_URI']); $uri = str_replace('http://', 'http', $uri); $uri = str_replace('//', '/', $uri); $uri = str_replace('http', 'http://', $uri); $uri = str_replace('/careers', '', $uri); /* Replace e-mail template variables. */ $stringsToFind = array( '%CANDFIRSTNAME%', '%CANDFULLNAME%', '%JBODOWNER%', '%CANDOWNER%', // Because the candidate was just added, we assume '%JBODTITLE%', // the candidate owner = job order owner. '%JBODCLIENT%', '%CANDCATSURL%', '%JBODID%', '%JBODCATSURL%' ); $replacementStrings = array( $firstName, $firstName . ' ' . $lastName, $jobOrderData['ownerFullName'], $jobOrderData['ownerFullName'], $jobOrderData['title'], $jobOrderData['companyName'], '<a href="http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strpos($uri, '?')) . '?m=candidates&a=show&candidateID=' . $candidateID . '">'. 'http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strpos($uri, '?')) . '?m=candidates&a=show&candidateID=' . $candidateID . '</a>', $jobOrderData['jobOrderID'], '<a href="http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strpos($uri, '?')) . '?m=joborders&a=show&jobOrderID=' . $jobOrderData['jobOrderID'] . '">'. 'http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strpos($uri, '?')) . '?m=joborders&a=show&jobOrderID=' . $jobOrderData['jobOrderID'] . '</a>', ); $candidatesEmailTemplate = str_replace( $stringsToFind, $replacementStrings, $candidatesEmailTemplate ); $emailContents = $candidatesEmailTemplate; if (!empty($emailContents)) { if(!$jobOrders->isLoaded()) { $jobOrders->load($jobOrderID); } $jobOrders->sendEmail( $automatedUser['userID'], $jobOrderData['owner_email'], CAREERS_OWNERAPPLY_SUBJECT, $emailContents ); if ($jobOrderData['owner_email'] != $jobOrderData['recruiter_email']) { $jobOrders->sendEmail( $automatedUser['userID'], $jobOrderData['recruiter_email'], CAREERS_OWNERAPPLY_SUBJECT, $emailContents ); } } }
private function addActivityChangeStatus() { /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('candidateID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); } /* Bail out if we don't have a valid job order ID. */ if (!$this->isOptionalIDValid('jobOrderID', $_GET)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid job order ID.'); } $selectedJobOrderID = $_GET['jobOrderID']; $candidateID = $_GET['candidateID']; $candidates = new Candidates($this->_siteID); $candidateData = $candidates->get($candidateID); /* Bail out if we got an empty result set. */ if (empty($candidateData)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this); return; /*$this->fatalModal( 'The specified candidate ID could not be found.' );*/ } $pipelines = new Pipelines($this->_siteID); $pipelineRS = $pipelines->getCandidatePipeline($candidateID); $statusRS = $pipelines->getStatusesForPicking(); if ($selectedJobOrderID != -1) { $selectedStatusID = ResultSetUtility::getColumnValueByIDValue($pipelineRS, 'jobOrderID', $selectedJobOrderID, 'statusID'); } else { $selectedStatusID = -1; } /* Get the change status email template. */ $emailTemplates = new EmailTemplates($this->_siteID); $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_STATUSCHANGE'); if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) { $statusChangeTemplate = ''; $emailDisabled = '1'; } else { $statusChangeTemplate = $statusChangeTemplateRS['textReplaced']; $emailDisabled = $statusChangeTemplateRS['disabled']; } /* Replace e-mail template variables. '%CANDSTATUS%', '%JBODTITLE%', * '%JBODCLIENT%' are replaced by JavaScript. */ $stringsToFind = array('%CANDOWNER%', '%CANDFIRSTNAME%', '%CANDFULLNAME%'); $replacementStrings = array($candidateData['ownerFullName'], $candidateData['firstName'], $candidateData['firstName'] . ' ' . $candidateData['lastName'], $candidateData['firstName'], $candidateData['firstName']); $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate); /* Are we in "Only Schedule Event" mode? */ $onlyScheduleEvent = $this->isChecked('onlyScheduleEvent', $_GET); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); if (!eval(Hooks::get('CANDIDATE_ADD_ACTIVITY_CHANGE_STATUS'))) { return; } if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo()) { $allowEventReminders = true; } else { $allowEventReminders = false; } $this->_template->assign('candidateID', $candidateID); $this->_template->assign('pipelineRS', $pipelineRS); $this->_template->assign('statusRS', $statusRS); $this->_template->assign('selectedJobOrderID', $selectedJobOrderID); $this->_template->assign('selectedStatusID', $selectedStatusID); $this->_template->assign('allowEventReminders', $allowEventReminders); $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail()); $this->_template->assign('calendarEventTypes', $calendarEventTypes); $this->_template->assign('statusChangeTemplate', $statusChangeTemplate); $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent); $this->_template->assign('emailDisabled', $emailDisabled); $this->_template->assign('isFinishedMode', false); $this->_template->assign('isJobOrdersMode', false); $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl'); }