191$parameters = array();
193$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
199if (empty($reshook) && $action ==
'add') {
208 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
212 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
214 if (!
GETPOST(
"country_id") && !empty((
float) $project->price_booth)) {
216 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
220 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Societe")).
"<br>\n";
224 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
228 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
232 $langs->load(
"errors");
233 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
239 $thirdparty =
new Societe($db);
240 $resultfetchthirdparty = $thirdparty->fetch(0, $societe);
242 if ($resultfetchthirdparty < 0) {
245 $errmsg .= $thirdparty->error;
246 $errors = array_merge($errors, $thirdparty->errors);
247 } elseif ($resultfetchthirdparty == 0) {
249 $genericcompanyname =
'Unknown company';
251 if (!empty($societe)) {
252 $thirdparty->name = $societe;
254 $thirdparty->name = $genericcompanyname;
256 $thirdparty->address =
GETPOST(
"address");
257 $thirdparty->zip =
GETPOST(
"zipcode");
258 $thirdparty->town =
GETPOST(
"town");
259 $thirdparty->client = $thirdparty::PROSPECT;
260 $thirdparty->fournisseur = 0;
261 $thirdparty->country_id =
GETPOSTINT(
"country_id");
262 $thirdparty->state_id =
GETPOSTINT(
"state_id");
263 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
267 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
268 $module = substr($module, 0,
dol_strlen($module) - 4);
270 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
271 foreach ($dirsociete as $dirroot) {
277 $modCodeClient =
new $module($db);
278 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
280 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
281 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
283 $thirdparty->code_client = $tmpcode;
284 $readythirdparty = $thirdparty->create($user);
285 if ($readythirdparty < 0) {
287 $errmsg .= $thirdparty->error;
288 $errors = array_merge($errors, $thirdparty->errors);
290 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
291 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
297 $resultcontact = $contact->fetch(0,
null,
'', $email);
298 if ($resultcontact <= 0) {
300 $contact->socid = $thirdparty->id;
301 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
302 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
303 $contact->address = (string)
GETPOST(
"address",
'alpha');
304 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
305 $contact->town = (string)
GETPOST(
"town",
'alpha');
306 $contact->country_id =
GETPOSTINT(
"country_id");
308 $contact->email = $email;
309 $contact->statut = 1;
311 $resultcreatecontact = $contact->create($user);
312 if ($resultcreatecontact < 0) {
314 $errmsg .= $contact->error;
323 $resultcategory = $category->fetch(
getDolGlobalString(
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'));
325 if ($resultcategory <= 0) {
327 $errmsg .= $category->error;
329 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
330 if ($resultsetcategory < 0) {
332 $errmsg .= $thirdparty->error;
334 $thirdparty->fournisseur = 1;
338 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
339 $module = substr($module, 0,
dol_strlen($module) - 4);
341 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
342 foreach ($dirsociete as $dirroot) {
348 $modCodeFournisseur =
new $module($db);
349 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
350 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
351 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
353 $thirdparty->code_fournisseur = $tmpcode;
355 $res = $thirdparty->update(0, $user, 1, 1, 1);
367 $conforbooth->label = $label;
368 $conforbooth->fk_soc = $thirdparty->id;
369 $conforbooth->fk_project = $project->id;
370 $conforbooth->note = $note;
371 $conforbooth->fk_action = $eventtype;
372 $conforbooth->datep = $datestart;
373 $conforbooth->datep2 = $dateend;
374 $conforbooth->datec =
dol_now();
378 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
384 if ($nb_post_max > 0) {
385 $sql =
"SELECT COUNT(ref) as nb_confs";
386 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
387 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
388 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
389 $resql = $db->query($sql);
391 $num = $db->num_rows($resql);
395 $obj = $db->fetch_object($resql);
396 $nb_post_ip = $obj->nb_confs;
401 $resultconforbooth = 0;
403 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
405 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
406 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
409 $resultconforbooth = $conforbooth->create($user);
411 if ($resultconforbooth <= 0) {
413 $errmsg .= $conforbooth->error;
416 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
417 if ($resultaddcontact < 0) {
419 $errmsg .= $conforbooth->error;
423 if (!empty((
float) $project->price_booth)) {
424 $productforinvoicerow =
new Product($db);
425 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_BOOTH_LOCATION'));
426 if ($resultprod < 0) {
428 $errmsg .= $productforinvoicerow->error;
432 $facture->socid = $thirdparty->id;
435 $facture->cond_reglement_id = $contact->cond_reglement_id;
436 $facture->fk_project = $project->id;
438 if (empty($facture->cond_reglement_id)) {
439 $paymenttermstatic =
new PaymentTerm($contact->db);
440 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
441 if (empty($facture->cond_reglement_id)) {
443 $contact->error =
'ErrorNoPaymentTermRECEPFound';
444 $contact->errors[] = $contact->error;
447 $resultfacture = $facture->create($user);
448 if ($resultfacture <= 0) {
449 $contact->error = $facture->error;
450 $contact->errors = $facture->errors;
454 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
458 if (!$error && is_object($facture)) {
460 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
461 $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')), (
float) $project->price_booth, 1, $vattouse, 0, 0, $productforinvoicerow->id, 0,
dol_now(),
'', 0, 0, 0,
'HT', 0, 1);
463 $contact->error = $facture->error;
464 $contact->errors = $facture->errors;
485 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
486 $conforbooth->update($user);
493 if (!$error && is_object($thirdparty)) {
497 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
498 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
502 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
504 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
506 $arraydefaultmessage =
null;
509 if (!empty($labeltouse)) {
510 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
515 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
516 $subject = $arraydefaultmessage->topic;
517 $msg = $arraydefaultmessage->content;
526 $sendto = $thirdparty->email;
528 $urlback = $_SERVER[
"REQUEST_URI"];
529 $trackid =
'proj'.$project->id;
533 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid);
535 $result = $mailfile->sendfile();
537 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
539 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
543 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.
$id.
'&securekey='.$securekeyurl;
544 header(
"Location: ".$redirection);
556$form =
new Form($db);
562print
'<div align="center">';
563print
'<div id="divsubscribe">';
568print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
569print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0,
'',
'center');
571print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
574print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
579print
'<div class="justify subscriptionformhelptext">';
581if ($project->date_start_event || $project->date_end_event) {
582 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
584if ($project->date_start_event) {
586 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
587 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
592if ($project->date_start_event && $project->date_end_event) {
595if ($project->date_end_event) {
597 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
598 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
603if ($project->date_start_event || $project->date_end_event) {
606if ($project->location) {
607 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
609if ($project->note_public) {
610 print
'<br><!-- note public --><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';