/**
  * Perform the main actions of the page.
  */
 public function action()
 {
     parent::action();
     $factory = I2CE_FormFactory::instance();
     $this->template->setAttribute("class", "active", "menuDashboard", "a[@href='dashboard']");
     $this->template->appendFileById("menu_dashboard.html", "ul", "menuDashboard");
 }
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $dataelement = $factory->createContainer('dataelement');
         if (!$dataelement instanceof iHRIS_DataElement) {
             I2CE::raiseError("Could not create Data Element form");
             return;
         }
         $dataelement->load($this->post);
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'dataelement|' . $id;
             }
         } else {
             $id = 'dataelement|0';
         }
         $dataelement = $factory->createContainer($id);
         if (!$dataelement instanceof iHRIS_DataElement) {
             I2CE::raiseError("Could not create valid Data Element form from id:{$id}");
             return;
         }
         $dataelement->populate();
         $dataelement->load($this->request());
     }
     $this->setObject($dataelement);
 }
 /**
  * Perform the actions of this page.
  * @return boolean
  */
 protected function action()
 {
     if (parent::action()) {
         $next_month = getdate(mktime(0, 0, 0, $this->month + 1, 1, $this->year));
         $db_start = sprintf('%04d-%02d-%02d', $this->year, $this->month, 1);
         $db_end = sprintf('%04d-%02d-%02d', $next_month['year'], $next_month['mon'], $next_month['mday']);
         $find_instances = array('operator' => 'OR', 'operand' => array(0 => array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'style' => 'greaterthan_equals', 'field' => 'start_date', 'data' => array('value' => $db_start)), 1 => array('operator' => 'FIELD_LIMIT', 'style' => 'lessthan', 'field' => 'start_date', 'data' => array('value' => $db_end)))), 1 => array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'style' => 'greaterthan_equals', 'field' => 'end_date', 'data' => array('value' => $db_start)), 1 => array('operator' => 'FIELD_LIMIT', 'style' => 'lessthan', 'field' => 'end_date', 'data' => array('value' => $db_end))))));
         $instances = I2CE_FormStorage::search("scheduled_training_course", false, $find_instances);
         $factory = I2CE_FormFactory::instance();
         $month_end = new DateTime($db_end);
         $deviation = 35;
         $base = array(70, 116, 149);
         foreach ($instances as $instance) {
             $rgb = array();
             foreach ($base as $idx => $num) {
                 $rgb[$idx] = rand($num - $deviation, $num + $deviation);
             }
             $inst = $factory->createContainer("scheduled_training_course|{$instance}");
             $inst->populate();
             $this->addForm($inst, $inst->start_date->getDateTimeObj(), $inst->end_date->getDateTimeObj(), 'calendar_training_course_day.html', $rgb);
         }
     } else {
         return false;
     }
     return true;
 }
 /**
  * Create a new instance of a page.
  * 
  * The default constructor should be called by any pages extending this object.  It creates the
  * {@link I2CE_Template} and {@link I2CE_User} objects and sets up the basic member variables.
  * @param array $args
  * @param array $request_remainder The remainder of the request path
  */
 public function __construct($args, $request_remainder, $get = null, $post = null)
 {
     parent::__construct($args, $request_remainder, $get, $post);
     $this->form_factory = I2CE_FormFactory::instance();
     $this->check_map = I2CE_ModuleFactory::instance()->isEnabled("Lists");
     $this->locale = I2CE_Locales::DEFAULT_LOCALE;
 }
 /**
  * Perform the main actions of the page.
  * @return boolean
  */
 protected function action()
 {
     if (!parent::action()) {
         return false;
     }
     if (!$this->hasPermission("task(person_can_edit_child_form_person_instance)")) {
         $this->userMessage("You do not have permission to edit participants for this instance.");
         return false;
     }
     if (!$this->get_exists('person') || !$this->get_exists('instance')) {
         $this->template->addFile('action_participants_error.html');
         return true;
     }
     $person_instance = $this->getPersonInstance($this->get('person'), $this->get('instance'));
     $piObj = I2CE_FormFactory::instance()->createContainer("person_instance|" . $person_instance);
     if ($person_instance) {
         $piObj->populate();
         if ($piObj->attending == 0) {
             $piObj->attending = 1;
             $this->template->addFile("action_participants_add.html");
         } else {
             $piObj->attending = 0;
             $this->template->addFile("action_participants_remove.html");
         }
     } else {
         $piObj->setParent($this->get('person'));
         $piObj->getField('provider_instance')->setFromDB($this->get('instance'));
         $piObj->getField('attending')->setFromDB(1);
         $this->template->addFile("action_participants_add.html");
     }
     return $piObj->save($this->user);
 }
 protected function loadObjects()
 {
     if (!$this->hasPermission("task(can_schedule_students_course_enrollment)") or $this->getUser()->role == "admin") {
         $this->setRedirect("noaccess");
     }
     $factory = I2CE_FormFactory::instance();
     $username = $this->getUser()->username;
     $training_institution = IHS_PageFormLecturer::fetch_institution($username);
     $where = array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution));
     $fields = I2CE_FormStorage::search("schedule_course_enrollment", false, $where);
     foreach ($fields as $id) {
         //do nothing
     }
     if ($id) {
         $form = "schedule_course_enrollment|" . $id;
     } else {
         $form = "schedule_course_enrollment";
     }
     $courseEnrObj = $factory->createContainer($form);
     $courseEnrObj->populate();
     if ($this->isPost()) {
         $courseEnrObj->load($this->post);
     }
     $courseEnrObj->getField("training_institution")->setFromDB($training_institution);
     $this->setObject($courseEnrObj);
 }
 protected function ensureLimits()
 {
     if ($this->ensured) {
         return;
     }
     if ($this->storage->is_scalar()) {
         return false;
     }
     if (!$this->parent instanceof I2CE_Swiss_CustomReports_Report_ReportingForm_Field) {
         return false;
     }
     $factory = I2CE_FormFactory::instance();
     $formName = $this->parent->getForm();
     $formObj = $factory->createForm($formName);
     if (!$formObj instanceof I2CE_Form) {
         I2CE::raiseError("Could not instantiate the form {$formName}  at " . $this->configPath);
         return false;
     }
     $field = $this->parent->getName();
     $allowed_limits = $formObj->getLimitStyles($field);
     $excludes = I2CE::getConfig()->getAsArray("/modules/CustomReports/limit_excludes/displayed");
     foreach ($allowed_limits as $limit => $data) {
         if (in_array($limit, $excludes)) {
             continue;
         }
         $swissLimit = $this->getChild($limit, true);
         if (is_array($data) && count($data) == 1 && in_array('value', $data)) {
             $swissLimit->setAllowPivot(true);
         } else {
             $swissLimit->setAllowPivot(false);
         }
     }
     $this->ensured = true;
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.
  */
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $trainingprovider = $factory->createContainer('trainingprovider');
         if (!$trainingprovider instanceof iHRIS_TrainingProvider) {
             I2CE::raiseError("Could not create trainingprovider form");
             return;
         }
         $trainingprovider->load($this->post);
         $name_ignore = $trainingprovider->getField('name_ignore');
         $ignore_path = array('forms', 'trainingprovider', $trainingprovider->getID(), 'ignore', 'name');
         if ($name_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
             $name_ignore->setFromPost($this->post($ignore_path));
         }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'trainingprovider|' . $id;
             }
         } else {
             $id = 'trainingprovider|0';
         }
         $trainingprovider = $factory->createContainer($id);
         if (!$trainingprovider instanceof iHRIS_TrainingProvider) {
             I2CE::raiseError("Could not create valid trainingprovider form from id:{$id}");
             return;
         }
         $trainingprovider->populate();
     }
     $this->setObject($trainingprovider);
 }
 protected function noData($contentNode)
 {
     if (!($noDataNode = $this->template->appendFileByNode("customReports_notfound.html", 'div', $contentNode)) instanceof DOMNode) {
         return;
     }
     $link = '';
     if (!$this->config->setIfIsSet($link, 'create_link') || !$link) {
         return;
     }
     $createNode = $this->template->addFile("customReports_notfound_create.html", 'div', $noDataNode);
     if (!$createNode instanceof DOMNode) {
         return;
     }
     if (!($linkNode = $this->template->getElementByName('create_form_link', 0)) instanceof DOMNode) {
         return;
     }
     $this->template->addHeaderLink('create_from_limits.js');
     $rel = $this->reportObj->getFormRelationship();
     $form = $rel->getPrimaryForm();
     if (!($formObj = I2CE_FormFactory::instance()->createContainer($form)) instanceof I2CE_Form) {
         return;
     }
     $form_name = $formObj->getDisplayName();
     $js = 'createFormFromSearch(this,"' . $form . '");';
     $linkNode->setAttribute('onClick', $js);
     $this->template->setDisplayData('has_create_data', 1, $createNode);
     $this->template->setDisplayData('create_form_link', $link, $createNode);
     $this->template->setDisplayData('create_form_name', $form_name, $createNode);
 }
