dolibarr  17.0.4
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  $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
64  $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
65  $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
66 
67  $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
68  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
69  $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity);
70  $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity);
71  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
72  if ($forcetype < 0) {
73  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
74  } else {
75  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
76  }
77  if ($forcemorphy == '-1') {
78  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
79  } else {
80  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
81  }
82 
83  if (!($res > 0)) {
84  $error++;
85  }
86 
87  if (!$error) {
88  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
89  } else {
90  setEventMessages($langs->trans("Error"), null, 'errors');
91  }
92 }
93 
94 
95 /*
96  * View
97  */
98 
99 $form = new Form($db);
100 
101 $title = $langs->trans("MembersSetup");
102 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
103 llxHeader('', $title, $help_url);
104 
105 
106 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
107 print load_fiche_titre($title, $linkback, 'title_setup');
108 
109 $head = member_admin_prepare_head();
110 
111 
112 
113 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
114 print '<input type="hidden" name="action" value="update">';
115 print '<input type="hidden" name="token" value="'.newToken().'">';
116 
117 print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
118 
119 if ($conf->use_javascript_ajax) {
120  print "\n".'<script type="text/javascript">';
121  print 'jQuery(document).ready(function () {
122  function initemail()
123  {
124  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
125  {
126  jQuery("#tremail").hide();
127  }
128  else
129  {
130  jQuery("#tremail").show();
131  }
132  }
133  function initfields()
134  {
135  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
136  {
137  jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
138  }
139  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
140  {
141  jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
142  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
143  else jQuery("#tremail").show();
144  }
145  }
146  initfields();
147  jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
148  jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
149  })';
150  print '</script>'."\n";
151 }
152 
153 
154 print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
155 
156 $param = '';
157 
158 $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
159 if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
160  // Button off, click to enable
161  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
162  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
163  $enabledisablehtml .= '</a>';
164 } else {
165  // Button on, click to disable
166  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
167  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
168  $enabledisablehtml .= '</a>';
169 }
170 print $enabledisablehtml;
171 print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
172 
173 print '<br><br>';
174 
175 
176 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
177  print '<br>';
178  //print $langs->trans('FollowingLinksArePublic').'<br>';
179  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
180  if (isModEnabled('multicompany')) {
181  $entity_qr = '?entity='.$conf->entity;
182  } else {
183  $entity_qr = '';
184  }
185 
186  // Define $urlwithroot
187  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
188  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
189  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
190 
191  print '<div class="urllink">';
192  print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
193  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
194  print '</div>';
195  print ajax_autoselect('publicurlmember');
196 
197  print '<br>';
198 
199  print '<div class="div-table-responsive-no-min">';
200  print '<table class="noborder centpercent">';
201 
202  print '<tr class="liste_titre">';
203  print '<td>'.$langs->trans("Parameter").'</td>';
204  print '<td>'.$langs->trans("Value").'</td>';
205  print "</tr>\n";
206 
207  // Force Type
208  $adht = new AdherentType($db);
209  print '<tr class="oddeven drag" id="trforcetype"><td>';
210  print $langs->trans("ForceMemberType");
211  print '</td><td>';
212  $listofval = array();
213  $listofval += $adht->liste_array(1);
214  $forcetype = empty($conf->global->MEMBER_NEWFORM_FORCETYPE) ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE;
215  print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
216  print "</td></tr>\n";
217 
218  // Force nature of member (mor/phy)
219  $morphys["phy"] = $langs->trans("Physical");
220  $morphys["mor"] = $langs->trans("Moral");
221  print '<tr class="oddeven drag" id="trforcenature"><td>';
222  print $langs->trans("ForceMemberNature");
223  print '</td><td>';
224  $forcenature = empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY) ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY;
225  print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
226  print "</td></tr>\n";
227 
228  // Amount
229  print '<tr class="oddeven" id="tramount"><td>';
230  print $langs->trans("DefaultAmount");
231  print '</td><td>';
232  print '<input type="text" class="right width50" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
233  print "</td></tr>\n";
234 
235  // Min amount
236  print '<tr class="oddeven" id="tredit"><td>';
237  print $langs->trans("MinimumAmount");
238  print '</td><td>';
239  print '<input type="text" class="right width50" id="MEMBER_MIN_AMOUNT" name="MEMBER_MIN_AMOUNT" value="'.(!empty($conf->global->MEMBER_MIN_AMOUNT) ? $conf->global->MEMBER_MIN_AMOUNT : '').'">';
240  print "</td></tr>\n";
241 
242  // SHow counter of validated members publicly
243  print '<tr class="oddeven" id="tredit"><td>';
244  print $langs->trans("MemberCountersArePublic");
245  print '</td><td>';
246  print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", (!empty($conf->global->MEMBER_COUNTERS_ARE_PUBLIC) ? $conf->global->MEMBER_COUNTERS_ARE_PUBLIC : 0), 1);
247  print "</td></tr>\n";
248 
249  // Jump to an online payment page
250  print '<tr class="oddeven" id="trpayment"><td>';
251  print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
252  print '</td><td>';
253  $listofval = array();
254  $listofval['-1'] = $langs->trans('No');
255  $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
256  if (isModEnabled('paybox')) {
257  $listofval['paybox'] = 'Paybox';
258  }
259  if (isModEnabled('paypal')) {
260  $listofval['paypal'] = 'PayPal';
261  }
262  if (isModEnabled('stripe')) {
263  $listofval['stripe'] = 'Stripe';
264  }
265  print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
266  print "</td></tr>\n";
267 
268  print '</table>';
269  print '</div>';
270 
271  print '<div class="center">';
272  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
273  print '</div>';
274 }
275 
276 
277 print dol_get_fiche_end();
278 
279 print '</form>';
280 
281 // End of page
282 llxFooter();
283 $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:632
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:556
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
isModEnabled($module)
Is Dolibarr module enabled.
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:199
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.