public function save() { $project_id = phpgw::get_var('id'); if ($project_id && is_numeric($project_id)) { $project = $this->so->get_single($project_id); } else { $project = new logistic_project(); } $project->populate(); if ($project->validate()) { $project_id = $this->so->store($project); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'logistic.uiproject.view', 'id' => $project_id)); } else { $this->edit($project); } }
protected function populate(int $project_id, &$project) { if ($project == null) { $project = new logistic_project((int) $project_id); $project->set_name($this->unmarshal($this->db->f('name'), 'string')); $project->set_description($this->unmarshal($this->db->f('description'), 'string')); $project->set_project_type_id($this->unmarshal($this->db->f('project_type_id'), 'int')); if ($project->get_project_type_id() && $project->get_project_type_id() > 0) { $project->set_project_type_label($this->get_project_type_label($this->unmarshal($this->db->f('project_type_id'), 'int'))); } $project->set_start_date($this->unmarshal($this->db->f('start_date'), 'int')); $project->set_end_date($this->unmarshal($this->db->f('end_date'), 'int')); } return $project; }
/** * Get a static reference to the storage object associated with this model object * * @return the storage object */ public static function get_so() { if (self::$so == null) { self::$so = CreateObject('logistic.soproject'); } return self::$so; }