Exemplo n.º 10
0
 /**
  * Perform the main actions of the page.
  */
 protected function action()
 {
     $factory = I2CE_FormFactory::instance();
     $this->template->setAttribute("class", "active", "menuConfigure", "a[@href='configure']");
     $this->template->appendFileById("menu_configure.html", "ul", "menuConfigure");
     parent::action();
 }
Exemplo n.º 11
0
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.
  */
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $person = $factory->createContainer('person');
         if (!$person instanceof iHRIS_Person) {
             I2CE::raiseError("Could not create person form");
             return;
         }
         $person->load($this->post);
         $surname_ignore = $person->getField('surname_ignore');
         $ignore_path = array('forms', 'person', $person->getID(), 'ignore', 'surname');
         if ($surname_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
             $surname_ignore->setFromPost($this->post($ignore_path));
         }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'person|' . $id;
             }
         } else {
             $id = 'person|0';
         }
         $person = $factory->createContainer($id);
         if (!$person instanceof iHRIS_Person) {
             I2CE::raiseError("Could not create valid person form from id:{$id}");
             return;
         }
         $person->populate();
         $person->load($this->request());
     }
     $this->setObject($person, I2CE_PageForm::EDIT_PRIMARY, null, true);
 }
 protected function action()
 {
     if (!parent::action()) {
         return false;
     }
     I2CE::raiseError("aremaC <- sthgiL");
     if (!is_scalar($search_form = array_shift($this->request_remainder)) || !($search_obj = I2CE_FormFactory::instance()->createContainer($search_form)) instanceof CSD_SearchMatches || (!($matches = $search_obj->getField('matches'))) instanceof I2CE_FormField_ASSOC_MAP_RESULTS) {
         return false;
     }
     I2CE::raiseError(print_r($this->request(), true));
     if (($maxField = $search_obj->getField('max')) instanceof I2CE_FormField_INT) {
         if ($maxField->getValue() > 200) {
             $maxField->setValue(200);
         }
     }
     $search_obj->load($this->post, false, false);
     I2CE::raiseError($search_obj->getXMLRepresentation(false));
     $search_obj->setID("1");
     //so it will populate
     $search_obj->populate(true);
     if (count($results = $matches->getValue()) > 200) {
         return false;
         I2CE::raiseError("Too many results");
     }
     $this->data['length'] = count($results);
     $this->data['data'] = $results;
     I2CE::raiseError("REQ=" . print_r($this->request(), true));
     $this->data = array($this->data);
     I2CE::raiseError(print_r($this->data, true));
     return true;
 }
 /**
  * Set up the main object for this page as well as the training provider.
  */
 protected function loadPrimaryObject()
 {
     $this->factory = I2CE_FormFactory::instance();
     if (!$this->request_exists('id')) {
         $this->userMessage("Invalid Training Provider Requested");
         return false;
     }
     if ($this->request_exists('id')) {
         $id = $this->request('id');
         if (strpos($id, '|') === false) {
             I2CE::raiseError("Deprecated use of id variable");
             $id = 'trainingprovider|' . $id;
         }
     } else {
         $id = 'trainingprovider|0';
     }
     $this->mainObj = $this->factory->createContainer($id);
     $this->mainObj->populate();
     if (!$this->mainObj instanceof iHRIS_TrainingProvider && $this->mainObj->getParentID() != 0) {
         $provider = $this->factory->createContainer($this->mainObj->getParent());
         $provider->populate();
         $this->template->setForm($provider);
     }
     $this->template->setForm($this->mainObj);
 }
 public function validate_form_reschedule_course($form)
 {
     $semester = implode("|", $form->new_semester);
     $course = implode("|", $form->training);
     $academic_year = implode("|", $form->academic_year);
     $username = $this->getUser()->username;
     $training_institution = iHRIS_PageFormLecturer::fetch_institution($username);
     $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $course)), 2 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $training_institution))));
     $is_rescheduled = I2CE_FormStorage::search("reschedule_course", false, $where);
     if (count($is_rescheduled) > 0) {
         $form->setInvalidMessage("training", "This Course Already Rescheduled For This Semester In This Academic Year");
     }
     $ff = I2CE_FormFactory::instance();
     if (!($courseObj = $ff->createContainer($course)) instanceof iHRIS_Training) {
         return;
     }
     $courseObj->populate();
     $crs_semester = $courseObj->getField("semester")->getDBValue();
     if ($crs_semester == $semester) {
         $form->setInvalidMessage("new_semester", "This Course Is Currently Offered In This Semester");
         return;
     }
     $sem = $form->new_semester[1];
     $crs_semester = explode("|", $crs_semester);
     $crs_semester = $crs_semester[1];
     if ($crs_semester > $sem or $sem - $crs_semester != 1) {
         $form->setInvalidMessage("new_semester", "A Course Must Be Rescheduled To A Next Semester");
     }
 }
 /**
  * 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;
 }
 /**
  * Load the history object for this page.
  */
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     $this->history = $factory->createContainer($this->get('id'));
     $this->history->populate();
     $this->template->setForm($this->history);
 }
 protected function loadObjects()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->isPost()) {
         $dataset = $factory->createContainer('dataset');
         if (!$dataset instanceof iHRIS_DataSet) {
             I2CE::raiseError("Could not create Data Set form");
             return;
         }
         $dataset->load($this->post);
         //$surname_ignore = $person->getField('surname_ignore');
         //$ignore_path = array('forms','person',$person->getID(),'ignore','surname');
         //            if ($surname_ignore instanceof I2CE_FormField && $this->post_exists($ignore_path)) {
         //                $surname_ignore->setFromPost($this->post($ignore_path));
         //            }
     } else {
         if ($this->get_exists('id')) {
             $id = $this->get('id');
             if (strpos($id, '|') === false) {
                 I2CE::raiseError("Depcreated use of id variable");
                 $id = 'dataset|' . $id;
             }
         } else {
             $id = 'dataset|0';
         }
         $dataset = $factory->createContainer($id);
         if (!$dataset instanceof iHRIS_DataSet) {
             I2CE::raiseError("Could not create valid Data Set form from id:{$id}");
             return;
         }
         $dataset->populate();
         $dataset->load($this->request());
     }
     $this->setObject($dataset);
 }
