dolibarr  x.y.z
suggestbooth.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 
38 // For MultiCompany module.
39 // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
40 // TODO This should be useless. Because entity must be retrieve from object ref and not from url.
41 $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
42 if (is_numeric($entity)) {
43  define("DOLENTITY", $entity);
44 }
45 
46 // Load Dolibarr environment
47 require '../../main.inc.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
49 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
52 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
53 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
54 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
55 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
56 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
57 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
58 
59 global $dolibarr_main_url_root;
60 
61 // Init vars
62 $errmsg = '';
63 $num = 0;
64 $error = 0;
65 $backtopage = GETPOST('backtopage', 'alpha');
66 $action = GETPOST('action', 'aZ09');
67 
68 $eventtype = GETPOST("eventtype");
69 $email = GETPOST("email");
70 $societe = GETPOST("societe");
71 $label = GETPOST("label");
72 $note = GETPOST("note");
73 $datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
74 $dateend = dol_mktime(23, 59, 59, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
75 $id = GETPOST('id');
76 
77 $project = new Project($db);
78 $resultproject = $project->fetch($id);
79 if ($resultproject < 0) {
80  $error++;
81  $errmsg .= $project->error;
82 }
83 
84 // Security check
85 $securekeyreceived = GETPOST("securekey");
86 $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
87 
88 if ($securekeytocompare != $securekeyreceived) {
89  print $langs->trans('MissingOrBadSecureKey');
90  exit;
91 }
92 
93 // Load translation files
94 $langs->loadLangs(array("main", "companies", "install", "other", "eventorganization"));
95 
96 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
97 $hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
98 
99 $extrafields = new ExtraFields($db);
100 
101 $user->loadDefaultValues();
102 
103 $cactioncomm = new CActionComm($db);
104 $arrayofconfboothtype = $cactioncomm->liste_array('', 'id', '', 0, "module='booth@eventorganization'");
105 
106 // Security check
107 if (empty($conf->eventorganization->enabled)) {
108  httponly_accessforbidden('Module Event organization not enabled');
109 }
110 
111 
123 function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
124 {
125  global $user, $conf, $langs, $mysoc;
126 
127  top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
128 
129  print '<body id="mainbody" class="publicnewmemberform">';
130 
131  // Define urllogo
132  $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
133 
134  if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
135  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
136  } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
137  $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
138  } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
139  $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
140  }
141 
142  print '<div class="center">';
143 
144  // Output html code for logo
145  if ($urllogo) {
146  print '<div class="backgreypublicpayment">';
147  print '<div class="logopublicpayment">';
148  print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
149  print '>';
150  print '</div>';
151  if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
152  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>';
153  }
154  print '</div>';
155  }
156 
157  if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH)) {
158  print '<div class="backimagepublicsuggestbooth">';
159  print '<img id="idPROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH" src="'.$conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH.'">';
160  print '</div>';
161  }
162 
163  print '</div>';
164 
165  print '<div class="divmainbodylarge">';
166 }
167 
173 function llxFooterVierge()
174 {
175  print '</div>';
176 
177  printCommonFooter('public');
178 
179  print "</body>\n";
180  print "</html>\n";
181 }
182 
183 
184 
185 /*
186  * Actions
187  */
188 
189 $parameters = array();
190 // Note that $action and $object may have been modified by some hooks
191 $reshook = $hookmanager->executeHooks('doActions', $parameters, $project, $action);
192 if ($reshook < 0) {
193  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
194 }
195 
196 // Action called when page is submitted
197 if (empty($reshook) && $action == 'add') {
198  $error = 0;
199 
200  $urlback = '';
201 
202  $db->begin();
203 
204  if (!GETPOST("email")) {
205  $error++;
206  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
207  }
208  if (!GETPOST("label")) {
209  $error++;
210  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label"))."<br>\n";
211  }
212  if (!GETPOST("note")) {
213  $error++;
214  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Note"))."<br>\n";
215  }
216  if (!GETPOST("email")) {
217  $error++;
218  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
219  }
220  if (!GETPOST("lastname")) {
221  $error++;
222  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name"))."<br>\n";
223  }
224  if (!GETPOST("societe")) {
225  $error++;
226  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Societe"))."<br>\n";
227  }
228  if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
229  $error++;
230  $langs->load("errors");
231  $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
232  }
233  if (!GETPOST("country_id") && !empty(floatval($project->price_booth))) {
234  $error++;
235  $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country"))."<br>\n";
236  }
237 
238  if (!$error) {
239  // Getting the thirdparty or creating it
240  $thirdparty = new Societe($db);
241  $resultfetchthirdparty = $thirdparty->fetch('', $societe);
242 
243  if ($resultfetchthirdparty<=0) {
244  // Need to create a new one (not found or multiple with the same name)
245  $thirdparty->name = $societe;
246  $thirdparty->address = GETPOST("address");
247  $thirdparty->zip = GETPOST("zipcode");
248  $thirdparty->town = GETPOST("town");
249  $thirdparty->client = 2;
250  $thirdparty->fournisseur = 0;
251  $thirdparty->country_id = GETPOST("country_id", 'int');
252  $thirdparty->state_id = GETPOST("state_id", 'int');
253  $thirdparty->email = $email;
254 
255  // Load object modCodeTiers
256  $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
257  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
258  $module = substr($module, 0, dol_strlen($module) - 4);
259  }
260  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
261  foreach ($dirsociete as $dirroot) {
262  $res = dol_include_once($dirroot.$module.'.php');
263  if ($res) {
264  break;
265  }
266  }
267  $modCodeClient = new $module($db);
268 
269  if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
270  $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
271  }
272  $thirdparty->code_client = $tmpcode;
273  $readythirdparty = $thirdparty->create($user);
274  if ($readythirdparty <0) {
275  $error++;
276  $errmsg .= $thirdparty->error;
277  } else {
278  $thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs);
279  $thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs);
280  }
281  }
282  // From there we have a thirdparty, now looking for the contact
283  if (!$error) {
284  $contact = new Contact($db);
285  $resultcontact = $contact->fetch('', '', '', $email);
286  if ($resultcontact<=0) {
287  // Need to create a contact
288  $contact->socid = $thirdparty->id;
289  $contact->lastname = (string) GETPOST("lastname", 'alpha');
290  $contact->firstname = (string) GETPOST("firstname", 'alpha');
291  $contact->address = (string) GETPOST("address", 'alpha');
292  $contact->zip = (string) GETPOST("zipcode", 'alpha');
293  $contact->town = (string) GETPOST("town", 'alpha');
294  $contact->country_id = (int) GETPOST("country_id", 'int');
295  $contact->state_id = (int) GETPOST("state_id", 'int');
296  $contact->email = $email;
297  $contact->statut = 1; //Default status to Actif
298 
299  $resultcreatecontact = $contact->create($user);
300  if ($resultcreatecontact<0) {
301  $error++;
302  $errmsg .= $contact->error;
303  }
304  }
305  }
306 
307  if (!$error) {
308  // Adding supplier tag and tag from setup to thirdparty
309  $category = new Categorie($db);
310 
311  $resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
312 
313  if ($resultcategory<=0) {
314  $error++;
315  $errmsg .= $category->error;
316  } else {
317  $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER, false);
318  if ($resultsetcategory < 0) {
319  $error++;
320  $errmsg .= $thirdparty->error;
321  } else {
322  $thirdparty->fournisseur = 1;
323 
324  // Load object modCodeFournisseur
325  $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
326  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
327  $module = substr($module, 0, dol_strlen($module) - 4);
328  }
329  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
330  foreach ($dirsociete as $dirroot) {
331  $res = dol_include_once($dirroot.$module.'.php');
332  if ($res) {
333  break;
334  }
335  }
336  $modCodeFournisseur = new $module;
337  if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
338  $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
339  }
340  $thirdparty->code_fournisseur = $tmpcode;
341 
342  $res = $thirdparty->update(0, $user, 1, 1, 1);
343 
344  if ($res <= 0) {
345  $error++;
346  }
347  }
348  }
349  }
350 
351  if (!$error) {
352  // We have the contact and the thirdparty
353  $conforbooth = new ConferenceOrBooth($db);
354  $conforbooth->label = $label;
355  $conforbooth->fk_soc = $thirdparty->id;
356  $conforbooth->fk_project = $project->id;
357  $conforbooth->note = $note;
358  $conforbooth->fk_action = $eventtype;
359  $conforbooth->datep = $datestart;
360  $conforbooth->datep2 = $dateend;
361  $conforbooth->datec = dol_now();
362  $conforbooth->tms = dol_now();
363  $conforbooth->ip = getUserRemoteIP();
364 
365  $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
366  $now = dol_now();
367  $minmonthpost = dol_time_plus_duree($now, -1, "m");
368 
369  // Calculate nb of post for IP
370  $nb_post_ip = 0;
371  if ($nb_post_max > 0) { // Calculate only if there is a limit to check
372  $sql = "SELECT COUNT(ref) as nb_confs";
373  $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
374  $sql .= " WHERE ip = '".$db->escape($conforbooth->ip)."'";
375  $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
376  $resql = $db->query($sql);
377  if ($resql) {
378  $num = $db->num_rows($resql);
379  $i = 0;
380  while ($i < $num) {
381  $i++;
382  $obj = $db->fetch_object($resql);
383  $nb_post_ip = $obj->nb_confs;
384  }
385  }
386  }
387 
388  $resultconforbooth = 0;
389 
390  if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
391  $error++;
392  $errmsg .= $langs->trans("AlreadyTooMuchPostOnThisIPAdress");
393  array_push($conforbooth->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
394  setEventMessage($errmsg, 'errors');
395  } else {
396  $resultconforbooth = $conforbooth->create($user);
397  }
398  if ($resultconforbooth<=0) {
399  $error++;
400  $errmsg .= $conforbooth->error;
401  } else {
402  // Adding the contact to the project
403  $resultaddcontact = $conforbooth->add_contact($contact->id, 'RESPONSIBLE');
404  if ($resultaddcontact<0) {
405  $error++;
406  $errmsg .= $conforbooth->error;
407  } else {
408  // If this is a paying booth, we have to redirect to payment page and create an invoice
409  if (!empty(floatval($project->price_booth))) {
410  $productforinvoicerow = new Product($db);
411  $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_BOOTH_LOCATION);
412  if ($resultprod < 0) {
413  $error++;
414  $errmsg .= $productforinvoicerow->error;
415  } else {
416  $facture = new Facture($db);
417  $facture->type = Facture::TYPE_STANDARD;
418  $facture->socid = $thirdparty->id;
419  $facture->paye = 0;
420  $facture->date = dol_now();
421  $facture->cond_reglement_id = $contact->cond_reglement_id;
422  $facture->fk_project = $project->id;
423 
424  if (empty($facture->cond_reglement_id)) {
425  $paymenttermstatic = new PaymentTerm($contact->db);
426  $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
427  if (empty($facture->cond_reglement_id)) {
428  $error++;
429  $contact->error = 'ErrorNoPaymentTermRECEPFound';
430  $contact->errors[] = $contact->error;
431  }
432  }
433  $resultfacture = $facture->create($user);
434  if ($resultfacture <= 0) {
435  $contact->error = $facture->error;
436  $contact->errors = $facture->errors;
437  $error++;
438  } else {
439  $db->commit();
440  $facture->add_object_linked($conforbooth->element, $conforbooth->id);
441  }
442  }
443 
444  if (!$error) {
445  // Add line to draft invoice
446  $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
447  $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);
448  if ($result <= 0) {
449  $contact->error = $facture->error;
450  $contact->errors = $facture->errors;
451  $error++;
452  }
453  /*if (!$error) {
454  $valid = true;
455  $sourcetouse = 'boothlocation';
456  $reftouse = $facture->id;
457  $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.$sourcetouse.'&ref='.$reftouse.'&booth='.$conforbooth->id;
458  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
459  if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
460  $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
461  } else {
462  $redirection .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
463  }
464  }
465  Header("Location: ".$redirection);
466  exit;
467  }*/
468  }
469  } else {
470  // If no price has been set for the booth, we confirm it as suggested and we update
471  $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
472  $conforbooth->update($user);
473  }
474  }
475  }
476  }
477  }
478  if (!$error) {
479  $db->commit();
480 
481  // Sending mail
482  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
483  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
484  $formmail = new FormMail($db);
485  // Set output language
486  $outputlangs = new Translate('', $conf);
487  $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
488  // Load traductions files required by page
489  $outputlangs->loadLangs(array("main", "members"));
490  // Get email content from template
491  $arraydefaultmessage = null;
492 
493  $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH;
494  if (!empty($labeltouse)) {
495  $arraydefaultmessage = $formmail->getEMailTemplate($db, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
496  }
497 
498  if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
499  $subject = $arraydefaultmessage->topic;
500  $msg = $arraydefaultmessage->content;
501  }
502 
503  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
504  complete_substitutions_array($substitutionarray, $outputlangs, $object);
505 
506  $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
507  $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
508 
509  $sendto = $thirdparty->email;
510  $from = $conf->global->MAILING_EMAIL_FROM;
511  $urlback = $_SERVER["REQUEST_URI"];
512 
513  $ishtml = dol_textishtml($texttosend); // May contain urls
514 
515  $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml);
516 
517  $result = $mailfile->sendfile();
518  if ($result) {
519  dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
520  } else {
521  dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
522  }
523 
524  $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
525  $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl;
526  Header("Location: ".$redirection);
527  exit;
528  } else {
529  $db->rollback();
530  }
531 }
532 
533 
534 /*
535  * View
536  */
537 
538 $form = new Form($db);
539 $formcompany = new FormCompany($db);
540 
541 llxHeaderVierge($langs->trans("NewSuggestionOfBooth"));
542 
543 print '<br>';
544 
545 // Event summary
546 print '<div class="center">';
547 print '<span class="large">'.$project->title.'</span><br>';
548 print img_picto('', 'calendar', 'class="pictofixedwidth"').$langs->trans("Date").': ';
549 print dol_print_date($project->date_start, 'daytext');
550 if ($project->date_end && $project->date_start != $project->date_end) {
551  print ' - '.dol_print_date($project->date_end, 'daytext');
552 }
553 print '<br><br>'."\n";
554 //print $langs->trans("EvntOrgRegistrationWelcomeMessage")."\n";
555 //print $project->note_public."\n";
556 //print img_picto('', 'map-marker-alt').$langs->trans("Location").': xxxx';
557 print '</div>';
558 
559 
560 print load_fiche_titre($langs->trans("NewSuggestionOfBooth"), '', '', 0, 0, 'center');
561 
562 
563 print '<div align="center">';
564 print '<div id="divsubscribe">';
565 print '<div class="center subscriptionformhelptext justify">';
566 
567 dol_htmloutput_errors($errmsg);
568 
569 // Print form
570 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
571 print '<input type="hidden" name="token" value="'.newToken().'" / >';
572 print '<input type="hidden" name="entity" value="'.$entity.'" />';
573 print '<input type="hidden" name="action" value="add" />';
574 print '<input type="hidden" name="id" value="'.$id.'" />';
575 print '<input type="hidden" name="securekey" value="'.$securekeyreceived.'" />';
576 
577 print '<br>';
578 
579 print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
580 //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
581 
582 print dol_get_fiche_head('');
583 
584 print '<script type="text/javascript">
585 jQuery(document).ready(function () {
586  jQuery(document).ready(function () {
587  jQuery("#selectcountry_id").change(function() {
588  document.newmember.action.value="create";
589  document.newmember.submit();
590  });
591  });
592 });
593 </script>';
594 
595 print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
596 
597 // Name
598 print '<tr><td><label for="lastname">'.$langs->trans("Lastname").'<span style="color: red">*</span></label></td>';
599 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>';
600 print '</tr>';
601 // Email
602 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";
603 // Company
604 print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'<span style="color: red">*</span>';
605 print ' </td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
606 // Address
607 print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
608 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";
609 // Zip / Town
610 print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
611 print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1);
612 print ' / ';
613 print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
614 print '</td></tr>';
615 // Country
616 print '<tr><td>'.$langs->trans('Country');
617 print '<span style="color:red">*</span>';
618 
619 print '</td><td>';
620 $country_id = GETPOST('country_id');
621 if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
622  $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
623 }
624 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
625  $country_code = dol_user_country();
626  //print $country_code;
627  if ($country_code) {
628  $new_country_id = getCountry($country_code, 3, $db, $langs);
629  //print 'xxx'.$country_code.' - '.$new_country_id;
630  if ($new_country_id) {
631  $country_id = $new_country_id;
632  }
633  }
634 }
635 $country_code = getCountry($country_id, 2, $db, $langs);
636 print $form->select_country($country_id, 'country_id');
637 print '</td></tr>';
638 // State
639 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
640  print '<tr><td>'.$langs->trans('State').'</td><td>';
641  if ($country_code) {
642  print $formcompany->select_state(GETPOST("state_id"), $country_code);
643  } else {
644  print '';
645  }
646  print '</td></tr>';
647 }
648 // Type of event
649 print '<tr><td>'.$langs->trans("Format").'<span style="color: red">*</span></td>'."\n";
650 print '<td>'.Form::selectarray('eventtype', $arrayofconfboothtype, $eventtype, 1).'</td>';
651 // Label
652 print '<tr><td>'.$langs->trans("LabelOfBooth").'<span style="color: red">*</span></td>'."\n";
653 print '</td><td><input type="text" name="label" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>'."\n";
654 // Note
655 print '<tr><td>'.$langs->trans("Description").'<span style="color: red">*</span></td>'."\n";
656 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";
657 
658 print "</table>\n";
659 
660 print dol_get_fiche_end();
661 
662 
663 // Show all action buttons
664 print '<div class="center">';
665 print '<br>';
666 print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" name="suggestbooth" id="suggestbooth" class="button">';
667 print '</div>';
668 print '<br><br>';
669 
670 
671 
672 print "</form>\n";
673 print "<br>";
674 print '</div></div>';
675 
676 
678 
679 $db->close();
Class to manage different types of events.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Class for ConferenceOrBooth.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage invoices.
const TYPE_STANDARD
Standard invoice.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Class to manage payment terms records in dictionary.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_user_country()
Return country code for current user.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getUserRemoteIP()
Return the IP of remote user.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1530
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.
if(empty($conf->eventorganization->enabled)) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
Show header for new member.
llxFooterVierge()
Show footer for new member.