index.php 11 KB

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