website.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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', 'alpha');
  33. if (!$user->admin) accessforbidden();
  34. /*
  35. * Actions
  36. */
  37. if ($action == 'setMEMBER_ENABLE_PUBLIC')
  38. {
  39. if (GETPOST('value')) dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
  40. else dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
  41. }
  42. if ($action == 'update')
  43. {
  44. $public = GETPOST('MEMBER_ENABLE_PUBLIC');
  45. $amount = GETPOST('MEMBER_NEWFORM_AMOUNT');
  46. $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
  47. $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
  48. $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE');
  49. $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
  50. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
  51. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
  52. $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
  53. if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
  54. else $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
  55. if (!$res > 0) $error++;
  56. if (!$error)
  57. {
  58. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  59. }
  60. else
  61. {
  62. setEventMessages($langs->trans("Error"), null, 'errors');
  63. }
  64. }
  65. /*
  66. * View
  67. */
  68. $form = new Form($db);
  69. $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
  70. llxHeader('', $langs->trans("MembersSetup"), $help_url);
  71. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  72. print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
  73. $head = member_admin_prepare_head();
  74. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  75. print '<input type="hidden" name="action" value="update">';
  76. print '<input type="hidden" name="token" value="'.newToken().'">';
  77. dol_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
  78. if ($conf->use_javascript_ajax)
  79. {
  80. print "\n".'<script type="text/javascript" language="javascript">';
  81. print 'jQuery(document).ready(function () {
  82. function initemail()
  83. {
  84. if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
  85. {
  86. jQuery("#tremail").hide();
  87. }
  88. else
  89. {
  90. jQuery("#tremail").show();
  91. }
  92. }
  93. function initfields()
  94. {
  95. if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
  96. {
  97. jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
  98. }
  99. if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
  100. {
  101. jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
  102. if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
  103. else jQuery("#tremail").show();
  104. }
  105. }
  106. initfields();
  107. jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
  108. jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
  109. })';
  110. print '</script>'."\n";
  111. }
  112. print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
  113. $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
  114. if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
  115. {
  116. // Button off, click to enable
  117. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
  118. $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
  119. $enabledisablehtml .= '</a>';
  120. }
  121. else
  122. {
  123. // Button on, click to disable
  124. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
  125. $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
  126. $enabledisablehtml .= '</a>';
  127. }
  128. print $enabledisablehtml;
  129. print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
  130. print '<br>';
  131. if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
  132. {
  133. print '<br>';
  134. print '<table class="noborder centpercent">';
  135. print '<tr class="liste_titre">';
  136. print '<td>'.$langs->trans("Parameter").'</td>';
  137. print '<td class="right">'.$langs->trans("Value").'</td>';
  138. print "</tr>\n";
  139. // Force Type
  140. $adht = new AdherentType($db);
  141. print '<tr class="oddeven drag" id="trforcetype"><td>';
  142. print $langs->trans("ForceMemberType");
  143. print '</td><td class="right">';
  144. $listofval = array();
  145. $listofval += $adht->liste_array();
  146. $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
  147. print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
  148. print "</td></tr>\n";
  149. // Amount
  150. print '<tr class="oddeven" id="tramount"><td>';
  151. print $langs->trans("DefaultAmount");
  152. print '</td><td class="right">';
  153. print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
  154. print "</td></tr>\n";
  155. // Can edit
  156. print '<tr class="oddeven" id="tredit"><td>';
  157. print $langs->trans("CanEditAmount");
  158. print '</td><td class="right">';
  159. print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
  160. print "</td></tr>\n";
  161. // Jump to an online payment page
  162. print '<tr class="oddeven" id="trpayment"><td>';
  163. print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
  164. print '</td><td class="right">';
  165. $listofval = array();
  166. $listofval['-1'] = $langs->trans('No');
  167. $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
  168. if (!empty($conf->paybox->enabled)) $listofval['paybox'] = 'Paybox';
  169. if (!empty($conf->paypal->enabled)) $listofval['paypal'] = 'PayPal';
  170. if (!empty($conf->stripe->enabled)) $listofval['stripe'] = 'Stripe';
  171. print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
  172. print "</td></tr>\n";
  173. print '</table>';
  174. print '<div class="center">';
  175. print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
  176. print '</div>';
  177. }
  178. dol_fiche_end();
  179. print '</form>';
  180. if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
  181. {
  182. print '<br>';
  183. //print $langs->trans('FollowingLinksArePublic').'<br>';
  184. print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':<br>';
  185. if ($conf->multicompany->enabled) {
  186. $entity_qr = '?entity='.$conf->entity;
  187. } else {
  188. $entity_qr = '';
  189. }
  190. // Define $urlwithroot
  191. $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
  192. $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  193. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  194. print '<a target="_blank" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.$urlwithroot.'/public/members/new.php'.$entity_qr.'</a>';
  195. }
  196. // End of page
  197. llxFooter();
  198. $db->close();