}
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;
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'] = '';
$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')
$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)
$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());
* 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);
// 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;
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]);
}
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
$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;
+}
?>
* 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
country = {?},
region = {?},
regiontxt = {?},
- tel = {?},
- fax = {?},
pub = {?},
- tel_pub = {?},
datemaj = NOW(),
statut = {?},
uid = {?}, adrid = {?}",
$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{
country = {?},
region = {?},
regiontxt = {?},
- tel = {?},
- fax = {?},
pub = {?},
- tel_pub = {?},
datemaj = NOW(),
statut = {?}
WHERE uid = {?} AND adrid = {?}",
$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
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];
$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;
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])
$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;
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);
?>
$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
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.");
}
}
}
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) {
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']);
}
}
$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
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)
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;
$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
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 = "";
$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']." : </em>\n<strong>".$tel['tel']."</strong>\n</div>\n";
+ }
if (!$params['nodiv'])
{
$txthtml = "<div class='adresse'>\n".$txthtml."</div>\n";
{* 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}
{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 :</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é :</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 :</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} :</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"> </td></tr>
{/section}
<tr><td colspan="5"> </td></tr>
{/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}
--- /dev/null
+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 = "";