25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/modules/printsheet/modules_labels.php';
32 $langs->loadLangs(array(
"members",
"errors"));
39 $foruserid =
GETPOST(
'foruserid',
'alphanohtml');
40 $foruserlogin =
GETPOST(
'foruserlogin',
'alphanohtml');
41 $mode =
GETPOST(
'mode',
'aZ09');
42 $model =
GETPOST(
"model",
'aZ09');
43 $modellabel =
GETPOST(
"modellabel",
'aZ09');
51 $extrafields->fetch_name_optionals_label($object->table_element);
58 if ($mode ==
'cardlogin' && empty($foruserlogin)) {
59 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login"));
62 if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
63 $arrayofmembers = array();
66 $sql =
"SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
67 $sql .=
" d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
68 $sql .=
" t.libelle as type,";
69 $sql .=
" c.code as country_code, c.label as country";
71 if (!empty($extrafields->attributes[$object->table_element][
'label']))
72 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
73 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
74 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
75 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)";
76 $sql .=
" WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
77 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
78 if (is_numeric($foruserid)) $sql .=
" AND d.rowid=".$foruserid;
79 if ($foruserlogin) $sql .=
" AND d.login='".$db->escape($foruserlogin).
"'";
80 $sql .=
" ORDER BY d.rowid ASC";
83 $result = $db->query($sql);
85 $num = $db->num_rows($result);
88 $objp = $db->fetch_object($result);
90 if ($objp->country ==
'-') $objp->country =
'';
92 $adherentstatic->id = $objp->rowid;
93 $adherentstatic->lastname = $objp->lastname;
94 $adherentstatic->firstname = $objp->firstname;
97 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
98 $adherentstatic->array_options = array();
99 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
100 $tmpkey =
'options_'.$key;
101 if (!empty($objp->$tmpkey)) {
102 $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
111 $substitutionarray = array(
112 '__ID__'=>$objp->rowid,
113 '__LOGIN__'=>$objp->login,
114 '__FIRSTNAME__'=>$objp->firstname,
115 '__LASTNAME__'=>$objp->lastname,
116 '__FULLNAME__'=>$adherentstatic->getFullName($langs),
117 '__COMPANY__'=>$objp->company,
118 '__ADDRESS__'=>$objp->address,
119 '__ZIP__'=>$objp->zip,
120 '__TOWN__'=>$objp->town,
121 '__COUNTRY__'=>$objp->country,
122 '__COUNTRY_CODE__'=>$objp->country_code,
123 '__EMAIL__'=>$objp->email,
125 '__TYPE__'=>$objp->type,
129 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
130 '__SERVER__'=>
"http://".$_SERVER[
"SERVER_NAME"].
"/"
135 if (empty($mode) || $mode ==
'card' || $mode ==
'cardlogin') {
136 $textleft =
make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
137 $textheader =
make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
138 $textfooter =
make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
139 $textright =
make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
141 if (is_numeric($foruserid) || $foruserlogin) {
142 $nb = $_Avery_Labels[$model][
'NX'] * $_Avery_Labels[$model][
'NY'];
143 if ($nb <= 0) $nb = 1;
145 for ($j = 0; $j < $nb; $j++) {
146 $arrayofmembers[] = array(
147 'textleft'=>$textleft,
148 'textheader'=>$textheader,
149 'textfooter'=>$textfooter,
150 'textright'=>$textright,
152 'photo'=>$objp->photo
156 $arrayofmembers[] = array(
157 'textleft'=>$textleft,
158 'textheader'=>$textheader,
159 'textfooter'=>$textfooter,
160 'textright'=>$textright,
162 'photo'=>$objp->photo
168 if ($mode ==
'label') {
169 if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT =
"__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
170 $textleft =
make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
175 $arrayofmembers[] = array(
'textleft'=>$textleft,
176 'textheader'=>$textheader,
177 'textfooter'=>$textfooter,
178 'textright'=>$textright,
180 'photo'=>$objp->photo);
187 if (empty($mode) || $mode ==
'card' || $mode ==
'cardlogin') {
188 if (!count($arrayofmembers)) {
189 $mesg = $langs->trans(
"ErrorRecordNotFound");
191 if (empty($model) || $model ==
'-1') {
192 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
195 } elseif ($mode ==
'label') {
196 if (!count($arrayofmembers)) {
197 $mesg = $langs->trans(
"ErrorRecordNotFound");
199 if (empty($modellabel) || $modellabel ==
'-1') {
200 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
223 $form =
new Form($db);
225 llxHeader(
'', $langs->trans(
"MembersCards"));
229 print '<span class="opacitymedium">'.$langs->trans(
"LinkToGeneratedPagesDesc").
'</span><br>';
236 print img_picto(
'',
'puce').
' '.$langs->trans(
"DocForAllMembersCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv(
"None"))).
' ';
237 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
238 print '<input type="hidden" name="token" value="'.newToken().
'">';
239 print '<input type="hidden" name="foruserid" value="all">';
240 print '<input type="hidden" name="mode" value="card">';
241 print '<input type="hidden" name="action" value="builddoc">';
242 print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
244 $arrayoflabels = array();
245 foreach (array_keys($_Avery_Labels) as $codecards) {
246 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
248 asort($arrayoflabels);
249 print $form->selectarray(
'model', $arrayoflabels, (
GETPOST(
'model') ?
GETPOST(
'model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
250 print '<br><input class="button" type="submit" value="'.$langs->trans(
"BuildDoc").
'">';
255 print img_picto(
'',
'puce').
' '.$langs->trans(
"DocForOneMemberCards", ($conf->global->ADHERENT_CARD_TYPE ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv(
"None"))).
' ';
256 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
257 print '<input type="hidden" name="token" value="'.newToken().
'">';
258 print '<input type="hidden" name="mode" value="cardlogin">';
259 print '<input type="hidden" name="action" value="builddoc">';
260 print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
262 $arrayoflabels = array();
263 foreach (array_keys($_Avery_Labels) as $codecards) {
264 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
266 asort($arrayoflabels);
267 print $form->selectarray(
'model', $arrayoflabels, (
GETPOST(
'model') ?
GETPOST(
'model') : $conf->global->ADHERENT_CARD_TYPE), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
268 print '<br>'.$langs->trans(
"Login").
': <input size="10" type="text" name="foruserlogin" value="'.
GETPOST(
'foruserlogin').
'">';
269 print '<br><input class="button" type="submit" value="'.$langs->trans(
"BuildDoc").
'">';
274 print img_picto(
'',
'puce').
' '.$langs->trans(
"DocForLabels", $conf->global->ADHERENT_ETIQUETTE_TYPE).
' ';
275 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
276 print '<input type="hidden" name="token" value="'.newToken().
'">';
277 print '<input type="hidden" name="mode" value="label">';
278 print '<input type="hidden" name="action" value="builddoc">';
279 print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
281 $arrayoflabels = array();
282 foreach (array_keys($_Avery_Labels) as $codecards) {
283 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
285 asort($arrayoflabels);
286 print $form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') : $conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
287 print '<br><input class="button" type="submit" value="'.$langs->trans(
"BuildDoc").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir= '', $template= 'standard')
Cree un fichier de cartes de visites en fonction du modele de ADHERENT_CARDS_ADDON_PDF.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage members of a foundation.
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.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
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...