Fix display of the type of the phone numbers in the pdf. (Closes #1151)
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 24 Jun 2010 07:49:46 +0000 (09:49 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 24 Jun 2010 07:50:35 +0000 (09:50 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/profilefields.inc.php
modules/carnet/contacts.pdf.inc.php
plugins/function.display_phones.php

index 0f6d3df..6854079 100644 (file)
@@ -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) {
index 573d7a9..3f35235 100644 (file)
@@ -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');
         }
     }
index 8e4a493..39728ed 100644 (file)
@@ -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 .= "<div>\n<em>" . $tel_type . "&nbsp;: </em>\n<strong>" . $tel->display . "</strong>\n";
             $comment = "";
             if ($tel->comment != "") {