25require
'../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
30require_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');
42$modelcard =
GETPOST(
"modelcard",
'aZ09');
43$model =
GETPOST(
"model",
'aZ09');
44$modellabel =
GETPOST(
"modellabel",
'aZ09');
52$extrafields->fetch_name_optionals_label($object->table_element);
62if ($mode ==
'cardlogin' && empty($foruserlogin)) {
63 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login"));
66if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
67 $arrayofmembers = array();
70 $sql =
"SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
71 $sql .=
" d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
72 $sql .=
" t.libelle as type,";
73 $sql .=
" c.code as country_code, c.label as country";
75 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
76 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
77 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
80 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
81 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
82 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
83 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ef on (d.rowid = ef.fk_object)";
85 $sql .=
" WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
86 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
87 if (is_numeric($foruserid)) {
88 $sql .=
" AND d.rowid = ".(int) $foruserid;
91 $sql .=
" AND d.login = '".$db->escape($foruserlogin).
"'";
93 $sql .=
" ORDER BY d.rowid ASC";
96 $result = $db->query($sql);
98 $num = $db->num_rows($result);
101 $objp = $db->fetch_object($result);
103 if ($objp->country ==
'-') {
107 $adherentstatic->id = $objp->rowid;
108 $adherentstatic->ref = $objp->ref;
109 $adherentstatic->lastname = $objp->lastname;
110 $adherentstatic->firstname = $objp->firstname;
113 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
114 $adherentstatic->array_options = array();
115 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
116 $tmpkey =
'options_'.$key;
117 if (!empty($objp->$tmpkey)) {
118 $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
127 $substitutionarray = array(
128 '__ID__' => $objp->rowid,
129 '__REF__' => $objp->ref,
130 '__LOGIN__' => empty($objp->login) ?
'' : $objp->login,
131 '__FIRSTNAME__' => empty($objp->firstname) ?
'' : $objp->firstname,
132 '__LASTNAME__' => empty($objp->lastname) ?
'' : $objp->lastname,
133 '__FULLNAME__' => $adherentstatic->
getFullName($langs),
134 '__COMPANY__' => empty($objp->company) ?
'' : $objp->company,
135 '__ADDRESS__' => empty($objp->address) ?
'' : $objp->address,
136 '__ZIP__' => empty($objp->zip) ?
'' : $objp->zip,
137 '__TOWN__' => empty($objp->town) ?
'' : $objp->town,
138 '__COUNTRY__' => empty($objp->country) ?
'' : $objp->country,
139 '__COUNTRY_CODE__' => empty($objp->country_code) ?
'' : $objp->country_code,
140 '__EMAIL__' => empty($objp->email) ?
'' : $objp->email,
142 '__TYPE__' => empty($objp->
type) ?
'' : $objp->
type,
144 '__MONTH__' => $month,
146 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
147 '__SERVER__' =>
"https://".$_SERVER[
"SERVER_NAME"].
"/"
152 if (empty($mode) || $mode ==
'card' || $mode ==
'cardlogin') {
153 $textleft =
make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
154 $textheader =
make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
155 $textfooter =
make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
156 $textright =
make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
158 if (is_numeric($foruserid) || $foruserlogin) {
159 $nb = $_Avery_Labels[$model][
'NX'] * $_Avery_Labels[$model][
'NY'];
164 for ($j = 0; $j < $nb; $j++) {
165 $arrayofmembers[] = array(
166 'textleft'=>$textleft,
167 'textheader'=>$textheader,
168 'textfooter'=>$textfooter,
169 'textright'=>$textright,
172 'photo'=>$objp->photo
176 $arrayofmembers[] = array(
177 'textleft'=>$textleft,
178 'textheader'=>$textheader,
179 'textfooter'=>$textfooter,
180 'textright'=>$textright,
183 'photo'=>$objp->photo
189 if ($mode ==
'label') {
190 if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) {
191 $conf->global->ADHERENT_ETIQUETTE_TEXT =
"__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
193 $textleft =
make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
198 $arrayofmembers[] = array(
199 'textleft'=>$textleft,
200 'textheader'=>$textheader,
201 'textfooter'=>$textfooter,
202 'textright'=>$textright,
205 'photo'=>$objp->photo,
213 $outputlangs = $langs;
215 if (empty($mode) || $mode ==
'card') {
216 if (!count($arrayofmembers)) {
217 $mesg = $langs->trans(
"ErrorRecordNotFound");
219 if (empty($modelcard) || $modelcard ==
'-1') {
220 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
223 $result =
members_card_pdf_create($db, $arrayofmembers, $modelcard, $outputlangs,
'',
'standard',
'tmp_cards');
225 } elseif ($mode ==
'cardlogin') {
226 if (!count($arrayofmembers)) {
227 $mesg = $langs->trans(
"ErrorRecordNotFound");
229 if (empty($model) || $model ==
'-1') {
230 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
233 $result =
members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs,
'',
'standard',
'tmp_cards_login');
235 } elseif ($mode ==
'label') {
236 if (!count($arrayofmembers)) {
237 $mesg = $langs->trans(
"ErrorRecordNotFound");
239 if (empty($modellabel) || $modellabel ==
'-1') {
240 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
265$form =
new Form($db);
267llxHeader(
'', $langs->trans(
"MembersCards"));
269print
load_fiche_titre($langs->trans(
"LinkToGeneratedPages"),
'', $adherentstatic->picto);
271print
'<span class="opacitymedium">'.$langs->trans(
"LinkToGeneratedPagesDesc").
'</span><br>';
278print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForAllMembersCards", (!empty($conf->global->ADHERENT_CARD_TYPE) ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv(
"None"))).
' ';
279print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
280print
'<input type="hidden" name="token" value="'.newToken().
'">';
281print
'<input type="hidden" name="foruserid" value="all">';
282print
'<input type="hidden" name="mode" value="card">';
283print
'<input type="hidden" name="action" value="builddoc">';
284print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
286$arrayoflabels = array();
287foreach (array_keys($_Avery_Labels) as $codecards) {
288 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
290asort($arrayoflabels);
291print $form->selectarray(
'modelcard', $arrayoflabels, (
GETPOST(
'modelcard') ?
GETPOST(
'modelcard') : (empty($conf->global->ADHERENT_CARD_TYPE) ?
'' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
292print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
297print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForOneMemberCards", (!empty($conf->global->ADHERENT_CARD_TYPE) ? $conf->global->ADHERENT_CARD_TYPE : $langs->transnoentitiesnoconv(
"None"))).
' ';
298print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
299print
'<input type="hidden" name="token" value="'.newToken().
'">';
300print
'<input type="hidden" name="mode" value="cardlogin">';
301print
'<input type="hidden" name="action" value="builddoc">';
302print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
304$arrayoflabels = array();
305foreach (array_keys($_Avery_Labels) as $codecards) {
306 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
308asort($arrayoflabels);
309print $form->selectarray(
'model', $arrayoflabels, (
GETPOST(
'model') ?
GETPOST(
'model') : (empty($conf->global->ADHERENT_CARD_TYPE) ?
'' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
310print
'<br>'.$langs->trans(
"Login").
': <input class="with100" type="text" name="foruserlogin" value="'.
GETPOST(
'foruserlogin').
'">';
311print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
316print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForLabels", (empty($conf->global->ADHERENT_ETIQUETTE_TYPE) ?
'' : $conf->global->ADHERENT_ETIQUETTE_TYPE)).
' ';
317print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
318print
'<input type="hidden" name="token" value="'.newToken().
'">';
319print
'<input type="hidden" name="mode" value="label">';
320print
'<input type="hidden" name="action" value="builddoc">';
321print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
323$arrayoflabels = array();
324foreach (array_keys($_Avery_Labels) as $codecards) {
325 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
327asort($arrayoflabels);
328print $form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') : (empty($conf->global->ADHERENT_ETIQUETTE_TYPE) ?
'' : $conf->global->ADHERENT_ETIQUETTE_TYPE)), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
329print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated 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.
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.