nb de tels variables par adresse, wish 400
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 7 Jun 2006 09:49:17 +0000 (09:49 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 7 Jun 2006 09:49:17 +0000 (09:49 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@299 839d8a87-29fc-0310-9880-83ba4fa771e5

17 files changed:
htdocs/css/default.css
htdocs/fiche.php
include/contacts.pdf.inc.php
include/money/paypal.inc.php
include/profil/assign_adresses.inc.php
include/profil/get_adresses.inc.php
include/profil/update_adresses.inc.php
include/profil/verif_adresses.inc.php
include/profil/verif_emploi.inc.php
include/synchro_ax.inc.php
include/user.func.inc.php
include/webservices/manageurs.server.inc.php
plugins/function.display_address.php
templates/include/flags.radio.tpl
templates/profil/adresses.tpl
templates/vcard.tpl
upgrade/0.9.10/02_tels.sql [new file with mode: 0644]

index 1f1655c..fec37e1 100644 (file)
@@ -274,22 +274,22 @@ table.flags {
 }
 table.flags input { margin: 0px 2px; padding: 0px; }
 
-table.flags td.texte {
+table.flags td.texte, tr.flags td.texte {
     font-size: smaller;
     font-weight: bold;
     padding: 3px;
 }
-table.flags td.vert {
+table.flags td.vert, tr.flags td.vert {
     background: green;
     padding: 3px;
     text-align: center;
 }
-table.flags td.orange {
+table.flags td.orange, tr.flags td.orange {
     background: #ff9900;
     padding: 3px;
     text-align: center;
 }
-table.flags td.rouge {
+table.flags td.rouge, tr.flags td.rouge {
     background: red;
     padding: 3px;
     text-align: center;
index de68402..c37e37b 100644 (file)
@@ -83,7 +83,11 @@ if (!logged() || Env::has('public')) {
     if ($user['web_pub'] != 'public') $user['web'] = '';
     if ($user['freetext_pub'] !=  'public') $user['freetext'] = '';
     foreach ($user['adr'] as $i=>$adr) {
-        if ($adr['pub'] != 'public' && $adr['tel_pub'] != 'public')
+        foreach ($adr['tels'] as $j=>$tel) {
+            if ($tel['tel_pub'] != 'public')
+                unset($user['adr'][$i]['tels'][$j]);
+        }
+        if (($adr['pub'] != 'public') && (count($user['adr'][$i]['tels']) == 0))
             unset($user['adr'][$i]);
         elseif ($adr['pub'] != 'public') {
             $user['adr'][$i]['adr1'] = '';
@@ -96,10 +100,6 @@ if (!logged() || Env::has('public')) {
             $user['adr'][$i]['country'] = '00';
             $user['adr'][$i]['countrytxt'] = '';
         }
-        elseif ($adr['tel_pub'] != 'public') {
-            $user['adr'][$i]['tel'] = '';
-            $user['adr'][$i]['fax'] = '';
-        }
     }
     foreach ($user['adr_pro'] as $i=>$adr) {
         if ($adr['pub'] != 'public' && $adr['tel_pub'] != 'public' && $adr['adr_pub'] != 'public' && $adr['email_pub'] != 'public')
index ad74af0..3c9ad3a 100644 (file)
@@ -182,12 +182,10 @@ class ContactsPDF extends FPDF
 
         $this->TableRow($l, $r);
 
-        if ($a['tel']) {
-            $this->TableRow('Téléphone', $a['tel'], 'Mono');
-        }
-        if ($a['fax']) {
-            $this->TableRow('Fax', $a['fax'], 'Mono');
-        }
+        foreach ($a['tels'] as $tel)
+            if ($tel['tel']) {
+                $this->TableRow($tel['tel_type'], $tel['tel'], 'Mono');
+            }
     }
 
     function AddressPro($a)
index bac5a75..baafbb3 100644 (file)
@@ -77,9 +77,10 @@ class PayPal
        $res = $globals->xdb->query(
                "SELECT a.adr1 AS address1, a.adr2 AS address2,
                        a.city, a.postcode AS zip, a.country,
-                       IF(a.tel, a.tel, q.profile_mobile) AS night_phone_b
+                       IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b
                   FROM auth_user_quick AS q
              LEFT JOIN adresses        AS a ON (q.user_id = a.uid)
+             LEFT JOIN tels        AS t ON (t.uid = a.uid AND t.adrid = a.adrid)
                  WHERE q.user_id = {?} AND FIND_IN_SET('active', a.statut)
                  LIMIT 1", Session::getInt('uid'));
        $this->infos['client']=array_merge($info_client, $res->fetchOneAssoc());
index 72be3d2..9cab098 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
+//on génère une éventuelle nouvelle adresse
+if (!isset($adresses) || (count($adresses) < $nb_adr_max)){
+  $adrid = generate_new_adrid();
+  $adresses[$adrid]['adrid'] = $adrid;
+  $adr = &$adresses[$adrid];
+  $adr['adr1'] = '';
+  $adr['adr2'] = '';
+  $adr['adr3'] = '';
+  $adr['postcode'] = '';
+  $adr['city'] = '';
+  $adr['country'] = '00';
+  $adr['region'] = '';
+  $adr['secondaire'] = 1;
+  $adr['courrier'] = 0;
+  $adr['active'] = 0;
+  $adr['temporaire'] = 1;
+  $adr['pub'] = 'private';
+  $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...)
+}
+
+unset($adr);
+unset($adrid);
+
+reset($adresses);
+//on génère un éventuel nouveau tel pour chaque adresse
+foreach($adresses as $adrid => $adr){
+  if (!isset($adr['tels'])) {
+    $adresses[$adrid]['tels'] = array(
+      array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Tél.', 'telid' => 0, 'new_tel' => true),
+      array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Fax', 'telid' => 1, 'new_tel' => true));
+  } elseif (count($adr['tels']) < $nb_tel_max) {
+    $adresses[$adrid]['tels'][] = 
+      array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Autre', 'telid' => generate_new_telid($adr), 'new_tel' => true);
+  }
+}
+
+unset($adr);
+unset($adrid);
+
+//tri des adresses :
+
+reset($adresses);
+$i = 1;
+foreach($adresses as $adrid_ => $adr_){
+  if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){
+    $ordre_des_adrid[$i] = $adrid_;
+    $i++;
+    $est_attribuee[$adrid_] = 1;
+  }
+  else
+    $est_attribuee[$adrid_] = 0;
+}
+
+reset($adresses);
+foreach($adresses as $adrid_ => $adr_){
+  if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee
+    $ordre_des_adrid[$i] = $adrid_;
+    $i++;
+    $est_attribuee[$adrid_] = 1;
+  }
+}
+
+reset($adresses);
+foreach($adresses as $adrid_ => $adr_){
+  if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee
+    $ordre_des_adrid[$i] = $adrid_;
+    $i++;
+    $est_attribuee[$adrid_] = 1;
+  }
+}
+reset($adresses);
+foreach($adresses as $adrid_ => $adr_){
+  if($est_attribuee[$adrid_] == 0){ // non attribuee
+     $ordre_des_adrid[$i] = $adrid_;
+     $i++;
+     $est_attribuee[$adrid_] = 1;
+  }
+}
+
+$nb_adr = $i - 1;
+$page->assign_by_ref('ordre_adrid',$ordre_des_adrid);
+$page->assign('nb_adr',$nb_adr+1);
 
 $page->assign('adresses', $adresses);
 
index 74bd2ab..341a563 100644 (file)
@@ -23,6 +23,8 @@ require_once('geoloc.inc.php');
 
 // on limite à 6 adresses personnelles par utilisateur
 $nb_adr_max = 6; // ( = max(adrid possibles)
+// on limite à 4 numéros de téléphone par adresse
+$nb_tel_max = 4; // ( = max(telid possibles)
 
 //les adresses sont stockées dans un tableau global indéxé par adrid;
 
@@ -31,13 +33,14 @@ function is_adr_empty($adrid){
   return ( 
     ($adr['adr1'] == '') && ($adr['adr2'] == '') && ($adr['adr3'] == '') &&
     ($adr['postcode'] == '') && ($adr['city'] == '') && ($adr['country'] == '00') &&
-    ($adr['tel'] == '') && ($adr['fax'] == '')
+    (count($adr['tels']) == 0)
     );
 }
 
 function delete_address($adrid, $in_request_array = false){
     global $globals;
     $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid);
+    $globals->xdb->execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid);
     if($in_request_array == true){
       unset($_REQUEST['adrid'][$adrid]);
     }
@@ -67,7 +70,7 @@ $res = $globals->xdb->iterRow(
        FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut),
        FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut),
        adr1, adr2, adr3, postcode, city, cityid,
-        a.country, region, regiontxt, tel, fax, pub, tel_pub,
+        a.country, region, regiontxt, pub,
        gp.pays AS countrytxt, gp.display
        FROM adresses AS a INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
        WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order
@@ -83,13 +86,28 @@ for ($i = 0; $i < $nb_adr; $i++) {
        $adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'],
        $adresses[$adrid]['active'], $adresses[$adrid]['temporaire'],
        $adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['postcode'], $adresses[$adrid]['city'], $adresses[$adrid]['cityid'],
-       $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'],
+       $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'],
        $adresses[$adrid]['pub'],
-       $adresses[$adrid]['tel_pub'],$adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next();
+       $adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next();
   $adresses[$adrid]['nouvelle'] = 'modif';
   $adresses[$adrid]['numero_formulaire'] = -1;
   require_once('geoloc.inc.php');
   $adresses[$adrid]['txt'] = get_address_text($adresses[$adrid]);
 }
 
+$restels = $globals->xdb->iterator(
+    "SELECT
+    t.adrid, telid, tel_type, t.tel_pub, t.tel
+    FROM tels AS t INNER JOIN adresses AS a ON(t.uid = a.uid AND t.adrid = a.adrid)
+    WHERE t.uid = {?} AND NOT FIND_IN_SET('pro',statut) ORDER BY t.adrid, tel_type DESC, telid"
+, Session::getInt('uid', -1)   
+);
+while ($tel = $restels->next()) {
+    $adrid = $tel['adrid'];
+    unset($tel['adrid']);
+    if (!isset($adresses[$adrid]['tels']))
+        $adresses[$adrid]['tels'] = array($tel);
+    else
+        $adresses[$adrid]['tels'][] = $tel;
+}
 ?>
index a055076..cf85507 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-
 reset($adresses);
 
+function insert_new_tel($adrid, $tel) {
+  global $globals;
+  if ($tel['tel'] == "") return;
+ $globals->xdb->execute(
+   "INSERT INTO tels SET
+    tel_type = {?},
+    tel_pub = {?},
+    tel = {?},
+    uid = {?},
+    adrid = {?},
+    telid = {?}",
+    $tel['tel_type'],
+    $tel['tel_pub'],
+    $tel['tel'],
+    Session::getInt('uid', -1),
+    $adrid,
+    $tel['telid']);
+}
+
 foreach($adresses as $adrid => $adr){
 
   if($adr['nouvelle'] != 'new'){ // test si on vient de creer cette adresse dans verif_adresse.inc.php
@@ -46,10 +64,7 @@ foreach($adresses as $adrid => $adr){
                         country = {?},
                         region = {?},
                         regiontxt = {?},
-                        tel = {?},
-                        fax = {?},
                         pub = {?},
-                        tel_pub = {?},
                         datemaj = NOW(),
                         statut = {?},
                         uid = {?}, adrid = {?}",
@@ -62,12 +77,12 @@ foreach($adresses as $adrid => $adr){
                         $adr['country'],
                         $adr['region'],
                         $adr['regiontxt'],
-                        $adr['tel'],
-                        $adr['fax'],
                         $adr['pub'],
-                        $adr['tel_pub'],
                         $statut,
                         Session::getInt('uid', -1), $adrid);
+       $telsvalues = "";                
+       foreach ($adr['tels'] as $tel) 
+         insert_new_tel($adrid, $tel);
     }
     
     else{ 
@@ -83,10 +98,7 @@ foreach($adresses as $adrid => $adr){
                                 country = {?},
                                 region = {?},
                                 regiontxt = {?},
-                                tel = {?},
-                                fax = {?},
                                 pub = {?},
-                                tel_pub = {?},
                                 datemaj = NOW(),
                                 statut = {?}
                                 WHERE uid = {?} AND adrid = {?}",
@@ -99,13 +111,41 @@ foreach($adresses as $adrid => $adr){
                                 $adr['country'],
                                 $adr['region'],
                                 $adr['regiontxt'],
-                                $adr['tel'],
-                                $adr['fax'],
                                 $adr['pub'],
-                                $adr['tel_pub'],
                                 $statut,
                                 Session::getInt('uid', -1), $adrid
                    );
+       foreach ($adr['tels'] as $tel) {
+         if ($tel['new_tel'])
+          insert_new_tel($adrid, $tel);
+        else
+          if ($tel['tel'] != "") {
+          $globals->xdb->execute(
+           "UPDATE tels SET
+            tel_type = {?},
+            tel_pub = {?},
+            tel = {?}
+            WHERE
+            uid = {?} AND
+            adrid = {?} AND
+            telid = {?}",
+            $tel['tel_type'],
+            $tel['tel_pub'],
+            $tel['tel'],
+            Session::getInt('uid', -1),
+            $adrid,
+            $tel['telid']);
+          } else {
+          $globals->xdb->execute(
+           "DELETE FROM tels WHERE
+            uid = {?} AND
+            adrid = {?} AND
+            telid = {?}",
+            Session::getInt('uid', -1),
+            $adrid,
+            $tel['telid']);
+          }
+       }
     }// fin nouvelle / ancienne adresse
   }//fin if nouvellement crée
 }//fin foreach
index 93ee5cb..89e79c4 100644 (file)
@@ -43,12 +43,36 @@ function generate_new_adrid(){
   return $new_adrid;
 }
 
+function generate_new_telid($adr){
+  $i = 0;
+  $telid_array = Array();
+  foreach($adr['tels'] as $tel){
+    $telid_array[$i] = $tel['telid'];
+    $i++;
+  }
+  sort($telid_array,SORT_NUMERIC); // classe les adrid dans l'ordre croissant
+  $new_telid = 0;
+  foreach($telid_array as $current_telid)
+    if ($current_telid == $new_telid)
+      $new_telid ++;
+    else 
+      return $new_telid;//s'ils sont differents, il y a un trou dans la liste des telid donc new_telid convient
+  //si aucun convient, on retourne le plus grand des telid actuel + 1
+  return $new_telid;
+}
+
 function replace_ifset_adr($varname, $i){
   $tab = Env::getMixed($varname, Array());
   if (isset($tab[$i]))
        $GLOBALS['adresses'][$i][$varname] = $tab[$i];
 }
 
+function replace_ifset_tel($varname, $i, $t){
+  $tab = Env::getMixed($varname.$t, Array());
+  if (isset($tab[$i]))
+       $GLOBALS['adresses'][$i]['tels'][$t][$varname] = $tab[$i];  
+}
+
 function get_adr_arg($varname, $i) {
   $tab = Env::getMixed($varname, Array());
   return $tab[$i];
@@ -63,9 +87,16 @@ function set_flag_adr($varname,$i){
      $GLOBALS['adresses'][$i][$varname] = '0';
 }
 
+function replace_tel($i, $t){
+  replace_ifset_tel('telid', $i, $t);
+  replace_ifset_tel('tel', $i, $t);
+  replace_ifset_tel('tel_pub', $i, $t);
+  replace_ifset_tel('tel_type', $i, $t);
+  replace_ifset_tel('new_tel', $i, $t);
+}
 
 function replace_address($i){
-  global $adresses;
+  global $adresses, $nb_tel_max;
   if(!isset($adresses[$i])){
     $adresses[$i]['nouvelle'] = 'ajout';
     $adresses[$i]['adrid'] = $i;
@@ -86,10 +117,15 @@ function replace_address($i){
   replace_ifset_adr('cityid', $i);
   replace_ifset_adr('country', $i);
   replace_ifset_adr('region', $i);
-  replace_ifset_adr('tel', $i);
-  replace_ifset_adr('fax', $i);
   replace_ifset_adr('pub', $i);
-  replace_ifset_adr('tel_pub', $i);
+  
+  for ($telid = 0; $telid <= $nb_tel_max; $telid++) {
+    $tab = Env::getMixed('telid'.$telid, Array());
+    if(isset($tab[$i])){ //ce telid etait donc present dans le formulaire
+      replace_tel($i, $telid);
+    }
+  }
   if (!get_adr_arg('parsevalid', $i)) replace_ifset_adr('txt', $i);
   $tab = Env::getMixed('numero_formulaire', Array());
   if($tab[$i])
@@ -136,35 +172,33 @@ foreach($adresses as $adrid => $adr) {
   $description = (($adr['numero_formulaire'] > 0)?"Adresse n°{$adr['numero_formulaire']}":"Nouvelle adresse");
   if (strlen(strtok($adr['adr1'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr1']))
     {
-      $str_error = $str_error."Le champ '$description - Ligne 1' contient un caractère interdit.<BR />";
+      $page->trig("Le champ '$description - Ligne 1' contient un caractère interdit.");
     }
   if (strlen(strtok($adr['adr2'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr2']))
     {
-      $str_error = $str_error."Le champ '$description - Ligne 2' contient un caractère interdit.<BR />";
+      $page->trig("Le champ '$description - Ligne 2' contient un caractère interdit.");
     }
   if (strlen(strtok($adr['adr3'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr3']))
     {
-      $str_error = $str_error."Le champ '$description - Ligne 3' contient un caractère interdit.<BR />";
+      $page->trig("Le champ '$description - Ligne 3' contient un caractère interdit.");
     }
   if (strlen(strtok($adr['postcode'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode']))
     {
-      $str_error = $str_error."Le champ '$description - Code Postal' contient un caractère interdit.<BR />";
+      $page->trig("Le champ '$description - Code Postal' contient un caractère interdit.");
     }
   if (strlen(strtok($adr['city'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode']))
     {
-      $str_error = $str_error."Le champ '$description - Ville' contient un caractère interdit.<BR />";
-    }
-  if (strlen(strtok($adr['tel'],"<>{}@&#~\/:;?,!§*_`[]|%$^=\"")) < strlen($adr['tel']))
-    {
-      $str_error = $str_error."Le champ '$description - Téléphone' contient un caractère interdit.<BR />";
+      $page->trig("Le champ '$description - Ville' contient un caractère interdit.");
     }
-  if (strlen(strtok($adr['fax'],"<>{}@&#~\/:;?,!§*_`[]|%$^=\"")) < strlen($adr['fax']))
-    {
-      $str_error = $str_error."Le champ '$description - Fax' contient un caractère interdit.<BR />";
+  foreach ($adr['tels'] as $tel) {
+    if (strlen(strtok($tel['tel'],"<>{}@&#~\/:;?,!§*_`[]|%$^=\"")) < strlen($tel['tel']))
+      {
+        $page->trig("Le champ '$description - ".$tel['tel_type']."' contient un caractère interdit.");
+      }
     }
   if(!$adr['secondaire']){
     if($adresses_principales == 1){ //deja une adresse principale
-      $str_error = $str_error."Tu ne peux avoir qu'une résidence principale.<BR />";
+      $page->trig("Tu ne peux avoir qu'une résidence principale.");
       $adresses_principales++;//pour eviter de repeter le message plusieurs fois
     }
     else $adresses_principales = 1;
@@ -177,79 +211,14 @@ foreach($adresses as $adrid => $adr) {
 if(isset($adresses)){ // s'il y en a
   reset($adresses);
   foreach($adresses as $adrid => $adr){
+    // on vire les tels vides
+    foreach ($adr['tels'] as $telid => $tel) {
+      if ($tel['tel'] == '') unset($adresses[$adrid]['tels'][$telid]);
+    }
     if(is_adr_empty($adrid)){
        delete_address($adrid);
     }
   }
 }
-//on génère une éventuelle nouvelle adresse
-if (!isset($adresses) || (count($adresses) < $nb_adr_max)){
-  $adrid = generate_new_adrid();
-  $adresses[$adrid]['adrid'] = $adrid;
-  $adr = &$adresses[$adrid];
-  $adr['adr1'] = '';
-  $adr['adr2'] = '';
-  $adr['adr3'] = '';
-  $adr['postcode'] = '';
-  $adr['city'] = '';
-  $adr['country'] = '00';
-  $adr['region'] = '';
-  $adr['tel'] = '';
-  $adr['fax'] = '';
-  $adr['secondaire'] = 1;
-  $adr['courrier'] = 0;
-  $adr['active'] = 0;
-  $adr['temporaire'] = 1;
-  $adr['pub'] = 'private';
-  $adr['tel_pub'] = 'private';
-  $adr['nouvelle'] = 'new'; //n'est pas issue d'un formulaire (sert dans update_adresses...)
-}
-
-unset($adr);
-unset($adrid);
-
-//tri des adresses :
-
-reset($adresses);
-$i = 1;
-foreach($adresses as $adrid_ => $adr_){
-  if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){
-    $ordre_des_adrid[$i] = $adrid_;
-    $i++;
-    $est_attribuee[$adrid_] = 1;
-  }
-  else
-    $est_attribuee[$adrid_] = 0;
-}
-
-reset($adresses);
-foreach($adresses as $adrid_ => $adr_){
-  if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee
-    $ordre_des_adrid[$i] = $adrid_;
-    $i++;
-    $est_attribuee[$adrid_] = 1;
-  }
-}
-
-reset($adresses);
-foreach($adresses as $adrid_ => $adr_){
-  if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee
-    $ordre_des_adrid[$i] = $adrid_;
-    $i++;
-    $est_attribuee[$adrid_] = 1;
-  }
-}
-reset($adresses);
-foreach($adresses as $adrid_ => $adr_){
-  if($est_attribuee[$adrid_] == 0){ // non attribuee
-     $ordre_des_adrid[$i] = $adrid_;
-     $i++;
-     $est_attribuee[$adrid_] = 1;
-  }
-}
-
-$nb_adr = $i - 1;
-$page->assign_by_ref('ordre_adrid',$ordre_des_adrid);
-$page->assign('nb_adr',$nb_adr+1);
 
 ?>
index 02f7d77..b7b4523 100644 (file)
@@ -59,19 +59,19 @@ replace_ifset($cv,"cv");
 $j = $i+1;
 if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i]))
 {
-$str_error = $str_error."Le champ 'Entreprise $j' contient un caractère interdit.<BR />";
+    $page->trig("Le champ 'Entreprise $j' contient un caractère interdit.");
 }
 
 //validité du poste
 if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
 {
-$str_error = $str_error."Le champ 'Poste $j' contient un caractère interdit.<BR />";
+    $page->trig("Le champ 'Poste $j' contient un caractère interdit.");
 }
 
 //validité du CV
 if (strlen(strtok($cv,"<>{}~§`")) < strlen($cv))
 {
-  $str_error = $str_error."Le champ 'Curriculum vitae' contient un caractère interdit.<BR />";
+    $page->trig("Le champ 'Curriculum vitae' contient un caractère interdit.");
 }
 
 // correction du champ web si vide
@@ -95,35 +95,35 @@ if ($emailpro[$i]) {
 
 if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
     {
-      $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.");
     }
   if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
     {
-      $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.");
     }
   if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
     {
-      $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.");
     }
   if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
     {
-      $str_error = $str_error."Le champ 'Code Postal professionnel $j' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit.");
     }
   if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
     {
-      $str_error = $str_error."Le champ 'Ville professionnelle $j' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit.");
     }
   if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
     {
-      $str_error = $str_error."Le champ 'Téléphone professionnel $j' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit.");
     }
   if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
     {
-      $str_error = $str_error."Le champ 'Fax professionnel $j' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit.");
     }
   if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
     {
-      $str_error = $str_error."Le champ 'Mobile professionnel $j' contient un caractère interdit.<BR />";
+      $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit.");
     }
 
 }
index 8345172..3f78e2b 100644 (file)
@@ -117,6 +117,7 @@ function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=n
     }
     if (is_array($del_address)) foreach($del_address as $adrid) {
         $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid);
+        $globals->xdb->execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}", $userax['uid'], $adrid);
     }
 
     if (is_array($del_pro)) foreach($del_pro as $entrid) {
@@ -162,15 +163,25 @@ function import_from_ax($userax, $nom_usage=false, $mobile=false, $del_address=n
                              adr1 = {?}, adr2 = {?}, adr3 = {?},
                              postcode = {?}, city = {?},
                          country = {?},
-                         tel = {?}, fax = {?},
                          datemaj = NOW(),
-                         pub = 'ax',
-                         tel_pub = 'ax'",
+                         pub = 'ax'",
                 $userax['uid'], $new_adrid,
                 $adr['adr1'], $adr['adr2'], $adr['adr3'],
                 $adr['postcode'], $adr['city'],
-                $a2,
-                $adr['tel'], $adr['fax']);
+                $a2);
+            // import tels
+            if ($adr['tel'])
+                $globals->xdb->execute(
+                    "INSERT INTO adresses
+                        SET uid = {?}, adrid = {?}, tel = {?},
+                        telid = 0, tel_type = 'Tel.', tel_pub = 'ax'",
+                    $userax["uid"], $new_adrid, $adr['tel']);
+            if ($adr['fax'])
+                $globals->xdb->execute(
+                    "INSERT INTO adresses
+                        SET uid = {?}, adrid = {?}, tel = {?},
+                        telid = 1, tel_type = 'Fax', tel_pub = 'ax'",
+                    $userax["uid"], $new_adrid, $adr['fax']);
         }
     }
     
index 5de36d8..8add780 100644 (file)
@@ -204,17 +204,35 @@ function &get_user_details($login, $from_uid = '')
 
     $user['adr_pro'] = get_user_details_pro($uid);
 
-    $sql  = "SELECT  a.adr1,a.adr2,a.adr3,a.postcode,a.city,
-                     gp.pays AS countrytxt,a.region, a.regiontxt, a.tel,a.fax,
+    $sql  = "SELECT  a.adrid, a.adr1,a.adr2,a.adr3,a.postcode,a.city,
+                     gp.pays AS countrytxt,a.region, a.regiontxt,
                      FIND_IN_SET('active', a.statut) AS active, a.adrid,
                      FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
-                     a.pub, a.tel_pub, gp.display
+                     a.pub, gp.display
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
               WHERE  uid= {?} AND NOT FIND_IN_SET('pro',a.statut)
            ORDER BY  NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)";
     $res  = $globals->xdb->query($sql, $uid);
     $user['adr'] = $res->fetchAllAssoc();
+    $adrid_index = array();
+    foreach ($user['adr'] as $i => $adr) 
+        $adrid_index[$adr['adrid']] = $i;
+    
+    $sql = "SELECT  t.adrid, t.tel_pub, t.tel_type, t.tel
+              FROM  tels AS t
+        INNER JOIN  adresses AS a ON (a.uid = t.uid) AND (a.adrid = t.adrid)
+             WHERE  t.uid = {?} AND NOT FIND_IN_SET('pro',a.statut)
+          ORDER BY  t.adrid, t.tel_type DESC, t.telid";
+    $restel = $globals->xdb->iterator($sql, $uid);
+    while ($nexttel = $restel->next()) {
+        $adrid = $nexttel['adrid'];
+        unset($nexttel['adrid']);
+        if (!isset($user['adr'][$adrid_index[$adrid]]['tels'])) 
+            $user['adr'][$adrid_index[$adrid]]['tels'] = array($nexttel);
+        else
+            $user['adr'][$adrid_index[$adrid]]['tels'][] = $nexttel;
+    }
 
     $sql  = "SELECT  text
                FROM  binets_ins
index 159268a..11679d5 100644 (file)
@@ -34,13 +34,14 @@ function get_annuaire_infos($method, $params) {
                     FROM  auth_user_md5 AS a
                     INNER JOIN auth_user_quick AS q USING (user_id)
                     WHERE  a.matricule = {?}", $params[1]);
+            $array = $res->next();
         }
         else{
             $res = $globals->xdb->iterRow(
                  "SELECT     q.profile_mobile AS cell, a.naissance AS age,
                              adr.adr1, adr.adr2, adr.adr3,
                              adr.postcode, adr.city, adr.country,
-                             adr.tel, adr.fax
+                             adr.uid, adr.adrid
                        FROM  auth_user_md5 AS a
                  INNER JOIN  auth_user_quick AS q USING (user_id)
                   LEFT JOIN  adresses AS adr ON(adr.uid = a.user_id)
@@ -49,25 +50,22 @@ function get_annuaire_infos($method, $params) {
                    ORDER BY  NOT FIND_IN_SET('active', adr.statut),
                              FIND_IN_SET('res-secondaire', adr.statut),
                              NOT FIND_IN_SET('courrier', adr.statut)", $params[1]);
-
-                    }
-
-        //traitement des adresses si necessaire
-        if (isset($params[2])) {
+            //traitement des adresses si necessaire
             if(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
-                        $adr['pays'], $adr['tel'], $adr['fax']) = $res->next())
+                        $adr['pays'], $uid, $adr['adrid']) = $res->next())
             {
                 $array['cell']      = $cell;
                 $array['age']       = $age;
                 $array['adresse'][] = $adr;
 
+
                 //on clamp le numero au nombre d'adresses dispo
                 $adresse = min((int) $params[2], $res->total());
 
                 if ($adresse != 1) { //on ne veut pas la premiere adresse
                     $i = 2;
                     while(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
-                                $adr['pays'], $adr['tel'], $adr['fax']) = $res->next())
+                                $adr['pays'], , $adr['adrid']) = $res->next())
                     {
                         if($adresse == $i){//si on veut cette adresse en particulier
                             $array['adresse'][0] = $adr;
@@ -80,15 +78,37 @@ function get_annuaire_infos($method, $params) {
                         $i++;
                     }
                 }
+                
+                // on rajoute les numéros de tél
+                $adrid_index = array();
+                foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i;
+                // on rajoute les numéros de tels
+                $restel = $globals->xdb->iterator(
+                    "SELECT t.tel, t.tel_type, t.adrid
+                       FROM tels AS t
+                 INNER JOIN adresses AS a ON (t.adrid = a.adrid AND t.uid = a.uid)
+                      WHERE t.uid = {?} AND NOT FIND_IN_SET('pro', a.statut)", $uid);
+                while ($tel = $restel->next()) $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel;
+                foreach ($array['adresse'] as $i => $adr) {
+                    unset($lasttel);
+                    foreach($adr['tels'] as $j => $t){
+                        if (!isset($array['adresse'][$i]['tel']) && (strpos($t['tel_type'], 'Tél') === 0)) $array['adresse'][$i]['tel'] = $t['tel']; 
+                        elseif (!isset($array['adresse'][$i]['fax']) && (strpos($t['tel_type'], 'Fax') === 0)) $array['adresse'][$i]['fax'] = $t['tel'];
+                        else $lasttel = $t['tel'];
+                        if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) break; 
+                    }
+                    if (!isset($array['adresse'][$i]['tel']) && isset($lasttel))
+                        $array['adresse'][$i]['tel'] = $lasttel;
+                    elseif (!isset($array['adresse'][$i]['fax']) && isset($lasttel))
+                        $array['adresse'][$i]['fax'] = $lasttel;
+                    unset($array['adresse'][$i]['adrid']);
+                    unset($array['adresse'][$i]['tels']);
+                }
             }
             else{
                 $array = false;
             }
         }
-        else { //cas où on ne veut pas d'adresse
-            $array = $res->next();
-        }
-        
 
         if ($array) { // on a bien eu un résultat : le matricule etait bon
 
index 1ac3801..2a4f1a9 100644 (file)
 function smarty_function_display_address($param, &$smarty) {
     require_once('geoloc.inc.php');
     $txtad = get_address_text($param['adr']);
-    if (!$txtad && !$param['adr']['tel'] && !$param['adr']['fax'] && !$param['adr']['mobile']) return "";
+    if (!$txtad &&
+        !$param['adr']['tels'] && !count($param['adr']['tels']) &&
+        !$param['adr']['tel'] &&
+        !$param['adr']['fax'] &&
+        !$param['adr']['mobile']) return "";
 
     $lines = explode("\n",$txtad);
     $txthtml = "";
@@ -44,6 +48,10 @@ function smarty_function_display_address($param, &$smarty) {
        $txthtml .= "<div>\n<em>Fax : </em>\n<strong>".$param['adr']['fax']."</strong>\n</div>\n";
     if ($param['adr']['mobile'])
        $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['mobile']."</strong>\n</div>\n";
+    if ($param['adr']['tels'] && count($param['adr']['tels'])) {
+        foreach ($param['adr']['tels'] as $tel) 
+            $txthtml .= "<div>\n<em>".$tel['tel_type']."&nbsp;: </em>\n<strong>".$tel['tel']."</strong>\n</div>\n";
+    }
     if (!$params['nodiv'])
     {
        $txthtml = "<div class='adresse'>\n".$txthtml."</div>\n";
index bdcada3..de93bed 100644 (file)
@@ -19,7 +19,7 @@
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-
+{if $display neq "mini"}
     <tr>
       <td colspan="5" class="pflags">
         <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
         </table>
       </td>
     </tr>
+{else}
+            <td class="vert">
+              <input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if} />
+            </td>
+            <td class="orange">
+              <input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if} />
+            </td>
+            <td class="rouge">
+              <input type="radio" name="{$name}" value="private" {if $val eq 'private'}checked="checked"{/if} />
+            </td>
+{/if}
index aaf59d3..6b5d0fd 100644 (file)
@@ -69,7 +69,7 @@
     {include file="geoloc/form.address.tpl" adr=$adr titre=$titre url="`$smarty.server.PHP_SELF`?old_tab=`$smarty.request.old_tab`"}
     <tr>
       <td class="colg">
-        <span class="titre">Cette adresse est&nbsp;:</span>
+        <span class="titre">Adresse:</span>
       </td>
       <td class="cold">
         <input type="radio" name="temporaire[{$adrid}]" value="0" {if !$adr.temporaire}checked="checked"{/if} />
         <input type="checkbox" name="courrier[{$adrid}]" value="1" {if $adr.courrier}checked="checked"{/if} /> on peut m'y envoyer du courrier par la poste
       </td>
     </tr>
-    {include file="include/flags.radio.tpl" name="tel_pub[$adrid]" val=$adr.tel_pub}
-    <tr>
-      <td class="colg">
-        <span class="titre">Téléphone associé&nbsp;:</span>
-      </td>
-      <td>
-        <input type="text" size="19" maxlength="28" name="tel[{$adrid}]" value="{$adr.tel}" />
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Fax&nbsp;:</span>
-      </td>
-      <td>
-        <input type="text" size="19" maxlength="28" name="fax[{$adrid}]" value="{$adr.fax}" />
-      </td>
-    </tr>
+    {foreach from=$adr.tels item="tel"}
+      <tr class="flags">
+        <td class="colg">
+          <input type="hidden" name="telid{$tel.telid}[{$adrid}]" value="{$tel.telid}"/>
+          {if $tel.new_tel}
+            <input type="hidden" name="new_tel{$tel.telid}[{$adrid}]" value="1"/>
+          {/if}
+          <span class="titre" onclick="this.style.display='none';var d = document.getElementById('tel_type{$adrid}_{$tel.telid}');d.style.display='inline';d.select();d.focus();">{$tel.tel_type}&nbsp;:</span>
+          <input id="tel_type{$adrid}_{$tel.telid}" style="display:none" type="text" size="5" maxlength="20" name="tel_type{$tel.telid}[{$adrid}]" value="{$tel.tel_type}"/>
+        </td>
+        <td>
+          <input type="text" size="19" maxlength="28" name="tel{$tel.telid}[{$adrid}]" value="{$tel.tel}" />
+        </td>
+          {include file="include/flags.radio.tpl" name="tel_pub`$tel.telid`[$adrid]" val=$tel.tel_pub display="mini"}
+      </tr>        
+    {/foreach}
     <tr><td colspan="5">&nbsp;</td></tr>
     {/section}
     <tr><td colspan="5">&nbsp;</td></tr>
index e600de6..188599e 100644 (file)
@@ -57,13 +57,12 @@ ADR;TYPE=work;ENCODING=QUOTED-PRINTABLE:{format_adr adr=$vcard.adr_pro[0]}
 {/if}
 {foreach item=adr from=$vcard.adr}
 ADR;TYPE=home{if $adr.courier},postal{/if};ENCODING=QUOTED-PRINTABLE:{format_adr adr=$adr}
-{if $adr.tel}
-TEL;TYPE=home;ENCODING=QUOTED-PRINTABLE:{$adr.tel|qp_enc}
-{/if}
-{if $adr.fax}
-FAX;TYPE=home;ENCODING=QUOTED-PRINTABLE:{$adr.fax|qp_enc}
+{foreach item=tel from=$adr.tels}
+{if $tel.tel}
+{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home;ENCODING=QUOTED-PRINTABLE:{$tel.tel|qp_enc}
 {/if}
 {/foreach}
+{/foreach}
 {if $vcard.web}
 URL;ENCODING=QUOTED-PRINTABLE:{$vcard.web|qp_enc}
 {/if}
diff --git a/upgrade/0.9.10/02_tels.sql b/upgrade/0.9.10/02_tels.sql
new file mode 100644 (file)
index 0000000..6314401
--- /dev/null
@@ -0,0 +1,12 @@
+CREATE TABLE `tels` (
+  `uid` smallint(5) unsigned NOT NULL default '0',
+  `adrid` tinyint(1) unsigned NOT NULL default '0',
+  `telid` tinyint(1) unsigned NOT NULL default '0',
+  `tel_type` varchar(20) NOT NULL default '',
+  `tel_pub` enum('private','ax','public') NOT NULL default 'private',
+  `tel` varchar(30) NOT NULL default '',
+  PRIMARY KEY  (`uid`,`adrid`,`telid`)
+  )
+INSERT INTO tels SELECT uid, adrid, 0, 'Tél.', tel_pub, tel FROM adresses;
+INSERT INTO tels SELECT uid, adrid, 1, 'Fax', tel_pub, fax FROM adresses;
+DELETE FROM tels WHERE tel = "";