dolibarr  16.0.5
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 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("admin", "members"));
35 
36 $action = GETPOST('action', 'aZ09');
37 
38 if (!$user->admin) {
40 }
41 
42 $error = 0;
43 
44 
45 /*
46  * Actions
47  */
48 
49 if ($action == 'setMEMBER_ENABLE_PUBLIC') {
50  if (GETPOST('value')) {
51  dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
52  } else {
53  dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
54  }
55 }
56 
57 if ($action == 'update') {
58  $public = GETPOST('MEMBER_ENABLE_PUBLIC');
59  $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2);
60  $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
61  $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
62  $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE', 'int');
63  $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09');
64 
65  $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
66  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
67  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
68  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
69  if ($forcetype < 0) {
70  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
71  } else {
72  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
73  }
74  if ($forcemorphy == '-1') {
75  $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity);
76  } else {
77  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity);
78  }
79 
80  if (!($res > 0)) {
81  $error++;
82  }
83 
84  if (!$error) {
85  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
86  } else {
87  setEventMessages($langs->trans("Error"), null, 'errors');
88  }
89 }
90 
91 
92 /*
93  * View
94  */
95 
96 $form = new Form($db);
97 
98 $title = $langs->trans("MembersSetup");
99 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
100 llxHeader('', $title, $help_url);
101 
102 
103 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
104 print load_fiche_titre($title, $linkback, 'title_setup');
105 
106 $head = member_admin_prepare_head();
107 
108 
109 
110 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
111 print '<input type="hidden" name="action" value="update">';
112 print '<input type="hidden" name="token" value="'.newToken().'">';
113 
114 print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
115 
116 if ($conf->use_javascript_ajax) {
117  print "\n".'<script type="text/javascript">';
118  print 'jQuery(document).ready(function () {
119  function initemail()
120  {
121  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
122  {
123  jQuery("#tremail").hide();
124  }
125  else
126  {
127  jQuery("#tremail").show();
128  }
129  }
130  function initfields()
131  {
132  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
133  {
134  jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
135  }
136  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
137  {
138  jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
139  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
140  else jQuery("#tremail").show();
141  }
142  }
143  initfields();
144  jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
145  jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
146  })';
147  print '</script>'."\n";
148 }
149 
150 
151 print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
152 
153 $param = '';
154 
155 $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
156 if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
157  // Button off, click to enable
158  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
159  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
160  $enabledisablehtml .= '</a>';
161 } else {
162  // Button on, click to disable
163  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
164  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
165  $enabledisablehtml .= '</a>';
166 }
167 print $enabledisablehtml;
168 print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
169 
170 
171 print '<br>';
172 
173 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
174  print '<br>';
175 
176  print '<div class="div-table-responsive-no-min">';
177  print '<table class="noborder centpercent">';
178 
179  print '<tr class="liste_titre">';
180  print '<td>'.$langs->trans("Parameter").'</td>';
181  print '<td>'.$langs->trans("Value").'</td>';
182  print "</tr>\n";
183 
184  // Force Type
185  $adht = new AdherentType($db);
186  print '<tr class="oddeven drag" id="trforcetype"><td>';
187  print $langs->trans("ForceMemberType");
188  print '</td><td>';
189  $listofval = array();
190  $listofval += $adht->liste_array(1);
191  $forcetype = empty($conf->global->MEMBER_NEWFORM_FORCETYPE) ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE;
192  print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
193  print "</td></tr>\n";
194 
195  // Force nature of member (mor/phy)
196  $morphys["phy"] = $langs->trans("Physical");
197  $morphys["mor"] = $langs->trans("Moral");
198  print '<tr class="oddeven drag" id="trforcenature"><td>';
199  print $langs->trans("ForceMemberNature");
200  print '</td><td>';
201  $forcenature = empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY) ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY;
202  print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1);
203  print "</td></tr>\n";
204 
205  // Amount
206  print '<tr class="oddeven" id="tramount"><td>';
207  print $langs->trans("DefaultAmount");
208  print '</td><td>';
209  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 : '').'">';
210  print "</td></tr>\n";
211 
212  // Can edit
213  print '<tr class="oddeven" id="tredit"><td>';
214  print $langs->trans("CanEditAmount");
215  print '</td><td>';
216  print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
217  print "</td></tr>\n";
218 
219  // Jump to an online payment page
220  print '<tr class="oddeven" id="trpayment"><td>';
221  print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
222  print '</td><td>';
223  $listofval = array();
224  $listofval['-1'] = $langs->trans('No');
225  $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
226  if (!empty($conf->paybox->enabled)) {
227  $listofval['paybox'] = 'Paybox';
228  }
229  if (!empty($conf->paypal->enabled)) {
230  $listofval['paypal'] = 'PayPal';
231  }
232  if (!empty($conf->stripe->enabled)) {
233  $listofval['stripe'] = 'Stripe';
234  }
235  print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
236  print "</td></tr>\n";
237 
238  print '</table>';
239  print '</div>';
240 
241  print '<div class="center">';
242  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
243  print '</div>';
244 }
245 
246 
247 print dol_get_fiche_end();
248 
249 print '</form>';
250 
251 
252 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
253  print '<br>';
254  //print $langs->trans('FollowingLinksArePublic').'<br>';
255  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
256  if (!empty($conf->multicompany->enabled)) {
257  $entity_qr = '?entity='.$conf->entity;
258  } else {
259  $entity_qr = '';
260  }
261 
262  // Define $urlwithroot
263  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
264  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
265  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
266 
267  print '<div class="urllink">';
268  print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">';
269  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
270  print '</div>';
271  print ajax_autoselect('publicurlmember');
272 }
273 
274 // End of page
275 llxFooter();
276 $db->close();
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
member_admin_prepare_head
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:183
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
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:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
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:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9681
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59