Ejemplo n.º 1
0
/**
 * Convert an XML timetable to ICAL
 */
function XMLTimeTableToICAL($raw)
{
    global $CAMPUSM_XML;
    $cal = new Calendar();
    // This is a bit of a mess
    $parsed = new SimpleXMLElement($raw);
    // Extract the children of the children with the correct namespace
    $entries = $parsed->children($CAMPUSM_XML)->children($CAMPUSM_XML);
    foreach ($entries->calitem as $calitem) {
        $cal->addEvent(new CalendarEvent($calitem->desc1, $calitem->locCode, new DateTime($calitem->start), new DateTime($calitem->end), $calitem->desc2));
    }
    return $cal;
}
Ejemplo n.º 2
0
 /**
  * Add an event to the array of active events
  * @param object
  * @param integer
  * @param integer
  * @param string
  * @param string
  */
 protected function addEvent($objEvent, $intStart, $intEnd, $strUrl, $strLink)
 {
     parent::addEvent($objEvent, $intStart, $intEnd, $strUrl, $strLink);
     if ($GLOBALS['tags']['showInFeeds']) {
         if ($intStart < time()) {
             return;
         }
         $intKey = date('Ymd', $intStart);
         $lastindex = count($this->arrEvents[$intKey][$intStart]) - 1;
         $tags = $this->getTagsForTableAndId('tl_calendar_events', $objEvent->id);
         if (strlen($tags)) {
             $this->arrEvents[$intKey][$intStart][$lastindex]['description'] .= $tags;
         }
     }
 }
