suggestbooth.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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/suggestbooth.php
  19. * \ingroup member
  20. * \brief Example of form to suggest a booth
  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. if (!defined('NOIPCHECK')) {
  35. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  36. }
  37. // For MultiCompany module.
  38. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
  39. // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
  40. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
  41. if (is_numeric($entity)) {
  42. define("DOLENTITY", $entity);
  43. }
  44. require '../../main.inc.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  46. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  47. require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
  48. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  49. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  50. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  51. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  52. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
  53. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  54. global $dolibarr_main_url_root;
  55. // Init vars
  56. $errmsg = '';
  57. $num = 0;
  58. $error = 0;
  59. $backtopage = GETPOST('backtopage', 'alpha');
  60. $action = GETPOST('action', 'aZ09');
  61. $eventtype = GETPOST("eventtype");
  62. $email = GETPOST("email");
  63. $societe = GETPOST("societe");
  64. $label = GETPOST("label");
  65. $note = GETPOST("note");
  66. $datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
  67. $dateend = dol_mktime(23, 59, 59, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
  68. $id = GETPOST('id');
  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. $securekeyreceived = GETPOST("securekey");
  77. $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
  78. if ($securekeytocompare != $securekeyreceived) {
  79. print $langs->trans('MissingOrBadSecureKey');
  80. exit;
  81. }
  82. // Load translation files
  83. $langs->loadLangs(array("main", "companies", "install", "other", "eventorganization"));
  84. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  85. $hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
  86. $extrafields = new ExtraFields($db);
  87. $user->loadDefaultValues();
  88. $cactioncomm = new CActionComm($db);
  89. $arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='booth@eventorganization'");
  90. // Security check
  91. if (empty($conf->eventorganization->enabled)) {
  92. accessforbidden('', 0, 0, 1);
  93. }
  94. /**
  95. * Show header for new member
  96. *
  97. * @param string $title Title
  98. * @param string $head Head array
  99. * @param int $disablejs More content into html header
  100. * @param int $disablehead More content into html header
  101. * @param array $arrayofjs Array of complementary js files
  102. * @param array $arrayofcss Array of complementary css files
  103. * @return void
  104. */
  105. function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
  106. {
  107. global $user, $conf, $langs, $mysoc;
  108. top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
  109. print '<body id="mainbody" class="publicnewmemberform">';
  110. // Define urllogo
  111. $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
  112. if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
  113. $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
  114. } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
  115. $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
  116. } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
  117. $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
  118. }
  119. print '<div class="center">';
  120. // Output html code for logo
  121. if ($urllogo) {
  122. print '<div class="backgreypublicpayment">';
  123. print '<div class="logopublicpayment">';
  124. print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
  125. print '>';
  126. print '</div>';
  127. if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
  128. 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>';
  129. }
  130. print '</div>';
  131. }
  132. if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH)) {
  133. print '<div class="backimagepublicsuggestbooth">';
  134. print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH.'">';
  135. print '</div>';
  136. }
  137. print '</div>';
  138. print '<div class="divmainbodylarge">';
  139. }
  140. /**
  141. * Show footer for new member
  142. *
  143. * @return void
  144. */
  145. function llxFooterVierge()
  146. {
  147. print '</div>';
  148. printCommonFooter('public');
  149. print "</body>\n";
  150. print "</html>\n";
  151. }
  152. /*
  153. * Actions
  154. */
  155. $parameters = array();
  156. // Note that $action and $object may have been modified by some hooks
  157. $reshook = $hookmanager->executeHooks('doActions', $parameters, $project, $action);
  158. if ($reshook < 0) {
  159. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  160. }
  161. // Action called when page is submitted
  162. if (empty($reshook) && $action == 'add') {
  163. $error = 0;
  164. $urlback = '';
  165. $db->begin();
  166. if (!GETPOST("email")) {
  167. $error++;
  168. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
  169. }
  170. if (!GETPOST("label")) {
  171. $error++;
  172. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label"))."<br>\n";
  173. }
  174. if (!GETPOST("note")) {
  175. $error++;
  176. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Note"))."<br>\n";
  177. }
  178. if (!GETPOST("email")) {
  179. $error++;
  180. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
  181. }
  182. if (!GETPOST("lastname")) {
  183. $error++;
  184. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name"))."<br>\n";
  185. }
  186. if (!GETPOST("societe")) {
  187. $error++;
  188. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Societe"))."<br>\n";
  189. }
  190. if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
  191. $error++;
  192. $langs->load("errors");
  193. $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
  194. }
  195. if (!GETPOST("country_id") && !empty(floatval($project->price_booth))) {
  196. $error++;
  197. $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country"))."<br>\n";
  198. }
  199. if (!$error) {
  200. // Getting the thirdparty or creating it
  201. $thirdparty = new Societe($db);
  202. $resultfetchthirdparty = $thirdparty->fetch('', $societe);
  203. if ($resultfetchthirdparty<=0) {
  204. // Need to create a new one (not found or multiple with the same name)
  205. $thirdparty->name = $societe;
  206. $thirdparty->address = GETPOST("address");
  207. $thirdparty->zip = GETPOST("zipcode");
  208. $thirdparty->town = GETPOST("town");
  209. $thirdparty->client = 2;
  210. $thirdparty->fournisseur = 0;
  211. $thirdparty->country_id = GETPOST("country_id", 'int');
  212. $thirdparty->state_id = GETPOST("state_id", 'int');
  213. $thirdparty->email = $email;
  214. // Load object modCodeTiers
  215. $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
  216. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  217. $module = substr($module, 0, dol_strlen($module) - 4);
  218. }
  219. $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
  220. foreach ($dirsociete as $dirroot) {
  221. $res = dol_include_once($dirroot.$module.'.php');
  222. if ($res) {
  223. break;
  224. }
  225. }
  226. $modCodeClient = new $module($db);
  227. if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
  228. $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
  229. }
  230. $thirdparty->code_client = $tmpcode;
  231. $readythirdparty = $thirdparty->create($user);
  232. if ($readythirdparty <0) {
  233. $error++;
  234. $errmsg .= $thirdparty->error;
  235. } else {
  236. $thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs);
  237. $thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs);
  238. }
  239. }
  240. // From there we have a thirdparty, now looking for the contact
  241. if (!$error) {
  242. $contact = new Contact($db);
  243. $resultcontact = $contact->fetch('', '', '', $email);
  244. if ($resultcontact<=0) {
  245. // Need to create a contact
  246. $contact->socid = $thirdparty->id;
  247. $contact->lastname = (string) GETPOST("lastname", 'alpha');
  248. $contact->firstname = (string) GETPOST("firstname", 'alpha');
  249. $contact->address = (string) GETPOST("address", 'alpha');
  250. $contact->zip = (string) GETPOST("zipcode", 'alpha');
  251. $contact->town = (string) GETPOST("town", 'alpha');
  252. $contact->country_id = (int) GETPOST("country_id", 'int');
  253. $contact->state_id = (int) GETPOST("state_id", 'int');
  254. $contact->email = $email;
  255. $contact->statut = 1; //Default status to Actif
  256. $resultcreatecontact = $contact->create($user);
  257. if ($resultcreatecontact<0) {
  258. $error++;
  259. $errmsg .= $contact->error;
  260. }
  261. }
  262. }
  263. if (!$error) {
  264. // Adding supplier tag and tag from setup to thirdparty
  265. $category = new Categorie($db);
  266. $resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
  267. if ($resultcategory<=0) {
  268. $error++;
  269. $errmsg .= $category->error;
  270. } else {
  271. $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER, false);
  272. if ($resultsetcategory < 0) {
  273. $error++;
  274. $errmsg .= $thirdparty->error;
  275. } else {
  276. $thirdparty->fournisseur = 1;
  277. // Load object modCodeFournisseur
  278. $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
  279. if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
  280. $module = substr($module, 0, dol_strlen($module) - 4);
  281. }
  282. $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
  283. foreach ($dirsociete as $dirroot) {
  284. $res = dol_include_once($dirroot.$module.'.php');
  285. if ($res) {
  286. break;
  287. }
  288. }
  289. $modCodeFournisseur = new $module;
  290. if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
  291. $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
  292. }
  293. $thirdparty->code_fournisseur = $tmpcode;
  294. $res = $thirdparty->update(0, $user, 1, 1, 1);
  295. if ($res <= 0) {
  296. $error++;
  297. }
  298. }
  299. }
  300. }
  301. if (!$error) {
  302. // We have the contact and the thirdparty
  303. $conforbooth = new ConferenceOrBooth($db);
  304. $conforbooth->label = $label;
  305. $conforbooth->fk_soc = $thirdparty->id;
  306. $conforbooth->fk_project = $project->id;
  307. $conforbooth->note = $note;
  308. $conforbooth->fk_action = $eventtype;
  309. $conforbooth->datep = $datestart;
  310. $conforbooth->datep2 = $dateend;
  311. $conforbooth->datec = dol_now();
  312. $conforbooth->tms = dol_now();
  313. $resultconforbooth = $conforbooth->create($user);
  314. if ($resultconforbooth<=0) {
  315. $error++;
  316. $errmsg .= $conforbooth->error;
  317. } else {
  318. // Adding the contact to the project
  319. $resultaddcontact = $conforbooth->add_contact($contact->id, 'RESPONSIBLE');
  320. if ($resultaddcontact<0) {
  321. $error++;
  322. $errmsg .= $conforbooth->error;
  323. } else {
  324. // If this is a paying booth, we have to redirect to payment page and create an invoice
  325. if (!empty(floatval($project->price_booth))) {
  326. $productforinvoicerow = new Product($db);
  327. $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_BOOTH_LOCATION);
  328. if ($resultprod < 0) {
  329. $error++;
  330. $errmsg .= $productforinvoicerow->error;
  331. } else {
  332. $facture = new Facture($db);
  333. $facture->type = Facture::TYPE_STANDARD;
  334. $facture->socid = $thirdparty->id;
  335. $facture->paye = 0;
  336. $facture->date = dol_now();
  337. $facture->cond_reglement_id = $contact->cond_reglement_id;
  338. $facture->fk_project = $project->id;
  339. if (empty($facture->cond_reglement_id)) {
  340. $paymenttermstatic = new PaymentTerm($contact->db);
  341. $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
  342. if (empty($facture->cond_reglement_id)) {
  343. $error++;
  344. $contact->error = 'ErrorNoPaymentTermRECEPFound';
  345. $contact->errors[] = $contact->error;
  346. }
  347. }
  348. $resultfacture = $facture->create($user);
  349. if ($resultfacture <= 0) {
  350. $contact->error = $facture->error;
  351. $contact->errors = $facture->errors;
  352. $error++;
  353. } else {
  354. $db->commit();
  355. $facture->add_object_linked($conforbooth->element, $conforbooth->id);
  356. }
  357. }
  358. if (!$error) {
  359. // Add line to draft invoice
  360. $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
  361. $result = $facture->addline($langs->trans("BoothLocationFee", $conforbooth->label, dol_print_date($conforbooth->datep, '%d/%m/%y %H:%M:%S'), dol_print_date($conforbooth->datep2, '%d/%m/%y %H:%M:%S')), floatval($project->price_booth), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1);
  362. if ($result <= 0) {
  363. $contact->error = $facture->error;
  364. $contact->errors = $facture->errors;
  365. $error++;
  366. }
  367. /*if (!$error) {
  368. $valid = true;
  369. $sourcetouse = 'boothlocation';
  370. $reftouse = $facture->id;
  371. $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.$sourcetouse.'&ref='.$reftouse.'&booth='.$conforbooth->id;
  372. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
  373. if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
  374. $redirection .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $sourcetouse . $reftouse, 2); // Use the source in the hash to avoid duplicates if the references are identical
  375. } else {
  376. $redirection .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
  377. }
  378. }
  379. Header("Location: ".$redirection);
  380. exit;
  381. }*/
  382. }
  383. } else {
  384. // If no price has been set for the booth, we confirm it as suggested and we update
  385. $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
  386. $conforbooth->update($user);
  387. }
  388. }
  389. }
  390. }
  391. }
  392. if (!$error) {
  393. $db->commit();
  394. // Sending mail
  395. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  396. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  397. $formmail = new FormMail($db);
  398. // Set output language
  399. $outputlangs = new Translate('', $conf);
  400. $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
  401. // Load traductions files required by page
  402. $outputlangs->loadLangs(array("main", "members"));
  403. // Get email content from template
  404. $arraydefaultmessage = null;
  405. $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH;
  406. if (!empty($labeltouse)) {
  407. $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
  408. }
  409. if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
  410. $subject = $arraydefaultmessage->topic;
  411. $msg = $arraydefaultmessage->content;
  412. }
  413. $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
  414. complete_substitutions_array($substitutionarray, $outputlangs, $object);
  415. $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
  416. $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
  417. $sendto = $thirdparty->email;
  418. $from = $conf->global->MAILING_EMAIL_FROM;
  419. $urlback = $_SERVER["REQUEST_URI"];
  420. $ishtml = dol_textishtml($texttosend); // May contain urls
  421. $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml);
  422. $result = $mailfile->sendfile();
  423. if ($result) {
  424. dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
  425. } else {
  426. dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
  427. }
  428. $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
  429. $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl;
  430. Header("Location: ".$redirection);
  431. exit;
  432. } else {
  433. $db->rollback();
  434. }
  435. }
  436. /*
  437. * View
  438. */
  439. $form = new Form($db);
  440. $formcompany = new FormCompany($db);
  441. llxHeaderVierge($langs->trans("NewSuggestionOfBooth"));
  442. print '<br>';
  443. // Event summary
  444. print '<div class="center">';
  445. print '<span class="large">'.$project->title.'</span><br>';
  446. print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': ';
  447. print dol_print_date($project->date_start, 'daytext');
  448. if ($project->date_end && $project->date_start != $project->date_end) {
  449. print ' - '.dol_print_date($project->date_end, 'daytext');
  450. }
  451. print '<br><br>'."\n";
  452. //print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n";
  453. //print $project->note_public."\n";
  454. //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
  455. print '</div>';
  456. print load_fiche_titre($langs->trans("NewSuggestionOfBooth"), '', '', 0, 0, 'center');
  457. print '<div align="center">';
  458. print '<div id="divsubscribe">';
  459. print '<div class="center subscriptionformhelptext justify">';
  460. dol_htmloutput_errors($errmsg);
  461. // Print form
  462. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
  463. print '<input type="hidden" name="token" value="'.newToken().'" / >';
  464. print '<input type="hidden" name="entity" value="'.$entity.'" />';
  465. print '<input type="hidden" name="action" value="add" />';
  466. print '<input type="hidden" name="id" value="'.$id.'" />';
  467. print '<input type="hidden" name="securekey" value="'.$securekeyreceived.'" />';
  468. print '<br>';
  469. print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
  470. //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
  471. print dol_get_fiche_head('');
  472. print '<script type="text/javascript">
  473. jQuery(document).ready(function () {
  474. jQuery(document).ready(function () {
  475. jQuery("#selectcountry_id").change(function() {
  476. document.newmember.action.value="create";
  477. document.newmember.submit();
  478. });
  479. });
  480. });
  481. </script>';
  482. print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
  483. // Name
  484. print '<tr><td><label for="lastname">'.$langs->trans("Lastname").'<span style="color: red">*</span></label></td>';
  485. print '<td colspan="3"><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("lastname", 'alpha') ?GETPOST("lastname", 'alpha') : $object->lastname).'" autofocus="autofocus"></td>';
  486. print '</tr>';
  487. // Email
  488. print '<tr><td>'.$langs->trans("Email").'<span style="color: red">*</span></td><td><input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
  489. // Company
  490. print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'<span style="color: red">*</span>';
  491. print ' </td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
  492. // Address
  493. print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
  494. print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
  495. // Zip / Town
  496. print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
  497. print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
  498. print ' / ';
  499. print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
  500. print '</td></tr>';
  501. // Country
  502. print '<tr><td>'.$langs->trans('Country');
  503. print '<span style="color:red">*</span>';
  504. print '</td><td>';
  505. $country_id = GETPOST('country_id');
  506. if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
  507. $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
  508. }
  509. if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
  510. $country_code = dol_user_country();
  511. //print $country_code;
  512. if ($country_code) {
  513. $new_country_id = getCountry($country_code, 3, $db, $langs);
  514. //print 'xxx'.$country_code.' - '.$new_country_id;
  515. if ($new_country_id) {
  516. $country_id = $new_country_id;
  517. }
  518. }
  519. }
  520. $country_code = getCountry($country_id, 2, $db, $langs);
  521. print $form->select_country($country_id, 'country_id');
  522. print '</td></tr>';
  523. // State
  524. if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
  525. print '<tr><td>'.$langs->trans('State').'</td><td>';
  526. if ($country_code) {
  527. print $formcompany->select_state(GETPOST("state_id"), $country_code);
  528. } else {
  529. print '';
  530. }
  531. print '</td></tr>';
  532. }
  533. // Type of event
  534. print '<tr><td>'.$langs->trans("Format").'<span style="color: red">*</span></td>'."\n";
  535. print '<td>'.Form::selectarray('eventtype', $arrayofconfboothtype, $eventtype, 1).'</td>';
  536. // Label
  537. print '<tr><td>'.$langs->trans("LabelOfBooth").'<span style="color: red">*</span></td>'."\n";
  538. print '</td><td><input type="text" name="label" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>'."\n";
  539. // Note
  540. print '<tr><td>'.$langs->trans("Description").'<span style="color: red">*</span></td>'."\n";
  541. print '<td><textarea name="note" id="note" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('note', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
  542. print "</table>\n";
  543. print dol_get_fiche_end();
  544. // Show all action buttons
  545. print '<div class="center">';
  546. print '<br>';
  547. print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" name="suggestbooth" id="suggestbooth" class="button">';
  548. print '</div>';
  549. print '<br><br>';
  550. print "</form>\n";
  551. print "<br>";
  552. print '</div></div>';
  553. llxFooterVierge();
  554. $db->close();