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