Ejemplo n.º 3
0
        } elseif ($e['appointment_status'] === "student_arrived") {
            $category = "st-arrived";
        } elseif ($e['appointment_status'] === "follow_up_complete") {
            $category = "follow-up-complete";
        }
        if ($e['appointment_description'] == null) {
            $e['appointment_description'] = "";
        }
        //Create the event array the itself holds event objects
        $event_array[] = array('id' => $e['event_id'], 'parent_event_id' => $e['parent_event_id'], 'emp_id' => $e['emp_id'], 'last_modified' => $e['last_modified'], 'lm_fname' => $e['lm_fname'], 'lm_lname' => $e['lm_lname'], 'updated_on' => $l10nDate->format($e['updated_on'], 'date_time'), 'series' => $e['recurrence_parent_event_id'], 'invited' => "", 'creator_alt' => "", 'invited_alt' => "", 'cfname' => $e['first_name'], 'clname' => $e['last_name'], 'title' => $e['label'], 'type' => $e['appointment_type_id'], 'start' => $e['appointment_start'], 'end' => $e['appointment_end'], 'className' => $category, 'description' => $e['appointment_description'], 'sname' => $e['st_fname'] . ' ' . $e['st_lname'], 'snumber' => $e['student'], 'estatus' => $e['appointment_status'], 'arrivalstatus' => $e['student_arrival_status'], 'allDay' => $e['all_day'] === "1" ? true : false, 'color' => $e['background_color'], 'textColor' => $e['text_color'], 'borderColor' => "white", 'dass_alert' => $e['dass_alert'], 'dass_count' => $e['dass_count']);
    }
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($event_array);
    exit;
} elseif ($_GET['page'] === "add-event") {
    $cal->addEvent($_POST);
    $loggers['audit']->info("Event added to calendar");
} elseif ($_GET['page'] === "delete-event") {
    if ($_POST['series'] !== 'true') {
        $cal->deleteEvent($_POST['event_id']);
        $loggers['audit']->info("Event {$_POST['event_id']} deleted from calendar");
    } else {
        $cal->deleteFutureEvents($_POST['event_id'], $_POST['recurrence_parent_event_id']);
        $loggers['audit']->info("All future events of recurrence parent event {$_POST['event_id']} deleted from calendar");
    }
} elseif ($_GET['page'] === "update-event") {
    if (isset($_POST['update_recurring']) && $_POST['update_recurring'] === 'all-future') {
        $cal->updateFutureEvents($_POST['event_id'], $_POST);
        $loggers['audit']->info("All future events of recurrence parent event {$_POST['event_id']} updated in calendar");
    } else {
        $cal->updateEvent($_POST['event_id'], $_POST);
Ejemplo n.º 4
0
</form></div></div>-->

<?php 
$cal = new Calendar($this->curDate);
//        $cal->addEvent('event 1');
//        $cal->addEvent('event 2', 10);
//$cal->addEvent('event 3', 10, 10);
//        $cal->addEvent('event 4', 10, 10, 10);
foreach ($this->event as $val) {
    $event = $val['keterangan'];
    $tgl = str_replace("-", "", $val['tgl']);
    $date = substr($tgl, -2);
    $month = substr($tgl, 4, 2);
    $year = substr($tgl, 2, 2);
    //    echo $year.'-'.$month.'-'.$date.'-'.$event;
    $cal->addEvent($event, $date, $month, $year);
}
echo "<div id=table-wrapper>";
$cal->makeCalendar();
//$cal->makeEvents();
echo "</div>";
?>

<!--    </td></tr></table>-->
<script>
    
    $(document).ready(function(){
//        $('#form-wrapper').fadeOut(0);
        $('#warning').fadeOut(0);
    });
    
Ejemplo n.º 5
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');
 }
Ejemplo n.º 6
0
 /**
  * Return the calendar
  */
 public function get_view($date = '', $type = '', $widget = 0, $ecwd_views, $preview)
 {
     require_once 'calendar-class.php';
     $categories = get_categories(array('taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category'));
     $tags = get_terms('ecwd_event_tag', array('hide_empty' => false));
     //Get events data
     //Generate the calendar markup and return it
     $cal = new Calendar($type, $date, '', $widget, $this->page_items, $this->page, $this->displays, $this->filters, $this->event_search, array(), $preview);
     $search_params = $this->search;
     if (is_array($search_params) && (isset($search_params['query']) && $search_params['query'] !== '' || isset($search_params['category']) && $search_params['category'] > 0 || isset($search_params['tag']) && $search_params['tag'] > 0) || isset($search_params['venue']) && $search_params['venue'] > 0 || isset($search_params['organizer']) && $search_params['organizer'] > 0) {
         $cal->search_params = $this->search;
     }
     if ($categories) {
         $cal->add_terms('categories', $categories);
     }
     if ($tags) {
         $cal->add_terms('tags', $tags);
     }
     $args = array('post_type' => ECWD_PLUGIN_PREFIX . '_venue', 'post_status' => 'publish', 'posts_per_page' => -1, 'ignore_sticky_posts' => 1);
     $venues = get_posts($args);
     if ($venues) {
         $cal->add_terms('venues', $venues);
     }
     $args = array('post_type' => ECWD_PLUGIN_PREFIX . '_organizer', 'post_status' => 'publish', 'posts_per_page' => -1, 'ignore_sticky_posts' => 1);
     $organizers = get_posts($args);
     if ($organizers) {
         $cal->add_terms('organizers', $organizers);
     }
     if ($this->events) {
         foreach ($this->events as $id => $event) {
             $cal->addEvent($event);
         }
     }
     return $cal->showcal();
 }
Ejemplo n.º 7
0
    public function onAddEvent()
    {
        if ($this->_accessLevel < ACCESS_LEVEL_EDIT)
        {
            CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Invalid user level for action.');
        }

        /* Bail out if we received an invalid date. */
        $trimmedDate = $this->getTrimmedInput('dateAdd', $_POST);
        if (empty($trimmedDate) ||
            !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY))
        {
            CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.');
        }

        // 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 dur = 30. */
        if (!$this->isOptionalIDValid('duration', $_POST))
        {
            $duration = 30;
        }
        else
        {
            $duration = $_POST['duration'];
        }

        /* 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_BADINDEX, $this, 'Invalid time format ID.');
        }

        $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)
            );
        }

        $timeZoneOffset = $_SESSION['CATS']->getTimeZoneOffset();

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

        $calendar = new Calendar($this->_siteID);
        $eventID = $calendar->addEvent(
            $type, $date, $description, $allDay, $this->_userID, -1, -1, -1,
            $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime,
            $publicEntry, $timeZoneOffset
        );

        if ($eventID <= 0)
        {
            CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to add calendar event.');
        }

        /* 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=addEvent. */
        $newGet = $_GET;
        $newParams = array();

        unset($newGet['a']);
        $newGet['showEvent'] = $eventID;

        foreach ($newGet AS $name => $value)
        {
            $newParams[] = urlencode($name) . '=' . urlencode($value);
        }

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

        CATSUtility::transferRelativeURI(implode('&', $newParams));
    }
Ejemplo n.º 8
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');
 }