28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/modules/printsheet/modules_labels.php';
45$langs->loadLangs(array(
"members",
"errors"));
52$foruserid =
GETPOST(
'foruserid',
'alphanohtml');
53$foruserlogin =
GETPOST(
'foruserlogin',
'alphanohtml');
55$modelcard =
GETPOST(
"modelcard",
'aZ09');
56$model =
GETPOST(
"model",
'aZ09');
57$modellabel =
GETPOST(
"modellabel",
'aZ09');
65$extrafields->fetch_name_optionals_label(
$object->table_element);
75if ($mode ==
'cardlogin' && empty($foruserlogin)) {
76 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login"));
79if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
80 $arrayofmembers = array();
83 $sql =
"SELECT d.rowid, d.ref, d.civility, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
84 $sql .=
" d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
85 $sql .=
" t.libelle as type,";
86 $sql .=
" c.code as country_code, c.label as country";
88 if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
89 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
90 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
94 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
95 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ef on (d.rowid = ef.fk_object)";
98 $sql .=
" WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
99 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
100 if (is_numeric($foruserid)) {
101 $sql .=
" AND d.rowid = ".(int) $foruserid;
104 $sql .=
" AND d.login = '".$db->escape($foruserlogin).
"'";
106 $sql .=
" ORDER BY d.rowid ASC";
109 $result = $db->query($sql);
111 $num = $db->num_rows($result);
114 $objp = $db->fetch_object($result);
116 if ($objp->country ==
'-') {
120 $adherentstatic->id = $objp->rowid;
121 $adherentstatic->ref = $objp->ref;
122 $adherentstatic->lastname = $objp->lastname;
123 $adherentstatic->firstname = $objp->firstname;
126 if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
127 $adherentstatic->array_options = array();
128 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
129 $tmpkey =
'options_'.$key;
130 if (!empty($objp->$tmpkey)) {
131 $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
140 $substitutionarray = array(
141 '__MEMBER_ID__' => $objp->rowid,
142 '__MEMBER_REF__' => $objp->ref,
143 '__MEMBER_LOGIN__' => empty($objp->login) ?
'' : $objp->login,
144 '__MEMBER_TITLE__' => empty($objp->civility) ?
'' : $langs->trans(
"Civility".$objp->civility),
145 '__MEMBER_FIRSTNAME__' => empty($objp->firstname) ?
'' : $objp->firstname,
146 '__MEMBER_LASTNAME__' => empty($objp->lastname) ?
'' : $objp->lastname,
147 '__MEMBER_FULLNAME__' => $adherentstatic->
getFullName($langs),
148 '__MEMBER_COMPANY__' => empty($objp->company) ?
'' : $objp->company,
149 '__MEMBER_ADDRESS__' => empty($objp->
address) ?
'' : $objp->
address,
150 '__MEMBER_ZIP__' => empty($objp->zip) ?
'' : $objp->zip,
151 '__MEMBER_TOWN__' => empty($objp->town) ?
'' : $objp->town,
152 '__MEMBER_COUNTRY__' => empty($objp->country) ?
'' : $objp->country,
153 '__MEMBER_COUNTRY_CODE__' => empty($objp->country_code) ?
'' : $objp->country_code,
154 '__MEMBER_EMAIL__' => empty($objp->
email) ?
'' : $objp->
email,
156 '__MEMBER_TYPE__' => empty($objp->
type) ?
'' : $objp->
type,
158 '__MONTH__' => $month,
160 '__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,
161 '__SERVER__' =>
"https://".$_SERVER[
"SERVER_NAME"].
"/"
163 foreach ($adherentstatic->array_options as $key => $val) {
164 $substitutionarray[
'__'.strtoupper($key).
'__'] = $val;
169 if (empty($mode) || $mode ==
'card' || $mode ==
'cardlogin') {
175 if (is_numeric($foruserid) || $foruserlogin) {
176 $nb = $_Avery_Labels[$model][
'NX'] * $_Avery_Labels[$model][
'NY'];
181 for ($j = 0; $j < $nb; $j++) {
182 $arrayofmembers[] = array(
183 'textleft'=>$textleft,
184 'textheader'=>$textheader,
185 'textfooter'=>$textfooter,
186 'textright'=>$textright,
189 'photo'=>$objp->photo
193 $arrayofmembers[] = array(
194 'textleft'=>$textleft,
195 'textheader'=>$textheader,
196 'textfooter'=>$textfooter,
197 'textright'=>$textright,
200 'photo'=>$objp->photo
206 if ($mode ==
'label') {
208 $conf->global->ADHERENT_ETIQUETTE_TEXT =
"__MEMBER_TITLE__\n__MEMBER_FULLNAME__\n__MEMBER_ADDRESS__\n__MEMBER_ZIP__ __MEMBER_TOWN__\n__MEMBER_COUNTRY__";
215 $arrayofmembers[] = array(
216 'textleft'=>$textleft,
217 'textheader'=>$textheader,
218 'textfooter'=>$textfooter,
219 'textright'=>$textright,
222 'photo'=>$objp->photo,
230 $outputlangs = $langs;
232 if (empty($mode) || $mode ==
'card') {
233 if (!count($arrayofmembers)) {
234 $mesg = $langs->trans(
"ErrorRecordNotFound");
236 if (empty($modelcard) || $modelcard ==
'-1') {
237 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
240 $result =
members_card_pdf_create($db, $arrayofmembers, $modelcard, $outputlangs,
'',
'standard',
'tmp_cards');
242 } elseif ($mode ==
'cardlogin') {
243 if (!count($arrayofmembers)) {
244 $mesg = $langs->trans(
"ErrorRecordNotFound");
246 if (empty($model) || $model ==
'-1') {
247 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_CARD_TYPE"));
250 $result =
members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs,
'',
'standard',
'tmp_cards_login');
252 } elseif ($mode ==
'label') {
253 if (!count($arrayofmembers)) {
254 $mesg = $langs->trans(
"ErrorRecordNotFound");
256 if (empty($modellabel) || $modellabel ==
'-1') {
257 $mesg = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DescADHERENT_ETIQUETTE_TYPE"));
282$form =
new Form($db);
284$title = $langs->trans(
'MembersCards');
285$help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Mitglieder';
287llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-member page-cards');
289print
load_fiche_titre($langs->trans(
"LinkToGeneratedPages"),
'', $adherentstatic->picto);
291print
'<span class="opacitymedium">'.$langs->trans(
"LinkToGeneratedPagesDesc").
'</span><br>';
298print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForAllMembersCards",
getDolGlobalString(
'ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv(
"None"))).
' ';
299print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
300print
'<input type="hidden" name="token" value="'.newToken().
'">';
301print
'<input type="hidden" name="foruserid" value="all">';
302print
'<input type="hidden" name="mode" value="card">';
303print
'<input type="hidden" name="action" value="builddoc">';
304print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
306$arrayoflabels = array();
307foreach (array_keys($_Avery_Labels) as $codecards) {
308 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
310asort($arrayoflabels);
311print $form->selectarray(
'modelcard', $arrayoflabels, (
GETPOST(
'modelcard') ?
GETPOST(
'modelcard') :
getDolGlobalString(
'ADHERENT_CARD_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
312print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
317print
img_picto(
'',
'card').
' '.$langs->trans(
"DocForOneMemberCards",
getDolGlobalString(
'ADHERENT_CARD_TYPE', $langs->transnoentitiesnoconv(
"None"))).
' ';
318print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
319print
'<input type="hidden" name="token" value="'.newToken().
'">';
320print
'<input type="hidden" name="mode" value="cardlogin">';
321print
'<input type="hidden" name="action" value="builddoc">';
322print $langs->trans(
"DescADHERENT_CARD_TYPE").
' ';
324$arrayoflabels = array();
325foreach (array_keys($_Avery_Labels) as $codecards) {
326 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
328asort($arrayoflabels);
329print $form->selectarray(
'model', $arrayoflabels, (
GETPOST(
'model') ?
GETPOST(
'model') :
getDolGlobalString(
'ADHERENT_CARD_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
330print
'<br>'.$langs->trans(
"Login").
': <input class="width100" type="text" name="foruserlogin" value="'.
GETPOST(
'foruserlogin').
'">';
331print
'<br><input type="submit" class="button small" value="'.$langs->trans(
"BuildDoc").
'">';
337print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
338print
'<input type="hidden" name="token" value="'.newToken().
'">';
339print
'<input type="hidden" name="mode" value="label">';
340print
'<input type="hidden" name="action" value="builddoc">';
341print $langs->trans(
"DescADHERENT_ETIQUETTE_TYPE").
' ';
343$arrayoflabels = array();
344foreach (array_keys($_Avery_Labels) as $codecards) {
345 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
347asort($arrayoflabels);
348print $form->selectarray(
'modellabel', $arrayoflabels, (
GETPOST(
'modellabel') ?
GETPOST(
'modellabel') :
getDolGlobalString(
'ADHERENT_ETIQUETTE_TYPE')), 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
349print
'<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
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.