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