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.'/partnership/lib/partnership.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("admin", "partnership"));
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 == 'setPARTNERSHIP_ENABLE_PUBLIC') {
51  if (GETPOST('value')) {
52  dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
53  } else {
54  dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
55  }
56 }
57 
58 if ($action == 'update') {
59  $public = GETPOST('PARTNERSHIP_ENABLE_PUBLIC');
60 
61  $res = dolibarr_set_const($db, "PARTNERSHIP_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
62 
63  if (!($res > 0)) {
64  $error++;
65  }
66 
67  if (!$error) {
68  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
69  } else {
70  setEventMessages($langs->trans("Error"), null, 'errors');
71  }
72 }
73 
74 
75 /*
76  * View
77  */
78 
79 $form = new Form($db);
80 
81 $title = $langs->trans('PartnershipSetup');
82 $help_url = '';
83 //$help_url = 'EN:Module_Partnership|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
84 llxHeader('', $title, $help_url);
85 
86 
87 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
88 print load_fiche_titre($title, $linkback, 'title_setup');
89 
91 
92 
93 
94 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
95 print '<input type="hidden" name="action" value="update">';
96 print '<input type="hidden" name="token" value="'.newToken().'">';
97 
98 print dol_get_fiche_head($head, 'website', $langs->trans("Partnerships"), -1, 'partnership');
99 
100 if ($conf->use_javascript_ajax) {
101  print "\n".'<script type="text/javascript" language="javascript">';
102  print 'jQuery(document).ready(function () {
103  function initemail()
104  {
105  if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\')
106  {
107  jQuery("#tremail").hide();
108  }
109  else
110  {
111  jQuery("#tremail").show();
112  }
113  }
114  function initfields()
115  {
116  if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'0\')
117  {
118  jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
119  }
120  if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'1\')
121  {
122  jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
123  if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
124  else jQuery("#tremail").show();
125  }
126  }
127  initfields();
128  jQuery("#PARTNERSHIP_ENABLE_PUBLIC").change(function() { initfields(); });
129  jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").change(function() { initemail(); });
130  })';
131  print '</script>'."\n";
132 }
133 
134 
135 print '<span class="opacitymedium">'.$langs->trans("PublicFormRegistrationPartnerDesc").'</span><br><br>';
136 
137 $param = '';
138 
139 $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
140 if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
141  // Button off, click to enable
142  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
143  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
144  $enabledisablehtml .= '</a>';
145 } else {
146  // Button on, click to disable
147  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
148  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
149  $enabledisablehtml .= '</a>';
150 }
151 print $enabledisablehtml;
152 print '<input type="hidden" id="PARTNERSHIP_ENABLE_PUBLIC" name="PARTNERSHIP_ENABLE_PUBLIC" value="'.(empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC) ? 0 : 1).'">';
153 
154 
155 print '<br>';
156 
157 
158 /*
159 if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
160  print '<br>';
161 
162  print '<div class="div-table-responsive-no-min">';
163  print '<table class="noborder centpercent">';
164 
165  print '<tr class="liste_titre">';
166  print '<td>'.$langs->trans("Parameter").'</td>';
167  print '<td class="right">'.$langs->trans("Value").'</td>';
168  print "</tr>\n";
169 
170  // Amount
171  print '<tr class="oddeven" id="tramount"><td>';
172  print $langs->trans("DefaultAmount");
173  print '</td><td class="right">';
174  print '<input type="text" class="right width75" id="PARTNERSHIP_NEWFORM_AMOUNT" name="PARTNERSHIP_NEWFORM_AMOUNT" value="'.(!empty($conf->global->PARTNERSHIP_NEWFORM_AMOUNT) ? $conf->global->PARTNERSHIP_NEWFORM_AMOUNT : '').'">';
175  print "</td></tr>\n";
176 
177  // Can edit
178  print '<tr class="oddeven" id="tredit"><td>';
179  print $langs->trans("CanEditAmount");
180  print '</td><td class="right">';
181  print $form->selectyesno("PARTNERSHIP_NEWFORM_EDITAMOUNT", (!empty($conf->global->PARTNERSHIP_NEWFORM_EDITAMOUNT) ? $conf->global->PARTNERSHIP_NEWFORM_EDITAMOUNT : 0), 1);
182  print "</td></tr>\n";
183 
184  // Jump to an online payment page
185  print '<tr class="oddeven" id="trpayment"><td>';
186  print $langs->trans("PARTNERSHIP_NEWFORM_PAYONLINE");
187  print '</td><td class="right">';
188  $listofval = array();
189  $listofval['-1'] = $langs->trans('No');
190  $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
191  if (!empty($conf->paybox->enabled)) {
192  $listofval['paybox'] = 'Paybox';
193  }
194  if (!empty($conf->paypal->enabled)) {
195  $listofval['paypal'] = 'PayPal';
196  }
197  if (!empty($conf->stripe->enabled)) {
198  $listofval['stripe'] = 'Stripe';
199  }
200  print $form->selectarray("PARTNERSHIP_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) ? $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE : ''), 0);
201  print "</td></tr>\n";
202 
203 
204  print '</table>';
205  print '</div>';
206 
207  print '<div class="center">';
208  print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
209  print '</div>';
210 }
211 */
212 
213 
214 print dol_get_fiche_end();
215 
216 print '</form>';
217 
218 
219 if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
220  print '<br>';
221  //print $langs->trans('FollowingLinksArePublic').'<br>';
222  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
223  if (!empty($conf->multicompany->enabled)) {
224  $entity_qr = '?entity='.$conf->entity;
225  } else {
226  $entity_qr = '';
227  }
228 
229  // Define $urlwithroot
230  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
231  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
232  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
233 
234  print '<div class="urllink">';
235  print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">';
236  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
237  print '</div>';
238  print ajax_autoselect('publicurlmember');
239 }
240 
241 // End of page
242 llxFooter();
243 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
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
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
partnershipAdminPrepareHead
partnershipAdminPrepareHead()
Prepare admin pages header.
Definition: partnership.lib.php:29
$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
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