dolibarr  20.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  *
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 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("admin", "members"));
36 
37 $action = GETPOST('action', 'aZ09');
38 
39 if (!$user->admin) {
41 }
42 
43 $error = 0;
44 
45 
46 /*
47  * Actions
48  */
49 
50 if ($action == 'setMEMBER_ENABLE_PUBLIC') {
51  if (GETPOST('value')) {
52  dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
53  } else {
54  dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
55  }
56 }
57 
58 if ($action == 'update') {
59  $public = GETPOST('MEMBER_ENABLE_PUBLIC');
60  $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
61  $minamount = GETPOST('MEMBER_MIN_AMOUNT');
62  $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC');
63  $showtable = GETPOST('MEMBER_SHOW_TABLE');
64  $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED');
65  $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
66  $forcetype = GETPOSTINT('MEMBER_NEWFORM_FORCETYPE');
67  $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
68 
69  $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
70  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
71  $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
72  $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
73  $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", !$showtable, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show"
74  $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", !$showvoteallowed, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show"
75  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
76  if ($forcetype < 0) {
77  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
78  } else {
79  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
80  }
81  if ($forcemorphy == '-1') {
82  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
83  } else {
84  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
85  }
86 
87  if (!($res > 0)) {
88  $error++;
89  }
90 
91  if (!$error) {
92  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
93  } else {
94  setEventMessages($langs->trans("Error"), null, 'errors');
95  }
96 }
97 
98 
99 /*
100  * View
101  */
102 
103 $form = new Form($db);
104 
105 $title = $langs->trans("MembersSetup");
106 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
107 llxHeader('', $title, $help_url);
108 
109 
110 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
111 print load_fiche_titre($title, $linkback, 'title_setup');
112 
113 $head = member_admin_prepare_head();
114 
115 
116 
117 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
118 print '<input type="hidden" name="action" value="update">';
119 print '<input type="hidden" name="token" value="'.newToken().'">';
120 
121 print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
122 
123 if ($conf->use_javascript_ajax) {
124  print "\n".'<script type="text/javascript">';
125  print 'jQuery(document).ready(function () {
126  function initemail()
127  {
128  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
129  {
130  jQuery("#tremail").hide();
131  }
132  else
133  {
134  jQuery("#tremail").show();
135  }
136  }
137  function initfields()
138  {
139  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
140  {
141  jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
142  }
143  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
144  {
145  jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
146  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
147  else jQuery("#tremail").show();
148  }
149  }
150  initfields();
151  jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
152  jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
153  })';
154  print '</script>'."\n";
155 }
156 
157 
158 print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
159 
160 $param = '';
161 
162 $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
163 if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
164  // Button off, click to enable
165  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
166  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
167  $enabledisablehtml .= '</a>';
168 } else {
169  // Button on, click to disable
170  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
171  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
172  $enabledisablehtml .= '</a>';
173 }
174 print $enabledisablehtml;
175 print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(!getDolGlobalString('MEMBER_ENABLE_PUBLIC') ? 0 : 1).'">';
176 
177 print '<br><br>';
178 
179 
180 if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
181  print '<br>';
182  //print $langs->trans('FollowingLinksArePublic').'<br>';
183  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
184  if (isModEnabled('multicompany')) {
185  $entity_qr = '?entity='.((int) $conf->entity);
186  } else {
187  $entity_qr = '';
188  }
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 
195  print '<div class="urllink">';
196  print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
197  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
198  print '</div>';
199  print ajax_autoselect('publicurlmember');
200 
201  print '<br>';
202 
203  print '<div class="div-table-responsive-no-min">';
204  print '<table class="noborder centpercent">';
205 
206  print '<tr class="liste_titre">';
207  print '<td>'.$langs->trans("Parameter").'</td>';
208  print '<td>'.$langs->trans("Value").'</td>';
209  print "</tr>\n";
210 
211  // Force Type
212  $adht = new AdherentType($db);
213  print '<tr class="oddeven drag" id="trforcetype"><td>';
214  print $langs->trans("ForceMemberType");
215  print '</td><td>';
216  $listofval = array();
217  $listofval += $adht->liste_array(1);
218  $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1);
219  print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
220  print "</td></tr>\n";
221 
222  // Force nature of member (mor/phy)
223  $morphys = array();
224  $morphys["phy"] = $langs->trans("Physical");
225  $morphys["mor"] = $langs->trans("Moral");
226  print '<tr class="oddeven drag" id="trforcenature"><td>';
227  print $langs->trans("ForceMemberNature");
228  print '</td><td>';
229  $forcenature = getDolGlobalInt('MEMBER_NEWFORM_FORCEMORPHY', 0);
230  print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
231  print "</td></tr>\n";
232 
233  // Amount
234  print '<tr class="oddeven" id="tramount"><td>';
235  print $langs->trans("DefaultAmount");
236  print '</td><td>';
237  print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.getDolGlobalString('MEMBER_NEWFORM_AMOUNT').'">';
238  print "</td></tr>\n";
239 
240  // Min amount
241  print '<tr class="oddeven" id="tredit"><td>';
242  print $langs->trans("MinimumAmount");
243  print '</td><td>';
244  print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.getDolGlobalString('MEMBER_MIN_AMOUNT').'">';
245  print "</td></tr>\n";
246 
247  // SHow counter of validated members publicly
248  print '<tr class="oddeven" id="tredit"><td>';
249  print $langs->trans("MemberCountersArePublic");
250  print '</td><td>';
251  print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1);
252  print "</td></tr>\n";
253 
254  // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
255  $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
256  print '<tr class="oddeven" id="tredit"><td>';
257  print $langs->trans("MembersShowMembershipTypesTable");
258  print '</td><td>';
259  print $form->selectyesno("MEMBER_SHOW_TABLE", !$skiptable, 1); // Reverse the logic "hide -> show" for retrocompatibility
260  print "</td></tr>\n";
261 
262  // Show "vote allowed" setting for membership types
263  $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED');
264  print '<tr class="oddeven" id="tredit"><td>';
265  print $langs->trans("MembersShowVotesAllowed");
266  print '</td><td>';
267  print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", !$hidevoteallowed, 1); // Reverse the logic "hide -> show" for retrocompatibility
268  print "</td></tr>\n";
269 
270  // Jump to an online payment page
271  print '<tr class="oddeven" id="trpayment"><td>';
272  print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
273  print '</td><td>';
274  $listofval = array();
275  $listofval['-1'] = $langs->trans('No');
276  $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
277  if (isModEnabled('paybox')) {
278  $listofval['paybox'] = 'Paybox';
279  }
280  if (isModEnabled('paypal')) {
281  $listofval['paypal'] = 'PayPal';
282  }
283  if (isModEnabled('stripe')) {
284  $listofval['stripe'] = 'Stripe';
285  }
286  print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0);
287  print "</td></tr>\n";
288 
289  print '</table>';
290  print '</div>';
291 
292  print '<div class="center">';
293  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
294  print '</div>';
295 }
296 
297 
298 print dol_get_fiche_end();
299 
300 print '</form>';
301 
302 // End of page
303 llxFooter();
304 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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).
Definition: admin.lib.php:655
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:579
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage members type.
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $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.
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
member_admin_prepare_head()
Return array head with list of tabs to view object information.
Definition: member.lib.php:222
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.