189$parameters = array();
191$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
197if (empty($reshook) && $action ==
'add') {
206 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
210 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
212 if (!
GETPOST(
"country_id") && !empty((
float) $project->price_booth)) {
214 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
218 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Societe")).
"<br>\n";
222 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
226 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
230 $langs->load(
"errors");
231 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
236 $thirdparty =
new Societe($db);
237 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe);
239 if ($resultfetchthirdparty < 0) {
242 $errmsg .= $thirdparty->error;
243 $errors = array_merge($errors, $thirdparty->errors);
244 } elseif ($resultfetchthirdparty == 0) {
246 $genericcompanyname =
'Unknown company';
248 if (!empty($societe)) {
249 $thirdparty->name = $societe;
251 $thirdparty->name = $genericcompanyname;
253 $thirdparty->address =
GETPOST(
"address");
254 $thirdparty->zip =
GETPOST(
"zipcode");
255 $thirdparty->town =
GETPOST(
"town");
256 $thirdparty->client = $thirdparty::PROSPECT;
257 $thirdparty->fournisseur = 0;
258 $thirdparty->country_id =
GETPOST(
"country_id",
'int');
259 $thirdparty->state_id =
GETPOST(
"state_id",
'int');
260 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
263 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
264 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
265 $module = substr($module, 0,
dol_strlen($module) - 4);
267 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
268 foreach ($dirsociete as $dirroot) {
274 $modCodeClient =
new $module($db);
276 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
277 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
279 $thirdparty->code_client = $tmpcode;
280 $readythirdparty = $thirdparty->create($user);
281 if ($readythirdparty <0) {
283 $errmsg .= $thirdparty->error;
284 $errors = array_merge($errors, $thirdparty->errors);
286 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
287 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
293 $resultcontact = $contact->fetch(
'',
'',
'', $email);
294 if ($resultcontact<=0) {
296 $contact->socid = $thirdparty->id;
297 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
298 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
299 $contact->address = (string)
GETPOST(
"address",
'alpha');
300 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
301 $contact->town = (string)
GETPOST(
"town",
'alpha');
302 $contact->country_id = (int)
GETPOST(
"country_id",
'int');
303 $contact->state_id = (int)
GETPOST(
"state_id",
'int');
304 $contact->email = $email;
305 $contact->statut = 1;
307 $resultcreatecontact = $contact->create($user);
308 if ($resultcreatecontact<0) {
310 $errmsg .= $contact->error;
319 $resultcategory = $category->fetch($conf->global->EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH);
321 if ($resultcategory<=0) {
323 $errmsg .= $category->error;
325 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
326 if ($resultsetcategory < 0) {
328 $errmsg .= $thirdparty->error;
330 $thirdparty->fournisseur = 1;
333 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
334 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
335 $module = substr($module, 0,
dol_strlen($module) - 4);
337 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
338 foreach ($dirsociete as $dirroot) {
344 $modCodeFournisseur =
new $module();
345 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
346 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
348 $thirdparty->code_fournisseur = $tmpcode;
350 $res = $thirdparty->update(0, $user, 1, 1, 1);
362 $conforbooth->label = $label;
363 $conforbooth->fk_soc = $thirdparty->id;
364 $conforbooth->fk_project = $project->id;
365 $conforbooth->note = $note;
366 $conforbooth->fk_action = $eventtype;
367 $conforbooth->datep = $datestart;
368 $conforbooth->datep2 = $dateend;
369 $conforbooth->datec =
dol_now();
373 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
379 if ($nb_post_max > 0) {
380 $sql =
"SELECT COUNT(ref) as nb_confs";
381 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
382 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
383 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
384 $resql = $db->query($sql);
386 $num = $db->num_rows($resql);
390 $obj = $db->fetch_object($resql);
391 $nb_post_ip = $obj->nb_confs;
396 $resultconforbooth = 0;
398 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
400 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
401 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
404 $resultconforbooth = $conforbooth->create($user);
406 if ($resultconforbooth<=0) {
408 $errmsg .= $conforbooth->error;
411 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
412 if ($resultaddcontact<0) {
414 $errmsg .= $conforbooth->error;
417 if (!empty((
float) $project->price_booth)) {
418 $productforinvoicerow =
new Product($db);
419 $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_BOOTH_LOCATION);
420 if ($resultprod < 0) {
422 $errmsg .= $productforinvoicerow->error;
426 $facture->socid = $thirdparty->id;
429 $facture->cond_reglement_id = $contact->cond_reglement_id;
430 $facture->fk_project = $project->id;
432 if (empty($facture->cond_reglement_id)) {
433 $paymenttermstatic =
new PaymentTerm($contact->db);
434 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
435 if (empty($facture->cond_reglement_id)) {
437 $contact->error =
'ErrorNoPaymentTermRECEPFound';
438 $contact->errors[] = $contact->error;
441 $resultfacture = $facture->create($user);
442 if ($resultfacture <= 0) {
443 $contact->error = $facture->error;
444 $contact->errors = $facture->errors;
448 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
454 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
455 $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,
'',
'HT', 0, 1);
457 $contact->error = $facture->error;
458 $contact->errors = $facture->errors;
479 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
480 $conforbooth->update($user);
491 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
492 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
496 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
498 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
500 $arraydefaultmessage =
null;
503 if (!empty($labeltouse)) {
504 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
507 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
508 $subject = $arraydefaultmessage->topic;
509 $msg = $arraydefaultmessage->content;
518 $sendto = $thirdparty->email;
519 $from = $conf->global->MAILING_EMAIL_FROM;
520 $urlback = $_SERVER[
"REQUEST_URI"];
521 $trackid =
'proj'.$project->id;
525 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid);
527 $result = $mailfile->sendfile();
529 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
531 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
535 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.$id.
'&securekey='.$securekeyurl;
536 Header(
"Location: ".$redirection);
548$form =
new Form($db);
554print
'<div align="center">';
555print
'<div id="divsubscribe">';
560print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
561print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0, 0,
'center');
563print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
566print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
571print
'<div class="justify subscriptionformhelptext">';
573if ($project->date_start_event || $project->date_end_event) {
574 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
576if ($project->date_start_event) {
578 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
579 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
584if ($project->date_start_event && $project->date_end_event) {
587if ($project->date_end_event) {
589 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
590 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
595if ($project->date_start_event || $project->date_end_event) {
598if ($project->location) {
599 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
601if ($project->note_public) {
602 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';