NEW Can include extrafields into member card templates
This commit is contained in:
parent
291a0d46e6
commit
dff4249e97
@ -46,6 +46,10 @@ $mesg='';
|
|||||||
|
|
||||||
$adherentstatic=new Adherent($db);
|
$adherentstatic=new Adherent($db);
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extralabels = $extrafields->fetch_name_optionals_label('adherent');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -65,8 +69,12 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
|||||||
$sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
|
$sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
|
||||||
$sql.= " t.libelle as type,";
|
$sql.= " t.libelle as type,";
|
||||||
$sql.= " c.code as country_code, c.label as country";
|
$sql.= " c.code as country_code, c.label as country";
|
||||||
|
// Add fields from extrafields
|
||||||
|
foreach ($extrafields->attribute_label as $key => $val)
|
||||||
|
$sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
|
$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";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_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.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||||
$sql.= " AND d.entity IN (".getEntity('adherent').")";
|
$sql.= " AND d.entity IN (".getEntity('adherent').")";
|
||||||
if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
|
if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
|
||||||
@ -85,9 +93,27 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
|||||||
|
|
||||||
if ($objp->country == '-') $objp->country='';
|
if ($objp->country == '-') $objp->country='';
|
||||||
|
|
||||||
|
$adherentstatic->id=$objp->rowid;
|
||||||
$adherentstatic->lastname=$objp->lastname;
|
$adherentstatic->lastname=$objp->lastname;
|
||||||
$adherentstatic->firstname=$objp->firstname;
|
$adherentstatic->firstname=$objp->firstname;
|
||||||
|
|
||||||
|
// format extrafiled so they can be parsed in function complete_substitutions_array
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
$adherentstatic->array_options = array();
|
||||||
|
foreach($extrafields->attribute_label as $key => $val)
|
||||||
|
{
|
||||||
|
$tmpkey='options_'.$key;
|
||||||
|
if (!empty($objp->$tmpkey))
|
||||||
|
{
|
||||||
|
$adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
|
||||||
|
}
|
||||||
|
//if (!empty($objp->$key))
|
||||||
|
// $objp->array_options[$tmpkey] = $objp->$key;
|
||||||
|
//$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// List of values to scan for a replacement
|
// List of values to scan for a replacement
|
||||||
$substitutionarray = array (
|
$substitutionarray = array (
|
||||||
'%ID%'=>$objp->rowid,
|
'%ID%'=>$objp->rowid,
|
||||||
@ -110,7 +136,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
|||||||
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
||||||
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs);
|
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
|
||||||
|
|
||||||
// For business cards
|
// For business cards
|
||||||
if (empty($mode) || $mode=='card' || $mode=='cardlogin')
|
if (empty($mode) || $mode=='card' || $mode=='cardlogin')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user