24 if (!defined(
'NOLOGIN')) {
27 if (!defined(
'NOCSRFCHECK')) {
28 define(
"NOCSRFCHECK", 1);
30 if (!defined(
'NOIPCHECK')) {
31 define(
'NOIPCHECK',
'1');
33 if (!defined(
'NOBROWSERNOTIF')) {
34 define(
'NOBROWSERNOTIF',
'1');
36 if (!defined(
'NOIPCHECK')) {
37 define(
'NOIPCHECK',
'1');
43 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
44 if (is_numeric($entity)) {
45 define(
"DOLENTITY", $entity);
48 require
'../../main.inc.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
59 global $dolibarr_main_url_root;
65 $backtopage =
GETPOST(
'backtopage',
'alpha');
66 $action =
GETPOST(
'action',
'aZ09');
68 $eventtype =
GETPOST(
"eventtype");
78 $resultproject = $project->fetch($id);
79 if ($resultproject < 0) {
81 $errmsg .= $project->error;
85 $securekeyreceived =
GETPOST(
"securekey");
86 $securekeytocompare =
dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.
'conferenceorbooth'.$id,
'md5');
88 if ($securekeytocompare != $securekeyreceived) {
89 print $langs->trans(
'MissingOrBadSecureKey');
94 $langs->loadLangs(array(
"main",
"companies",
"install",
"other",
"eventorganization"));
97 $hookmanager->initHooks(array(
'publicnewmembercard',
'globalcard'));
101 $user->loadDefaultValues();
104 $arrayofconfboothtype = $cactioncomm->liste_array(
'',
'id',
'', 0,
"module='booth@eventorganization'");
107 if (empty($conf->eventorganization->enabled)) {
123 function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'')
125 global $user, $conf, $langs, $mysoc;
127 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
129 print
'<body id="mainbody" class="publicnewmemberform">';
132 $urllogo = DOL_URL_ROOT.
'/theme/common/login_logo.png';
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&modulepart=mycompany&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&modulepart=mycompany&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';
142 print
'<div class="center">';
146 print
'<div class="backgreypublicpayment">';
147 print
'<div class="logopublicpayment">';
148 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
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>';
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.
'">';
165 print
'<div class="divmainbodylarge">';
189 $parameters = array();
191 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
197 if (empty($reshook) && $action ==
'add') {
206 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
210 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
214 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
218 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
222 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
226 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Societe")).
"<br>\n";
230 $langs->load(
"errors");
231 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
233 if (!
GETPOST(
"country_id") && !empty(floatval($project->price_booth))) {
235 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
240 $thirdparty =
new Societe($db);
241 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe);
243 if ($resultfetchthirdparty<=0) {
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;
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);
260 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
261 foreach ($dirsociete as $dirroot) {
267 $modCodeClient =
new $module($db);
269 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
270 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
272 $thirdparty->code_client = $tmpcode;
273 $readythirdparty = $thirdparty->create($user);
274 if ($readythirdparty <0) {
276 $errmsg .= $thirdparty->error;
278 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
279 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
285 $resultcontact = $contact->fetch(
'',
'',
'', $email);
286 if ($resultcontact<=0) {
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;
299 $resultcreatecontact = $contact->create($user);
300 if ($resultcreatecontact<0) {
302 $errmsg .= $contact->error;
311 $resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
313 if ($resultcategory<=0) {
315 $errmsg .= $category->error;
317 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), CATEGORIE::TYPE_CUSTOMER,
false);
318 if ($resultsetcategory < 0) {
320 $errmsg .= $thirdparty->error;
322 $thirdparty->fournisseur = 1;
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);
329 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
330 foreach ($dirsociete as $dirroot) {
336 $modCodeFournisseur =
new $module;
337 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
338 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
340 $thirdparty->code_fournisseur = $tmpcode;
342 $res = $thirdparty->update(0, $user, 1, 1, 1);
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();
363 $resultconforbooth = $conforbooth->create($user);
364 if ($resultconforbooth<=0) {
366 $errmsg .= $conforbooth->error;
369 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
370 if ($resultaddcontact<0) {
372 $errmsg .= $conforbooth->error;
375 if (!empty(floatval($project->price_booth))) {
376 $productforinvoicerow =
new Product($db);
377 $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_BOOTH_LOCATION);
378 if ($resultprod < 0) {
380 $errmsg .= $productforinvoicerow->error;
384 $facture->socid = $thirdparty->id;
387 $facture->cond_reglement_id = $contact->cond_reglement_id;
388 $facture->fk_project = $project->id;
390 if (empty($facture->cond_reglement_id)) {
391 $paymenttermstatic =
new PaymentTerm($contact->db);
392 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
393 if (empty($facture->cond_reglement_id)) {
395 $contact->error =
'ErrorNoPaymentTermRECEPFound';
396 $contact->errors[] = $contact->error;
399 $resultfacture = $facture->create($user);
400 if ($resultfacture <= 0) {
401 $contact->error = $facture->error;
402 $contact->errors = $facture->errors;
406 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
412 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
413 $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);
415 $contact->error = $facture->error;
416 $contact->errors = $facture->errors;
437 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
438 $conforbooth->update($user);
448 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
449 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
453 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
455 $outputlangs->loadLangs(array(
"main",
"members"));
457 $arraydefaultmessage =
null;
459 $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH;
460 if (!empty($labeltouse)) {
461 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
464 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
465 $subject = $arraydefaultmessage->topic;
466 $msg = $arraydefaultmessage->content;
475 $sendto = $thirdparty->email;
476 $from = $conf->global->MAILING_EMAIL_FROM;
477 $urlback = $_SERVER[
"REQUEST_URI"];
481 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
483 $result = $mailfile->sendfile();
485 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
487 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
490 $securekeyurl =
dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.
'conferenceorbooth'.$id, 2);
491 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.$id.
'&securekey='.$securekeyurl;
492 Header(
"Location: ".$redirection);
512 print
'<div class="center">';
513 print
'<span class="large">'.$project->title.
'</span><br>';
514 print
img_picto(
'',
'calendar',
'class="pictofixedwidth"').$langs->trans(
"Date").
': ';
516 if ($project->date_end && $project->date_start != $project->date_end) {
517 print
' - '.dol_print_date($project->date_end,
'daytext');
519 print
'<br><br>'.
"\n";
526 print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0, 0,
'center');
529 print
'<div align="center">';
530 print
'<div id="divsubscribe">';
531 print
'<div class="center subscriptionformhelptext justify">';
536 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember">'.
"\n";
537 print
'<input type="hidden" name="token" value="'.newToken().
'" / >';
538 print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
539 print
'<input type="hidden" name="action" value="add" />';
540 print
'<input type="hidden" name="id" value="'.$id.
'" />';
541 print
'<input type="hidden" name="securekey" value="'.$securekeyreceived.
'" />';
545 print
'<br><span class="opacitymedium">'.$langs->trans(
"FieldsWithAreMandatory",
'*').
'</span><br>';
550 print
'<script type="text/javascript">
551 jQuery(document).ready(function () {
552 jQuery(document).ready(function () {
553 jQuery("#selectcountry_id").change(function() {
554 document.newmember.action.value="create";
555 document.newmember.submit();
561 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
564 print
'<tr><td><label for="lastname">'.$langs->trans(
"Lastname").
'<span style="color: red">*</span></label></td>';
565 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>';
568 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";
570 print
'<tr id="trcompany" class="trcompany"><td>'.$langs->trans(
"Company").
'<span style="color: red">*</span>';
571 print
' </td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
573 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
574 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";
576 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
577 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
579 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
582 print
'<tr><td>'.$langs->trans(
'Country');
583 print
'<span style="color:red">*</span>';
586 $country_id =
GETPOST(
'country_id');
587 if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
588 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
590 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
594 $new_country_id =
getCountry($country_code, 3, $db, $langs);
596 if ($new_country_id) {
597 $country_id = $new_country_id;
601 $country_code =
getCountry($country_id, 2, $db, $langs);
602 print
$form->select_country($country_id,
'country_id');
605 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
606 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
608 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
615 print
'<tr><td>'.$langs->trans(
"Format").
'<span style="color: red">*</span></td>'.
"\n";
616 print
'<td>'.Form::selectarray(
'eventtype', $arrayofconfboothtype, $eventtype, 1).
'</td>';
618 print
'<tr><td>'.$langs->trans(
"LabelOfBooth").
'<span style="color: red">*</span></td>'.
"\n";
619 print
'</td><td><input type="text" name="label" class="minwidth150" value="'.dol_escape_htmltag(
GETPOST(
'label')).
'"></td></tr>'.
"\n";
621 print
'<tr><td>'.$langs->trans(
"Description").
'<span style="color: red">*</span></td>'.
"\n";
622 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";
630 print
'<div class="center">';
632 print
'<input type="submit" value="'.$langs->trans(
"SuggestBooth").
'" name="suggestbooth" id="suggestbooth" class="button">';
640 print
'</div></div>';