/** * 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. It determines the type based on the * {@link $type} member variable. */ protected function loadObjects() { $this->student_registration = STS_PageFormPerson::load_current_registration($this->request("parent")); ###Deny drop semester for completed students### $progObj = $this->factory->createContainer($this->student_registration["training_program"]); $progObj->populate(); if ($this->student_registration["admission_type"] == "admission_type|full-time") { $total_semesters = $progObj->getField("total_semesters_fulltime")->getDBValue(); } else { if ($this->student_registration["admission_type"] == "admission_type|part-time") { $total_semesters = $progObj->getField("total_semesters_parttime")->getDBValue(); } } $completed = IHS_PageFormEnrollcourse::completed_school($this->student_registration["semester"], $total_semesters, $this->request("parent")); if ($completed) { $this->userMessage("You Have Completed The Program"); $this->setRedirect("view?id=" . $this->request("parent")); return; } ###End of denying drop semester for completed students### //check to ensure That A Student Must Resume Before Next Drop if ($this->get_exists("parent")) { $parent = $this->request("parent"); $persObj = $this->factory->createContainer($parent); $persObj->populateChildren("drop_semester"); foreach ($persObj->getChildren("drop_semester") as $dropSemObj) { if ($dropSemObj->getField("registration")->getDBValue() != $this->student_registration["id"]) { continue; } $dropSemObj->populateChildren("resume_semester"); $resSemObj = $dropSemObj->getChildren("resume_semester"); if (count($resSemObj) == 0) { $this->userMessage("This Student Is Currently Dropped In A Semester"); $this->setRedirect("view?id=" . $parent); return; } } //avoid a student to drop a semester when GPA is already there $persObj->populateChildren("registration"); $regObjs = $persObj->getChildren("registration"); foreach ($regObjs as $regObj) { if ($regObj->getField("registration_status")->getDBValue() != "registration_status|ongoing") { continue; } $semester = $regObj->getField("semester")->getDBValue(); } $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $semester)), 1 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $parent)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $this->student_registration["id"])))); $semGPA = I2CE_FormStorage::search("semester_GPA", false, $where); if (count($semGPA) > 0) { $this->userMessage("You Cant Drop This Semester"); $this->setRedirect("view?id=" . $parent); return; } } if ($this->isPost()) { $primary = $this->factory->createContainer($this->getForm()); if (!$primary instanceof I2CE_Form) { return false; } $primary->load($this->post); } elseif ($this->get_exists('id')) { if ($this->get_exists('id')) { $id = $this->get('id'); if (strpos($id, '|') === false) { I2CE::raiseError("Deprecated use of id variable"); $id = $this->getForm() . '|' . $id; } } else { $id = $this->getForm() . '|0'; } $primary = $this->factory->createContainer($id); if (!$primary instanceof I2CE_Form || $primary->getName() != $this->getForm()) { I2CE::raiseError("Could not create valid " . $this->getForm() . "form from id:{$id}"); return false; } $primary->populate(); } elseif ($this->get_exists('parent')) { $primary = $this->factory->createContainer($this->getForm()); if (!$primary instanceof I2CE_Form) { return; } $parent = $this->get('parent'); if (strpos($parent, '|') === false) { I2CE::raiseError("Deprecated use of parent variable"); $parent = 'person|' . $parent; } $primary->setParent($parent); } if ($this->isGet()) { $primary->load($this->get()); } $person = parent::loadPerson($primary->getParent()); if (!$person instanceof iHRIS_Person) { I2CE::raiseError("Could not create person form from " . $primary->getParent()); return; } $this->applyLimits($primary); $this->setObject($primary, I2CE_PageForm::EDIT_PRIMARY, null, true); $this->setObject($person, I2CE_PageForm::EDIT_PARENT, null, true); return true; }