Пример #1
0
 /**
  * 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');
 }
Пример #2
0
 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');
 }
Пример #3
0
    public function showCalendar()
    {
        $currentHour     = DateUtility::getAdjustedDate('H');
        $currentDay      = DateUtility::getAdjustedDate('j');
        $currentMonth    = DateUtility::getAdjustedDate('n');
        $currentYear     = DateUtility::getAdjustedDate('Y');
        $currentUnixTime = DateUtility::getAdjustedDate();
        $currentDateMDY  = DateUtility::getAdjustedDate('m-d-y');

        $currentWeek  = DateUtility::getWeekNumber($currentUnixTime) - DateUtility::getWeekNumber(
            mktime(0, 0, 0, $currentMonth, 1, $currentYear)
        );

        /* Do we have a valid date argument? If a month was specified and
         * isn't valid, fatal() out. If none was specified, use the current
         * month.
         */
        if ($this->isRequiredIDValid('month', $_GET) &&
            $this->isRequiredIDValid('year', $_GET))
        {
            $month = $_GET['month'];
            $year  = $_GET['year'];

            if (!checkdate($month, 1, $year))
            {
                CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.');
            }

            if ($month == $currentMonth && $year == $currentYear)
            {
                $isCurrentMonth = true;
            }
            else
            {
                $isCurrentMonth = false;
            }
        }
        else
        {
            $month = $currentMonth;
            $year  = $currentYear;
            $isCurrentMonth = true;
        }

        if (isset($_GET['view']))
        {
            $view = $_GET['view'];
        }
        else
        {
            $view = 'DEFAULT_VIEW';
        }

        if (isset($_GET['week']))
        {
            $week = $_GET['week'];
        }
        else
        {
            $week = $currentWeek+1;
        }

        if (isset($_GET['day']))
        {
            $day = $_GET['day'];
        }
        else
        {
            $day = $currentDay;
        }

        if (isset($_GET['showEvent']))
        {
            $showEvent = $_GET['showEvent'];
        }
        else
        {
            $showEvent = null;
        }

        $userIsSuperUser = ($this->_accessLevel < ACCESS_LEVEL_SA ? 0 : 1);
        if ($userIsSuperUser && isset($_GET['superuser']) && $_GET['superuser'] == 1)
        {
            $superUserActive = true;
        }
        else
        {
            $superUserActive = false;
        }

        $startingWeekday = DateUtility::getStartingWeekday($month, $year);
        $daysInMonth     = DateUtility::getDaysInMonth($month, $year);

        $calendar = new Calendar($this->_siteID);

        $monthBefore = $month - 1;
        $monthAfter  = $month + 1;
        $yearBefore  = $year;
        $yearAfter   = $year;

        if ($monthAfter > 12)
        {
            $monthAfter = 1;
            $yearAfter = $year + 1;
        }

        if ($monthBefore < 1)
        {
            $monthBefore = 12;
            $yearBefore = $year - 1;
        }

        $eventsStringNow = $calendar->makeEventString(
            $calendar->getEventArray($month, $year),
            $month,
            $year
        );

        $eventsStringBefore = $calendar->makeEventString(
            $calendar->getEventArray($monthBefore, $yearBefore),
            $monthBefore,
            $yearBefore
        );

        $eventsStringAfter = $calendar->makeEventString(
            $calendar->getEventArray($monthAfter, $yearAfter),
            $monthAfter,
            $yearAfter
        );

        $eventsString = implode(
            '@',
            array($eventsStringNow, $eventsStringBefore, $eventsStringAfter, $userIsSuperUser)
        );

        /* Textual representation of the month and year. */
        $dateString = date(
            'F Y',
            mktime($_SESSION['CATS']->getTimeZoneOffset(), 0, 0, $month, 1, $year)
        );

        /* The offset is the number of days after the first Sunday on a given
         * calendar page on which the 1st of the month falls. We subtract 1
         * because Sunday has a value of 1.
         */
        $startingOffset = $startingWeekday - 1;

        $userEmail = $_SESSION['CATS']->getEmail();

        $calendarEventTypes = $calendar->getAllEventTypes();

        $calendarSettings = new CalendarSettings($this->_siteID);
        $calendarSettingsRS = $calendarSettings->getAll();

        if ($view == 'DEFAULT_VIEW')
        {
            $view = $calendarSettingsRS['calendarView'];
        }

        $summaryHTML = $calendar->getUpcomingEventsHTML(12, UPCOMING_FOR_CALENDAR);

        if (!eval(Hooks::get('CALENDAR_SHOW'))) return;

        if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo())
        {
            $allowEventReminders = true;
        }
        else
        {
            $allowEventReminders = false;
        }

        /* FIXME: Configurable */
        $this->_template->assign('dayHourStart', $calendarSettingsRS['dayStart']);
        $this->_template->assign('dayHourEnd', $calendarSettingsRS['dayStop']);
        $this->_template->assign('firstDayMonday', $calendarSettingsRS['firstDayMonday']);
        $this->_template->assign('allowAjax', ($calendarSettingsRS['noAjax'] == 0 ? true : false));
        $this->_template->assign('defaultPublic', ($calendarSettingsRS['defaultPublic'] == 0 ? 'false' : 'true'));
        $this->_template->assign('militaryTime', false);

        $this->_template->assign('active', $this);
        $this->_template->assign('currentDateMDY', $currentDateMDY);
        $this->_template->assign('startingWeekday', $startingWeekday);
        $this->_template->assign('daysInMonth', $daysInMonth);
        $this->_template->assign('currentHour', $currentHour);
        $this->_template->assign('currentDay', $currentDay);
        $this->_template->assign('currentMonth', $currentMonth);
        $this->_template->assign('currentYear', $currentYear);
        $this->_template->assign('startingOffset', $startingOffset);
        $this->_template->assign('userEmail', $userEmail);
        $this->_template->assign('userID', $this->_userID);
        $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
        $this->_template->assign('summaryHTML', $summaryHTML);
        $this->_template->assign('userIsSuperUser', $userIsSuperUser);
        $this->_template->assign('superUserActive', $superUserActive);
        $this->_template->assign('calendarEventTypes', $calendarEventTypes);
        $this->_template->assign('view', $view);
        $this->_template->assign('day', $day);
        $this->_template->assign('week', $week);
        $this->_template->assign('month', $month);
        $this->_template->assign('year', $year);
        $this->_template->assign('showEvent', $showEvent);
        $this->_template->assign('dateString', $dateString);
        $this->_template->assign('isCurrentMonth', $isCurrentMonth);
        $this->_template->assign('eventsString', $eventsString);
        $this->_template->assign('allowEventReminders', $allowEventReminders);
        $this->_template->display('./modules/calendar/Calendar.php');
    }
Пример #4
0
 /**
  * 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');
 }