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