202$parameters = array();
204$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
210if (empty($reshook) && $action ==
'add') {
219 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
223 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
225 if (!
GETPOST(
"country_id") && !empty((
float) $project->price_booth)) {
227 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
231 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Societe")).
"<br>\n";
235 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
239 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
243 $langs->load(
"errors");
244 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
250 $thirdparty =
new Societe($db);
251 $resultfetchthirdparty = $thirdparty->fetch(0, $societe);
253 if ($resultfetchthirdparty < 0) {
256 $errmsg .= $thirdparty->error;
257 $errors = array_merge($errors, $thirdparty->errors);
258 } elseif ($resultfetchthirdparty == 0) {
260 $genericcompanyname =
'Unknown company';
262 if (!empty($societe)) {
263 $thirdparty->name = $societe;
265 $thirdparty->name = $genericcompanyname;
267 $thirdparty->address =
GETPOST(
"address");
268 $thirdparty->zip =
GETPOST(
"zipcode");
269 $thirdparty->town =
GETPOST(
"town");
270 $thirdparty->client = $thirdparty::PROSPECT;
271 $thirdparty->fournisseur = 0;
272 $thirdparty->country_id =
GETPOSTINT(
"country_id");
273 $thirdparty->state_id =
GETPOSTINT(
"state_id");
274 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
278 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
279 $module = substr($module, 0,
dol_strlen($module) - 4);
281 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
282 foreach ($dirsociete as $dirroot) {
288 $modCodeClient =
new $module($db);
289 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
291 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
292 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
294 $thirdparty->code_client = $tmpcode;
295 $readythirdparty = $thirdparty->create($user);
296 if ($readythirdparty < 0) {
298 $errmsg .= $thirdparty->error;
299 $errors = array_merge($errors, $thirdparty->errors);
301 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
302 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
308 $resultcontact = $contact->fetch(0,
null,
'', $email);
309 if ($resultcontact <= 0) {
311 $contact->socid = $thirdparty->id;
312 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
313 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
314 $contact->address = (string)
GETPOST(
"address",
'alpha');
315 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
316 $contact->town = (string)
GETPOST(
"town",
'alpha');
317 $contact->country_id =
GETPOSTINT(
"country_id");
319 $contact->email = $email;
320 $contact->statut = 1;
322 $resultcreatecontact = $contact->create($user);
323 if ($resultcreatecontact < 0) {
325 $errmsg .= $contact->error;
334 $resultcategory = $category->fetch(
getDolGlobalString(
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'));
336 if ($resultcategory <= 0) {
338 $errmsg .= $category->error;
340 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
341 if ($resultsetcategory < 0) {
343 $errmsg .= $thirdparty->error;
345 $thirdparty->fournisseur = 1;
349 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
350 $module = substr($module, 0,
dol_strlen($module) - 4);
352 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
353 foreach ($dirsociete as $dirroot) {
359 $modCodeFournisseur =
new $module($db);
360 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
361 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
362 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
364 $thirdparty->code_fournisseur = $tmpcode;
366 $res = $thirdparty->update(0, $user, 1, 1, 1);
378 $conforbooth->label = $label;
379 $conforbooth->fk_soc = $thirdparty->id;
380 $conforbooth->fk_project = $project->id;
381 $conforbooth->note = $note;
382 $conforbooth->fk_action = $eventtype;
383 $conforbooth->datep = $datestart;
384 $conforbooth->datep2 = $dateend;
385 $conforbooth->datec =
dol_now();
389 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
395 if ($nb_post_max > 0) {
396 $sql =
"SELECT COUNT(ref) as nb_confs";
397 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
398 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
399 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
400 $resql = $db->query($sql);
402 $num = $db->num_rows($resql);
406 $obj = $db->fetch_object($resql);
407 $nb_post_ip = $obj->nb_confs;
412 $resultconforbooth = 0;
414 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
416 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
417 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
420 $resultconforbooth = $conforbooth->create($user);
422 if ($resultconforbooth <= 0) {
424 $errmsg .= $conforbooth->error;
427 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
428 if ($resultaddcontact < 0) {
430 $errmsg .= $conforbooth->error;
434 if (!empty((
float) $project->price_booth)) {
435 $productforinvoicerow =
new Product($db);
436 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_BOOTH_LOCATION'));
437 if ($resultprod < 0) {
439 $errmsg .= $productforinvoicerow->error;
443 $facture->socid = $thirdparty->id;
446 $facture->cond_reglement_id = $contact->cond_reglement_id;
447 $facture->fk_project = $project->id;
449 if (empty($facture->cond_reglement_id)) {
450 $paymenttermstatic =
new PaymentTerm($contact->db);
451 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
452 if (empty($facture->cond_reglement_id)) {
454 $contact->error =
'ErrorNoPaymentTermRECEPFound';
455 $contact->errors[] = $contact->error;
458 $resultfacture = $facture->create($user);
459 if ($resultfacture <= 0) {
460 $contact->error = $facture->error;
461 $contact->errors = $facture->errors;
465 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
469 if (!$error && is_object($facture)) {
471 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
472 $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);
474 $contact->error = $facture->error;
475 $contact->errors = $facture->errors;
496 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
497 $conforbooth->update($user);
504 if (!$error && is_object($thirdparty)) {
508 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
509 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
513 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
515 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
517 $arraydefaultmessage =
null;
520 if (!empty($labeltouse)) {
521 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
526 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
527 $subject = $arraydefaultmessage->topic;
528 $msg = $arraydefaultmessage->content;
537 $sendto = $thirdparty->email;
539 $urlback = $_SERVER[
"REQUEST_URI"];
540 $trackid =
'proj'.$project->id;
544 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid);
546 $result = $mailfile->sendfile();
548 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
550 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
554 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.
$id.
'&securekey='.$securekeyurl;
555 header(
"Location: ".$redirection);
567$form =
new Form($db);
573print
'<div align="center">';
574print
'<div id="divsubscribe">';
579print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
580print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0,
'',
'center');
582print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
585print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
590print
'<div class="justify subscriptionformhelptext">';
592if ($project->date_start_event || $project->date_end_event) {
593 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
595if ($project->date_start_event) {
597 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
598 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
603if ($project->date_start_event && $project->date_end_event) {
606if ($project->date_end_event) {
608 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
609 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
614if ($project->date_start_event || $project->date_end_event) {
617if ($project->location) {
618 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
620if ($project->note_public) {
621 print
'<br><!-- note public --><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';