website.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/adherents/admin/website.php
  22. * \ingroup member
  23. * \brief File of main public page for member module
  24. */
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("admin", "members"));
  32. $action = GETPOST('action', 'aZ09');
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. $error = 0;
  37. /*
  38. * Actions
  39. */
  40. if ($action == 'setMEMBER_ENABLE_PUBLIC') {
  41. if (GETPOST('value')) {
  42. dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
  43. } else {
  44. dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
  45. }
  46. }
  47. if ($action == 'update') {
  48. $public = GETPOST('MEMBER_ENABLE_PUBLIC');
  49. $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
  50. $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
  51. $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
  52. $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
  53. $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
  54. $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
  55. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
  56. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
  57. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
  58. if ($forcetype < 0) {
  59. $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
  60. } else {
  61. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
  62. }
  63. if ($forcemorphy == '-1') {
  64. $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
  65. } else {
  66. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
  67. }
  68. if (!($res > 0)) {
  69. $error++;
  70. }
  71. if (!$error) {
  72. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  73. } else {
  74. setEventMessages($langs->trans("Error"), null, 'errors');
  75. }
  76. }
  77. /*
  78. * View
  79. */
  80. $form = new Form($db);
  81. $title = $langs->trans("MembersSetup");
  82. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  83. llxHeader('', $title, $help_url);
  84. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  85. print load_fiche_titre($title, $linkback, 'title_setup');
  86. $head = member_admin_prepare_head();
  87. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  88. print '<input type="hidden" name="action" value="update">';
  89. print '<input type="hidden" name="token" value="'.newToken().'">';
  90. print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
  91. if ($conf->use_javascript_ajax) {
  92. print "\n".'<script type="text/javascript">';
  93. print 'jQuery(document).ready(function () {
  94. function initemail()
  95. {
  96. if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
  97. {
  98. jQuery("#tremail").hide();
  99. }
  100. else
  101. {
  102. jQuery("#tremail").show();
  103. }
  104. }
  105. function initfields()
  106. {
  107. if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
  108. {
  109. jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
  110. }
  111. if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
  112. {
  113. jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
  114. if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
  115. else jQuery("#tremail").show();
  116. }
  117. }
  118. initfields();
  119. jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
  120. jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
  121. })';
  122. print '</script>'."\n";
  123. }
  124. print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
  125. $param = '';
  126. $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
  127. if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
  128. // Button off, click to enable
  129. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
  130. $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
  131. $enabledisablehtml .= '</a>';
  132. } else {
  133. // Button on, click to disable
  134. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
  135. $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
  136. $enabledisablehtml .= '</a>';
  137. }
  138. print $enabledisablehtml;
  139. print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
  140. print '<br><br>';
  141. if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
  142. print '<br>';
  143. //print $langs->trans('FollowingLinksArePublic').'<br>';
  144. print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
  145. if (isModEnabled('multicompany')) {
  146. $entity_qr = '?entity='.$conf->entity;
  147. } else {
  148. $entity_qr = '';
  149. }
  150. // Define $urlwithroot
  151. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  152. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  153. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  154. print '<div class="urllink">';
  155. print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
  156. print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
  157. print '</div>';
  158. print ajax_autoselect('publicurlmember');
  159. print '<br>';
  160. print '<div class="div-table-responsive-no-min">';
  161. print '<table class="noborder centpercent">';
  162. print '<tr class="liste_titre">';
  163. print '<td>'.$langs->trans("Parameter").'</td>';
  164. print '<td>'.$langs->trans("Value").'</td>';
  165. print "</tr>\n";
  166. // Force Type
  167. $adht = new AdherentType($db);
  168. print '<tr class="oddeven drag" id="trforcetype"><td>';
  169. print $langs->trans("ForceMemberType");
  170. print '</td><td>';
  171. $listofval = array();
  172. $listofval += $adht->liste_array(1);
  173. $forcetype = empty($conf->global->MEMBER_NEWFORM_FORCETYPE) ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE;
  174. print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
  175. print "</td></tr>\n";
  176. // Force nature of member (mor/phy)
  177. $morphys["phy"] = $langs->trans("Physical");
  178. $morphys["mor"] = $langs->trans("Moral");
  179. print '<tr class="oddeven drag" id="trforcenature"><td>';
  180. print $langs->trans("ForceMemberNature");
  181. print '</td><td>';
  182. $forcenature = empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY) ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY;
  183. print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
  184. print "</td></tr>\n";
  185. // Amount
  186. print '<tr class="oddeven" id="tramount"><td>';
  187. print $langs->trans("DefaultAmount");
  188. print '</td><td>';
  189. print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
  190. print "</td></tr>\n";
  191. // Can edit
  192. print '<tr class="oddeven" id="tredit"><td>';
  193. print $langs->trans("CanEditAmount");
  194. print '</td><td>';
  195. print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
  196. print "</td></tr>\n";
  197. // Jump to an online payment page
  198. print '<tr class="oddeven" id="trpayment"><td>';
  199. print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
  200. print '</td><td>';
  201. $listofval = array();
  202. $listofval['-1'] = $langs->trans('No');
  203. $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
  204. if (isModEnabled('paybox')) {
  205. $listofval['paybox'] = 'Paybox';
  206. }
  207. if (isModEnabled('paypal')) {
  208. $listofval['paypal'] = 'PayPal';
  209. }
  210. if (isModEnabled('stripe')) {
  211. $listofval['stripe'] = 'Stripe';
  212. }
  213. print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
  214. print "</td></tr>\n";
  215. print '</table>';
  216. print '</div>';
  217. print '<div class="center">';
  218. print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
  219. print '</div>';
  220. }
  221. print dol_get_fiche_end();
  222. print '</form>';
  223. // End of page
  224. llxFooter();
  225. $db->close();