index.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. /**
  18. * \file htdocs/public/project/index.php
  19. * \ingroup core
  20. * \brief File to offer a way to suggest a conference or a booth for an event
  21. */
  22. if (!defined('NOLOGIN')) {
  23. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  24. }
  25. if (!defined('NOCSRFCHECK')) {
  26. define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
  27. }
  28. if (!defined('NOIPCHECK')) {
  29. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  30. }
  31. if (!defined('NOBROWSERNOTIF')) {
  32. define('NOBROWSERNOTIF', '1');
  33. }
  34. // For MultiCompany module.
  35. // Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php
  36. $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))));
  37. if (is_numeric($entity)) {
  38. define("DOLENTITY", $entity);
  39. }
  40. // Load Dolibarr environment
  41. require '../../main.inc.php';
  42. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  43. require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
  44. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  45. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  46. require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
  47. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  48. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  49. // Hook to be used by external payment modules (ie Payzen, ...)
  50. $hookmanager = new HookManager($db);
  51. $hookmanager->initHooks(array('newpayment'));
  52. // Load translation files
  53. $langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
  54. // Security check
  55. // No check on module enabled. Done later according to $validpaymentmethod
  56. $action = GETPOST('action', 'aZ09');
  57. $id = GETPOST('id', 'int');
  58. $securekeyreceived = GETPOST("securekey", 'alpha');
  59. $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
  60. if ($securekeytocompare != $securekeyreceived) {
  61. print $langs->trans('MissingOrBadSecureKey');
  62. exit;
  63. }
  64. // Define $urlwithroot
  65. //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  66. //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  67. $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
  68. $project = new Project($db);
  69. $resultproject = $project->fetch($id);
  70. if ($resultproject < 0) {
  71. $error++;
  72. $errmsg .= $project->error;
  73. }
  74. // Security check
  75. if (empty($conf->project->enabled)) {
  76. httponly_accessforbidden('Module Project not enabled');
  77. }
  78. /*
  79. * Actions
  80. */
  81. if (GETPOST('suggestbooth')) {
  82. header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  83. exit;
  84. }
  85. if (GETPOST('suggestconference')) {
  86. header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  87. exit;
  88. }
  89. if (GETPOST('viewandvote')) {
  90. header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  91. exit;
  92. }
  93. /*
  94. * View
  95. */
  96. $head = '';
  97. if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
  98. $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
  99. }
  100. $conf->dol_hide_topmenu = 1;
  101. $conf->dol_hide_leftmenu = 1;
  102. $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
  103. llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
  104. print '<span id="dolpaymentspan"></span>'."\n";
  105. print '<div class="center">'."\n";
  106. print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
  107. print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
  108. print '<input type="hidden" name="action" value="dopayment">'."\n";
  109. print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
  110. //print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
  111. print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
  112. print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
  113. print '<input type="hidden" name="e" value="'.$entity.'" />';
  114. print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
  115. print "\n";
  116. // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
  117. // Define logo and logosmall
  118. $logosmall = $mysoc->logo_small;
  119. $logo = $mysoc->logo;
  120. $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
  121. if (!empty($conf->global->$paramlogo)) {
  122. $logosmall = $conf->global->$paramlogo;
  123. } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
  124. $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
  125. }
  126. //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
  127. // Define urllogo
  128. $urllogo = '';
  129. $urllogofull = '';
  130. if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
  131. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
  132. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
  133. } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
  134. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
  135. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
  136. }
  137. // Output html code for logo
  138. if ($urllogo) {
  139. print '<div class="backgreypublicpayment">';
  140. print '<div class="logopublicpayment">';
  141. print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
  142. print '>';
  143. print '</div>';
  144. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  145. 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>';
  146. }
  147. print '</div>';
  148. }
  149. if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
  150. print '<div class="backimagepublicorganizedevent">';
  151. print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
  152. print '</div>';
  153. }
  154. print '<br>';
  155. // Event summary
  156. print '<div class="center">';
  157. print '<span class="large">'.$project->title.'</span><br>';
  158. print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': ';
  159. print dol_print_date($project->date_start, 'daytext');
  160. if ($project->date_end && $project->date_start != $project->date_end) {
  161. print ' - '.dol_print_date($project->date_end, 'daytext');
  162. }
  163. print '<br><br>'."\n";
  164. print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n";
  165. print $project->note_public."\n";
  166. //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
  167. print '</div>';
  168. print '<br>';
  169. print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
  170. print $text;
  171. // Output payment summary form
  172. print '<tr><td align="center">';
  173. $found = false;
  174. $error = 0;
  175. $var = false;
  176. $object = null;
  177. print "\n";
  178. // Show all action buttons
  179. print '<br>';
  180. // Output introduction text
  181. $foundaction = 0;
  182. if ($project->accept_booth_suggestions) {
  183. $foundaction++;
  184. print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button width500">';
  185. print '<br><br>';
  186. }
  187. if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
  188. $foundaction++;
  189. print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button width500">';
  190. print '<br><br>';
  191. }
  192. if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
  193. $foundaction++;
  194. print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button width500">';
  195. }
  196. if (! $foundaction) {
  197. print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
  198. }
  199. print '</td></tr>'."\n";
  200. print '</table>'."\n";
  201. print '</form>'."\n";
  202. print '</div>'."\n";
  203. print '<br>';
  204. htmlPrintOnlineFooter($mysoc, $langs, 1, $suffix, $object);
  205. llxFooter('', 'public');
  206. $db->close();