dolibarr  x.y.z
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 // Hook to be used by external payment modules (ie Payzen, ...)
54 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
55 $hookmanager = new HookManager($db);
56 $hookmanager->initHooks(array('newpayment'));
57 
58 // Load translation files
59 $langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
60 
61 // Security check
62 // No check on module enabled. Done later according to $validpaymentmethod
63 
64 $action = GETPOST('action', 'aZ09');
65 $id = GETPOST('id', 'int');
66 $securekeyreceived = GETPOST("securekey", 'alpha');
67 $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
68 
69 if ($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);
81 if ($resultproject < 0) {
82  $error++;
83  $errmsg .= $project->error;
84 }
85 
86 // Security check
87 if (empty($conf->project->enabled)) {
88  httponly_accessforbidden('Module Project not enabled');
89 }
90 
91 
92 /*
93  * Actions
94  */
95 
96 if (GETPOST('suggestbooth')) {
97  header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
98  exit;
99 }
100 
101 if (GETPOST('suggestconference')) {
102  header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
103  exit;
104 }
105 
106 if (GETPOST('viewandvote')) {
107  header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
108  exit;
109 }
110 
111 
112 
113 
114 /*
115  * View
116  */
117 
118 $head = '';
119 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
120  $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
121 }
122 
123 $conf->dol_hide_topmenu = 1;
124 $conf->dol_hide_leftmenu = 1;
125 
126 $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
127 llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
128 
129 print '<span id="dolpaymentspan"></span>'."\n";
130 print '<div class="center">'."\n";
131 print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
132 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
133 print '<input type="hidden" name="action" value="dopayment">'."\n";
134 print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
135 //print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
136 print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
137 print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
138 print '<input type="hidden" name="e" value="'.$entity.'" />';
139 print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
140 print "\n";
141 
142 
143 // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
144 // Define logo and logosmall
145 $logosmall = $mysoc->logo_small;
146 $logo = $mysoc->logo;
147 $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
148 if (!empty($conf->global->$paramlogo)) {
149  $logosmall = $conf->global->$paramlogo;
150 } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
151  $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
152 }
153 //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
154 // Define urllogo
155 $urllogo = '';
156 $urllogofull = '';
157 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
158  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
159  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
160 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
161  $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
162  $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
163 }
164 
165 // Output html code for logo
166 if ($urllogo) {
167  print '<div class="backgreypublicpayment">';
168  print '<div class="logopublicpayment">';
169  print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
170  print '>';
171  print '</div>';
172  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
173  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>';
174  }
175  print '</div>';
176 }
177 
178 if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
179  print '<div class="backimagepublicorganizedevent">';
180  print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
181  print '</div>';
182 }
183 
184 print '<br>';
185 
186 
187 // Event summary
188 print '<div class="center">';
189 print '<span class="large">'.$project->title.'</span><br>';
190 print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': ';
191 print dol_print_date($project->date_start, 'daytext');
192 if ($project->date_end && $project->date_start != $project->date_end) {
193  print ' - '.dol_print_date($project->date_end, 'daytext');
194 }
195 print '<br><br>'."\n";
196 print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n";
197 print $project->note_public."\n";
198 //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
199 print '</div>';
200 
201 
202 print '<br>';
203 
204 print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
205 
206 print $text;
207 
208 // Output payment summary form
209 print '<tr><td align="center">';
210 
211 $found = false;
212 $error = 0;
213 $var = false;
214 
215 $object = null;
216 
217 print "\n";
218 
219 
220 // Show all action buttons
221 print '<br>';
222 
223 // Output introduction text
224 $foundaction = 0;
225 if ($project->accept_booth_suggestions) {
226  $foundaction++;
227  print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button width500">';
228  print '<br><br>';
229 }
230 if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
231  $foundaction++;
232  print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button width500">';
233  print '<br><br>';
234 }
235 if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
236  $foundaction++;
237  print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button width500">';
238 }
239 
240 if (! $foundaction) {
241  print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
242 }
243 
244 print '</td></tr>'."\n";
245 
246 print '</table>'."\n";
247 
248 print '</form>'."\n";
249 print '</div>'."\n";
250 print '<br>';
251 
252 
253 htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
254 
255 llxFooter('', 'public');
256 
257 $db->close();
Class to manage hooks.
Class to manage projects.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.