adherent.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/adherents/admin/adherent.php
  27. * \ingroup member
  28. * \brief Page to setup the module Foundation
  29. */
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array("admin", "members"));
  35. if (!$user->admin) accessforbidden();
  36. $type = array('yesno', 'texte', 'chaine');
  37. $action = GETPOST('action', 'alpha');
  38. /*
  39. * Actions
  40. */
  41. //
  42. if ($action == 'updateall')
  43. {
  44. $db->begin();
  45. $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
  46. $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
  47. $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
  48. $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
  49. $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
  50. // Use vat for invoice creation
  51. if ($conf->facture->enabled)
  52. {
  53. $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
  54. $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
  55. if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
  56. {
  57. $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
  58. }
  59. }
  60. if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
  61. {
  62. setEventMessages('ErrorFailedToSaveDate', null, 'errors');
  63. $db->rollback();
  64. }
  65. else
  66. {
  67. setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
  68. $db->commit();
  69. }
  70. }
  71. // Action to update or add a constant
  72. if ($action == 'update' || $action == 'add')
  73. {
  74. $constname = GETPOST('constname', 'alpha');
  75. $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
  76. if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = '';
  77. if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
  78. {
  79. if ($constvalue) $constvalue = 0;
  80. else $constvalue = 1;
  81. }
  82. $consttype = GETPOST('consttype', 'alpha');
  83. $constnote = GETPOST('constnote');
  84. $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
  85. if (!$res > 0) $error++;
  86. if (!$error)
  87. {
  88. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  89. }
  90. else
  91. {
  92. setEventMessages($langs->trans("Error"), null, 'errors');
  93. }
  94. }
  95. // Action to enable of a submodule of the adherent module
  96. if ($action == 'set')
  97. {
  98. $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
  99. if ($result < 0)
  100. {
  101. print $db->error();
  102. }
  103. }
  104. // Action to disable a submodule of the adherent module
  105. if ($action == 'unset')
  106. {
  107. $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
  108. if ($result < 0)
  109. {
  110. print $db->error();
  111. }
  112. }
  113. /*
  114. * View
  115. */
  116. $form = new Form($db);
  117. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  118. llxHeader('', $langs->trans("MembersSetup"), $help_url);
  119. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  120. print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
  121. $head = member_admin_prepare_head();
  122. dol_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user');
  123. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  124. print '<input type="hidden" name="token" value="'.newToken().'">';
  125. print '<input type="hidden" name="action" value="updateall">';
  126. print load_fiche_titre($langs->trans("MemberMainOptions"), '', '');
  127. print '<table class="noborder centpercent">';
  128. print '<tr class="liste_titre">';
  129. print '<td>'.$langs->trans("Description").'</td>';
  130. print '<td>'.$langs->trans("Value").'</td>';
  131. print "</tr>\n";
  132. // Login/Pass required for members
  133. print '<tr class="oddeven"><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
  134. print $form->selectyesno('ADHERENT_LOGIN_NOT_REQUIRED', (!empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED) ? 0 : 1), 1);
  135. print "</td></tr>\n";
  136. // Mail required for members
  137. print '<tr class="oddeven"><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
  138. print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);
  139. print "</td></tr>\n";
  140. // Send mail information is on by default
  141. print '<tr class="oddeven"><td>'.$langs->trans("MemberSendInformationByMailByDefault").'</td><td>';
  142. print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1);
  143. print "</td></tr>\n";
  144. // Insert subscription into bank account
  145. print '<tr class="oddeven"><td>'.$langs->trans("MoreActionsOnSubscription").'</td>';
  146. $arraychoices = array('0'=>$langs->trans("None"));
  147. if (!empty($conf->banque->enabled)) $arraychoices['bankdirect'] = $langs->trans("MoreActionBankDirect");
  148. if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['invoiceonly'] = $langs->trans("MoreActionInvoiceOnly");
  149. if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice");
  150. print '<td>';
  151. print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
  152. if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice')
  153. {
  154. print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>';
  155. }
  156. print '</td>';
  157. print "</tr>\n";
  158. // Use vat for invoice creation
  159. if ($conf->facture->enabled)
  160. {
  161. print '<tr class="oddeven"><td>'.$langs->trans("VATToUseForSubscriptions").'</td>';
  162. if (!empty($conf->banque->enabled))
  163. {
  164. print '<td>';
  165. 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);
  166. print '</td>';
  167. }
  168. else
  169. {
  170. print '<td class="right">';
  171. print $langs->trans("WarningModuleNotActive", $langs->transnoentities("Module85Name"));
  172. print '</td>';
  173. }
  174. print "</tr>\n";
  175. if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
  176. {
  177. print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
  178. print '<td>';
  179. $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
  180. print '</td>';
  181. }
  182. print "</tr>\n";
  183. }
  184. print '</table>';
  185. print '<div class="center">';
  186. print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
  187. print '</div>';
  188. print '</form>';
  189. print '<br>';
  190. /*
  191. * Edit info of model document
  192. */
  193. $constantes = array(
  194. 'ADHERENT_CARD_TYPE',
  195. // 'ADHERENT_CARD_BACKGROUND',
  196. 'ADHERENT_CARD_HEADER_TEXT',
  197. 'ADHERENT_CARD_TEXT',
  198. 'ADHERENT_CARD_TEXT_RIGHT',
  199. 'ADHERENT_CARD_FOOTER_TEXT'
  200. );
  201. print load_fiche_titre($langs->trans("MembersCards"), '', '');
  202. $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
  203. $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
  204. $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
  205. $helptext .= '__YEAR__, __MONTH__, __DAY__';
  206. form_constantes($constantes, 0, $helptext);
  207. print '<br>';
  208. /*
  209. * Edit info of model document
  210. */
  211. $constantes = array('ADHERENT_ETIQUETTE_TYPE', 'ADHERENT_ETIQUETTE_TEXT');
  212. print load_fiche_titre($langs->trans("MembersTickets"), '', '');
  213. $helptext = '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
  214. $helptext .= '__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
  215. $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
  216. $helptext .= '__YEAR__, __MONTH__, __DAY__';
  217. form_constantes($constantes, 0, $helptext);
  218. dol_fiche_end();
  219. // End of page
  220. llxFooter();
  221. $db->close();