/** * Returns an array of events in a month, keyed by each day of the month. * There will always be a key present for each day of the month, but if * there are no events for a day then it's corresponding value will be an * empty array. * * @param integer Month number (1-12). * @param integer Year (four-digit). * @return array Multi-dimensional result set array. */ public function getEventArray($month, $year) { // FIXME: Rewrite this query to use date ranges in WHERE, so that // indexes can be used. $sql = sprintf("SELECT\n calendar_event.calendar_event_id AS eventID,\n calendar_event.data_item_id AS dataItemID,\n calendar_event.data_item_type AS dataItemType,\n calendar_event.joborder_id AS jobOrderID,\n calendar_event.duration AS duration,\n calendar_event.all_day AS allDay,\n calendar_event.title AS title,\n calendar_event.description AS description,\n calendar_event.reminder_enabled AS reminderEnabled,\n calendar_event.reminder_email AS reminderEmail,\n calendar_event.reminder_time AS reminderTime,\n calendar_event.public AS public,\n DATE_FORMAT(\n calendar_event.date, '%%d'\n ) AS day,\n DATE_FORMAT(\n calendar_event.date, '%%m'\n ) AS month,\n DATE_FORMAT(\n calendar_event.date, '%%y'\n ) AS year,\n DATE_FORMAT(\n calendar_event.date, '%%m-%%d-%%y'\n ) AS date,\n DATE_FORMAT(\n calendar_event.date, '%%h:%%i %%p'\n ) AS time,\n DATE_FORMAT(\n calendar_event.date, '%%H'\n ) AS hour,\n DATE_FORMAT(\n calendar_event.date, '%%i'\n ) AS minute,\n calendar_event.date AS dateSort,\n DATE_FORMAT(\n calendar_event.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'\n ) AS dateCreated,\n calendar_event_type.calendar_event_type_id AS eventType,\n calendar_event_type.short_description AS eventTypeDescription,\n entered_by_user.user_id AS userID,\n entered_by_user.first_name AS enteredByFirstName,\n entered_by_user.last_name AS enteredByLastName\n FROM\n calendar_event\n LEFT JOIN calendar_event_type\n ON calendar_event.type = calendar_event_type.calendar_event_type_id\n LEFT JOIN user AS entered_by_user\n ON calendar_event.entered_by = entered_by_user.user_id\n WHERE\n DATE_FORMAT(calendar_event.date, '%%c') = %s\n AND\n DATE_FORMAT(calendar_event.date, '%%Y') = %s\n AND\n calendar_event.site_id = %s\n ORDER BY\n dateSort ASC", $month, $year, $this->_siteID); $rs = $this->_db->getAllAssoc($sql); /* Build an array of result set arrays for each day of the month. * Days without any events scheduled will have an empty array. */ $daysInMonth = DateUtility::getDaysInMonth($month, $year); for ($i = 1; $i <= $daysInMonth; ++$i) { /* See if we can find a row in the result set that has 'day' set * to $i. */ $firstOffset = ResultSetUtility::findRowByColumnValue($rs, 'day', $i); /* Found? If yes, $firstOffset now contains the offset of the row; * otherwise false. */ if ($firstOffset === false) { /* No events for this date. */ $array[$i] = array(); continue; } /* Store the first row we found that has 'day' set to $i. */ $array[$i] = array($rs[$firstOffset]); /* There could be more than one row that has 'day' set to $i * (multiple events on the same day). We are going to tell * findRowByColumnValue() to skip the first row (we found it * and stored it already), and then keep increasing the number * of rows to skip until we can't find any more rows. */ for ($skip = 1;; ++$skip) { $nextOffset = ResultSetUtility::findRowByColumnValue($rs, 'day', $i, $skip); if ($nextOffset === false) { /* No more rows for this date. */ break; } /* Found another one; store the row. */ $array[$i][] = $rs[$nextOffset]; } } return $array; }
private function displayPublicJobOrders() { $site = new Site(-1); $careerPortalSiteID = $site->getFirstSiteID(); if (!eval(Hooks::get('RSS_SITEID'))) { return; } $jobOrders = new JobOrders($careerPortalSiteID); $rs = $jobOrders->getAll(JOBORDERS_STATUS_ACTIVE, -1, -1, -1, false, true); /* XML Headers */ header('Content-type: text/xml'); $indexName = CATSUtility::getIndexName(); $stream = sprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<rss version=\"2.0\">\n" . "<channel>\n" . "<title>New Job Orders</title>\n" . "<description>CATS RSS Feed</description>\n" . "<link>%s</link>\n" . "<pubDate>%s</pubDate>\n", CATSUtility::getAbsoluteURI(), DateUtility::getRSSDate()); foreach ($rs as $rowIndex => $row) { $uri = sprintf("%scareers/?p=showJob&ID=%d", CATSUtility::getAbsoluteURI(), $row['jobOrderID']); // Fix URL if viewing from /rss without using globals or dirup '../' if (strpos($_SERVER['PHP_SELF'], '/rss/') !== false) { $uri = str_replace('/rss/', '/', $uri); } $stream .= sprintf("<item>\n" . "<title>%s (%s)</title>\n" . "<description>Located in %s.</description>\n" . "<link>%s</link>\n" . "</item>\n", $row['title'], $jobOrders->typeCodeToString($row['type']), StringUtility::makeCityStateString($row['city'], $row['state']), $uri); } $stream .= "</channel>\n</rss>\n"; echo $stream; }
function testConvert() { $dates = array(array('/', '01/01/01', DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD, '2001/01/01'), array('/', '02/27/01', DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD, '2001/02/27'), array('-', '01-01-01', DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD, '2001-01-01'), array('-', '02-27-01', DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD, '2001-02-27'), array('-', '2002-01-30', DATE_FORMAT_YYYYMMDD, DATE_FORMAT_MMDDYY, '01-30-02')); foreach ($dates as $key => $value) { $this->assertIdentical(DateUtility::convert($value[0], $value[1], $value[2], $value[3]), $value[4]); } }
private function show() { /* Bail out if we don't have a valid company ID. */ if (!$this->isRequiredIDValid('companyID', $_GET)) { $this->listByView('Invalid company ID.'); return; } $companyID = $_GET['companyID']; $companies = new Companies($this->_siteID); $data = $companies->get($companyID); /* Bail out if we got an empty result set. */ if (empty($data)) { $this->listByView('The specified company ID could not be found.'); return; } /* We want to handle formatting the city and state here instead * of in the template. */ $data['cityAndState'] = StringUtility::makeCityStateString($data['city'], $data['state']); /* * Replace newlines with <br />, fix HTML "special" characters, and * strip leading empty lines and spaces. */ $data['notes'] = trim(nl2br(htmlspecialchars($data['notes'], ENT_QUOTES))); /* Chop $data['notes'] to make $data['shortNotes']. */ if (strlen($data['notes']) > self::NOTES_MAXLEN) { $data['shortNotes'] = substr($data['notes'], 0, self::NOTES_MAXLEN); $isShortNotes = true; } else { $data['shortNotes'] = $data['notes']; $isShortNotes = false; } /* Hot companies [can] have different title styles than normal companies. */ if ($data['isHot'] == 1) { $data['titleClass'] = 'jobTitleHot'; } else { $data['titleClass'] = 'jobTitleCold'; } /* Link to Google Maps for this address */ if (!empty($data['address']) && !empty($data['city']) && !empty($data['state'])) { $data['googleMaps'] = '<a href="http://maps.google.com/maps?q=' . urlencode($data['address']) . '+' . urlencode($data['city']) . '+' . urlencode($data['state']); /* Google Maps will find an address without Zip. */ if (!empty($data['zip'])) { $data['googleMaps'] .= '+' . $data['zip']; } $data['googleMaps'] .= '" target=_blank><img src="images/google_maps.gif" style="border: none;" class="absmiddle" /></a>'; } else { $data['googleMaps'] = ''; } /* Attachments */ $attachments = new Attachments($this->_siteID); $attachmentsRS = $attachments->getAll(DATA_ITEM_COMPANY, $companyID); foreach ($attachmentsRS as $rowNumber => $attachmentsData) { /* Show an attachment icon based on the document's file type. */ $attachmentIcon = strtolower(FileUtility::getAttachmentIcon($attachmentsRS[$rowNumber]['originalFilename'])); $attachmentsRS[$rowNumber]['attachmentIcon'] = $attachmentIcon; } /* Job Orders for this company */ $jobOrders = new JobOrders($this->_siteID); $jobOrdersRS = $jobOrders->getAll(JOBORDERS_STATUS_ALL, -1, $companyID, -1); if (!empty($jobOrdersRS)) { foreach ($jobOrdersRS as $rowIndex => $row) { /* Convert '00-00-00' dates to empty strings. */ $jobOrdersRS[$rowIndex]['startDate'] = DateUtility::fixZeroDate($jobOrdersRS[$rowIndex]['startDate']); /* Hot jobs [can] have different title styles than normal * jobs. */ if ($jobOrdersRS[$rowIndex]['isHot'] == 1) { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkCold'; } $jobOrdersRS[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($jobOrdersRS[$rowIndex]['recruiterFirstName'], $jobOrdersRS[$rowIndex]['recruiterLastName'], false, LAST_NAME_MAXLEN); $jobOrdersRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($jobOrdersRS[$rowIndex]['ownerFirstName'], $jobOrdersRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } } /* Contacts for this company */ $contacts = new Contacts($this->_siteID); $contactsRS = $contacts->getAll(-1, $companyID); $contactsRSWC = null; if (!empty($contactsRS)) { foreach ($contactsRS as $rowIndex => $row) { /* Hot contacts [can] have different title styles than normal contacts. */ if ($contactsRS[$rowIndex]['isHot'] == 1) { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkCold'; } if (!empty($contactsRS[$rowIndex]['ownerFirstName'])) { $contactsRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($contactsRS[$rowIndex]['ownerFirstName'], $contactsRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } else { $contactsRS[$rowIndex]['ownerAbbrName'] = 'None'; } if ($contactsRS[$rowIndex]['leftCompany'] == 0) { $contactsRSWC[] = $contactsRS[$rowIndex]; } else { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkDead'; } } } /* Add an MRU entry. */ $_SESSION['CATS']->getMRU()->addEntry(DATA_ITEM_COMPANY, $companyID, $data['name']); /* Get extra fields. */ $extraFieldRS = $companies->extraFields->getValuesForShow($companyID); /* Get departments. */ $departmentsRS = $companies->getDepartments($companyID); /* Is the user an admin - can user see history? */ if ($this->_accessLevel < ACCESS_LEVEL_DEMO) { $privledgedUser = false; } else { $privledgedUser = true; } $this->_template->assign('active', $this); $this->_template->assign('data', $data); $this->_template->assign('attachmentsRS', $attachmentsRS); $this->_template->assign('departmentsRS', $departmentsRS); $this->_template->assign('extraFieldRS', $extraFieldRS); $this->_template->assign('isShortNotes', $isShortNotes); $this->_template->assign('jobOrdersRS', $jobOrdersRS); $this->_template->assign('contactsRS', $contactsRS); $this->_template->assign('contactsRSWC', $contactsRSWC); $this->_template->assign('privledgedUser', $privledgedUser); $this->_template->assign('companyID', $companyID); if (!eval(Hooks::get('CLIENTS_SHOW'))) { return; } $this->_template->display('./modules/companies/Show.tpl'); }
$type = $_REQUEST['type']; $jobOrderID = $_REQUEST['jobOrderID']; /* Decode and trim the activity notes from the company. */ $activityNote = trim(urldecode($_REQUEST['notes'])); $activityDate = trim(urldecode($_REQUEST['date'])); $activityHour = trim(urldecode($_REQUEST['hour'])); $activityMinute = trim(urldecode($_REQUEST['minute'])); $activityAMPM = trim(urldecode($_REQUEST['ampm'])); if (!DateUtility::validate('-', $activityDate, DATE_FORMAT_MMDDYY)) { die('Invalid availability date.'); return; } /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $activityHour, $activityMinute, $activityAMPM)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $activityDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); /* Highlight what needs highlighting. */ if (strpos($activityNote, 'Status change: ') === 0) { $pipelines = new Pipelines($siteID); $statusRS = $pipelines->getStatusesForPicking(); foreach ($statusRS as $data) { $activityNote = StringUtility::replaceOnce($data['status'], '<span style="color: #ff6c00;">' . $data['status'] . '</span>', $activityNote); } } /* Save the new activity entry. */ $activityEntries = new ActivityEntries($siteID); $activityEntries->update($activityID, $type, $activityNote, $jobOrderID, $date, $_SESSION['CATS']->getTimeZoneOffset()); /* Grab the current activity entry. */ $activityEntry = $activityEntries->get($activityID); /* Send back "(No Notes)" to be displayed if we don't have any. */ if (empty($activityEntry['notes'])) {
private function manageUsers() { /* Bail out if the user doesn't have SA permissions. */ if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this); return; //$this->fatal(ERROR_NO_PERMISSION); } $users = new Users($this->_siteID); $rs = $users->getAll(); $license = $users->getLicenseData(); foreach ($rs as $rowIndex => $row) { $rs[$rowIndex]['successfulDate'] = DateUtility::fixZeroDate($rs[$rowIndex]['successfulDate'], 'Never'); $rs[$rowIndex]['unsuccessfulDate'] = DateUtility::fixZeroDate($rs[$rowIndex]['unsuccessfulDate'], 'Never'); // FIXME: The last test here might be redundant. // FIXME: Put this in a private method. It is duplicated twice so far. $siteIDPosition = strpos($row['username'], '@' . $_SESSION['CATS']->getSiteID()); if ($siteIDPosition !== false && substr($row['username'], $siteIDPosition) == '@' . $_SESSION['CATS']->getSiteID()) { $rs[$rowIndex]['username'] = str_replace('@' . $_SESSION['CATS']->getSiteID(), '', $row['username']); } } $this->_template->assign('active', $this); $this->_template->assign('subActive', 'User Management'); $this->_template->assign('rs', $rs); $this->_template->assign('license', $license); $this->_template->display('./modules/settings/Users.tpl'); }
/** * Processes an Add Activity / Schedule Event form and displays * contacts/AddActivityScheduleEventModal.tpl. This is factored out * for code clarity. * * @param boolean from joborders module perspective * @param integer "regarding" job order ID or -1 * @param string module directory * @return void */ private function _addActivityScheduleEvent($regardingID, $directoryOverride = '') { /* Module directory override for fatal() calls. */ if ($directoryOverride != '') { $moduleDirectory = $directoryOverride; } else { $moduleDirectory = $this->_moduleDirectory; } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('contactID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.'); } $contactID = $_POST['contactID']; //if (!eval(Hooks::get('CONTACT_ON_ADD_ACTIVITY_SCHEDULE_EVENT_PRE'))) return; if ($this->isChecked('addActivity', $_POST)) { /* Bail out if we don't have a valid job order ID. */ if (!$this->isOptionalIDValid('activityTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.'); } $activityTypeID = $_POST['activityTypeID']; $activityNote = $this->getTrimmedInput('activityNote', $_POST); $activityNote = htmlspecialchars($activityNote); /* Add the activity entry. */ $activityEntries = new ActivityEntries($this->_siteID); $activityID = $activityEntries->add($contactID, DATA_ITEM_CONTACT, $activityTypeID, $activityNote, $this->_userID, $regardingID); $activityTypes = $activityEntries->getTypes(); $activityTypeDescription = ResultSetUtility::getColumnValueByIDValue($activityTypes, 'typeID', $activityTypeID, 'type'); $activityAdded = true; } else { $activityAdded = false; $activityNote = ''; $activityTypeDescription = ''; } if ($this->isChecked('scheduleEvent', $_POST)) { /* Bail out if we received an invalid date. */ $trimmedDate = $this->getTrimmedInput('dateAdd', $_POST); if (empty($trimmedDate) || !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid date.'); } /* Bail out if we don't have a valid event type. */ if (!$this->isRequiredIDValid('eventTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid event type ID.'); } /* Bail out if we don't have a valid time format ID. */ if (!isset($_POST['allDay']) || $_POST['allDay'] != '0' && $_POST['allDay'] != '1') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid time format ID.'); } $eventTypeID = $_POST['eventTypeID']; if ($_POST['allDay'] == 1) { $allDay = true; } else { $allDay = false; } $publicEntry = $this->isChecked('publicEntry', $_POST); $reminderEnabled = $this->isChecked('reminderToggle', $_POST); $reminderEmail = $this->getTrimmedInput('sendEmail', $_POST); $reminderTime = $this->getTrimmedInput('reminderTime', $_POST); $duration = -1; /* Is this a scheduled event or an all day event? */ if ($allDay) { $date = DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD); $hour = 12; $minute = 0; $meridiem = 'AM'; } else { /* Bail out if we don't have a valid hour. */ if (!isset($_POST['hour'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid hour.'); } /* Bail out if we don't have a valid minute. */ if (!isset($_POST['minute'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid minute.'); } /* Bail out if we don't have a valid meridiem value. */ if (!isset($_POST['meridiem']) || $_POST['meridiem'] != 'AM' && $_POST['meridiem'] != 'PM') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid meridiem value.'); } $hour = $_POST['hour']; $minute = $_POST['minute']; $meridiem = $_POST['meridiem']; /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $hour, $minute, $meridiem)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); } $description = $this->getTrimmedInput('description', $_POST); $title = $this->getTrimmedInput('title', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($title)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.'); } if ($regardingID > 0) { $eventJobOrderID = $regardingID; } else { $eventJobOrderID = -1; } $calendar = new Calendar($this->_siteID); $eventID = $calendar->addEvent($eventTypeID, $date, $description, $allDay, $this->_userID, $contactID, DATA_ITEM_CONTACT, $eventJobOrderID, $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime, $publicEntry, $_SESSION['CATS']->getTimeZoneOffset()); if ($eventID <= 0) { CommonErrors::fatalModal(COMMONERROR_RECORDERROR, $this, 'Failed to add calendar event.'); } /* Extract the date parts from the specified date. */ $parsedDate = strtotime($date); $formattedDate = date('l, F jS, Y', $parsedDate); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); $eventTypeDescription = ResultSetUtility::getColumnValueByIDValue($calendarEventTypes, 'typeID', $eventTypeID, 'description'); $eventHTML = sprintf('<p>An event of type <span class="bold">%s</span> has been scheduled on <span class="bold">%s</span>.</p>', htmlspecialchars($eventTypeDescription), htmlspecialchars($formattedDate)); $eventScheduled = true; } else { $eventHTML = '<p>No event has been scheduled.</p>'; $eventScheduled = false; } if (isset($_GET['onlyScheduleEvent'])) { $onlyScheduleEvent = true; } else { $onlyScheduleEvent = false; } if (!$activityAdded && !$eventScheduled) { $changesMade = false; } else { $changesMade = true; } if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_POST'))) { return; } $this->_template->assign('contactID', $contactID); $this->_template->assign('regardingID', $regardingID); $this->_template->assign('activityAdded', $activityAdded); $this->_template->assign('activityDescription', $activityNote); $this->_template->assign('activityType', $activityTypeDescription); $this->_template->assign('eventScheduled', $eventScheduled); $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent); $this->_template->assign('eventHTML', $eventHTML); $this->_template->assign('changesMade', $changesMade); $this->_template->assign('isFinishedMode', true); $this->_template->display('./modules/contacts/AddActivityScheduleEventModal.tpl'); }
private function newSubmissions() { /* Grab an instance of Statistics. */ $statistics = new Statistics($this->_siteID); $RS = $statistics->getSubmissionsByPeriod(TIME_PERIOD_LASTTWOWEEKS); // FIXME: Factor out these calculations? Common to most of these graphs. $firstDay = mktime(0, 0, 0, DateUtility::getAdjustedDate('m'), DateUtility::getAdjustedDate('d') - DateUtility::getAdjustedDate('w') - 7, DateUtility::getAdjustedDate('Y')); $y = array(); for ($i = 0; $i < 14; $i++) { $thisDay = mktime(0, 0, 0, date('m', $firstDay), date('d', $firstDay) + $i, date('Y', $firstDay)); $y[] = date('d', $thisDay); } /* Get values. */ $x = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); foreach ($RS as $lineRS) { $thisDay = mktime(0, 0, 0, $lineRS['month'], $lineRS['day'], $lineRS['year']); $dayOfWeek = (int) date('w', $thisDay); if (DateUtility::getWeekNumber($thisDay) != DateUtility::getWeekNumber()) { $x[$dayOfWeek]++; } else { $x[$dayOfWeek + 7]++; } } $graph = new GraphSimple($y, $x, 'Orange', 'New Submissions', $this->width, $this->height); if (!eval(Hooks::get('GRAPH_NEW_SUBMISSIONS'))) { return; } $graph->draw(); die; }
/** * Preforms some basic find/replace rules on template text and returns the * resulting string. * * @param string template text * @return string modified template text */ public function replaceVariables($text) { $email = $_SESSION['CATS']->getEmail(); $siteName = $_SESSION['CATS']->getSiteName(); $fullName = $_SESSION['CATS']->getFullName(); if ($_SESSION['CATS']->isDateDMY()) { $dateFormat = 'd-m-y'; } else { $dateFormat = 'm-d-y'; } if (isset($_SESSION['CATS'])) { $isLoggedIn = $_SESSION['CATS']->isLoggedIn(); } else { $isLoggedIn = false; } /* Variables to be replaced. */ $stringsToFind = array('%DATETIME%', '%SITENAME%', '%USERFULLNAME%', '%USERMAIL%'); if ($isLoggedIn) { $replacementStrings = array(DateUtility::getAdjustedDate($dateFormat . ' g:i A'), $siteName, $fullName, '<a href="mailto:' . $email . '">' . $email . '</a>'); } else { $site = new Site(-1); $siteID = $site->getFirstSiteID(); if (!eval(Hooks::get('CAREERS_SITEID'))) { return; } $siteRS = $site->getSiteBySiteID($siteID); if (!isset($siteRS['name'])) { die('An error has occurred: No site exists with this site name.'); } $siteName = $siteRS['name']; $replacementStrings = array(DateUtility::getAdjustedDate($dateFormat . ' g:i A'), $siteName, '', '<a href="mailto:' . $email . '">' . $email . '</a>'); } return str_replace($stringsToFind, $replacementStrings, $text); }
private function displayPublicJobOrders() { $site = new Site(-1); $careerPortalSiteID = $site->getFirstSiteID(); if (!eval(Hooks::get('RSS_SITEID'))) { return; } $jobOrders = new JobOrders($careerPortalSiteID); $rs = $jobOrders->getAll(JOBORDERS_STATUS_ACTIVE, -1, -1, -1, false, true); // Log that this file was accessed // FIXME: Does this really need to involve two queries? Can we store // the IDs in constants too? HTTPLogger::addHTTPLog(HTTPLogger::getHTTPLogTypeIDByName('xml'), $careerPortalSiteID); /* XML Headers */ header('Content-type: text/xml'); $indexName = CATSUtility::getIndexName(); $availTemplates = XmlTemplate::getTemplates(); if (isset($_GET['t'])) { $templateName = $_GET['t']; // Check if the template exists foreach ($availTemplates as $template) { if (!strcasecmp($template['xml_template_name'], $templateName)) { $templateSections = XmlTemplate::loadTemplate($templateName); } } } // no template exists, load the default (which will always be first) if (!isset($templateSections)) { $templateSections = XmlTemplate::loadTemplate($templateName = $availTemplates[0]["xml_template_name"]); } // get the section bodies from the template into strings $templateHeader = $templateSections[XTPL_HEADER_STRING]; $templateJob = $templateSections[XTPL_JOB_STRING]; $templateFooter = $templateSections[XTPL_FOOTER_STRING]; $tags = XmlTemplate::loadTemplateTags($templateHeader); foreach ($tags as $tag) { switch ($tag) { case 'date': $templateHeader = XmlTemplate::replaceTemplateTags($tag, DateUtility::getRSSDate(), $templateHeader); break; case 'siteURL': $templateHeader = XmlTemplate::replaceTemplateTags($tag, CATSUtility::getAbsoluteURI(''), $templateHeader); break; } } $stream = $templateHeader; $tags = XmlTemplate::loadTemplateTags($templateJob); $careerPortalSettings = new CareerPortalSettings($careerPortalSiteID); $settings = $careerPortalSettings->getAll(); if ($settings['allowBrowse'] == 1) { // browse the jobs, adding a section body for each job foreach ($rs as $rowIndex => $row) { $txtJobPosting = $templateJob; foreach ($tags as $tag) { switch ($tag) { case 'siteURL': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, substr(CATSUtility::getAbsoluteURI(''), 0, -4), $txtJobPosting); break; case 'jobTitle': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $row['title'], $txtJobPosting); break; case 'jobPostDate': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, DateUtility::getRSSDate(strtotime($row['dateCreatedSort'])), $txtJobPosting); break; case 'jobURL': $uri = sprintf("%scareers/?p=showJob&ID=%d&ref=%s", substr(CATSUtility::getAbsoluteURI(), 0, -4), $row['jobOrderID'], $templateName); $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $uri, $txtJobPosting); break; case 'jobID': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $row['jobOrderID'], $txtJobPosting); break; case 'hiringCompany': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, 'CATS (www.catsone.com)', $txtJobPosting); break; case 'jobCity': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $row['city'], $txtJobPosting); break; case 'jobState': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $row['state'], $txtJobPosting); break; // FIXME: Make this expandable to non-US? // FIXME: Make this expandable to non-US? case 'jobCountry': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, "US", $txtJobPosting); break; case 'jobZipCode': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, '', $txtJobPosting); break; case 'jobDescription': $txtJobPosting = XmlTemplate::replaceTemplateTags($tag, $row['jobDescription'], $txtJobPosting); break; } } $stream .= $txtJobPosting; } } $stream .= $templateFooter; echo $stream; }
public function generateJobOrderReportPDF() { /* E_STRICT doesn't like FPDF. */ $errorReporting = error_reporting(); error_reporting($errorReporting & ~ E_STRICT); include_once('./lib/fpdf/fpdf.php'); error_reporting($errorReporting); // FIXME: Hook? $isASP = $_SESSION['CATS']->isASP(); $unixName = $_SESSION['CATS']->getUnixName(); $siteName = $this->getTrimmedInput('siteName', $_GET); $companyName = $this->getTrimmedInput('companyName', $_GET); $jobOrderName = $this->getTrimmedInput('jobOrderName', $_GET); $periodLine = $this->getTrimmedInput('periodLine', $_GET); $accountManager = $this->getTrimmedInput('accountManager', $_GET); $recruiter = $this->getTrimmedInput('recruiter', $_GET); $notes = $this->getTrimmedInput('notes', $_GET); if (isset($_GET['dataSet'])) { $dataSet = $_GET['dataSet']; $dataSet = explode(',', $dataSet); } else { $dataSet = array(4, 3, 2, 1); } /* PDF Font Face. */ // FIXME: Customizable. $fontFace = 'helvetica'; $pdf=new \TCPDF(); //$pdf = new FPDF(); $pdf->AddPage(); if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_PRE'))) return; $pdf->SetFont($fontFace, 'B', 10); if ($isASP && $unixName == 'cognizo') { /* TODO: MAKE THIS CUSTOMIZABLE FOR EVERYONE. */ $pdf->Image('images/cognizo-logo.jpg', 130, 10, 59, 20); $pdf->SetXY(129,27); $pdf->Write(5, 'Information Technology Consulting'); } $pdf->SetXY(25, 35); $pdf->SetFont($fontFace, 'BU', 14); $pdf->Write(5, "Recruiting Summary Report\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, DateUtility::getAdjustedDate('l, F d, Y') . "\n\n\n"); $pdf->SetFont($fontFace, 'B', 10); $pdf->SetX(25); $pdf->Write(5, 'Company: '. $companyName . "\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Position: ' . $jobOrderName . "\n\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Period: ' . $periodLine . "\n\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Account Manager: ' . $accountManager . "\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Recruiter: ' . $recruiter . "\n"); /* Note that the server is not logged in when getting this file from * itself. */ // FIXME: Pass session cookie in URL? Use cURL and send a cookie? I // really don't like this... There has to be a way. // FIXME: "could not make seekable" - http://demo.catsone.net/index.php?m=graphs&a=jobOrderReportGraph&data=%2C%2C%2C // in /usr/local/www/catsone.net/data/lib/fpdf/fpdf.php on line 1500 $URI = CATSUtility::getAbsoluteURI( CATSUtility::getIndexName() . '?m=graphs&a=jobOrderReportGraph&data=' . urlencode(implode(',', $dataSet)) ); $pdf->Image($URI, 70, 95, 80, 80, 'jpg'); $pdf->SetXY(25,180); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(255, 0, 0); $pdf->Write(5, 'Screened'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' by ' . $siteName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(0, 125, 0); $pdf->Write(5, 'Submitted'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' to ' . $companyName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(0, 0, 255); $pdf->Write(5, 'Interviewed'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' by ' . $companyName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(255, 75, 0); $pdf->Write(5, 'Placed'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' at ' . $companyName . ": \n\n\n"); if ($notes != '') { $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, "Notes:\n"); $len = strlen($notes); $maxChars = 70; $pdf->SetLeftMargin(25); $pdf->SetRightMargin(25); $pdf->SetX(25); $pdf->Write(5, $notes . "\n"); } $pdf->SetXY(165, 180); $pdf->SetFont($fontFace, 'B', 10); $pdf->Write(5, $dataSet[0] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[1] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[2] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[3] . "\n\n"); $pdf->Rect(3, 6, 204, 285); if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_POST'))) return; $pdf->Output(); die(); }
public function onEditEvent() { 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 event ID. */ if (!$this->isRequiredIDValid('eventID', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid event ID.'); } // FIXME: typeID /* Bail out if we don't have a valid event type. */ if (!$this->isRequiredIDValid('type', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid event type ID.'); } /* If we don't have a valid event duration, set duration to 30. */ if (!$this->isOptionalIDValid('duration', $_POST)) { $duration = 30; } else { $duration = $_POST['duration']; } /* If we have a valid data item type / ID, associate it. */ if ($this->isRequiredIDValid('dataItemID', $_POST) && $this->isRequiredIDValid('dataItemType', $_POST)) { $dataItemID = $_POST['dataItemID']; $dataItemType = $_POST['dataItemType']; } else { $dataItemID = 'NULL'; $dataItemType = 'NULL'; } /* If we have a valid job order ID, associate it. */ if ($this->isRequiredIDValid('jobOrderID', $_POST)) { $jobOrderID = $_POST['jobOrderID']; } else { $jobOrderID = 'NULL'; } /* Bail out if we received an invalid date. */ $trimmedDate = $this->getTrimmedInput('dateEdit', $_POST); if (empty($trimmedDate) || !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY)) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.'); } /* Bail out if we don't have a valid time format ID. */ if (!isset($_POST['allDay']) || ($_POST['allDay'] != '0' && $_POST['allDay'] != '1')) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid time format ID.'); } $eventID = $_POST['eventID']; $type = $_POST['type']; if ($_POST['allDay'] == 1) { $allDay = true; } else { $allDay = false; } $publicEntry = $this->isChecked('publicEntry', $_POST); $reminderEnabled = $this->isChecked('reminderToggle', $_POST); $description = $this->getTrimmedInput('description', $_POST); $title = $this->getTrimmedInput('title', $_POST); $reminderEmail = $this->getTrimmedInput('sendEmail', $_POST); $reminderTime = $this->getTrimmedInput('reminderTime', $_POST); // FIXME: Reminder time must be an integer! /* Bail out if any of the required fields are empty. */ if (empty($title)) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.'); } /* Is this a scheduled event or an all day event? */ if ($allDay) { $date = DateUtility::convert( '-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD ); $hour = 12; $minute = 0; $meridiem = 'AM'; } else { /* Bail out if we don't have a valid hour. */ if (!isset($_POST['hour'])) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid hour.'); } /* Bail out if we don't have a valid minute. */ if (!isset($_POST['minute'])) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid minute.'); } /* Bail out if we don't have a valid meridiem value. */ if (!isset($_POST['meridiem']) || ($_POST['meridiem'] != 'AM' && $_POST['meridiem'] != 'PM')) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid meridiem value.'); } $hour = $_POST['hour']; $minute = $_POST['minute']; $meridiem = $_POST['meridiem']; /* Convert formatted time to UNIX timestamp. */ $time = strtotime( sprintf('%s:%s %s', $hour, $minute, $meridiem) ); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf( '%s %s', DateUtility::convert( '-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD ), date('H:i:00', $time) ); } if (!eval(Hooks::get('CALENDAR_EDIT_PRE'))) return; /* Update the event. */ $calendar = new Calendar($this->_siteID); if (!$calendar->updateEvent($eventID, $type, $date, $description, $allDay, $dataItemID, $dataItemType, 'NULL', $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime, $publicEntry, $_SESSION['CATS']->getTimeZoneOffset())) { CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to update calendar event.'); } if (!eval(Hooks::get('CALENDAR_EDIT_POST'))) return; /* Extract the date parts from the specified date. */ $parsedDate = strtotime($date); $day = date('j', $parsedDate); $month = date('n', $parsedDate); $year = date('Y', $parsedDate); /* Transfer to same url without a=editEvent. */ $newGet = $_GET; $newParams = array(); unset($newGet['a']); $newGet['showEvent'] = $eventID; foreach ($newGet AS $name => $value) { $newParams[] = urlencode($name) . '=' . urlencode($value); } CATSUtility::transferRelativeURI(implode('&', $newParams)); }
/** * Formats SQL result set for display. This is factored out for code * clarity. * * @param array result set from listByView() * @return array formatted result set */ private function _formatListByViewResults($resultSet) { if (empty($resultSet)) { return $resultSet; } foreach ($resultSet as $rowIndex => $row) { /* Get info strings for popup titles */ $resultSet[$rowIndex]['jobOrderInfo'] = InfoString::make(DATA_ITEM_JOBORDER, $resultSet[$rowIndex]['jobOrderID'], $this->_siteID); $resultSet[$rowIndex]['companyInfo'] = InfoString::make(DATA_ITEM_COMPANY, $resultSet[$rowIndex]['companyID'], $this->_siteID); /* Truncate job order title. */ if (strlen($resultSet[$rowIndex]['title']) > self::TRUNCATE_JOBORDER_TITLE) { $resultSet[$rowIndex]['title'] = substr($resultSet[$rowIndex]['title'], 0, self::TRUNCATE_JOBORDER_TITLE) . "..."; } /* Truncate company name. */ if (strlen($resultSet[$rowIndex]['companyName']) > self::TRUNCATE_CLIENT_NAME) { $resultSet[$rowIndex]['companyName'] = substr($resultSet[$rowIndex]['companyName'], 0, self::TRUNCATE_CLIENT_NAME) . "..."; } /* Convert '00-00-00' dates to empty strings. */ $resultSet[$rowIndex]['startDate'] = DateUtility::fixZeroDate($resultSet[$rowIndex]['startDate']); /* Hot jobs [can] have different title styles than normal * jobs. */ if ($resultSet[$rowIndex]['isHot'] == 1) { $resultSet[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $resultSet[$rowIndex]['linkClass'] = 'jobLinkCold'; } $resultSet[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['recruiterFirstName'], $resultSet[$rowIndex]['recruiterLastName'], false, LAST_NAME_MAXLEN); $resultSet[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['ownerFirstName'], $resultSet[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); if ($resultSet[$rowIndex]['attachmentPresent'] == 1) { $resultSet[$rowIndex]['iconTag'] = '<img src="images/paperclip.gif" alt="" width="16" height="16" />'; } else { $resultSet[$rowIndex]['iconTag'] = ' '; } } if (!eval(Hooks::get('JO_FORMAT_LIST_BY_VIEW_RESULTS'))) { return; } return $resultSet; }
/** * Returns the "Quick Links" navigation HTML for the top right corner of * the Activities page. * * @return string "Quick Links" HTML */ public function getQuickLinks() { $today = array( 'month' => date('n'), 'day' => date('j'), 'year' => date('Y') ); $yesterdayTimeStamp = DateUtility::subtractDaysFromDate(time(), 1); $yesterday = array( 'month' => date('n', $yesterdayTimeStamp), 'day' => date('j', $yesterdayTimeStamp), 'year' => date('Y', $yesterdayTimeStamp) ); $baseURL = sprintf( '%s?m=activity&a=viewByDate&getback=getback', CATSUtility::getIndexName() ); $quickLinks[0] = sprintf( '<a href="%s&startMonth=%s&startDay=%s&startYear=%s&endMonth=%s&endDay=%s&endYear=%s">Today</a>', $baseURL, $today['month'], $today['day'], $today['year'], $today['month'], $today['day'], $today['year'] ); $quickLinks[1] = sprintf( '<a href="%s&startMonth=%s&startDay=%s&startYear=%s&endMonth=%s&endDay=%s&endYear=%s">Yesterday</a>', $baseURL, $yesterday['month'], $yesterday['day'], $yesterday['year'], $yesterday['month'], $yesterday['day'], $yesterday['year'] ); $quickLinks[2] = sprintf( '<a href="%s&period=lastweek">Last Week</a>', $baseURL ); $quickLinks[3] = sprintf( '<a href="%s&period=lastmonth">Last Month</a>', $baseURL ); $quickLinks[4] = sprintf( '<a href="%s&period=lastsixmonths">Last 6 Months</a>', $baseURL ); $quickLinks[5] = sprintf( '<a href="%s&period=all">All</a>', $baseURL ); return implode(' | ', $quickLinks); }
/** * Processes an Add Activity / Change Status form and displays * candidates/AddActivityChangeStatusModal.tpl. This is factored out * for code clarity. * * @param boolean from joborders module perspective * @param integer "regarding" job order ID or -1 * @param string module directory * @return void */ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID, $directoryOverride = '') { $notificationHTML = ''; $pipelines = new Pipelines($this->_siteID); $statusRS = $pipelines->getStatusesForPicking(); /* Module directory override for fatal() calls. */ if ($directoryOverride != '') { $moduleDirectory = $directoryOverride; } else { $moduleDirectory = $this->_moduleDirectory; } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('candidateID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); } /* Do we have a valid status ID. */ if (!$this->isOptionalIDValid('statusID', $_POST)) { $statusID = -1; } else { $statusID = $_POST['statusID']; } $candidateID = $_POST['candidateID']; if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_PRE'))) { return; } if ($this->isChecked('addActivity', $_POST)) { /* Bail out if we don't have a valid job order ID. */ if (!$this->isOptionalIDValid('activityTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.'); } $activityTypeID = $_POST['activityTypeID']; $activityNote = $this->getTrimmedInput('activityNote', $_POST); $activityNote = htmlspecialchars($activityNote); // FIXME: Move this to a highlighter-method? */ if (strpos($activityNote, 'Status change: ') === 0) { foreach ($statusRS as $data) { $activityNote = StringUtility::replaceOnce($data['status'], '<span style="color: #ff6c00;">' . $data['status'] . '</span>', $activityNote); } } /* Add the activity entry. */ $activityEntries = new ActivityEntries($this->_siteID); $activityID = $activityEntries->add($candidateID, DATA_ITEM_CANDIDATE, $activityTypeID, $activityNote, $this->_userID, $regardingID); $activityTypes = $activityEntries->getTypes(); $activityTypeDescription = ResultSetUtility::getColumnValueByIDValue($activityTypes, 'typeID', $activityTypeID, 'type'); $activityAdded = true; } else { $activityAdded = false; $activityNote = ''; $activityTypeDescription = ''; } if ($regardingID <= 0 || $statusID == -1) { $statusChanged = false; $oldStatusDescription = ''; $newStatusDescription = ''; } else { $data = $pipelines->get($candidateID, $regardingID); /* Bail out if we got an empty result set. */ if (empty($data)) { $this->fatalModal('The specified pipeline entry could not be found.'); } $validStatus = ResultSetUtility::findRowByColumnValue($statusRS, 'statusID', $statusID); /* If the status is invalid or unchanged, don't mess with it. */ if ($validStatus === false || $statusID == $data['status']) { $oldStatusDescription = ''; $newStatusDescription = ''; $statusChanged = false; } else { $oldStatusDescription = $data['status']; $newStatusDescription = ResultSetUtility::getColumnValueByIDValue($statusRS, 'statusID', $statusID, 'status'); if ($oldStatusDescription != $newStatusDescription) { $statusChanged = true; } else { $statusChanged = false; } } if ($statusChanged && $this->isChecked('triggerEmail', $_POST)) { $customMessage = $this->getTrimmedInput('customMessage', $_POST); // FIXME: Actually validate the e-mail address? if (empty($data['candidateEmail'])) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> An e-mail notification' . ' could not be sent to the candidate because the candidate' . ' does not have a valid e-mail address.</p>'; } else { if (empty($customMessage)) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> An e-mail notification' . ' will not be sent because the message text specified was blank.</p>'; } else { if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> Demo users can not send' . ' E-Mails. No E-Mail was sent.</p>'; } else { $email = $data['candidateEmail']; $notificationHTML = '<p>An e-mail notification has been sent to the candidate.</p>'; } } } } else { $email = ''; $customMessage = ''; $notificationHTML = '<p>No e-mail notification has been sent to the candidate.</p>'; } /* Set the pipeline entry's status, but don't send e-mails for now. */ $pipelines->setStatus($candidateID, $regardingID, $statusID, $email, $customMessage); /* If status = placed, and open positions > 0, reduce number of open positions by one. */ if ($statusID == PIPELINE_STATUS_PLACED && is_numeric($data['openingsAvailable']) && $data['openingsAvailable'] > 0) { $jobOrders = new JobOrders($this->_siteID); $jobOrders->updateOpeningsAvailable($regardingID, $data['openingsAvailable'] - 1); } } if ($this->isChecked('scheduleEvent', $_POST)) { /* Bail out if we received an invalid date. */ $trimmedDate = $this->getTrimmedInput('dateAdd', $_POST); if (empty($trimmedDate) || !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid date.'); } /* Bail out if we don't have a valid event type. */ if (!$this->isRequiredIDValid('eventTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid event type ID.'); } /* Bail out if we don't have a valid time format ID. */ if (!isset($_POST['allDay']) || $_POST['allDay'] != '0' && $_POST['allDay'] != '1') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid time format ID.'); } $eventTypeID = $_POST['eventTypeID']; if ($_POST['allDay'] == 1) { $allDay = true; } else { $allDay = false; } $publicEntry = $this->isChecked('publicEntry', $_POST); $reminderEnabled = $this->isChecked('reminderToggle', $_POST); $reminderEmail = $this->getTrimmedInput('sendEmail', $_POST); $reminderTime = $this->getTrimmedInput('reminderTime', $_POST); $duration = $this->getTrimmedInput('duration', $_POST); /* Is this a scheduled event or an all day event? */ if ($allDay) { $date = DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD); $hour = 12; $minute = 0; $meridiem = 'AM'; } else { /* Bail out if we don't have a valid hour. */ if (!isset($_POST['hour'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid hour.'); } /* Bail out if we don't have a valid minute. */ if (!isset($_POST['minute'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid minute.'); } /* Bail out if we don't have a valid meridiem value. */ if (!isset($_POST['meridiem']) || $_POST['meridiem'] != 'AM' && $_POST['meridiem'] != 'PM') { $this->fatalModal('Invalid meridiem value.', $moduleDirectory); } $hour = $_POST['hour']; $minute = $_POST['minute']; $meridiem = $_POST['meridiem']; /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $hour, $minute, $meridiem)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); } $description = $this->getTrimmedInput('description', $_POST); $title = $this->getTrimmedInput('title', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($title)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this); return; /*$this->fatalModal( 'Required fields are missing.', $moduleDirectory );*/ } if ($regardingID > 0) { $eventJobOrderID = $regardingID; } else { $eventJobOrderID = -1; } $calendar = new Calendar($this->_siteID); $eventID = $calendar->addEvent($eventTypeID, $date, $description, $allDay, $this->_userID, $candidateID, DATA_ITEM_CANDIDATE, $eventJobOrderID, $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime, $publicEntry, $_SESSION['CATS']->getTimeZoneOffset()); if ($eventID <= 0) { $this->fatalModal('Failed to add calendar event.', $moduleDirectory); } /* Extract the date parts from the specified date. */ $parsedDate = strtotime($date); $formattedDate = date('l, F jS, Y', $parsedDate); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); $eventTypeDescription = ResultSetUtility::getColumnValueByIDValue($calendarEventTypes, 'typeID', $eventTypeID, 'description'); $eventHTML = sprintf('<p>An event of type <span class="bold">%s</span> has been scheduled on <span class="bold">%s</span>.</p>', htmlspecialchars($eventTypeDescription), htmlspecialchars($formattedDate)); $eventScheduled = true; } else { $eventHTML = '<p>No event has been scheduled.</p>'; $eventScheduled = false; } if (isset($_GET['onlyScheduleEvent'])) { $onlyScheduleEvent = true; } else { $onlyScheduleEvent = false; } if (!$statusChanged && !$activityAdded && !$eventScheduled) { $changesMade = false; } else { $changesMade = true; } if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_POST'))) { return; } $this->_template->assign('candidateID', $candidateID); $this->_template->assign('regardingID', $regardingID); $this->_template->assign('oldStatusDescription', $oldStatusDescription); $this->_template->assign('newStatusDescription', $newStatusDescription); $this->_template->assign('statusChanged', $statusChanged); $this->_template->assign('activityAdded', $activityAdded); $this->_template->assign('activityDescription', $activityNote); $this->_template->assign('activityType', $activityTypeDescription); $this->_template->assign('eventScheduled', $eventScheduled); $this->_template->assign('eventHTML', $eventHTML); $this->_template->assign('notificationHTML', $notificationHTML); $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent); $this->_template->assign('changesMade', $changesMade); $this->_template->assign('isFinishedMode', true); $this->_template->assign('isJobOrdersMode', $isJobOrdersMode); $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl'); }