dolibarr  13.0.2
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) accessforbidden();
39 
40 
41 /*
42  * Actions
43  */
44 
45 if ($action == 'setMEMBER_ENABLE_PUBLIC') {
46  if (GETPOST('value')) dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
47  else dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
48 }
49 
50 if ($action == 'update') {
51  $public = GETPOST('MEMBER_ENABLE_PUBLIC');
52  $amount = GETPOST('MEMBER_NEWFORM_AMOUNT');
53  $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
54  $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
55  $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE');
56 
57  $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
58  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
59  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
60  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
61  if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
62  else {
63  $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
64  }
65 
66  if (!($res > 0)) $error++;
67 
68  if (!$error) {
69  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
70  } else {
71  setEventMessages($langs->trans("Error"), null, 'errors');
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 $form = new Form($db);
81 
82 $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
83 llxHeader('', $langs->trans("MembersSetup"), $help_url);
84 
85 
86 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
87 print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
88 
90 
91 
92 
93 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
94 print '<input type="hidden" name="action" value="update">';
95 print '<input type="hidden" name="token" value="'.newToken().'">';
96 
97 print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
98 
99 if ($conf->use_javascript_ajax) {
100  print "\n".'<script type="text/javascript" language="javascript">';
101  print 'jQuery(document).ready(function () {
102  function initemail()
103  {
104  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
105  {
106  jQuery("#tremail").hide();
107  }
108  else
109  {
110  jQuery("#tremail").show();
111  }
112  }
113  function initfields()
114  {
115  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
116  {
117  jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
118  }
119  if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
120  {
121  jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
122  if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
123  else jQuery("#tremail").show();
124  }
125  }
126  initfields();
127  jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
128  jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
129  })';
130  print '</script>'."\n";
131 }
132 
133 
134 print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
135 
136 
137 $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
138 if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
139  // Button off, click to enable
140  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
141  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
142  $enabledisablehtml .= '</a>';
143 } else {
144  // Button on, click to disable
145  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
146  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
147  $enabledisablehtml .= '</a>';
148 }
149 print $enabledisablehtml;
150 print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
151 
152 
153 print '<br>';
154 
155 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
156  print '<br>';
157 
158  print '<table class="noborder centpercent">';
159 
160  print '<tr class="liste_titre">';
161  print '<td>'.$langs->trans("Parameter").'</td>';
162  print '<td class="right">'.$langs->trans("Value").'</td>';
163  print "</tr>\n";
164 
165  // Force Type
166  $adht = new AdherentType($db);
167  print '<tr class="oddeven drag" id="trforcetype"><td>';
168  print $langs->trans("ForceMemberType");
169  print '</td><td class="right">';
170  $listofval = array();
171  $listofval += $adht->liste_array();
172  $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
173  print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval) > 1 ? 1 : 0);
174  print "</td></tr>\n";
175 
176  // Amount
177  print '<tr class="oddeven" id="tramount"><td>';
178  print $langs->trans("DefaultAmount");
179  print '</td><td class="right">';
180  print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(!empty($conf->global->MEMBER_NEWFORM_AMOUNT) ? $conf->global->MEMBER_NEWFORM_AMOUNT : '').'">';
181  print "</td></tr>\n";
182 
183  // Can edit
184  print '<tr class="oddeven" id="tredit"><td>';
185  print $langs->trans("CanEditAmount");
186  print '</td><td class="right">';
187  print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1);
188  print "</td></tr>\n";
189 
190  // Jump to an online payment page
191  print '<tr class="oddeven" id="trpayment"><td>';
192  print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
193  print '</td><td class="right">';
194  $listofval = array();
195  $listofval['-1'] = $langs->trans('No');
196  $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
197  if (!empty($conf->paybox->enabled)) $listofval['paybox'] = 'Paybox';
198  if (!empty($conf->paypal->enabled)) $listofval['paypal'] = 'PayPal';
199  if (!empty($conf->stripe->enabled)) $listofval['stripe'] = 'Stripe';
200  print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) ? $conf->global->MEMBER_NEWFORM_PAYONLINE : ''), 0);
201  print "</td></tr>\n";
202 
203  print '</table>';
204 
205  print '<div class="center">';
206  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
207  print '</div>';
208 }
209 
210 
211 print dol_get_fiche_end();
212 
213 print '</form>';
214 
215 
216 if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
217  print '<br>';
218  //print $langs->trans('FollowingLinksArePublic').'<br>';
219  print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':<br>';
220  if ($conf->multicompany->enabled) {
221  $entity_qr = '?entity='.$conf->entity;
222  } else {
223  $entity_qr = '';
224  }
225 
226  // Define $urlwithroot
227  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
228  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
229  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
230 
231  print '<a target="_blank" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.$urlwithroot.'/public/members/new.php'.$entity_qr.'</a>';
232 }
233 
234 // End of page
235 llxFooter();
236 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:167
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:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:499
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 ...
Class to manage members type.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59