dolibarr  18.0.0
member.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
8  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
10  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
11  * Copyright (C) 2020-2021 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 // Load Dolibarr environment
34 require '../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array("admin", "members"));
40 
41 if (!$user->admin) {
43 }
44 
45 
46 $choices = array('yesno', 'texte', 'chaine');
47 
48 $value = GETPOST('value', 'alpha');
49 $label = GETPOST('label', 'alpha');
50 $scandir = GETPOST('scandir', 'alpha');
51 $type = 'member';
52 
53 $action = GETPOST('action', 'aZ09');
54 
55 
56 /*
57  * Actions
58  */
59 
60 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
61 
62 if ($action == 'set_default') {
63  $ret = addDocumentModel($value, $type, $label, $scandir);
64  $res = true;
65 } elseif ($action == 'del_default') {
66  $ret = delDocumentModel($value, $type);
67  if ($ret > 0) {
68  if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == "$value") {
69  dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity);
70  }
71  }
72  $res = true;
73 } elseif ($action == 'setdoc') {
74  // Set default model
75  if (dolibarr_set_const($db, "MEMBER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) {
76  // The constant that was read ahead of the new set
77  // we therefore go through a variable to have a consistent display
78  $conf->global->MEMBER_ADDON_PDF_ODT = $value;
79  }
80 
81  // We activate the model
82  $ret = delDocumentModel($value, $type);
83  if ($ret > 0) {
84  $ret = addDocumentModel($value, $type, $label, $scandir);
85  }
86  $res = true;
87 } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
88  $code = $reg[1];
89  if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
90  header("Location: ".$_SERVER["PHP_SELF"]);
91  exit;
92  } else {
93  dol_print_error($db);
94  }
95 } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
96  $code = $reg[1];
97  if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
98  header("Location: ".$_SERVER["PHP_SELF"]);
99  exit;
100  } else {
101  dol_print_error($db);
102  }
103 } elseif ($action == 'updatemainoptions') {
104  $db->begin();
105  $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = 0;
106  $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
107  $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
108  $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
109  $res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity);
110  $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
111  $res7 = dolibarr_set_const($db, 'MEMBER_PUBLIC_ENABLED', GETPOST('MEMBER_PUBLIC_ENABLED', 'alpha'), 'chaine', 0, '', $conf->entity);
112  // Use vat for invoice creation
113  if (isModEnabled('facture')) {
114  $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
115  $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
116  if (isModEnabled("product") || isModEnabled("service")) {
117  $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
118  }
119  }
120  if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0) {
121  setEventMessages('ErrorFailedToSaveData', null, 'errors');
122  $db->rollback();
123  } else {
124  setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
125  $db->commit();
126  }
127 } elseif ($action == 'updatememberscards') {
128  $db->begin();
129  $res1 = $res2 = $res3 = $res4 = 0;
130  $res1 = dolibarr_set_const($db, 'ADHERENT_CARD_TYPE', GETPOST('ADHERENT_CARD_TYPE'), 'chaine', 0, '', $conf->entity);
131  $res2 = dolibarr_set_const($db, 'ADHERENT_CARD_HEADER_TEXT', GETPOST('ADHERENT_CARD_HEADER_TEXT', 'alpha'), 'chaine', 0, '', $conf->entity);
132  $res3 = dolibarr_set_const($db, 'ADHERENT_CARD_TEXT', GETPOST('ADHERENT_CARD_TEXT', 'alpha'), 'chaine', 0, '', $conf->entity);
133  $res3 = dolibarr_set_const($db, 'ADHERENT_CARD_TEXT_RIGHT', GETPOST('ADHERENT_CARD_TEXT_RIGHT', 'alpha'), 'chaine', 0, '', $conf->entity);
134  $res4 = dolibarr_set_const($db, 'ADHERENT_CARD_FOOTER_TEXT', GETPOST('ADHERENT_CARD_FOOTER_TEXT', 'alpha'), 'chaine', 0, '', $conf->entity);
135 
136  if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0) {
137  setEventMessages('ErrorFailedToSaveDate', null, 'errors');
138  $db->rollback();
139  } else {
140  setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
141  $db->commit();
142  }
143 } elseif ($action == 'updatememberstickets') {
144  $db->begin();
145  $res1 = $res2 = 0;
146  $res1 = dolibarr_set_const($db, 'ADHERENT_ETIQUETTE_TYPE', GETPOST('ADHERENT_ETIQUETTE_TYPE'), 'chaine', 0, '', $conf->entity);
147  $res2 = dolibarr_set_const($db, 'ADHERENT_ETIQUETTE_TEXT', GETPOST('ADHERENT_ETIQUETTE_TEXT', 'alpha'), 'chaine', 0, '', $conf->entity);
148 
149  if ($res1 < 0 || $res2 < 0) {
150  setEventMessages('ErrorFailedToSaveDate', null, 'errors');
151  $db->rollback();
152  } else {
153  setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
154  $db->commit();
155  }
156 } elseif ($action == 'setcodemember') {
157  $result = dolibarr_set_const($db, "MEMBER_CODEMEMBER_ADDON", $value, 'chaine', 0, '', $conf->entity);
158  if ($result <= 0) {
159  dol_print_error($db);
160  }
161 } elseif ($action == 'update' || $action == 'add') {
162  // Action to update or add a constant
163  $constname = GETPOST('constname', 'alpha');
164  $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
165 
166 
167  if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) {
168  $constvalue = '';
169  }
170  if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') { // Invert choice
171  if ($constvalue) {
172  $constvalue = 0;
173  } else {
174  $constvalue = 1;
175  }
176  }
177 
178  $consttype = GETPOST('consttype', 'alpha');
179  $constnote = GETPOST('constnote');
180  $res = dolibarr_set_const($db, $constname, $constvalue, $choices[$consttype], 0, $constnote, $conf->entity);
181 
182  if (!($res > 0)) {
183  $error++;
184  }
185 
186  if (!$error) {
187  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
188  } else {
189  setEventMessages($langs->trans("Error"), null, 'errors');
190  }
191 }
192 
193 // Action to enable of a submodule of the adherent module
194 if ($action == 'set') {
195  $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
196  if ($result < 0) {
197  print $db->error();
198  }
199 }
200 
201 // Action to disable a submodule of the adherent module
202 if ($action == 'unset') {
203  $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
204  if ($result < 0) {
205  print $db->error();
206  }
207 }
208 
209 
210 
211 /*
212  * View
213  */
214 
215 $form = new Form($db);
216 
217 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
218 
219 llxHeader('', $langs->trans("MembersSetup"), $help_url);
220 
221 
222 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
223 print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
224 
225 
226 $head = member_admin_prepare_head();
227 
228 print dol_get_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user');
229 
230 $dirModMember = array_merge(array('/core/modules/member/'), $conf->modules_parts['member']);
231 foreach ($conf->modules_parts['models'] as $mo) {
232  //Add more models
233  $dirModMember[] = $mo.'core/modules/member/';
234 }
235 
236 // Module to manage customer/supplier code
237 
238 print load_fiche_titre($langs->trans("MemberCodeChecker"), '', '');
239 
240 print '<div class="div-table-responsive-no-min">';
241 print '<table class="noborder centpercent">'."\n";
242 print '<tr class="liste_titre">'."\n";
243 print ' <td>'.$langs->trans("Name").'</td>';
244 print ' <td>'.$langs->trans("Description").'</td>';
245 print ' <td>'.$langs->trans("Example").'</td>';
246 print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
247 print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
248 print "</tr>\n";
249 
250 $arrayofmodules = array();
251 
252 foreach ($dirModMember as $dirroot) {
253  $dir = dol_buildpath($dirroot, 0);
254 
255  $handle = @opendir($dir);
256  if (is_resource($handle)) {
257  // Loop on each module find in opened directory
258  while (($file = readdir($handle)) !== false) {
259  // module filename has to start with mod_member_
260  if (substr($file, 0, 11) == 'mod_member_' && substr($file, -3) == 'php') {
261  $file = substr($file, 0, dol_strlen($file) - 4);
262  try {
263  dol_include_once($dirroot.$file.'.php');
264  } catch (Exception $e) {
265  dol_syslog($e->getMessage(), LOG_ERR);
266  continue;
267  }
268  $modCodeMember = new $file;
269  // Show modules according to features level
270  if ($modCodeMember->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
271  continue;
272  }
273  if ($modCodeMember->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
274  continue;
275  }
276 
277  $arrayofmodules[$file] = $modCodeMember;
278  }
279  }
280  closedir($handle);
281  }
282 }
283 
284 $arrayofmodules = dol_sort_array($arrayofmodules, 'position');
285 
286 foreach ($arrayofmodules as $file => $modCodeMember) {
287  print '<tr class="oddeven">'."\n";
288  print '<td width="140">'.$modCodeMember->name.'</td>'."\n";
289  print '<td>'.$modCodeMember->info($langs).'</td>'."\n";
290  print '<td class="nowrap">'.$modCodeMember->getExample($langs).'</td>'."\n";
291 
292  if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == "$file") {
293  print '<td class="center">'."\n";
294  print img_picto($langs->trans("Activated"), 'switch_on');
295  print "</td>\n";
296  } else {
297  $disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
298  print '<td class="center">';
299  if (!$disabled) {
300  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodemember&token='.newToken().'&value='.urlencode($file).'">';
301  }
302  print img_picto($langs->trans("Disabled"), 'switch_off');
303  if (!$disabled) {
304  print '</a>';
305  }
306  print '</td>';
307  }
308 
309  print '<td class="center">';
310  $s = $modCodeMember->getToolTip($langs, null, -1);
311  print $form->textwithpicto('', $s, 1);
312  print '</td>';
313 
314  print '</tr>';
315 }
316 print '</table>';
317 print '</div>';
318 
319 print "<br>";
320 
321 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
322 print '<input type="hidden" name="token" value="'.newToken().'">';
323 print '<input type="hidden" name="action" value="updatemainoptions">';
324 
325 
326 // Main options
327 
328 print load_fiche_titre($langs->trans("MemberMainOptions"), '', '');
329 
330 print '<div class="div-table-responsive-no-min">';
331 print '<table class="noborder centpercent">';
332 print '<tr class="liste_titre">';
333 print '<td>'.$langs->trans("Description").'</td>';
334 print '<td>'.$langs->trans("Value").'</td>';
335 print "</tr>\n";
336 
337 // Mail required for members
338 print '<tr class="oddeven"><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
339 print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);
340 print "</td></tr>\n";
341 
342 // Login/Pass required for members
343 print '<tr class="oddeven"><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
344 print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1);
345 print "</td></tr>\n";
346 
347 // Send mail information is on by default
348 print '<tr class="oddeven"><td>'.$langs->trans("MemberSendInformationByMailByDefault").'</td><td>';
349 print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1);
350 print "</td></tr>\n";
351 
352 // Create an external user login for each new member subscription validated
353 print '<tr class="oddeven"><td>'.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").'</td><td>';
354 print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN) ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1);
355 print "</td></tr>\n";
356 
357 // Create an external user login for each new member subscription validated
358 $linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
359 print '<tr class="oddeven"><td>'.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).'</td><td>';
360 print $form->selectyesno('MEMBER_PUBLIC_ENABLED', (!empty($conf->global->MEMBER_PUBLIC_ENABLED) ? $conf->global->MEMBER_PUBLIC_ENABLED : 0), 1);
361 print "</td></tr>\n";
362 
363 // Allow members to change type on renewal forms
364 /* To test during next beta
365 print '<tr class="oddeven"><td>'.$langs->trans("MemberAllowchangeOfType").'</td><td>';
366 print $form->selectyesno('MEMBER_ALLOW_CHANGE_OF_TYPE', (!empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE) ? 0 : 1), 1);
367 print "</td></tr>\n";
368 */
369 
370 // Insert subscription into bank account
371 print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
372 $arraychoices = array('0'=>$langs->trans("None"));
373 if (isModEnabled("banque")) {
374  $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect");
375 }
376 if (isModEnabled("banque") && isModEnabled("societe") && isModEnabled('facture')) {
377  $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly");
378 }
379 if (isModEnabled("banque") && isModEnabled("societe") && isModEnabled('facture')) {
380  $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
381 }
382 print '<td>';
383 print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, getDolGlobalString('ADHERENT_BANK_USE'), 0);
384 if (getDolGlobalString('ADHERENT_BANK_USE') == 'bankdirect' || getDolGlobalString('ADHERENT_BANK_USE') == 'bankviainvoice') {
385  print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>';
386 }
387 print '</td>';
388 print "</tr>\n";
389 
390 // Use vat for invoice creation
391 if (isModEnabled('facture')) {
392  print '<tr class="oddeven"><td>'.$langs->trans("VATToUseForSubscriptions").'</td>';
393  if (isModEnabled("banque")) {
394  print '<td>';
395  print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0);
396  print '</td>';
397  } else {
398  print '<td class="right">';
399  print $langs->trans("WarningModuleNotActive", $langs->transnoentities("Module85Name"));
400  print '</td>';
401  }
402  print "</tr>\n";
403 
404  if (isModEnabled("product") || isModEnabled("service")) {
405  print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
406  print '<td>';
407  $selected = (empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
408  print img_picto('', 'product', 'class="pictofixedwidth"');
409  $form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
410  print '</td>';
411  }
412  print "</tr>\n";
413 }
414 
415 print '</table>';
416 print '</div>';
417 
418 print '<div class="center">';
419 print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
420 print '</div>';
421 
422 print '</form>';
423 
424 
425 print '<br>';
426 
427 
428 // Document templates for documents generated from member record
429 
430 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
431 
432 // Defined model definition table
433 $def = array();
434 $sql = "SELECT nom as name";
435 $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
436 $sql .= " WHERE type = '".$db->escape($type)."'";
437 $sql .= " AND entity = ".$conf->entity;
438 $resql = $db->query($sql);
439 if ($resql) {
440  $i = 0;
441  $num_rows = $db->num_rows($resql);
442  while ($i < $num_rows) {
443  $obj = $db->fetch_object($resql);
444  array_push($def, $obj->name);
445  $i++;
446  }
447 } else {
448  dol_print_error($db);
449 }
450 
451 
452 print load_fiche_titre($langs->trans("MembersDocModules"), '', '');
453 
454 print '<div class="div-table-responsive-no-min">';
455 print '<table class="noborder centpercent">';
456 print '<tr class="liste_titre">';
457 print '<td>'.$langs->trans("Name").'</td>';
458 print '<td>'.$langs->trans("Description").'</td>';
459 print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
460 print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
461 print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
462 print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
463 print "</tr>\n";
464 
465 clearstatcache();
466 
467 foreach ($dirmodels as $reldir) {
468  foreach (array('', '/doc') as $valdir) {
469  $dir = dol_buildpath($reldir."core/modules/member".$valdir);
470  if (is_dir($dir)) {
471  $handle = opendir($dir);
472  if (is_resource($handle)) {
473  while (($file = readdir($handle)) !== false) {
474  $filelist[] = $file;
475  }
476  closedir($handle);
477  arsort($filelist);
478  foreach ($filelist as $file) {
479  if (preg_match('/\.class\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
480  if (file_exists($dir.'/'.$file)) {
481  $name = substr($file, 4, dol_strlen($file) - 14);
482  $classname = substr($file, 0, dol_strlen($file) - 10);
483 
484  require_once $dir.'/'.$file;
485  $module = new $classname($db);
486 
487  $modulequalified = 1;
488  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
489  $modulequalified = 0;
490  }
491  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
492  $modulequalified = 0;
493  }
494 
495  if ($modulequalified) {
496  print '<tr class="oddeven"><td width="100">';
497  print (empty($module->name) ? $name : $module->name);
498  print "</td><td>\n";
499  if (method_exists($module, 'info')) {
500  print $module->info($langs);
501  } else {
502  print $module->description;
503  }
504  print '</td>';
505 
506  // Active
507  if (in_array($name, $def)) {
508  print '<td class="center">'."\n";
509  print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&token='.newToken().'&value='.$name.'">';
510  print img_picto($langs->trans("Enabled"), 'switch_on');
511  print '</a>';
512  print '</td>';
513  } else {
514  print '<td class="center">'."\n";
515  print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&token='.newToken().'&value='.$name.'&scandir='.(!empty($module->scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
516  print "</td>";
517  }
518 
519  // Defaut
520  print '<td class="center">';
521  if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == $name) {
522  print img_picto($langs->trans("Default"), 'on');
523  } else {
524  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scandir='.(!empty($module->scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
525  }
526  print '</td>';
527 
528  // Info
529  $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
530  $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
531  if ($module->type == 'pdf') {
532  $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
533  }
534  $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
535  $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn(!empty($module->option_logo) ? $module->option_logo : 0, 1, 1);
536  $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn(!empty($module->option_multilang) ? $module->option_multilang : 0, 1, 1);
537 
538 
539  print '<td class="center">';
540  print $form->textwithpicto('', $htmltooltip, 1, 0);
541  print '</td>';
542 
543  // Preview
544  print '<td class="center">';
545  if ($module->type == 'pdf') {
546  print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
547  } else {
548  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
549  }
550  print '</td>';
551 
552  print "</tr>\n";
553  }
554  }
555  }
556  }
557  }
558  }
559  }
560 }
561 
562 print '</table>';
563 print '</div>';
564 
565 
566 
567 
568 // Generation of cards for members
569 
570 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
571 print '<input type="hidden" name="token" value="'.newToken().'">';
572 print '<input type="hidden" name="action" value="updatememberscards">';
573 
574 print load_fiche_titre($langs->trans("MembersCards"), '', '');
575 
576 $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
577 $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
578 $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
579 $helptext .= '__YEAR__, __MONTH__, __DAY__';
580 
581 print '<div class="div-table-responsive-no-min">';
582 print '<table class="noborder centpercent">';
583 print '<tr class="liste_titre">';
584 print '<td>'.$langs->trans("Description").'</td>';
585 print '<td>'.$form->textwithpicto($langs->trans("Value"), $helptext, 1, 'help', '', 0, 2, 'idhelptext').'</td>';
586 print "</tr>\n";
587 
588 // Format of cards page
589 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_CARD_TYPE").'</td><td>';
590 
591 require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
592 $arrayoflabels = array();
593 foreach (array_keys($_Avery_Labels) as $codecards) {
594  $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
595 }
596 print $form->selectarray('ADHERENT_CARD_TYPE', $arrayoflabels, getDolGlobalString('ADHERENT_CARD_TYPE') ? getDolGlobalString('ADHERENT_CARD_TYPE') : 'CARD', 1, 0, 0);
597 
598 print "</td></tr>\n";
599 
600 // Text printed on top of member cards
601 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_CARD_HEADER_TEXT").'</td><td>';
602 print '<input type="text" class="flat minwidth300" name="ADHERENT_CARD_HEADER_TEXT" value="'.dol_escape_htmltag(getDolGlobalString('ADHERENT_CARD_HEADER_TEXT')).'">';
603 print "</td></tr>\n";
604 
605 // Text printed on member cards (align on left)
606 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_CARD_TEXT").'</td><td>';
607 print '<textarea class="flat" name="ADHERENT_CARD_TEXT" cols="50" rows="5" wrap="soft">'."\n";
608 print getDolGlobalString('ADHERENT_CARD_TEXT');
609 print '</textarea>';
610 print "</td></tr>\n";
611 
612 // Text printed on member cards (align on right)
613 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_CARD_TEXT_RIGHT").'</td><td>';
614 print '<textarea class="flat" name="ADHERENT_CARD_TEXT_RIGHT" cols="50" rows="5" wrap="soft">'."\n";
615 print getDolGlobalString('ADHERENT_CARD_TEXT_RIGHT');
616 print '</textarea>';
617 print "</td></tr>\n";
618 
619 // Text printed on bottom of member cards
620 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_CARD_FOOTER_TEXT").'</td><td>';
621 print '<input type="text" class="flat minwidth300" name="ADHERENT_CARD_FOOTER_TEXT" value="'.dol_escape_htmltag(getDolGlobalString('ADHERENT_CARD_FOOTER_TEXT')).'">';
622 print "</td></tr>\n";
623 
624 print '</table>';
625 print '</div>';
626 
627 print '<div class="center">';
628 print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
629 print '</div>';
630 
631 print '</form>';
632 
633 print '<br>';
634 
635 // Membership address sheet
636 
637 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
638 print '<input type="hidden" name="token" value="'.newToken().'">';
639 print '<input type="hidden" name="action" value="updatememberstickets">';
640 
641 print load_fiche_titre($langs->trans("MembersTickets"), '', '');
642 
643 $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
644 $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
645 $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
646 $helptext .= '__YEAR__, __MONTH__, __DAY__';
647 
648 print '<div class="div-table-responsive-no-min">';
649 print '<table class="noborder centpercent">';
650 print '<tr class="liste_titre">';
651 print '<td>'.$langs->trans("Description").'</td>';
652 print '<td>'.$form->textwithpicto($langs->trans("Value"), $helptext, 1, 'help', '', 0, 2, 'idhelptext').'</td>';
653 print "</tr>\n";
654 
655 // Format of labels page
656 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_ETIQUETTE_TYPE").'</td><td>';
657 
658 require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
659 $arrayoflabels = array();
660 foreach (array_keys($_Avery_Labels) as $codecards) {
661  $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
662 }
663 print $form->selectarray('ADHERENT_ETIQUETTE_TYPE', $arrayoflabels, getDolGlobalString('ADHERENT_ETIQUETTE_TYPE') ? getDolGlobalString('ADHERENT_ETIQUETTE_TYPE') : 'CARD', 1, 0, 0);
664 
665 print "</td></tr>\n";
666 
667 // Text printed on member address sheets
668 print '<tr class="oddeven"><td>'.$langs->trans("DescADHERENT_ETIQUETTE_TEXT").'</td><td>';
669 print '<textarea class="flat" name="ADHERENT_ETIQUETTE_TEXT" cols="50" rows="5" wrap="soft">'."\n";
670 print getDolGlobalString('ADHERENT_ETIQUETTE_TEXT');
671 print '</textarea>';
672 print "</td></tr>\n";
673 
674 print '</table>';
675 print '</div>';
676 
677 print '<div class="center">';
678 print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
679 print '</div>';
680 
681 print '</form>';
682 
683 print '<br>';
684 
685 print "<br>";
686 
687 print dol_get_fiche_end();
688 
689 // End of page
690 llxFooter();
691 $db->close();
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6824
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:562
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5107
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8922
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1129
member_admin_prepare_head
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:221
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1158
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
img_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)
Definition: functions.lib.php:4135
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
Exception
delDocumentModel
delDocumentModel($name, $type)
Delete document model used by doc generator.
Definition: admin.lib.php:1949
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3997
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Definition: functions.lib.php:1979
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:638
addDocumentModel
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
Definition: admin.lib.php:1918
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4473
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1164