Exemplo n.º 18
0
 /**
  * Check for duplicates and save the user alert
  * @param I2CE_User $user
  * @param boolean $transact
  * @return boolean
  */
 public function save($user, $transact = true)
 {
     if ($this->getId() === '0') {
         $find_duplicates = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'message', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->message))), array('operator' => 'FIELD_LIMIT', 'field' => 'time_ack', 'style' => 'null'), array('operator' => 'FIELD_LIMIT', 'field' => 'alert_type', 'style' => 'equals', 'data' => array('value' => $this->alert_type))));
         if ($this->link == '') {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'null');
         } else {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'equals', 'data' => array('value' => $this->link));
         }
         if ($this->link_text == '') {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'null');
         } else {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->link_text)));
         }
         $found = I2CE_FormStorage::search('user_alert', $this->getParent(), $find_duplicates, array("-time_sent"), 1);
         if ($found) {
             I2CE::raiseMessage("found duplicates so increasing repeats. {$found}");
             $duplicate = I2CE_FormFactory::instance()->createContainer("user_alert|" . $found);
             $duplicate->populate();
             $duplicate->repeated++;
             return $duplicate->save($user, $transact);
         }
     }
     return parent::save($user, $transact);
 }
 /**
  * Perform the main actions of the page.
  */
 protected function action()
 {
     parent::action();
     $person_id = 0;
     if ($this->get_exists('parent')) {
         $person_id = $this->get('parent');
     }
     $factory = I2CE_FormFactory::instance();
     $personForm = $factory->createContainer($person_id);
     if (!$personForm instanceof I2CE_Form) {
         return;
     }
     $personForm->populate();
     $this->setForm($personForm);
     $this->setDisplayData('person_id', 'id=' . $person_id);
     if ($this->get_exists('id')) {
         $competency_ids = array($this->get('id'));
     } else {
         $competency_ids = $personForm->getChildIds('person_competency');
     }
     $compAppendNode = $this->template->getElementById('comp_list');
     if (!$compAppendNode instanceof DOMNode) {
         return;
     }
     foreach ($competency_ids as $competency_id) {
         $compNode = $this->template->appendFileByNode("personal_competency_evaluation_history_comp_each.html", 'div', $compAppendNode);
         $compForm = $factory->createContainer('person_competency' . '|' . $competency_id);
         if (!$compForm instanceof I2CE_Form) {
             continue;
         }
         $compForm->populate();
         $this->setForm($compForm, $compNode);
         $competency = $factory->createContainer($compForm->getField("competency")->getDBValue());
         $competency->populate();
         $this->setForm($competency, $compNode);
         $appendNode = $this->template->getElementById('evaluation_list', $compNode);
         if (!$appendNode instanceof DOMNode) {
             return;
         }
         $fields = array('evaluation_date', 'competency_evaluation');
         $compForm->populateHistory($fields);
         $all_dates = array();
         foreach ($fields as $field) {
             while ($compForm->getField($field)->hasNextHistory()) {
                 $entry = $compForm->getField($field)->nextHistory();
                 $all_dates[$entry->date->dbFormat()][$field] = $entry;
             }
         }
         foreach ($all_dates as $entries) {
             $evalNode = $this->template->appendFileByNode("personal_competency_evaluation_history_each.html", 'tr', $appendNode);
             if (!$evalNode instanceof DOMNode) {
                 return;
             }
             foreach ($entries as $field => $entry) {
                 $this->template->setDisplayDataImmediate($field, $compForm->getField($field)->getDisplayValue($entry), $evalNode);
             }
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Return the instance of this factory and create it if it doesn't exist.
  */
 public static function instance()
 {
     //function not needed when updating to php 5.3
     if (!self::$instance instanceof I2CE_FormFactory) {
         self::$instance = new I2CE_FormFactory();
     }
     return self::$instance;
 }
 /**
  * Create and load data for the objects used for this form.
  */
 protected function loadObjects()
 {
     $this->ff = I2CE_FormFactory::instance();
     //check to ensure that the current academic year is available
     iHRIS_AcademicYear::ensureAcademicYear();
     $selected_courses = $this->post("course");
     $person_id = $this->post("person_id");
     $curr_semester = $this->post("curr_semester");
     $student_registration = STS_PageFormPerson::load_current_registration($person_id);
     if (count($selected_courses) == 0) {
         $this->userMessage("No courses Selected!!!");
         $this->setRedirect("view?id=" . $this->person_id);
     }
     foreach ($selected_courses as $course) {
         $courseObj = $this->factory->createContainer($course);
         $courseObj->populate();
         $total_credits = $total_credits + $courseObj->getField("course_credits")->getDBValue();
     }
     $selected_courses = implode(",", $selected_courses);
     $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $person_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $curr_semester)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $student_registration["id"]))));
     $enrolled_courses = I2CE_FormStorage::search("enroll_course", false, $where);
     if (count($enrolled_courses) > 0) {
         foreach ($enrolled_courses as $enrollment) {
             $course_enrollment_form = "enroll_course|" . $enrollment;
         }
     } else {
         $course_enrollment_form = "enroll_course";
     }
     if (!($enrollcourseObj = $this->ff->createContainer($course_enrollment_form)) instanceof I2CE_Form) {
         I2CE::raiseError("Invalid Object");
         return false;
     }
     $trainingCourseField = $enrollcourseObj->getField("training");
     $trainingCourseField->setFromPost($selected_courses);
     $date_enrolled = date("Y-m-d");
     $enrollcourseObj->getField("date_enrolled")->setFromDB($date_enrolled);
     $semesterField = $enrollcourseObj->getField("semester");
     $semesterField->setFromPost($curr_semester);
     $enrollcourseObj->getField("total_credits")->setValue($total_credits);
     $enrollcourseObj->getField("registration")->setFromDB($student_registration["id"]);
     $current_academic_year = iHRIS_AcademicYear::currentAcademicYear();
     $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year);
     $academic_year_id = "academic_year|" . $academic_year_id;
     if (!($academicYearField = $enrollcourseObj->getField("academic_year")) instanceof I2CE_FormField_MAP) {
         return;
     }
     $academicYearField->setFromDB($academic_year_id);
     $parentObj = $this->ff->createContainer($person_id);
     if ($parentObj instanceof I2CE_Form) {
         $parentObj->populate();
     }
     $this->setObject($enrollcourseObj, I2CE_PageForm::EDIT_PRIMARY);
     $this->setObject($parentObj, I2CE_PageForm::EDIT_PARENT);
     parent::save();
     $this->userMessage("Courses Enrolled Successfully");
     $this->setRedirect("view?id=" . $person_id);
     return true;
 }
