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