dolibarr  16.0.5
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 require '../../main.inc.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
48 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
52 // Hook to be used by external payment modules (ie Payzen, ...)
53 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
54 $hookmanager = new HookManager($db);
55 $hookmanager->initHooks(array('newpayment'));
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 $action = GETPOST('action', 'aZ09');
64 $id = GETPOST('id', 'int');
65 $securekeyreceived = GETPOST("securekey", 'alpha');
66 $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
67 
68 if ($securekeytocompare != $securekeyreceived) {
69  print $langs->trans('MissingOrBadSecureKey');
70  exit;
71 }
72 
73 // Define $urlwithroot
74 //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
75 //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
76 $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
77 
78 $project = new Project($db);
79 $resultproject = $project->fetch($id);
80 if ($resultproject < 0) {
81  $error++;
82  $errmsg .= $project->error;
83 }
84 
85 // Security check
86 if (empty($conf->project->enabled)) {
87  accessforbidden('', 0, 0, 1);
88 }
89 
90 
91 /*
92  * Actions
93  */
94 
95 if (GETPOST('suggestbooth')) {
96  header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
97  exit;
98 }
99 
100 if (GETPOST('suggestconference')) {
101  header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
102  exit;
103 }
104 
105 if (GETPOST('viewandvote')) {
106  header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
107  exit;
108 }
109 
110 
111 
112 
113 /*
114  * View
115  */
116 
117 $head = '';
118 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
119  $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
120 }
121 
122 $conf->dol_hide_topmenu = 1;
123 $conf->dol_hide_leftmenu = 1;
124 
125 $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
126 llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
127 
128 print '<span id="dolpaymentspan"></span>'."\n";
129 print '<div class="center">'."\n";
130 print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
131 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
132 print '<input type="hidden" name="action" value="dopayment">'."\n";
133 print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
134 //print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
135 print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
136 print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
137 print '<input type="hidden" name="e" value="'.$entity.'" />';
138 print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
139 print "\n";
140 
141 
142 // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
143 // Define logo and logosmall
144 $logosmall = $mysoc->logo_small;
145 $logo = $mysoc->logo;
146 $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
147 if (!empty($conf->global->$paramlogo)) {
148  $logosmall = $conf->global->$paramlogo;
149 } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
150  $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
151 }
152 //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
153 // Define urllogo
154 $urllogo = '';
155 $urllogofull = '';
156 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
157  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
158  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
159 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
160  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
161  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
162 }
163 
164 // Output html code for logo
165 if ($urllogo) {
166  print '<div class="backgreypublicpayment">';
167  print '<div class="logopublicpayment">';
168  print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
169  print '>';
170  print '</div>';
171  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
172  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>';
173  }
174  print '</div>';
175 }
176 
177 if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
178  print '<div class="backimagepublicorganizedevent">';
179  print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
180  print '</div>';
181 }
182 
183 print '<br>';
184 
185 
186 // Event summary
187 print '<div class="center">';
188 print '<span class="large">'.$project->title.'</span><br>';
189 print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': ';
190 print dol_print_date($project->date_start, 'daytext');
191 if ($project->date_end && $project->date_start != $project->date_end) {
192  print ' - '.dol_print_date($project->date_end, 'daytext');
193 }
194 print '<br><br>'."\n";
195 print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n";
196 print $project->note_public."\n";
197 //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
198 print '</div>';
199 
200 
201 print '<br>';
202 
203 print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
204 
205 print $text;
206 
207 // Output payment summary form
208 print '<tr><td align="center">';
209 
210 $found = false;
211 $error = 0;
212 $var = false;
213 
214 $object = null;
215 
216 print "\n";
217 
218 
219 // Show all action buttons
220 print '<br>';
221 
222 // Output introduction text
223 $foundaction = 0;
224 if ($project->accept_booth_suggestions) {
225  $foundaction++;
226  print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button width500">';
227  print '<br><br>';
228 }
229 if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
230  $foundaction++;
231  print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button width500">';
232  print '<br><br>';
233 }
234 if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
235  $foundaction++;
236  print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button width500">';
237 }
238 
239 if (! $foundaction) {
240  print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
241 }
242 
243 print '</td></tr>'."\n";
244 
245 print '</table>'."\n";
246 
247 print '</form>'."\n";
248 print '</div>'."\n";
249 print '<br>';
250 
251 
252 htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
253 
254 llxFooter('', 'public');
255 
256 $db->close();
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
dol_hash
dol_hash($chain, $type='0')
Returns a hash of a string.
Definition: security.lib.php:104
llxHeader
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
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30