Exemplo n.º 22
0
 protected function getAllowedStyles()
 {
     $styles = array();
     if ($this->parent instanceof I2CE_Swiss_SVS && ($list = $this->parent->getField('list')) && ($listObj = I2CE_FormFactory::instance()->createContainer($list)) instanceof I2CE_List && is_array($lists = $listObj->getMeta('list'))) {
         $styles = array_keys($lists);
     }
     $styles = array_unique(array_merge($styles, array('default', 'id')));
     return $styles;
 }
 public function __construct($user = false)
 {
     I2CE_CachedForm::$spam = false;
     if (!$user instanceof I2CE_User) {
         $user = new I2CE_User();
     }
     $this->user = $user;
     $this->factory = I2CE_FormFactory::instance();
     $this->unique_fields = array();
 }
 public function action_drop_semester($page)
 {
     if (!$page instanceof iHRIS_PageView) {
         return false;
     }
     $template = $page->getTemplate();
     $appendNode = $template->getElementById('drop_semester');
     if (!$appendNode instanceof DOMNode) {
         return true;
     }
     $person = $page->getPerson();
     if (!$person instanceof iHRIS_Person) {
         return false;
     }
     $factory = I2CE_FormFactory::instance();
     $where = array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => "person|" . $person->getId()));
     $dropped_semIds = I2CE_FormStorage::search("drop_semester", false, $where);
     $drpsem = array();
     foreach ($dropped_semIds as $id) {
         $dropSemForm = $factory->createContainer('drop_semester' . '|' . $id);
         $dropSemForm->populate();
         $drpsem[] = $dropSemForm;
     }
     if (count($drpsem) == 0) {
         return false;
     }
     foreach ($drpsem as $child) {
         $node = $template->appendFileByNode('view_drop_semester.html', 'div', $appendNode);
         if (!$node instanceof DOMNode) {
             I2CE::raiseError("Could not find template {$template} for child form {$form} of person");
             return false;
         }
         $template->setForm($child, $node);
         $child->populateChildren('resume_semester');
         $resumes = $child->getChildren('resume_semester');
         if (count($resumes) > 0) {
             $template->setDisplayDataImmediate('has_exam_results', 1, $node);
             foreach ($resumes as $resume) {
                 if (!($resumeNode = $template->appendFileById('view_resume_semester.html', 'tbody', 'resume_semester', false, $node)) instanceof DOMNode) {
                     continue;
                 }
                 $template->setForm($resume, $resumeNode);
             }
         } else {
             $template->setDisplayDataImmediate('has_resume_semester', 0, $node);
         }
         $drop_semester = $factory->createContainer($child->drop_semester);
         if (!$drop_semester instanceof iHRIS_DropSemester || $drop_semester->getId() == '0') {
             I2CE::raiseError("Bad Drop Semester:" . $child->drop_semester);
             continue;
         }
         $drop_semester->populate();
         $template->setForm($drop_semester, $node);
     }
 }
 public function __construct($args, $request_remainder, $get = null, $post = null)
 {
     parent::__construct($args, $request_remainder, $get, $post);
     if ($this->request_exists('id')) {
         $id = $this->request('id');
         I2CE::raiseError("Recevied ({$id})");
         if (($this->person = I2CE_FormFactory::instance()->createContainer($id)) instanceof I2CE_Form) {
             $this->person->populate();
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Initializes any data for the page.
  *
  * @return boolean
  */
 protected function initPage()
 {
     $factory = I2CE_FormFactory::instance();
     if ($this->get_exists('username')) {
         $this->view_user = $factory->createContainer("user" . '|' . $this->get('username'));
         $this->view_user->populate();
     } else {
         $this->setRedirect("user");
     }
     return true;
 }
Exemplo n.º 27
0
 protected function _display($supress_output = false)
 {
     $this->template->addHeaderLink('mootools-core.js');
     $this->template->addHeaderLink('mootools-more.js');
     parent::_display($supress_output);
     if ($errors = I2CE_Dumper::cleanlyEndOutputBuffers()) {
         I2CE::raiseError("Errors:\n" . $errors);
     }
     $this->ff = I2CE_FormFactory::instance();
     if (!$this->request_exists('id') || !($formid = $this->request('id'))) {
         $this->pushError("Bad list id {$id}");
         //needs to be localized
         return false;
     }
     $success = true;
     list($form, $id) = array_pad(explode("|", $formid, 2), 2, '');
     I2CE::raiseError(print_r($this->request(), true));
     if ($id == '*') {
         $where = array('operator' => 'FIELD_LIMIT', 'field' => 'remap', 'style' => 'not_null', 'data' => array());
         $ids = I2CE_FormStorage::search($form, false, $where);
         I2CE::raiseError("Form {$form} has remapping data for " . implode(" ", $ids));
         if (count($ids) > 0) {
             foreach (I2CE_List::getFieldsMappingToList($form) as $rform => $fields) {
                 foreach ($fields as $fieldObj) {
                     $field = $fieldObj->getName();
                     foreach ($ids as $id) {
                         I2CE::raiseError("Checking for remaps on {$rform}+{$field}");
                         $success &= $this->doRemap($rform, $field, $form . '|' . $id);
                     }
                 }
             }
         }
         $url = "index.php/auto_list?form=" . $form;
     } else {
         $form = '';
         if (!$this->request_exists('form') || !($form = $this->request('form')) || !in_array($form, $this->ff->getForms())) {
             $this->pushError("Form {$form} not found");
             return false;
         }
         $field = '';
         if (!$this->request_exists('field') || !($field = $this->request('field'))) {
             $this->pushError("Bad Field {$field}");
             return false;
         }
         $success = $this->doRemap($form, $field, $formid);
         $url = "index.php/auto_list?id={$formid}&form=" . $form;
     }
     if ($success) {
         $this->pushContent("Data was succesully remapped.  Continue on to database lists <a href='{$url}'>site</a>?");
     } else {
         $this->pushContent("Data was <b>not</b> succesully remapped.  Continue on to database lists <a href='{$url}'>site</a>?");
     }
     return true;
 }
 public function getFieldNames()
 {
     if (!($formObj = I2CE_FormFactory::instance()->createContainer($this->getFormName())) instanceof I2CE_Form) {
         I2CE::raiseError("Bad form object");
         return array();
     }
     $fields = $formObj->getFieldNames();
     if (!is_array($fields)) {
         $fields = array();
     }
     return $fields;
 }
 protected function loadPrimary()
 {
     $formFactory = I2CE_FormFactory::instance();
     if ($this->get_exists('id')) {
         if (!($this->primObj = $formFactory->createContainer($this->get('id'))) instanceof I2CE_Form || $this->formRelationship->getPrimaryForm() != $this->primObj->getName()) {
             I2CE::raiseError("invalid form id :" . print_r($this->request(), true) . "\ndoes not match " . $this->formRelationship->getPrimaryForm());
             return false;
         }
         $this->primObj->populate();
     }
     return true;
 }
Exemplo n.º 30
0
 /**
  * Hooked method to marks a form as dirty (needs to be cached).
  * @param mixed $args.   an array of two elements whose first element is a form object, the second is the user
  */
 public function removeCache_hook($args)
 {
     if (!is_array($args) || !array_key_exists('form', $args)) {
         return;
     }
     $form = $args['form'];
     if (!$form instanceof I2CE_Form) {
         return;
     }
     $ff = I2CE_FormFactory::instance();
     $ff->removeFromCache($form);
     $form->cleanup();
 }