206$parameters = array();
208$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
214if (empty($reshook) && $action ==
'add') {
223 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
227 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
229 if (!
GETPOST(
"country_id") && !empty((
float) $project->price_booth)) {
231 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
235 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")).
"<br>\n";
239 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
243 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
247 $langs->load(
"errors");
248 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
254 $thirdparty =
new Societe($db);
255 $resultfetchthirdparty = $thirdparty->fetch(0, $societe);
257 if ($resultfetchthirdparty < 0) {
260 $errmsg .= $thirdparty->error;
261 $errors = array_merge($errors, $thirdparty->errors);
262 } elseif ($resultfetchthirdparty == 0) {
264 $genericcompanyname =
'Unknown company';
266 if (!empty($societe)) {
267 $thirdparty->name = $societe;
269 $thirdparty->name = $genericcompanyname;
271 $thirdparty->address =
GETPOST(
"address");
272 $thirdparty->zip =
GETPOST(
"zipcode");
273 $thirdparty->town =
GETPOST(
"town");
274 $thirdparty->client = $thirdparty::PROSPECT;
275 $thirdparty->fournisseur = 0;
276 $thirdparty->country_id =
GETPOSTINT(
"country_id");
277 $thirdparty->state_id =
GETPOSTINT(
"state_id");
278 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
282 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
283 $module = substr($module, 0,
dol_strlen($module) - 4);
285 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
286 foreach ($dirsociete as $dirroot) {
292 $modCodeClient =
new $module($db);
293 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
295 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
296 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
298 $thirdparty->code_client = $tmpcode;
299 $readythirdparty = $thirdparty->create($user);
300 if ($readythirdparty < 0) {
302 $errmsg .= $thirdparty->error;
303 $errors = array_merge($errors, $thirdparty->errors);
305 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
306 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
312 $resultcontact = $contact->fetch(0,
null,
'', $email);
313 if ($resultcontact <= 0) {
315 $contact->socid = $thirdparty->id;
316 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
317 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
318 $contact->address = (string)
GETPOST(
"address",
'alpha');
319 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
320 $contact->town = (string)
GETPOST(
"town",
'alpha');
321 $contact->country_id =
GETPOSTINT(
"country_id");
323 $contact->email = $email;
324 $contact->statut = 1;
326 $resultcreatecontact = $contact->create($user);
327 if ($resultcreatecontact < 0) {
329 $errmsg .= $contact->error;
338 $resultcategory = $category->fetch(
getDolGlobalInt(
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'));
340 if ($resultcategory <= 0) {
342 $errmsg .= $category->error;
344 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
345 if ($resultsetcategory < 0) {
347 $errmsg .= $thirdparty->error;
349 $thirdparty->fournisseur = 1;
353 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
354 $module = substr($module, 0,
dol_strlen($module) - 4);
356 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
357 foreach ($dirsociete as $dirroot) {
363 $modCodeFournisseur =
new $module($db);
364 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
365 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
366 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
368 $thirdparty->code_fournisseur = $tmpcode;
370 $res = $thirdparty->update(0, $user, 1, 1, 1);
382 $conforbooth->label = $label;
383 $conforbooth->fk_soc = $thirdparty->id;
384 $conforbooth->fk_project = $project->id;
385 $conforbooth->note = $note;
386 $conforbooth->fk_action = $eventtype;
387 $conforbooth->datep = $datestart;
388 $conforbooth->datep2 = $dateend;
389 $conforbooth->datec =
dol_now();
393 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
399 if ($nb_post_max > 0) {
400 $sql =
"SELECT COUNT(ref) as nb_confs";
401 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
402 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
403 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
404 $resql = $db->query($sql);
406 $num = $db->num_rows($resql);
410 $obj = $db->fetch_object($resql);
411 $nb_post_ip = $obj->nb_confs;
416 $resultconforbooth = 0;
418 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
420 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
421 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
424 $resultconforbooth = $conforbooth->create($user);
426 if ($resultconforbooth <= 0) {
428 $errmsg .= $conforbooth->error;
431 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
432 if ($resultaddcontact < 0) {
434 $errmsg .= $conforbooth->error;
438 if (!empty((
float) $project->price_booth)) {
439 $productforinvoicerow =
new Product($db);
440 $resultprod = $productforinvoicerow->fetch(
getDolGlobalInt(
'SERVICE_BOOTH_LOCATION'));
441 if ($resultprod < 0) {
443 $errmsg .= $productforinvoicerow->error;
447 $facture->socid = $thirdparty->id;
450 $facture->cond_reglement_id = $contact->cond_reglement_id;
451 $facture->fk_project = $project->id;
453 if (empty($facture->cond_reglement_id)) {
454 $paymenttermstatic =
new PaymentTerm($contact->db);
455 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
456 if (empty($facture->cond_reglement_id)) {
458 $contact->error =
'ErrorNoPaymentTermRECEPFound';
459 $contact->errors[] = $contact->error;
462 $resultfacture = $facture->create($user);
463 if ($resultfacture <= 0) {
464 $contact->error = $facture->error;
465 $contact->errors = $facture->errors;
469 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
473 if (!$error && is_object($facture)) {
475 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
476 $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);
478 $contact->error = $facture->error;
479 $contact->errors = $facture->errors;
500 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
501 $conforbooth->update($user);
508 if (!$error && is_object($thirdparty)) {
512 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
513 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
517 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
519 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
521 $arraydefaultmessage =
null;
523 $labeltouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH');
524 if (!empty($labeltouse)) {
525 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
530 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
531 $subject = $arraydefaultmessage->topic;
532 $msg = $arraydefaultmessage->content;
535 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
541 $sendto = $thirdparty->email;
543 $urlback = $_SERVER[
"REQUEST_URI"];
544 $trackid =
'proj'.$project->id;
548 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid);
550 $result = $mailfile->sendfile();
552 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
554 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
559 header(
"Location: ".$redirection);
571$form =
new Form($db);
577print
'<div align="center">';
578print
'<div id="divsubscribe">';
583print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
584print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0,
'',
'center');
586print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
589print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
594print
'<div class="justify subscriptionformhelptext">';
596if ($project->date_start_event || $project->date_end_event) {
597 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
599if ($project->date_start_event) {
601 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
602 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
607if ($project->date_start_event && $project->date_end_event) {
610if ($project->date_end_event) {
612 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
613 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
618if ($project->date_start_event || $project->date_end_event) {
621if ($project->location) {
622 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
624if ($project->note_public) {
625 print
'<br><!-- note public --><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';