190$parameters = array();
192$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $project, $action);
198if (empty($reshook) && $action ==
'add') {
207 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"<br>\n";
211 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
213 if (!
GETPOST(
"country_id") && !empty((
float) $project->price_booth)) {
215 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
219 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Societe")).
"<br>\n";
223 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")).
"<br>\n";
227 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Note")).
"<br>\n";
231 $langs->load(
"errors");
232 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
237 $thirdparty =
new Societe($db);
238 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe);
240 if ($resultfetchthirdparty < 0) {
243 $errmsg .= $thirdparty->error;
244 $errors = array_merge($errors, $thirdparty->errors);
245 } elseif ($resultfetchthirdparty == 0) {
247 $genericcompanyname =
'Unknown company';
249 if (!empty($societe)) {
250 $thirdparty->name = $societe;
252 $thirdparty->name = $genericcompanyname;
254 $thirdparty->address =
GETPOST(
"address");
255 $thirdparty->zip =
GETPOST(
"zipcode");
256 $thirdparty->town =
GETPOST(
"town");
257 $thirdparty->client = $thirdparty::PROSPECT;
258 $thirdparty->fournisseur = 0;
259 $thirdparty->country_id =
GETPOSTINT(
"country_id");
260 $thirdparty->state_id =
GETPOSTINT(
"state_id");
261 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
265 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
266 $module = substr($module, 0,
dol_strlen($module) - 4);
268 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
269 foreach ($dirsociete as $dirroot) {
275 $modCodeClient =
new $module($db);
277 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
278 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
280 $thirdparty->code_client = $tmpcode;
281 $readythirdparty = $thirdparty->create($user);
282 if ($readythirdparty < 0) {
284 $errmsg .= $thirdparty->error;
285 $errors = array_merge($errors, $thirdparty->errors);
287 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
288 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
294 $resultcontact = $contact->fetch(
'',
'',
'', $email);
295 if ($resultcontact <= 0) {
297 $contact->socid = $thirdparty->id;
298 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
299 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
300 $contact->address = (string)
GETPOST(
"address",
'alpha');
301 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
302 $contact->town = (string)
GETPOST(
"town",
'alpha');
303 $contact->country_id =
GETPOSTINT(
"country_id");
305 $contact->email = $email;
306 $contact->statut = 1;
308 $resultcreatecontact = $contact->create($user);
309 if ($resultcreatecontact < 0) {
311 $errmsg .= $contact->error;
320 $resultcategory = $category->fetch(
getDolGlobalString(
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'));
322 if ($resultcategory <= 0) {
324 $errmsg .= $category->error;
326 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
327 if ($resultsetcategory < 0) {
329 $errmsg .= $thirdparty->error;
331 $thirdparty->fournisseur = 1;
335 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
336 $module = substr($module, 0,
dol_strlen($module) - 4);
338 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
339 foreach ($dirsociete as $dirroot) {
345 $modCodeFournisseur =
new $module($db);
346 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
347 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
349 $thirdparty->code_fournisseur = $tmpcode;
351 $res = $thirdparty->update(0, $user, 1, 1, 1);
363 $conforbooth->label = $label;
364 $conforbooth->fk_soc = $thirdparty->id;
365 $conforbooth->fk_project = $project->id;
366 $conforbooth->note = $note;
367 $conforbooth->fk_action = $eventtype;
368 $conforbooth->datep = $datestart;
369 $conforbooth->datep2 = $dateend;
370 $conforbooth->datec =
dol_now();
374 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
380 if ($nb_post_max > 0) {
381 $sql =
"SELECT COUNT(ref) as nb_confs";
382 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
383 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
384 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
385 $resql = $db->query($sql);
387 $num = $db->num_rows($resql);
391 $obj = $db->fetch_object($resql);
392 $nb_post_ip = $obj->nb_confs;
397 $resultconforbooth = 0;
399 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
401 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
402 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
405 $resultconforbooth = $conforbooth->create($user);
407 if ($resultconforbooth <= 0) {
409 $errmsg .= $conforbooth->error;
412 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
413 if ($resultaddcontact < 0) {
415 $errmsg .= $conforbooth->error;
418 if (!empty((
float) $project->price_booth)) {
419 $productforinvoicerow =
new Product($db);
420 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_BOOTH_LOCATION'));
421 if ($resultprod < 0) {
423 $errmsg .= $productforinvoicerow->error;
427 $facture->socid = $thirdparty->id;
430 $facture->cond_reglement_id = $contact->cond_reglement_id;
431 $facture->fk_project = $project->id;
433 if (empty($facture->cond_reglement_id)) {
434 $paymenttermstatic =
new PaymentTerm($contact->db);
435 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
436 if (empty($facture->cond_reglement_id)) {
438 $contact->error =
'ErrorNoPaymentTermRECEPFound';
439 $contact->errors[] = $contact->error;
442 $resultfacture = $facture->create($user);
443 if ($resultfacture <= 0) {
444 $contact->error = $facture->error;
445 $contact->errors = $facture->errors;
449 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
455 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
456 $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);
458 $contact->error = $facture->error;
459 $contact->errors = $facture->errors;
480 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
481 $conforbooth->update($user);
492 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
493 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
497 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
499 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
501 $arraydefaultmessage =
null;
504 if (!empty($labeltouse)) {
505 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
508 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
509 $subject = $arraydefaultmessage->topic;
510 $msg = $arraydefaultmessage->content;
519 $sendto = $thirdparty->email;
521 $urlback = $_SERVER[
"REQUEST_URI"];
522 $trackid =
'proj'.$project->id;
526 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid);
528 $result = $mailfile->sendfile();
530 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
532 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
536 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.$id.
'&securekey='.$securekeyurl;
537 header(
"Location: ".$redirection);
549$form =
new Form($db);
555print
'<div align="center">';
556print
'<div id="divsubscribe">';
561print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
562print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0, 0,
'center');
564print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
567print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
572print
'<div class="justify subscriptionformhelptext">';
574if ($project->date_start_event || $project->date_end_event) {
575 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
577if ($project->date_start_event) {
579 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
580 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
585if ($project->date_start_event && $project->date_end_event) {
588if ($project->date_end_event) {
590 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
591 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
596if ($project->date_start_event || $project->date_end_event) {
599if ($project->location) {
600 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
602if ($project->note_public) {
603 print
'<br><!-- note public --><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';