dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array("admin", "partnership"));
46
47$action = GETPOST('action', 'aZ09');
48
49$error = 0;
50
51if (!$user->admin) {
53}
54
55
56/*
57 * Actions
58 */
59
60if ($action == 'setPARTNERSHIP_ENABLE_PUBLIC') {
61 if (GETPOST('value')) {
62 dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
63 } else {
64 dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
65 }
66}
67
68if ($action == 'update') {
69 $public = GETPOST('PARTNERSHIP_ENABLE_PUBLIC');
70
71 $res = dolibarr_set_const($db, "PARTNERSHIP_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
72
73 if (!($res > 0)) {
74 $error++;
75 }
76
77 if (!$error) {
78 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
79 } else {
80 setEventMessages($langs->trans("Error"), null, 'errors');
81 }
82}
83
84
85/*
86 * View
87 */
88
89$form = new Form($db);
90
91$title = $langs->trans('PartnershipSetup');
92$help_url = '';
93//$help_url = 'EN:Module_Partnership|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
94llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-partnership page-admin-website');
95
96
97$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
98print load_fiche_titre($title, $linkback, 'title_setup');
99
101
102
103
104print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
105print '<input type="hidden" name="action" value="update">';
106print '<input type="hidden" name="token" value="'.newToken().'">';
107
108print dol_get_fiche_head($head, 'website', $langs->trans("Partnerships"), -1, 'partnership');
109
110if ($conf->use_javascript_ajax) {
111 print "\n".'<script type="text/javascript" language="javascript">';
112 print 'jQuery(document).ready(function () {
113 function initemail()
114 {
115 if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\')
116 {
117 jQuery("#tremail").hide();
118 }
119 else
120 {
121 jQuery("#tremail").show();
122 }
123 }
124 function initfields()
125 {
126 if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'0\')
127 {
128 jQuery("#trforcetype, #tramount, #tredit, #trpayment, #tremail").hide();
129 }
130 if (jQuery("#PARTNERSHIP_ENABLE_PUBLIC").val()==\'1\')
131 {
132 jQuery("#trforcetype, #tramount, #tredit, #trpayment").show();
133 if (jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").val()==\'-1\') jQuery("#tremail").hide();
134 else jQuery("#tremail").show();
135 }
136 }
137 initfields();
138 jQuery("#PARTNERSHIP_ENABLE_PUBLIC").change(function() { initfields(); });
139 jQuery("#PARTNERSHIP_NEWFORM_PAYONLINE").change(function() { initemail(); });
140 })';
141 print '</script>'."\n";
142}
143
144
145print '<span class="opacitymedium">'.$langs->trans("PublicFormRegistrationPartnerDesc").'</span><br><br>';
146
147$param = '';
148
149$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
150if (!getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC')) {
151 // Button off, click to enable
152 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
153 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
154 $enabledisablehtml .= '</a>';
155} else {
156 // Button on, click to disable
157 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setPARTNERSHIP_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
158 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
159 $enabledisablehtml .= '</a>';
160}
161print $enabledisablehtml;
162print '<input type="hidden" id="PARTNERSHIP_ENABLE_PUBLIC" name="PARTNERSHIP_ENABLE_PUBLIC" value="'.(!getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC') ? 0 : 1).'">';
163
164
165print '<br>';
166
167
168/*
169if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
170 print '<br>';
171
172 print '<div class="div-table-responsive-no-min">';
173 print '<table class="noborder centpercent">';
174
175 print '<tr class="liste_titre">';
176 print '<td>'.$langs->trans("Parameter").'</td>';
177 print '<td class="right">'.$langs->trans("Value").'</td>';
178 print "</tr>\n";
179
180 // Amount
181 print '<tr class="oddeven" id="tramount"><td>';
182 print $langs->trans("DefaultAmount");
183 print '</td><td class="right">';
184 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 : '').'">';
185 print "</td></tr>\n";
186
187 // Jump to an online payment page
188 print '<tr class="oddeven" id="trpayment"><td>';
189 print $langs->trans("PARTNERSHIP_NEWFORM_PAYONLINE");
190 print '</td><td class="right">';
191 $listofval = array();
192 $listofval['-1'] = $langs->trans('No');
193 $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
194 if (isModEnabled('paybox')) {
195 $listofval['paybox'] = 'Paybox';
196 }
197 if (isModEnabled('paypal')) {
198 $listofval['paypal'] = 'PayPal';
199 }
200 if (isModEnabled('stripe')) {
201 $listofval['stripe'] = 'Stripe';
202 }
203 print $form->selectarray("PARTNERSHIP_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) ? $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE : ''), 0);
204 print "</td></tr>\n";
205
206
207 print '</table>';
208 print '</div>';
209
210 print '<div class="center">';
211 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
212 print '</div>';
213}
214*/
215
216
217print dol_get_fiche_end();
218
219print '</form>';
220
221
222if (getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC')) {
223 print '<br>';
224 //print $langs->trans('FollowingLinksArePublic').'<br>';
225 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
226 if (isModEnabled('multicompany')) {
227 $entity_qr = '?entity='.$conf->entity;
228 } else {
229 $entity_qr = '';
230 }
231
232 // Define $urlwithroot
233 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
234 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
235 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
236
237 print '<div class="urllink">';
238 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">';
239 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
240 print '</div>';
241 print ajax_autoselect('publicurlmember');
242}
243
244// End of page
245llxFooter();
246$db->close();
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
partnershipAdminPrepareHead()
Prepare admin pages header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.