/** * Create a new instance of this page. * * This will call the parent constructor and then setup the base * template pages for the {@link I2CE_Template template}. It also sets up the values * for the member variables. * @param string $title The title for this page. * @param string $form_name The form name of the form being edited. * @param mixed $access The role required to access this page. * @param array $files The list of template files to load for this page. */ public function __construct($args, $request_remainder) { $args['page_form'] = 'contact'; //we set it here to avoid an error message but it is not doing antyhign really parent::__construct($args, $request_remainder); if ($this->request_exists('contact_type')) { //we have to do this after the parent contrsuctor is called b/c request/post/get variables have not been processed $form_name = 'person_contact_' . $this->request('contact_type'); $args['page_form'] = $form_name; $this->form_name = $form_name; $this->form_link = 'contact?contact_type=' . $this->request('contact_type'); } else { I2CE::raiseError("no contact type specified"); } }
/** * Checks to see if any of the forms on this page have invalid messages * @return boolean */ public function hasInvalid() { return parent::hasInvalid() || $this->new_position->hasInvalid() || $this->current_person_position->hasInvalid() || $this->new_person_position->hasInvalid() || $this->new_salary->hasInvalid() || $this->current_salary->hasInvalid(); }
/** * Update the position for this to mark it as closed and then save the object. */ public function save() { if (!$this->hasPermission('task(person_can_edit_child_form_person_position)')) { $this->userMessage("You can't change a person's position"); return false; } $new_person_position = $this->getPrimary(); if ($this->post_exists('position_option') && $this->post('position_option') == 'create' && $this->new_position instanceof iHRIS_Position) { $this->new_position->setStatus("position_status|closed"); $this->new_position->save($this->user); $new_person_position->getField("position")->setFromDB($this->new_position->getNameId()); $position = $this->new_position; } else { $position = $this->factory->createContainer($new_person_position->getField("position")->getDBValue()); $position->statusOnly(); $position->closePosition($this->user, $this->getParent()->getId()); } if ($this->getParent()->isActive() && $this->old_position instanceof iHRIS_Position) { $this->old_position->statusOnly(); $this->old_position->save($this->user); $person = $this->getParent(); if ($this->old_person_position instanceof iHRIS_PersonPosition) { $this->old_person_position->end_date = $new_person_position->start_date; $this->old_person_position->save($this->user); I2CE_ModuleFactory::callHooks("make_promotion_save", $this->old_person_position, $new_person_position); } //$this->getPrimary()->reason = null; } I2CE_ModuleFactory::callHooks("make_offer_save", $new_person_position); foreach ($this->objects[self::EDIT_CHILD] as $obj) { if ($obj->getId() == '0') { $obj->setParent($new_person_position); } I2CE_ModuleFactory::callHooks("make_offer_save_" . $obj->getName(), $new_person_position, $obj); } parent::save(); }
/** * Save the objects to the database. * * Save the default object being edited and return to the view page. */ protected function save() { if ($this->creatingNewUser()) { if (!$this->hasPermission('task(users_can_edit)')) { return false; } if (!$this->userObj instanceof I2CE_User_Form || !($username = $this->userObj->username)) { return false; } $accessMech = I2CE::getUserAccess(); if ($accessMech->userExists($username, false)) { I2CE::raiseError("Trying to recreate existing user : " . $username); return false; } if (I2CE_User::hasDetail('creator')) { $this->userObj->creator = $this->user->username; } } return parent::save(); }
/** * Update the position for this to mark it as closed and then save the object. */ public function save() { $this->position->save($this->user); if (($personPosition = $this->getPrimary()) instanceof iHRIS_PersonPosition) { I2CE_ModuleFactory::callHooks("depart_position_save", $personPosition); } parent::save(); }
/** * Save the objects to the database. * * Save the default object being edited and return to the view page. If the action needs to be * logged then the {@link log} method is also called. Any pages overriding this default save method * will need to include any logging necessary. */ protected function save() { parent::save(); $this->setRedirect("view_training?id=" . $this->getPrimary()->getId()); }
/** * 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; }