dolibarr 25.0.0-alpha
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';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
44
45// Load translation files required by the page
46$langs->loadLangs(array("admin", "partnership"));
47
48$action = GETPOST('action', 'aZ09');
49
50$error = 0;
51
52if (!$user->admin) {
54}
55
56
57/*
58 * Actions
59 */
60
61if ($action == 'setPARTNERSHIP_ENABLE_PUBLIC') {
62 if (GETPOST('value')) {
63 dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
64 } else {
65 dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
66 }
67}
68
69if ($action == 'update') {
70 $public = GETPOST('PARTNERSHIP_ENABLE_PUBLIC');
71
72 $res = dolibarr_set_const($db, "PARTNERSHIP_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
73
74 if (!($res > 0)) {
75 $error++;
76 }
77
78 if (!$error) {
79 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
80 } else {
81 setEventMessages($langs->trans("Error"), null, 'errors');
82 }
83}
84
85
86/*
87 * View
88 */
89
90$form = new Form($db);
91
92$title = $langs->trans('PartnershipSetup');
93$help_url = '';
94//$help_url = 'EN:Module_Partnership|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
95llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-partnership page-admin-website');
96
97
98$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
99print load_fiche_titre($title, $linkback, 'title_setup');
100
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">';
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 '<div class="info">'.$langs->trans("PublicFormRegistrationPartnerDesc").'</div>';
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}
161
162print '<div class="neutral">';
163print $enabledisablehtml;
164print '<input type="hidden" id="PARTNERSHIP_ENABLE_PUBLIC" name="PARTNERSHIP_ENABLE_PUBLIC" value="'.(!getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC') ? 0 : 1).'">';
165print '</div>';
166
167/*
168if (getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC')) {
169 print '<br>';
170
171 print '<div class="div-table-responsive-no-min">';
172 print '<table class="noborder centpercent">';
173
174 print '<tr class="liste_titre">';
175 print '<td>'.$langs->trans("Parameter").'</td>';
176 print '<td class="right">'.$langs->trans("Value").'</td>';
177 print "</tr>\n";
178
179 // Amount
180 print '<tr class="oddeven" id="tramount"><td>';
181 print $langs->trans("DefaultAmount");
182 print '</td><td class="right">';
183 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 : '').'">';
184 print "</td></tr>\n";
185
186 // Jump to an online payment page
187 print '<tr class="oddeven" id="trpayment"><td>';
188 print $langs->trans("PARTNERSHIP_NEWFORM_PAYONLINE");
189 print '</td><td class="right">';
190 $listofval = array();
191 $listofval['-1'] = $langs->trans('No');
192 $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')';
193 if (isModEnabled('paypal')) {
194 $listofval['paypal'] = 'PayPal';
195 }
196 if (isModEnabled('stripe')) {
197 $listofval['stripe'] = 'Stripe';
198 }
199 print $form->selectarray("PARTNERSHIP_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) ? $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE : ''), 0);
200 print "</td></tr>\n";
201
202
203 print '</table>';
204 print '</div>';
205
206 print '<div class="center">';
207 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
208 print '</div>';
209}
210*/
211
212
213print dol_get_fiche_end();
214
215print '</form>';
216
217
218if (getDolGlobalString('PARTNERSHIP_ENABLE_PUBLIC')) {
219 print '<br>';
220 //print $langs->trans('FollowingLinksArePublic').'<br>';
221 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
222 if (isModEnabled('multicompany')) {
223 $entity_qr = '?entity='.$conf->entity;
224 } else {
225 $entity_qr = '';
226 }
227
228 // Define $urlwithroot
229 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
230 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
231 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
232
233 print '<div class="urllink">';
234 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">';
235 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/partnership/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
236 print '</div>';
237 print ajax_autoselect('publicurlmember');
238}
239
240// End of page
241llxFooter();
242$db->close();
global $dolibarr_main_url_root
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:91
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:73
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.