diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index b62f58117a2..ca194f8d51d 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -63,19 +63,24 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { $arrayofmembers = array(); // request taking into account member with up to date subscriptions - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; + $sql = "SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql .= " t.libelle as type,"; $sql .= " c.code as country_code, c.label as country"; // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + } + } $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + } $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".(int) $foruserid; if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; $sql .= " ORDER BY d.rowid ASC"; @@ -90,6 +95,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { if ($objp->country == '-') $objp->country = ''; $adherentstatic->id = $objp->rowid; + $adherentstatic->ref = $objp->ref; $adherentstatic->lastname = $objp->lastname; $adherentstatic->firstname = $objp->firstname; @@ -110,6 +116,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { // List of values to scan for a replacement $substitutionarray = array( '__ID__'=>$objp->rowid, + '__REF__'=>$objp->ref, '__LOGIN__'=>$objp->login, '__FIRSTNAME__'=>$objp->firstname, '__LASTNAME__'=>$objp->lastname, @@ -149,6 +156,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { 'textfooter'=>$textfooter, 'textright'=>$textright, 'id'=>$objp->rowid, + 'ref'=>$objp->ref, 'photo'=>$objp->photo ); } @@ -159,6 +167,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { 'textfooter'=>$textfooter, 'textright'=>$textright, 'id'=>$objp->rowid, + 'ref'=>$objp->ref, 'photo'=>$objp->photo ); } @@ -172,12 +181,15 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { $textfooter = ''; $textright = ''; - $arrayofmembers[] = array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'ref'=>$objp->ref, + 'photo'=>$objp->photo, + ); } $i++;