/**
  * Handle the actions for the page.
  * @return boolean
  */
 protected function action()
 {
     if (!$this->get_exists('id')) {
         $this->template->addFile("user_alerts_acknowledge_invalid.html");
         return true;
     } else {
         $user_alert = I2CE_FormFactory::instance()->createContainer($this->get('id'));
         if (!$user_alert instanceof iHRIS_UserAlert) {
             $this->template->addFile("user_alerts_acknowledge_invalid.html");
             return true;
         }
         $user_alert->populate();
         $user = $this->getUser();
         if (!$user_alert->getParentId()) {
             $this->template->addFile("user_alerts_acknowledge_invalid.html");
             return true;
         }
         if ($user_alert->getParentId() != $user->username && !$this->hasPermission("task(user_alerts_edit_all)")) {
             $this->template->addFile("user_alerts_acknowledge_perms.html");
             return true;
         }
         if ($user_alert->time_ack->equals(I2CE_Date::blank())) {
             $user_alert->time_ack = I2CE_Date::now();
             $user_alert->save($user);
         }
         if (array_key_exists('HTTP_REFERER', $_SERVER)) {
             $this->setRedirect($_SERVER['HTTP_REFERER']);
         } else {
             $this->setRedirect("view_alerts");
         }
     }
     return true;
 }
 /**
  * Populate the history of entries for the form field if the storage module handles history.
  * @param I2CE_FormField $form_field
  * @return boolean
  */
 public function FF_populateHistory($form_field)
 {
     $field = $form_field->getName();
     $form = $form_field->getContainer();
     if (!$form instanceof I2CE_Form) {
         return false;
     }
     $field_name = $form_field->getName();
     $fields = $this->lookupField($form->getName(), $form->getId(), array($field_name), false);
     if (!is_array($fields) || !array_key_exists($field_name, $fields)) {
         //no data to populate
         return true;
     }
     $last_modified = I2CE_Date::blank();
     $entry = new I2CE_Entry($last_modified, 1, 0, $form_field->getFromDB($fields[$field_name]));
     $form_field->addHistory($entry);
     return true;
 }
 /**
  * Populate the history of entries for the form field if the storage module handles history.
  * @param I2CE_FormField $form_field
  * @return boolean
  */
 public function FF_populateHistory($form_field)
 {
     $field = $form_field->getName();
     $form = $form_field->getContainer();
     if (!$form instanceof I2CE_Form) {
         return false;
     }
     $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array($field), $form->getId());
     $result = $this->db->getRow($fieldQry);
     if (I2CE::pearError($result, "Error populating field {$field} of form " . $form->getName())) {
         return false;
     }
     $ref = strtolower($form->getName() . '+' . $field);
     $entry = new I2CE_Entry(I2CE_Date::blank(), 1, 0, $form_field->getFromDB($result->{$ref}));
     $form_field->addHistory($entry);
     return true;
 }
 /**
  * Returns the value of this field as a human readable format.
  * @param I2CE_Entry $entry If a I2CE_Entry object has been passed to this method then it will return the value for that entry assuming it's an 
  * entry for this field.
  * @return mixed
  */
 public function getDisplayValue($entry = false, $style = 'default')
 {
     if ($entry instanceof I2CE_Entry) {
         $value = $entry->getValue();
     } else {
         $value = $this->getValue();
     }
     if ($value instanceof I2CE_Date) {
         return $value->displayDate();
     } else {
         return I2CE_Date::blank()->displayDate();
     }
 }
 /**
  * Checks to see if the most recent position for this person is still active and doesn't have an end date
  * for his/her position.
  * @see getLastPosition()
  * @return boolean
  */
 public function isActive_PersonPosition($pers_pos)
 {
     if (!$pers_pos instanceof iHRIS_PersonPosition) {
         return false;
     }
     if (isset($pers_pos->end_date) && $pers_pos->end_date instanceof I2CE_Date) {
         if ($pers_pos->end_date->equals(I2CE_Date::blank())) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * Populate the history of entries for the form field if the storage module handles history.
  * @param I2CE_FormField $form_field
  * @return boolean
  */
 public function FF_populateHistory($form_field)
 {
     $field = $form_field->getName();
     $form = $form_field->getContainer();
     if (!$form instanceof I2CE_Form) {
         return false;
     }
     if ($field == 'parent') {
         $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array('last_modified', 'who'), $form->getId(), true);
     } else {
         $fieldQry = $this->getRequiredFieldsQuery($form->getName(), array($field, 'last_modified', 'who'), $form->getId());
     }
     $result = $this->db->getRow($fieldQry);
     if (I2CE::pearError($result, "Error populating field {$field} of form " . $form->getName())) {
         return false;
     }
     $ref = $form->getName() . '+' . $field;
     $last_ref = $form->getName() . '+' . 'last_modified';
     $who_ref = $form->getName() . '+' . 'who';
     $date = null;
     $who = 99;
     if (isset($result->{$last_ref})) {
         $date = I2CE_Date::fromDB($result->{$last_ref});
     }
     if (!$date instanceof I2CE_Date) {
         $date = I2CE_Date::blank();
     }
     if (isset($result->{$who_ref})) {
         $who = $result->{$who_ref};
     }
     if (isset($result->{$ref})) {
         $entry = new I2CE_Entry($date, $who, 0, $form_field->getFromDB($result->{$ref}));
         $form_field->addHistory($entry);
     }
     return true;
 }
 protected function DATE_between_getLimitMenu($type, $fieldObj, $template, $name = '', $vals = array())
 {
     if (!is_array($vals)) {
         $vals = array();
     }
     $menuNode = $template->loadFile('limit_date_choice_between.html');
     if (!$menuNode instanceof DOMNode) {
         I2CE::raiseError("Could not load limit_date_choice_between.html");
         return;
     }
     $minNode = $template->query('.//*[@id="min_val"]', $menuNode);
     $maxNode = $template->query('.//*[@id="max_val"]', $menuNode);
     if ($minNode->length != 1 || $maxNode->length != 1) {
         I2CE::raiseError("Could not find where to put min and max nodes");
         return false;
     }
     $minNode = $minNode->item(0);
     $maxNode = $maxNode->item(0);
     if (array_key_exists('min', $vals)) {
         $min = I2CE_Date::now($type, $vals['min'], 'blank');
     } else {
         $min = I2CE_Date::blank($type);
     }
     if (array_key_exists('max', $vals)) {
         $max = I2CE_Date::now($type, $vals['max'], 'blank');
     } else {
         $max = I2CE_Date::blank($type);
     }
     if ($name) {
         $minName = $name . ':min';
         $maxName = $name . ':max';
     } else {
         $minName = 'min';
         $maxName = 'max';
     }
     self::addDateTimeElements($fieldObj, $template, $min, $minName, $minNode);
     self::addDateTimeElements($fieldObj, $template, $max, $maxName, $maxNode);
     return $menuNode;
 }
 /**
  * Populate the history of entries for the form field if the storage module handles history.
  * @param I2CE_FormField $form_field
  * @return boolean
  */
 public function FF_populateHistory($form_field)
 {
     $form_config = $this->getFormConfig($form_field);
     if ($form_config instanceof I2CE_MagicDataNode) {
         $field_name = $form_field->getName();
         $entry = new I2CE_Entry(I2CE_Date::blank(), 1, 0, $form_field->getFromDB($form_config->fields->{$field_name}));
         $form_field->addHistory($entry);
         return true;
     } else {
         return false;
     }
 }