dolibarr  19.0.0-dev
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 
24 if (!defined('NOLOGIN')) {
25  define("NOLOGIN", 1); // This means this output page does not require to be logged.
26 }
27 if (!defined('NOCSRFCHECK')) {
28  define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
29 }
30 if (!defined('NOIPCHECK')) {
31  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
32 }
33 if (!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 $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))));
40 if (is_numeric($entity)) {
41  define("DOLENTITY", $entity);
42 }
43 
44 // Load Dolibarr environment
45 require '../../main.inc.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
49 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
52 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
53 
54 global $dolibarr_main_url_root;
55 
56 // Load translation files
57 $langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
58 
59 // Security check
60 // No check on module enabled. Done later according to $validpaymentmethod
61 
62 $action = GETPOST('action', 'aZ09');
63 $id = GETPOST('id', 'int');
64 $securekeyreceived = GETPOST("securekey", 'alpha');
65 $securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $id), 'md5');
66 
67 if ($securekeytocompare != $securekeyreceived) {
68  print $langs->trans('MissingOrBadSecureKey');
69  exit;
70 }
71 
72 // Define $urlwithroot
73 //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
74 //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
75 $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
76 
77 $project = new Project($db);
78 $resultproject = $project->fetch($id);
79 if ($resultproject < 0) {
80  $error++;
81  $errmsg .= $project->error;
82 }
83 
84 $hookmanager->initHooks(array('newpayment'));
85 
86 $extrafields = new ExtraFields($db);
87 
88 $user->loadDefaultValues();
89 
90 // Security check
91 if (empty($conf->project->enabled)) {
92  httponly_accessforbidden('Module Project not enabled');
93 }
94 
95 
96 
108 function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
109 {
110  global $user, $conf, $langs, $mysoc;
111 
112  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
113 
114  print '<body id="mainbody" class="publicnewmemberform">';
115 
116  // Define urllogo
117  $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
118 
119  if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
120  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
121  } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
122  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
123  } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
124  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
125  }
126 
127  print '<div class="center">';
128  // Output html code for logo
129  if ($urllogo) {
130  print '<div class="backgreypublicpayment">';
131  print '<div class="logopublicpayment">';
132  print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
133  print '>';
134  print '</div>';
135  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
136  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>';
137  }
138  print '</div>';
139  }
140 
141  if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
142  print '<div class="backimagepubliceventorganizationsubscription">';
143  print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
144  print '</div>';
145  }
146 
147  print '</div>';
148 
149  print '<div class="divmainbodylarge">';
150 }
151 
157 function llxFooterVierge()
158 {
159  print '</div>';
160 
161  printCommonFooter('public');
162 
163  print "</body>\n";
164  print "</html>\n";
165 }
166 
167 
168 /*
169  * Actions
170  */
171 
172 if (GETPOST('suggestbooth')) {
173  header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
174  exit;
175 }
176 
177 if (GETPOST('suggestconference')) {
178  header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
179  exit;
180 }
181 
182 if (GETPOST('viewandvote')) {
183  header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
184  exit;
185 }
186 
187 
188 
189 
190 /*
191  * View
192  */
193 
194 $head = '';
195 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
196  $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
197 }
198 
199 $conf->dol_hide_topmenu = 1;
200 $conf->dol_hide_leftmenu = 1;
201 
202 $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
203 
204 llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
205 
206 //llxHeaderVierge($langs->trans("SuggestForm"));
207 
208 
209 
210 print '<span id="dolpaymentspan"></span>'."\n";
211 print '<div class="center">'."\n";
212 
213 print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
214 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
215 print '<input type="hidden" name="action" value="dopayment">'."\n";
216 print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
217 //print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
218 print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
219 print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
220 print '<input type="hidden" name="e" value="'.$entity.'" />';
221 print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
222 print "\n";
223 
224 
225 print '<div align="center">';
226 print '<div id="divsubscribe">';
227 
228 
229 // Sub banner
230 print '<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
231 print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, 0, 'center');
232 // Welcome message
233 print '<span class="opacitymedium">'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'</span>';
234 print '<br>';
235 // Title
236 print '<span class="eventlabel large">'.dol_escape_htmltag($project->title . ' '. $conference->label).'</span><br>';
237 print '</div>';
238 
239 // Help text
240 print '<div class="justify subscriptionformhelptext">';
241 
242 if ($project->date_start_event || $project->date_end_event) {
243  print '<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
244 }
245 if ($project->date_start_event) {
246  $format = 'day';
247  $tmparray = dol_getdate($project->date_start_event, false, '');
248  if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
249  $format = 'dayhour';
250  }
251  print dol_print_date($project->date_start_event, $format);
252 }
253 if ($project->date_start_event && $project->date_end_event) {
254  print ' - ';
255 }
256 if ($project->date_end_event) {
257  $format = 'day';
258  $tmparray = dol_getdate($project->date_end_event, false, '');
259  if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
260  $format = 'dayhour';
261  }
262  print dol_print_date($project->date_end_event, $format);
263 }
264 if ($project->date_start_event || $project->date_end_event) {
265  print '<br>';
266 }
267 if ($project->location) {
268  print '<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).'<br>';
269 }
270 
271 print '</div>';
272 
273 
274 print '<br>';
275 
276 print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
277 
278 print $text;
279 
280 // Output payment summary form
281 print '<tr><td align="center">';
282 
283 $found = false;
284 $error = 0;
285 $var = false;
286 
287 $object = null;
288 
289 print "\n";
290 
291 
292 // Show all action buttons
293 print '<br>';
294 
295 // Output introduction text
296 $foundaction = 0;
297 if ($project->accept_booth_suggestions) {
298  $foundaction++;
299  print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button width500">';
300  print '<br><br>';
301 }
302 if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
303  $foundaction++;
304  print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button width500">';
305  print '<br><br>';
306 }
307 if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
308  $foundaction++;
309  print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button width500">';
310 }
311 
312 if (! $foundaction) {
313  print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
314 }
315 
316 print '</td></tr>'."\n";
317 
318 print '</table>'."\n";
319 
320 
321 print '</div></div>';
322 
323 
324 print '</form>'."\n";
325 print '</div>'."\n";
326 print '<br>';
327 
328 
329 
330 htmlPrintOnlineFooter($mysoc, $langs, 1, $suffix, $object);
331 
332 llxFooter('', 'public');
333 
334 $db->close();
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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='', $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='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1625
llxFooterVierge()
Show footer for demo.
Definition: index.php:480
llxHeaderVierge($title, $head="")
Show header for demo.
Definition: index.php:466
llxFooter()
Footer empty.
Definition: index.php:71
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
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')
Returns a hash (non reversible encryption) of a string.