From c51d053f5f949b2ea86f4e60f46e2ce2e948e481 Mon Sep 17 00:00:00 2001 From: bettina Date: Fri, 22 Jun 2001 05:29:43 +0000 Subject: [PATCH] update addresses --- addressbook/inc/class.contacts_shared.inc.php | 61 +++++++++++++++++++ addressbook/templates/default/format_de.tpl | 21 +++++++ addressbook/templates/default/format_us.tpl | 18 ++++++ 3 files changed, 100 insertions(+) create mode 100644 addressbook/templates/default/format_de.tpl create mode 100644 addressbook/templates/default/format_us.tpl diff --git a/addressbook/inc/class.contacts_shared.inc.php b/addressbook/inc/class.contacts_shared.inc.php index e34b0d5acd..7372d373bf 100644 --- a/addressbook/inc/class.contacts_shared.inc.php +++ b/addressbook/inc/class.contacts_shared.inc.php @@ -266,5 +266,66 @@ return $new_ldap; } + + function formatted_address($id = '',$fields = '',$business = True) + { + global $phpgw,$phpgw_info; + + $font = $phpgw_info['theme']['font']; + + $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); + + $address = $this->read_single_entry($id,$fields); + + if ($address[0]['title']) + { + $title = $address[0]['title'] . ' '; + } + + 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']; + $country = $address[0]['adr_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']; + $country = $address[0]['adr_two_countryname']; + } + + if (! $country) + { + $country = $phpgw_info['user']['preferences']['common']['country']; + } + + if ($country == 'DE') + { + $t->set_file(array('address_format' => 'format_de.tpl')); + } + elseif ($country == 'US') + { + $t->set_file(array('address_format' => 'format_us.tpl')); + } + + $t->set_var('font',$font); + $t->set_var('title',$title); + $t->set_var('firstname',$address[0]['n_given']); + $t->set_var('lastname',$address[0]['n_family']); + $t->set_var('company',$address[0]['org_name']); + $t->set_var('department',$address[0]['org_unit']); + $t->set_var('street',$street); + $t->set_var('city',$city); + $t->set_var('zip',$zip); + $t->set_var('state',$state); + $t->set_var('country',$country); + + $t->pparse('out','address_format'); + } } ?> diff --git a/addressbook/templates/default/format_de.tpl b/addressbook/templates/default/format_de.tpl new file mode 100644 index 0000000000..b54dc2a016 --- /dev/null +++ b/addressbook/templates/default/format_de.tpl @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +
{title} {firstname} {lastname}
{company}
{department}
{city}
{zip}
{country}
diff --git a/addressbook/templates/default/format_us.tpl b/addressbook/templates/default/format_us.tpl new file mode 100644 index 0000000000..345e7f8dd2 --- /dev/null +++ b/addressbook/templates/default/format_us.tpl @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + +
{title} {firstname} {lastname}
{company}
{department}
{city}, {state} {zip}
{country}