protected function populate(int $party_id, &$party) { if ($party == null) { $party = new rental_party((int) $party_id); $party->set_account_number($this->unmarshal($this->db->f('account_number'), 'string')); $party->set_address_1($this->unmarshal($this->db->f('address_1'), 'string')); $party->set_address_2($this->unmarshal($this->db->f('address_2'), 'string')); $party->set_comment($this->unmarshal($this->db->f('comment'), 'string')); $party->set_company_name($this->unmarshal($this->db->f('company_name'), 'string')); $party->set_department($this->unmarshal($this->db->f('department'), 'string')); $party->set_email($this->unmarshal($this->db->f('email'), 'string')); $party->set_fax($this->unmarshal($this->db->f('fax'), 'string')); $party->set_first_name($this->unmarshal($this->db->f('first_name'), 'string')); $party->set_is_inactive($this->unmarshal($this->db->f('is_inactive'), 'bool')); $party->set_last_name($this->unmarshal($this->db->f('last_name'), 'string')); $party->set_location_id($this->unmarshal($this->db->f('org_location_id'), 'int')); $party->set_identifier($this->unmarshal($this->db->f('identifier'), 'string')); $party->set_mobile_phone($this->unmarshal($this->db->f('mobile_phone'), 'string')); $party->set_place($this->unmarshal($this->db->f('place'), 'string')); $party->set_postal_code($this->unmarshal($this->db->f('postal_code'), 'string')); $party->set_reskontro($this->unmarshal($this->db->f('reskontro'), 'string')); $party->set_title($this->unmarshal($this->db->f('title'), 'string')); $party->set_url($this->unmarshal($this->db->f('url'), 'string')); $party->set_org_enhet_id($this->unmarshal($this->db->f('org_enhet_id'), 'string')); $party->set_unit_leader($this->unmarshal($this->db->f('unit_leader'), 'string')); $sync_message = $party->set_sync_data(array('responsibility_id' => $this->unmarshal($this->db->f('responsibility_id'), 'string'), 'org_enhet_id' => $this->unmarshal($this->db->f('org_enhet_id'), 'string'), 'result_unit_number' => $this->unmarshal($this->db->f('result_unit_number'), 'string'))); if (isset($sync_message) && $sync_message != '') { $party->add_sync_problem($sync_message); } } return $party; }
/** * Public method. Called when user wants to edit a contract party. * @param HTTP::id the party ID */ public function edit() { $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . lang('edit'); // Get the contract part id $party_id = (int) phpgw::get_var('id'); // Retrieve the party object or create a new one if correct permissions if ($this->isExecutiveOfficer() || $this->isAdministrator()) { if (isset($party_id) && $party_id > 0) { $party = rental_soparty::get_instance()->get_single($party_id); } else { $party = new rental_party(); } } else { $this->render('permission_denied.php', array('error' => lang('permission_denied_edit'))); } if (isset($_POST['save_party'])) { if (isset($party)) { // ... set all parameters $party->set_identifier(phpgw::get_var('identifier')); $party->set_first_name(phpgw::get_var('firstname')); $party->set_last_name(phpgw::get_var('lastname')); $party->set_title(phpgw::get_var('title')); $party->set_company_name(phpgw::get_var('company_name')); $party->set_department(phpgw::get_var('department')); $party->set_address_1(phpgw::get_var('address1')); $party->set_address_2(phpgw::get_var('address2')); $party->set_postal_code(phpgw::get_var('postal_code')); $party->set_place(phpgw::get_var('place')); $party->set_phone(phpgw::get_var('phone')); $party->set_mobile_phone(phpgw::get_var('mobile_phone')); $party->set_fax(phpgw::get_var('fax')); $party->set_email(phpgw::get_var('email')); $party->set_url(phpgw::get_var('url')); $party->set_account_number(phpgw::get_var('account_number')); $party->set_reskontro(phpgw::get_var('reskontro')); $party->set_is_inactive(phpgw::get_var('is_inactive') == 'on' ? true : false); $party->set_comment(phpgw::get_var('comment')); //$party->set_location_id(phpgw::get_var('location_id')); $party->set_org_enhet_id(phpgw::get_var('org_enhet_id')); $party->set_unit_leader(phpgw::get_var('unit_leader')); if (rental_soparty::get_instance()->store($party)) { $message = lang('messages_saved_form'); } else { $error = lang('messages_form_error'); } } } $config = CreateObject('phpgwapi.config', 'rental'); $config->read(); return $this->render('party.php', array('party' => $party, 'editable' => true, 'message' => isset($message) ? $message : phpgw::get_var('message'), 'error' => isset($error) ? $error : phpgw::get_var('error'), 'cancel_link' => self::link(array('menuaction' => 'rental.uiparty.index', 'populate_form' => 'yes')), 'use_fellesdata' => $config->config_data['use_fellesdata'])); }