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