/** * 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() { if (!$this->hasPermission('task(person_can_edit_child_form_person_position)')) { $this->userMessage("You can change a person's position"); return false; } $pers_pos = $this->factory->createContainer('person_position|0'); if (!$pers_pos instanceof I2CE_Form) { I2CE::raiseError("no person position"); return; } $this->new_position = false; if ($this->isPost()) { if (array_key_exists('forms', $this->post) && is_array($this->post['forms']) && array_key_exists('person_position', $this->post['forms']) && is_array($this->post['forms']['person_position']) && array_key_exists(0, $this->post['forms']['person_position']) && is_array($this->post['forms']['person_position'][0]) && count($this->post['forms']['person_position'][0]) == 1) { reset($this->post['forms']['person_position'][0]); $pers_pos->setFromPost(current($this->post['forms']['person_position'][0])); } if ($this->post_exists('position_option') && $this->post('position_option') == 'create') { $pers_pos->getField('position')->setOption('required', false); $this->new_position = $this->factory->createContainer('position|0'); $this->new_position->setFromPost(current($this->post['forms']['position'][0])); } /* if (!$pers_pos->end_date->isValid() ) { $pers_pos->end_date = I2CE_Date::now(); } */ } elseif ($this->get_exists('id')) { $pers_pos->setID($this->get('id')); $pers_pos->populate(); } elseif ($this->get_exists('parent')) { $pers_pos->setParent($this->get('parent')); } if ($this->get_exists('position')) { $pers_pos->getField("position")->setFromDB($this->get('position')); } $person = $this->factory->createContainer($pers_pos->getParent()); if (!$person instanceof I2CE_Form) { I2CE::raiseError("no person form :" . $pers_pos->getParent()); return; } $person->populate(); $this->setObject($pers_pos, I2CE_PageForm::EDIT_PRIMARY, 'new_position'); $this->setObject($person, I2CE_PageForm::EDIT_PARENT); I2CE_ModuleFactory::callHooks("make_offer_display", $this, $pers_pos); $this->getParent()->populateLast(array("person_position" => "start_date")); $this->old_person_position = $this->getParent()->getLastPosition(); if ($this->getParent()->isActive() && $this->old_person_position instanceof iHRIS_PersonPosition) { $this->old_position = $this->factory->createContainer($this->old_person_position->getField('position')->getDBValue()); $this->old_position->populate(); //$this->old_position->statusOnly(); if ($this->isPost()) { $this->old_position->setFromPost($this->post['forms']['position'][$this->old_position->getId()]); //$this->old_position->setStatus( $_POST[ $this->old_position->getField('status')->getHTMLName() ] ); //$this->old_person_position->reason = $this->getPrimary()->reason; $this->old_person_position->setFromPost($this->post['forms']['person_position'][$this->old_person_position->getId()]); } //$this->old_position->getField('status')->setMap( "position", "lookupStatus", "listDepartureOptions" ); } else { $this->old_position = false; } if (!$this->new_position && $this->displayPositionForm() && ($this->post('can_edit_position') != "0" && !$this->get_exists('position'))) { $this->new_position = $this->factory->createContainer('position|0'); } //I2CE::raiseMessage(print_r($this->post(),true)); }