dolibarr 21.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Dorian Vabre <dorian.vabre@gmail.com>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25if (!defined('NOLOGIN')) {
26 define("NOLOGIN", 1); // This means this output page does not require to be logged.
27}
28if (!defined('NOCSRFCHECK')) {
29 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
30}
31if (!defined('NOIPCHECK')) {
32 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
33}
34if (!defined('NOBROWSERNOTIF')) {
35 define('NOBROWSERNOTIF', '1');
36}
37
38// For MultiCompany module.
39// Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php
40// Because 2 entities can have the same ref.
41$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1))));
42if (is_numeric($entity)) {
43 define("DOLENTITY", $entity);
44}
45
46// Load Dolibarr environment
47require '../../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
52require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
53require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
54require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
55
56global $dolibarr_main_url_root;
57
68// Load translation files
69$langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
70
71// Security check
72// No check on module enabled. Done later according to $validpaymentmethod
73
74$errmsg = '';
75$error = 0;
76$action = GETPOST('action', 'aZ09');
77$id = GETPOSTINT('id');
78$securekeyreceived = GETPOST("securekey", 'alpha');
79$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $id), 'md5');
80
81if ($securekeytocompare != $securekeyreceived) {
82 print $langs->trans('MissingOrBadSecureKey');
83 exit;
84}
85
86// Define $urlwithroot
87//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
88//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
89$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
90
91$project = new Project($db);
92$resultproject = $project->fetch($id);
93if ($resultproject < 0) {
94 $error++;
95 $errmsg .= $project->error;
96}
97
98$hookmanager->initHooks(array('newpayment'));
99
100$extrafields = new ExtraFields($db);
101
102$user->loadDefaultValues();
103
104// Security check
105if (empty($conf->project->enabled)) {
106 httponly_accessforbidden('Module Project not enabled');
107}
108
109
110
122function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
123{
124 global $conf, $langs, $mysoc;
125
126 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
127
128 print '<body id="mainbody" class="publicnewmemberform">';
129
130 // Define urllogo
131 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
132
133 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
134 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
135 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
136 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
137 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
138 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
139 }
140
141 print '<div class="center">';
142 // Output html code for logo
143 print '<div class="backgreypublicpayment">';
144 print '<div class="logopublicpayment">';
145 if ($urllogo) {
146 print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
147 }
148 if (empty($urllogo)) {
149 print $mysoc->name;
150 }
151 print '</div>';
152 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
153 print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans("PoweredBy").'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>';
154 }
155 print '</div>';
156
157 if (getDolGlobalString('PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT')) {
158 print '<div class="backimagepubliceventorganizationsubscription">';
159 print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="' . getDolGlobalString('PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT').'">';
160 print '</div>';
161 }
162
163 print '</div>';
164
165 print '<div class="divmainbodylarge">';
166}
167
174{
175 print '</div>';
176
177 printCommonFooter('public');
178
179 print "</body>\n";
180 print "</html>\n";
181}
182
183
184/*
185 * Actions
186 */
187
188if (GETPOST('suggestbooth')) {
189 header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
190 exit;
191}
192
193if (GETPOST('suggestconference')) {
194 header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
195 exit;
196}
197
198if (GETPOST('viewandvote')) {
199 header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
200 exit;
201}
202
203
204/*
205 * View
206 */
207
208$head = '';
209if (getDolGlobalString('ONLINE_PAYMENT_CSS_URL')) {
210 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('ONLINE_PAYMENT_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
211}
212
213$conf->dol_hide_topmenu = 1;
214$conf->dol_hide_leftmenu = 1;
215
216$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
217
218//llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
219
220llxHeaderVierge($langs->trans("SuggestForm"));
221
222
223print '<span id="dolpaymentspan"></span>'."\n";
224print '<div class="center">'."\n";
225
226print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
227print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
228print '<input type="hidden" name="action" value="dopayment">'."\n";
229print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
230//print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
231print '<input type="hidden" name="id" value="'.dol_escape_htmltag((string) $id).'">'."\n";
232print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
233print '<input type="hidden" name="e" value="'.$entity.'" />';
234print '<input type="hidden" name="forcesandbox" value="'.GETPOSTINT('forcesandbox').'" />';
235print "\n";
236
237
238print '<div align="center">';
239print '<div id="divsubscribe">';
240
241
242// Sub banner
243print '<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
244print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, '', 'center');
245// Welcome message
246print '<span class="opacitymedium">'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'</span>';
247print '<br>';
248// Title
249print '<span class="eventlabel large">'.dol_escape_htmltag($project->title . ' '. $conference->label).'</span><br>';
250print '</div>';
251
252// Help text
253print '<div class="justify subscriptionformhelptext">';
254
255if ($project->date_start_event || $project->date_end_event) {
256 print '<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
257}
258if ($project->date_start_event) {
259 $format = 'day';
260 $tmparray = dol_getdate($project->date_start_event, false, '');
261 if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
262 $format = 'dayhour';
263 }
264 print dol_print_date($project->date_start_event, $format);
265}
266if ($project->date_start_event && $project->date_end_event) {
267 print ' - ';
268}
269if ($project->date_end_event) {
270 $format = 'day';
271 $tmparray = dol_getdate($project->date_end_event, false, '');
272 if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
273 $format = 'dayhour';
274 }
275 print dol_print_date($project->date_end_event, $format);
276}
277if ($project->date_start_event || $project->date_end_event) {
278 print '<br>';
279}
280if ($project->location) {
281 print '<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).'<br>';
282}
283
284print '</div>';
285
286
287print '<br>';
288
289print '<table id="dolsuggestboost" summary="Suggest a boost form" class="center">'."\n";
290
291print $text;
292
293// Output payment summary form
294print '<tr><td align="center">';
295
296$found = false;
297$error = 0;
298$var = false;
299
300$object = null;
301
302print "\n";
303
304
305// Show all action buttons
306print '<br>';
307
308// Output introduction text
309$foundaction = 0;
310if ($project->accept_booth_suggestions) {
311 $foundaction++;
312 print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button minwidth250">';
313 print '<br><br>';
314}
315if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
316 $foundaction++;
317 print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button minwidth250">';
318 print '<br><br>';
319}
320if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
321 $foundaction++;
322 print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button minwidth250">';
323}
324
325if (! $foundaction) {
326 print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
327}
328
329print '</td></tr>'."\n";
330
331print '</table>'."\n";
332
333
334print '</div></div>';
335
336
337print '</form>'."\n";
338print '</div>'."\n";
339print '<br>';
340
341
342
343htmlPrintOnlineFooter($mysoc, $langs, 1, $suffix, $object);
344
345llxFooter('', 'public');
346
347$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage standard extra fields.
Class to manage projects.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Show header for booking.
Definition index.php:136
llxFooterVierge()
Show footer for demo.
Definition index.php:496
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.