public function add_result_unit(result_unit $result_unit)
 {
     $this->result_units[result_unit::get_identifier_from_name($result_unit->get_name())] = $result_unit;
 }
 public function serialize(rental_contract $contract = null)
 {
     $is_payer = '';
     if (isset($contract) && $contract->get_payer_id() == $this->id) {
         $is_payer = lang('is_payer');
     }
     $address_elements = array($this->address_1, $this->address_2, "{$this->postal_code} {$this->place}");
     $address = '';
     foreach ($address_elements as $element) {
         if ($element != null && $element != '') {
             if ($address != '') {
                 $address .= ', ';
             }
             $address .= $element;
         }
     }
     $location_name = $GLOBALS['phpgw']->locations->get_name($this->location_id);
     $result_unit_number = result_unit::get_identifier_from_name($location_name['location']);
     return array('id' => $this->id, 'name' => $this->get_name(), 'identifier' => $this->identifier, 'firstname' => $this->first_name, 'lastname' => $this->last_name, 'title' => $this->title, 'company_name' => $this->company_name, 'department' => $this->department, 'address' => $address, 'address1' => $this->address_1, 'address2' => $this->address_2, 'postal_code' => $this->postal_code, 'place' => $this->place, 'phone' => $this->phone, 'mobile_phone' => $this->mobile_phone, 'fax' => $this->fax, 'email' => $this->email, 'url' => $this->url, 'location_id' => $this->location_id, 'account_number' => $this->account_number, 'reskontro' => $this->reskontro, 'is_inactive' => $this->is_inactive, 'is_payer' => $is_payer, 'result_unit_number' => $result_unit_number, 'service_id' => $this->sync_data['service_id'], 'responsibility_id' => $this->sync_data['responsibility_id'], 'org_enhet_id' => $this->get_org_enhet_id(), 'unit_leader' => $this->get_unit_leader(), 'sync_message' => implode('<br/>', $this->get_sync_problems()));
 }
 /**
  * Update the database values for an existing party object.
  *
  * @param $party the party to be updated
  * @return boolean true if successful, false otherwise
  */
 function update($party)
 {
     $id = intval($party->get_id());
     $location_id = $this->marshal($party->get_location_id(), 'int');
     if ($location_id) {
         $loc = $GLOBALS['phpgw']->locations->get_name($location_id);
         $name = $loc['location'];
         $level_identifier = result_unit::get_identifier_from_name($name);
     }
     $result_unit_number = $this->marshal($level_identifier, 'string');
     $values = array('identifier = ' . $this->marshal($party->get_identifier(), 'string'), 'first_name = ' . $this->marshal($party->get_first_name(), 'string'), 'last_name =  ' . $this->marshal($party->get_last_name(), 'string'), 'title = ' . $this->marshal($party->get_title(), 'string'), 'company_name = ' . $this->marshal($party->get_company_name(), 'string'), 'department = ' . $this->marshal($party->get_department(), 'string'), 'address_1 = ' . $this->marshal($party->get_address_1(), 'string'), 'address_2 = ' . $this->marshal($party->get_address_2(), 'string'), 'postal_code = ' . $this->marshal($party->get_postal_code(), 'string'), 'place = ' . $this->marshal($party->get_place(), 'string'), 'phone = ' . $this->marshal($party->get_phone(), 'string'), 'mobile_phone = ' . $this->marshal($party->get_mobile_phone(), 'string'), 'fax = ' . $this->marshal($party->get_fax(), 'string'), 'email = ' . $this->marshal($party->get_email(), 'string'), 'url = ' . $this->marshal($party->get_url(), 'string'), 'account_number = ' . $this->marshal($party->get_account_number(), 'string'), 'reskontro = ' . $this->marshal($party->get_reskontro(), 'string'), 'is_inactive = ' . $this->marshal($party->is_inactive() ? 'true' : 'false', 'bool'), 'comment = ' . $this->marshal($party->get_comment(), 'string'), 'org_enhet_id = ' . $this->marshal($party->get_org_enhet_id(), 'int'), 'unit_leader = ' . $this->marshal($party->get_unit_leader(), 'string'), 'location_id = ' . $location_id, 'result_unit_number = ' . $result_unit_number);
     $result = $this->db->query('UPDATE rental_party SET ' . join(',', $values) . " WHERE id={$id}", __LINE__, __FILE__);
     return isset($result);
 }
 public static function get_name_of_location(int $location_id)
 {
     $location_name = $GLOBALS['phpgw']->locations->get_name($location_id);
     $result_unit_number = result_unit::get_identifier_from_name($location_name['location']);
     return $result_unit_number . " - " . $location_name['descr'];
 }