From 89d17c5a3c88c9b1efd189977eda05fda495421b Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 24 Jun 2010 09:49:46 +0200 Subject: [PATCH] Fix display of the type of the phone numbers in the pdf. (Closes #1151) Signed-off-by: Florent Bruneau --- include/profilefields.inc.php | 16 ++++++++++++++++ modules/carnet/contacts.pdf.inc.php | 4 ++-- plugins/function.display_phones.php | 14 +------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index 0f6d3df..6854079 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -173,6 +173,22 @@ class Phone ); } + /** User accessible version of the type + */ + public function displayType($short = false) + { + switch ($this->type) { + case Phone::TYPE_FIXED: + return $short ? 'Tél' : 'Fixe'; + case Phone::TYPE_FAX: + return 'Fax'; + case Phone::TYPE_MOBILE: + return $short ? 'Mob' : 'Mobile'; + default: + return $this->type; + } + } + /** Returns true if this phone's link matches the flags */ public function hasLink($flags) { diff --git a/modules/carnet/contacts.pdf.inc.php b/modules/carnet/contacts.pdf.inc.php index 573d7a9..3f35235 100644 --- a/modules/carnet/contacts.pdf.inc.php +++ b/modules/carnet/contacts.pdf.inc.php @@ -190,7 +190,7 @@ class ContactsPDF extends FPDF $this->TableRow($l, utf8_decode($a->text)); foreach ($a->phones() as $phone) { - $this->TableRow(utf8_decode($phone->type), + $this->TableRow(utf8_decode($phone->displayType()), utf8_decode($phone->display), 'Mono'); } } @@ -204,7 +204,7 @@ class ContactsPDF extends FPDF $this->TableRow('adresse pro', utf8_decode($a->address()->text)); } foreach ($a->phones() as $phone) { - $this->TableRow(utf8_decode($phone->type), + $this->TableRow(utf8_decode($phone->displayType()), utf8_decode($phone->display), 'Mono'); } } diff --git a/plugins/function.display_phones.php b/plugins/function.display_phones.php index 8e4a493..39728ed 100644 --- a/plugins/function.display_phones.php +++ b/plugins/function.display_phones.php @@ -25,19 +25,7 @@ function smarty_function_display_phones($param, &$smarty) if (count($param['tels'])) { foreach ($param['tels'] as $tel) { $tel_type = ($param['dcd'] ? 'Dernier ' : ''); - switch ($tel->type) { - case Phone::TYPE_FIXED: - $tel_type .= 'Tél'; - break; - case Phone::TYPE_FAX: - $tel_type .= 'Fax'; - break; - case Phone::TYPE_MOBILE: - $tel_type .= 'Mob'; - break; - default: - $tel_type .= $tel->type; - } + $tel_type .= $tel->displayType(true); $txthtml .= "
\n" . $tel_type . " : \n" . $tel->display . "\n"; $comment = ""; if ($tel->comment != "") { -- 2.1.4