protected function populate(int $activity_id, &$activity)
 {
     if ($activity == null) {
         $activity = new logistic_activity((int) $activity_id);
         $activity->set_name($this->unmarshal($this->db->f('name'), 'string'));
         $activity->set_description($this->unmarshal($this->db->f('description'), 'string'));
         $activity->set_parent_id($this->unmarshal($this->db->f('parent_activity_id'), 'int'));
         $activity->set_project_id($this->unmarshal($this->db->f('project_id'), 'int'));
         $activity->set_start_date($this->unmarshal($this->db->f('start_date'), 'int'));
         $activity->set_end_date($this->unmarshal($this->db->f('end_date'), 'int'));
         $activity->set_responsible_user_id($this->unmarshal($this->db->f('responsible_user_id'), 'int'));
         $activity->set_create_date($this->unmarshal($this->db->f('create_date'), 'int'));
         $activity->set_create_user($this->unmarshal($this->db->f('create_user'), 'int'));
         $activity->set_update_date($this->unmarshal($this->db->f('update_date'), 'int'));
         $activity->set_update_user($this->unmarshal($this->db->f('update_user'), 'int'));
     }
     return $activity;
 }
 public function save()
 {
     $activity_id = phpgw::get_var('id');
     if ($activity_id && is_numeric($activity_id)) {
         $activity = $this->so->get_single($activity_id);
     } else {
         $activity = new logistic_activity();
     }
     $activity->populate();
     //_debug_array($activity);die();
     if ($activity->validate()) {
         $activity_id = $this->so->store($activity);
         $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'logistic.uiactivity.view', 'id' => $activity_id, 'project_id' => $activity->get_project_id()));
     } else {
         $this->acl_edit($activity);
     }
 }
 /**
  * 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.soactivity');
     }
     return self::$so;
 }