website.php 8.9 KB

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