26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/modules/printsheet/modules_labels.php';
33$langs->loadLangs(array(
"members",
"errors"));
40$foruserid =
GETPOST(
'foruserid',
'alphanohtml');
41$foruserlogin =
GETPOST(
'foruserlogin',
'alphanohtml');
43$modelcard =
GETPOST(
"modelcard",
'aZ09');
44$model =
GETPOST(
"model",
'aZ09');
45$modellabel =
GETPOST(
"modellabel",
'aZ09');
53$extrafields->fetch_name_optionals_label(
$object->table_element);
63if ($mode ==
'cardlogin' && empty($foruserlogin)) {
64 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login"));
67if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
68 $arrayofmembers = array();
71 $sql =
"SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
72 $sql .=
" d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
73 $sql .=
" t.libelle as type,";
74 $sql .=
" c.code as country_code, c.label as country";
76 if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
77 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
78 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
81 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
82 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
83 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
84 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ef on (d.rowid = ef.fk_object)";
86 $sql .=
" WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
87 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
88 if (is_numeric($foruserid)) {
89 $sql .=
" AND d.rowid = ".(int) $foruserid;
92 $sql .=
" AND d.login = '".$db->escape($foruserlogin).
"'";
94 $sql .=
" ORDER BY d.rowid ASC";
97 $result = $db->query($sql);
99 $num = $db->num_rows($result);
102 $objp = $db->fetch_object($result);
104 if ($objp->country ==
'-') {
108 $adherentstatic->id = $objp->rowid;
109 $adherentstatic->ref = $objp->ref;
110 $adherentstatic->lastname = $objp->lastname;
111 $adherentstatic->firstname = $objp->firstname;
114 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
115 $adherentstatic->array_options = array();
116 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
117 $tmpkey =
'options_'.$key;
118 if (!empty($objp->$tmpkey)) {
119 $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
128 $substitutionarray = array(
129 '__ID__' => $objp->rowid,
130 '__REF__' => $objp->ref,
131 '__LOGIN__' => empty($objp->login) ?
'' : $objp->login,
132 '__FIRSTNAME__' => empty($objp->firstname) ?
'' : $objp->firstname,
133 '__LASTNAME__' => empty($objp->lastname) ?
'' : $objp->lastname,
134 '__FULLNAME__' => $adherentstatic->
getFullName($langs),
135 '__COMPANY__' => empty($objp->company) ?
'' : $objp->company,
137 '__ZIP__' => empty($objp->zip) ?
'' : $objp->zip,
138 '__TOWN__' => empty($objp->town) ?
'' : $objp->town,
139 '__COUNTRY__' => empty($objp->country) ?
'' : $objp->country,
140 '__COUNTRY_CODE__' => empty($objp->country_code) ?
'' : $objp->country_code,
141 '__EMAIL__' => empty($objp->
email) ?
'' : $objp->
email,
143 '__TYPE__' => empty($objp->
type) ?
'' : $objp->
type,
145 '__MONTH__' => $month,
147 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
148 '__SERVER__' =>
"https://".$_SERVER[
"SERVER_NAME"].
"/"
153 if (empty($mode) || $mode ==
'card' || $mode ==
'cardlogin') {
159 if (is_numeric($foruserid) || $foruserlogin) {
160 $nb = $_Avery_Labels[$model][
'NX'] * $_Avery_Labels[$model][
'NY'];
165 for ($j = 0; $j < $nb; $j++) {
166 $arrayofmembers[] = array(
167 'textleft'=>$textleft,
168 'textheader'=>$textheader,
169 'textfooter'=>$textfooter,
170 'textright'=>$textright,
173 'photo'=>$objp->photo
177 $arrayofmembers[] = array(
178 'textleft'=>$textleft,
179 'textheader'=>$textheader,
180 'textfooter'=>$textfooter,
181 'textright'=>$textright,
184 'photo'=>$objp->photo
190 if ($mode ==
'label') {
192 $conf->global->ADHERENT_ETIQUETTE_TEXT =
"__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
199 $arrayofmembers[] = array(
200 'textleft'=>$textleft,
201 'textheader'=>$textheader,
202 'textfooter'=>$textfooter,
203 'textright'=>$textright,
206 'photo'=>$objp->photo,
214 $outputlangs = $langs;
216 if (empty($mode) || $mode ==
'card') {
217 if (!count($arrayofmembers)) {
218 $mesg = $langs->trans(
"ErrorRecordNotFound");
220 if (empty($modelcard) || $modelcard ==
'-1') {
221 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
224 $result =
members_card_pdf_create($db, $arrayofmembers, $modelcard, $outputlangs,
'',
'standard',
'tmp_cards');
226 } elseif ($mode ==
'cardlogin') {
227 if (!count($arrayofmembers)) {
228 $mesg = $langs->trans(
"ErrorRecordNotFound");
230 if (empty($model) || $model ==
'-1') {
231 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
234 $result =
members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs,
'',
'standard',
'tmp_cards_login');
236 } elseif ($mode ==
'label') {
237 if (!count($arrayofmembers)) {
238 $mesg = $langs->trans(
"ErrorRecordNotFound");
240 if (empty($modellabel) || $modellabel ==
'-1') {
241 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
266$form =
new Form($db);
268$title = $langs->trans(
'MembersCards');
269$help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Mitglieder';
271llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-member page-cards');
273print
load_fiche_titre($langs->trans(
"LinkToGeneratedPages"),
'', $adherentstatic->picto);
275print
'<span class="opacitymedium">'.$langs->trans(
"LinkToGeneratedPagesDesc").
'</span><br>';
282print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForAllMembersCards",
getDolGlobalString(
'ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv(
"None"))).
' ';
283print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
284print
'<input type="hidden" name="token" value="'.newToken().
'">';
285print
'<input type="hidden" name="foruserid" value="all">';
286print
'<input type="hidden" name="mode" value="card">';
287print
'<input type="hidden" name="action" value="builddoc">';
288print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
290$arrayoflabels = array();
291foreach (array_keys($_Avery_Labels) as $codecards) {
292 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
294asort($arrayoflabels);
295print $form->selectarray(
'modelcard', $arrayoflabels, (
GETPOST(
'modelcard') ?
GETPOST(
'modelcard') :
getDolGlobalString(
'ADHERENT_CARD_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
296print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
301print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForOneMemberCards",
getDolGlobalString(
'ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv(
"None"))).
' ';
302print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
303print
'<input type="hidden" name="token" value="'.newToken().
'">';
304print
'<input type="hidden" name="mode" value="cardlogin">';
305print
'<input type="hidden" name="action" value="builddoc">';
306print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
308$arrayoflabels = array();
309foreach (array_keys($_Avery_Labels) as $codecards) {
310 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
312asort($arrayoflabels);
313print $form->selectarray(
'model', $arrayoflabels, (
GETPOST(
'model') ?
GETPOST(
'model') :
getDolGlobalString(
'ADHERENT_CARD_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
314print
'<br>'.$langs->trans(
"Login").
': <input class="with100" type="text" name="foruserlogin" value="'.
GETPOST(
'foruserlogin').
'">';
315print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
321print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
322print
'<input type="hidden" name="token" value="'.newToken().
'">';
323print
'<input type="hidden" name="mode" value="label">';
324print
'<input type="hidden" name="action" value="builddoc">';
325print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
327$arrayoflabels = array();
328foreach (array_keys($_Avery_Labels) as $codecards) {
329 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
331asort($arrayoflabels);
332print $form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') :
getDolGlobalString(
'ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
333print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div refaddress div address
members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard', $filename='tmp_cards')
Cree un fichier de cartes de visites en fonction du modele de ADHERENT_CARDS_ADDON_PDF.
doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf')
Create a document onto disk according to template module.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.