From 34fcd12d4b0d60280d500a596272373a6d4a8d76 Mon Sep 17 00:00:00 2001 From: bettina Date: Fri, 22 Jun 2001 01:58:47 +0000 Subject: [PATCH] added new function to format addresses in country specific style --- phpgwapi/inc/class.sbox.inc.php | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/phpgwapi/inc/class.sbox.inc.php b/phpgwapi/inc/class.sbox.inc.php index e1a5ae8654..a7327b54de 100644 --- a/phpgwapi/inc/class.sbox.inc.php +++ b/phpgwapi/inc/class.sbox.inc.php @@ -624,4 +624,78 @@ { return($this->country_array[$selected]); } + + function formatted_address($country = '',$id = '',$fields = '',$business = True) + { + global $phpgw,$phpgw_info,$d; + + $font = $phpgw_info['theme']['font']; + + $d = CreateObject('phpgwapi.contacts'); + + $address = $d->read_single_entry($id,$fields); + + $a = '' . $address[0]['title'] . '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + + if ($business) + { + $street = $address[0]['adr_one_street']; + $city = $address[0]['adr_one_locality']; + $zip = $address[0]['adr_one_postalcode']; + $state = $address[0]['adr_one_region']; + $newcountry = $address[0]['address_one_countryname']; + } + else + { + $street = $address[0]['adr_two_street']; + $city = $address[0]['adr_two_locality']; + $zip = $address[0]['adr_two_postalcode']; + $state = $address[0]['adr_two_region']; + $newcountry = $address[0]['address_two_countryname']; + } + + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + + if ($newcountry) + { + $country = $newcountry; + } + + if ($country == 'DE') + { + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + } + + if ($country == 'US') + { + $a .= '' . "\n"; + } + + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '' . "\n"; + $a .= '
' . $address[0]['n_given'] . ' ' . $address[0]['n_family'] . '
' . $address[0]['org_name'] . '
' . $address[0]['org_unit'] . '
' . $street . '
' . $city . '
' . $zip . '' . $city . ', ' . $state . '&bbsp;' . $zip . '
' . lang($country) . '
' . "\n"; + + return $a; + } } +?>