dolibarr 21.0.0-beta
website.php
Go to the documentation of this file.
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 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
35
46// Load translation files required by the page
47$langs->loadLangs(array("admin", "members"));
48
49$action = GETPOST('action', 'aZ09');
50
51if (!$user->admin) {
53}
54
55$error = 0;
56
57
58/*
59 * Actions
60 */
61
62if ($action == 'setMEMBER_ENABLE_PUBLIC') {
63 if (GETPOST('value')) {
64 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
65 } else {
66 dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
67 }
68}
69
70if ($action == 'update') {
71 $public = GETPOST('MEMBER_ENABLE_PUBLIC');
72 if (GETPOST('MEMBER_NEWFORM_AMOUNT') !== '') {
73 $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
74 } else {
75 $amount = '';
76 }
77 $minamount = GETPOST('MEMBER_MIN_AMOUNT');
78 $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
79 $showtable = GETPOST('MEMBER_SHOW_TABLE');
80 $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
81 $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
82 $forcetype = GETPOSTINT('MEMBER_NEWFORM_FORCETYPE');
83 $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
84
85 $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
86 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
87 $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
88 $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
89 $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", $showtable ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show"
90 $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", $showvoteallowed ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show"
91 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
92 if ($forcetype < 0) {
93 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
94 } else {
95 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
96 }
97 if ($forcemorphy == '-1') {
98 $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
99 } else {
100 $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
101 }
102
103 if (!($res > 0)) {
104 $error++;
105 }
106
107 if (!$error) {
108 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
109 } else {
110 setEventMessages($langs->trans("Error"), null, 'errors');
111 }
112}
113
114
115/*
116 * View
117 */
118
119$form = new Form($db);
120
121$title = $langs->trans("MembersSetup");
122$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
123
124llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-admin_website');
125
126
127$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
128print load_fiche_titre($title, $linkback, 'title_setup');
129
131
132
133
134print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
135print '<input type="hidden" name="action" value="update">';
136print '<input type="hidden" name="token" value="'.newToken().'">';
137
138print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
139
140if ($conf->use_javascript_ajax) {
141 print "\n".'<script type="text/javascript">';
142 print 'jQuery(document).ready(function () {
143 function initemail()
144 {
145 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
146 {
147 jQuery("#tremail").hide();
148 }
149 else
150 {
151 jQuery("#tremail").show();
152 }
153 }
154 function initfields()
155 {
156 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
157 {
158 jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
159 }
160 if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
161 {
162 jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
163 if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
164 else jQuery("#tremail").show();
165 }
166 }
167 initfields();
168 jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
169 jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
170 })';
171 print '</script>'."\n";
172}
173
174
175print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
176
177$param = '';
178
179$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
180if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
181 // Button off, click to enable
182 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
183 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
184 $enabledisablehtml .= '</a>';
185} else {
186 // Button on, click to disable
187 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
188 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
189 $enabledisablehtml .= '</a>';
190}
191print $enabledisablehtml;
192print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(!getDolGlobalString('MEMBER_ENABLE_PUBLIC') ? 0 : 1).'">';
193
194print '<br><br>';
195
196
197if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
198 print '<br>';
199 //print $langs->trans('FollowingLinksArePublic').'<br>';
200 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
201 if (isModEnabled('multicompany')) {
202 $entity_qr = '?entity='.((int) $conf->entity);
203 } else {
204 $entity_qr = '';
205 }
206
207 // Define $urlwithroot
208 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
209 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
210 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
211
212 print '<div class="urllink">';
213 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
214 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
215 print '</div>';
216 print ajax_autoselect('publicurlmember');
217
218 print '<br><br>';
219
220 print '<div class="div-table-responsive-no-min">';
221 print '<table class="noborder centpercent">';
222
223 print '<tr class="liste_titre">';
224 print '<td>'.$langs->trans("Parameter").'</td>';
225 print '<td>'.$langs->trans("Value").'</td>';
226 print "</tr>\n";
227
228 // Force Type
229 $adht = new AdherentType($db);
230 print '<tr class="oddeven drag" id="trforcetype"><td>';
231 print $langs->trans("ForceMemberType");
232 print '</td><td>';
233 $listofval = array();
234 $listofval += $adht->liste_array(1);
235 $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1);
236 print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
237 print "</td></tr>\n";
238
239 // Force nature of member (mor/phy)
240 $morphys = array();
241 $morphys["phy"] = $langs->trans("Physical");
242 $morphys["mor"] = $langs->trans("Moral");
243 print '<tr class="oddeven drag" id="trforcenature"><td>';
244 print $langs->trans("ForceMemberNature");
245 print '</td><td>';
246 $forcenature = getDolGlobalInt('MEMBER_NEWFORM_FORCEMORPHY', 0);
247 print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
248 print "</td></tr>\n";
249
250 // Amount
251 print '<tr class="oddeven" id="tramount"><td>';
252 print $langs->trans("DefaultAmount");
253 print '</td><td>';
254 print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.getDolGlobalString('MEMBER_NEWFORM_AMOUNT').'">';
255 print "</td></tr>\n";
256
257 // Min amount
258 print '<tr class="oddeven" id="tredit"><td>';
259 print $langs->trans("MinimumAmount");
260 print '</td><td>';
261 print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.getDolGlobalString('MEMBER_MIN_AMOUNT').'">';
262 print "</td></tr>\n";
263
264 // SHow counter of validated members publicly
265 print '<tr class="oddeven" id="tredit"><td>';
266 print $langs->trans("MemberCountersArePublic");
267 print '</td><td>';
268 print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1, false, 0, 1);
269 print "</td></tr>\n";
270
271 // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
272 $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
273 print '<tr class="oddeven" id="tredit"><td>';
274 print $langs->trans("MembersShowMembershipTypesTable");
275 print '</td><td>';
276 print $form->selectyesno("MEMBER_SHOW_TABLE", !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
277 print "</td></tr>\n";
278
279 // Show "vote allowed" setting for membership types
280 $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED');
281 print '<tr class="oddeven" id="tredit"><td>';
282 print $langs->trans("MembersShowVotesAllowed");
283 print '</td><td>';
284 print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
285 print "</td></tr>\n";
286
287 // Jump to an online payment page
288 print '<tr class="oddeven" id="trpayment"><td>';
289 print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
290 print '</td><td>';
291 $listofval = array();
292 $listofval['-1'] = $langs->trans('No');
293 $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
294 if (isModEnabled('paybox')) {
295 $listofval['paybox'] = 'Paybox';
296 }
297 if (isModEnabled('paypal')) {
298 $listofval['paypal'] = 'PayPal';
299 }
300 if (isModEnabled('stripe')) {
301 $listofval['stripe'] = 'Stripe';
302 }
303 print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0);
304 print "</td></tr>\n";
305
306 print '</table>';
307 print '</div>';
308
309 print '<div class="center">';
310 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
311 print '</div>';
312}
313
314
315print dol_get_fiche_end();
316
317print '</form>';
318
319// End of page
320llxFooter();
321$db->close();
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage members type.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
member_admin_prepare_head()
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.