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