index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
  51. $hookmanager = new HookManager($db);
  52. $hookmanager->initHooks(array('newpayment'));
  53. // Load translation files
  54. $langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
  55. // Security check
  56. // No check on module enabled. Done later according to $validpaymentmethod
  57. $action = GETPOST('action', 'aZ09');
  58. $id = GETPOST('id', 'int');
  59. $securekeyreceived = GETPOST("securekey", 'alpha');
  60. $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
  61. if ($securekeytocompare != $securekeyreceived) {
  62. print $langs->trans('MissingOrBadSecureKey');
  63. exit;
  64. }
  65. // Define $urlwithroot
  66. //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  67. //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  68. $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
  69. $project = new Project($db);
  70. $resultproject = $project->fetch($id);
  71. if ($resultproject < 0) {
  72. $error++;
  73. $errmsg .= $project->error;
  74. }
  75. // Security check
  76. if (empty($conf->project->enabled)) {
  77. httponly_accessforbidden('Module Project not enabled');
  78. }
  79. /*
  80. * Actions
  81. */
  82. if (GETPOST('suggestbooth')) {
  83. header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  84. exit;
  85. }
  86. if (GETPOST('suggestconference')) {
  87. header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  88. exit;
  89. }
  90. if (GETPOST('viewandvote')) {
  91. header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
  92. exit;
  93. }
  94. /*
  95. * View
  96. */
  97. $head = '';
  98. if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
  99. $head = '<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
  100. }
  101. $conf->dol_hide_topmenu = 1;
  102. $conf->dol_hide_leftmenu = 1;
  103. $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
  104. llxHeaderVierge($langs->trans("SuggestForm"));
  105. print '<span id="dolpaymentspan"></span>'."\n";
  106. print '<div class="center">'."\n";
  107. print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
  108. print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
  109. print '<input type="hidden" name="action" value="dopayment">'."\n";
  110. print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
  111. //print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
  112. print '<input type="hidden" name="id" value="'.dol_escape_htmltag($id).'">'."\n";
  113. print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
  114. print '<input type="hidden" name="e" value="'.$entity.'" />';
  115. print '<input type="hidden" name="forcesandbox" value="'.GETPOST('forcesandbox', 'int').'" />';
  116. print "\n";
  117. // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
  118. // Define logo and logosmall
  119. $logosmall = $mysoc->logo_small;
  120. $logo = $mysoc->logo;
  121. $paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
  122. if (!empty($conf->global->$paramlogo)) {
  123. $logosmall = $conf->global->$paramlogo;
  124. } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
  125. $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
  126. }
  127. //print '- Show logo (logosmall='.$logosmall.' logo='.$logo.') '."\n";
  128. // Define urllogo
  129. $urllogo = '';
  130. $urllogofull = '';
  131. if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
  132. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$logosmall);
  133. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
  134. } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
  135. $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$logo);
  136. $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
  137. }
  138. // Output html code for logo
  139. if ($urllogo) {
  140. print '<div class="backgreypublicpayment">';
  141. print '<div class="logopublicpayment">';
  142. print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
  143. print '>';
  144. print '</div>';
  145. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  146. 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>';
  147. }
  148. print '</div>';
  149. }
  150. if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
  151. print '<div class="backimagepublicorganizedevent">';
  152. print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT.'">';
  153. print '</div>';
  154. }
  155. print '<br>';
  156. print '<div align="center">';
  157. print '<div id="divsubscribe">';
  158. // Event summary
  159. print '<div class="center">';
  160. print '<span class="eventlabel large">'.dol_escape_htmltag($project->title . ' '. $project->label).'</span><br>';
  161. print '<br><br>'."\n";
  162. print '<span class="opacitymedium">'.$langs->trans("EvntOrgRegistrationWelcomeMessage")."</span>\n";
  163. print $project->note_public."\n";
  164. //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
  165. print '</div>';
  166. // Help text
  167. print '<div class="center subscriptionformhelptext">';
  168. if ($project->date_start_event || $project->date_end_event) {
  169. print '<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
  170. }
  171. if ($project->date_start_event) {
  172. $format = 'day';
  173. $tmparray = dol_getdate($project->date_start_event, false, '');
  174. if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
  175. $format = 'dayhour';
  176. }
  177. print dol_print_date($project->date_start_event, $format);
  178. }
  179. if ($project->date_start_event && $project->date_end_event) {
  180. print ' - ';
  181. }
  182. if ($project->date_end_event) {
  183. $format = 'day';
  184. $tmparray = dol_getdate($project->date_end_event, false, '');
  185. if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
  186. $format = 'dayhour';
  187. }
  188. print dol_print_date($project->date_end_event, $format);
  189. }
  190. if ($project->date_start_event || $project->date_end_event) {
  191. print '<br>';
  192. }
  193. if ($project->location) {
  194. print '<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).'<br>';
  195. }
  196. print '</div>';
  197. print '<br>';
  198. print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
  199. print $text;
  200. // Output payment summary form
  201. print '<tr><td align="center">';
  202. $found = false;
  203. $error = 0;
  204. $var = false;
  205. $object = null;
  206. print "\n";
  207. // Show all action buttons
  208. print '<br>';
  209. // Output introduction text
  210. $foundaction = 0;
  211. if ($project->accept_booth_suggestions) {
  212. $foundaction++;
  213. print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button width500">';
  214. print '<br><br>';
  215. }
  216. if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
  217. $foundaction++;
  218. print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button width500">';
  219. print '<br><br>';
  220. }
  221. if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
  222. $foundaction++;
  223. print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button width500">';
  224. }
  225. if (! $foundaction) {
  226. print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
  227. }
  228. print '</td></tr>'."\n";
  229. print '</table>'."\n";
  230. print '</div></div>';
  231. print '</form>'."\n";
  232. print '</div>'."\n";
  233. print '<br>';
  234. htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
  235. llxFooter('', 'public');
  236. $db->close();
  237. /**
  238. * Show header for new member
  239. *
  240. * @param string $title Title
  241. * @param string $head Head array
  242. * @param int $disablejs More content into html header
  243. * @param int $disablehead More content into html header
  244. * @param array $arrayofjs Array of complementary js files
  245. * @param array $arrayofcss Array of complementary css files
  246. * @return void
  247. */
  248. function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
  249. {
  250. global $user, $conf, $langs, $mysoc;
  251. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
  252. print '<body id="mainbody" class="publicnewmemberform">';
  253. // Define urllogo
  254. $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
  255. if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
  256. $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
  257. } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
  258. $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
  259. } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
  260. $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
  261. }
  262. print '<div class="center">';
  263. // Output html code for logo
  264. if ($urllogo) {
  265. print '<div class="backgreypublicpayment">';
  266. print '<div class="logopublicpayment">';
  267. print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
  268. print '>';
  269. print '</div>';
  270. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  271. 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>';
  272. }
  273. print '</div>';
  274. }
  275. if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_CONFERENCE)) {
  276. print '<div class="backimagepublicsuggestconference">';
  277. print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_CONFERENCE" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_CONFERENCE.'">';
  278. print '</div>';
  279. }
  280. print '</div>';
  281. print '<div class="divmainbodylarge">';
  282. }