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";
238 $thirdparty =
new Societe($db);
239 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe);
241 if ($resultfetchthirdparty < 0) {
244 $errmsg .= $thirdparty->error;
245 $errors = array_merge($errors, $thirdparty->errors);
246 } elseif ($resultfetchthirdparty == 0) {
248 $genericcompanyname =
'Unknown company';
250 if (!empty($societe)) {
251 $thirdparty->name = $societe;
253 $thirdparty->name = $genericcompanyname;
255 $thirdparty->address =
GETPOST(
"address");
256 $thirdparty->zip =
GETPOST(
"zipcode");
257 $thirdparty->town =
GETPOST(
"town");
258 $thirdparty->client = $thirdparty::PROSPECT;
259 $thirdparty->fournisseur = 0;
260 $thirdparty->country_id =
GETPOSTINT(
"country_id");
261 $thirdparty->state_id =
GETPOSTINT(
"state_id");
262 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
266 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
267 $module = substr($module, 0,
dol_strlen($module) - 4);
269 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
270 foreach ($dirsociete as $dirroot) {
276 $modCodeClient =
new $module($db);
278 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
279 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
281 $thirdparty->code_client = $tmpcode;
282 $readythirdparty = $thirdparty->create($user);
283 if ($readythirdparty < 0) {
285 $errmsg .= $thirdparty->error;
286 $errors = array_merge($errors, $thirdparty->errors);
288 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
289 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
295 $resultcontact = $contact->fetch(
'',
'',
'', $email);
296 if ($resultcontact <= 0) {
298 $contact->socid = $thirdparty->id;
299 $contact->lastname = (string)
GETPOST(
"lastname",
'alpha');
300 $contact->firstname = (string)
GETPOST(
"firstname",
'alpha');
301 $contact->address = (string)
GETPOST(
"address",
'alpha');
302 $contact->zip = (string)
GETPOST(
"zipcode",
'alpha');
303 $contact->town = (string)
GETPOST(
"town",
'alpha');
304 $contact->country_id =
GETPOSTINT(
"country_id");
306 $contact->email = $email;
307 $contact->statut = 1;
309 $resultcreatecontact = $contact->create($user);
310 if ($resultcreatecontact < 0) {
312 $errmsg .= $contact->error;
321 $resultcategory = $category->fetch(
getDolGlobalString(
'EVENTORGANIZATION_CATEG_THIRDPARTY_BOOTH'));
323 if ($resultcategory <= 0) {
325 $errmsg .= $category->error;
327 $resultsetcategory = $thirdparty->setCategoriesCommon(array($category->id), Categorie::TYPE_CUSTOMER,
false);
328 if ($resultsetcategory < 0) {
330 $errmsg .= $thirdparty->error;
332 $thirdparty->fournisseur = 1;
336 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
337 $module = substr($module, 0,
dol_strlen($module) - 4);
339 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
340 foreach ($dirsociete as $dirroot) {
346 $modCodeFournisseur =
new $module($db);
347 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
348 $tmpcode = $modCodeFournisseur->getNextValue($thirdparty, 1);
350 $thirdparty->code_fournisseur = $tmpcode;
352 $res = $thirdparty->update(0, $user, 1, 1, 1);
364 $conforbooth->label = $label;
365 $conforbooth->fk_soc = $thirdparty->id;
366 $conforbooth->fk_project = $project->id;
367 $conforbooth->note = $note;
368 $conforbooth->fk_action = $eventtype;
369 $conforbooth->datep = $datestart;
370 $conforbooth->datep2 = $dateend;
371 $conforbooth->datec =
dol_now();
375 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
381 if ($nb_post_max > 0) {
382 $sql =
"SELECT COUNT(ref) as nb_confs";
383 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
384 $sql .=
" WHERE ip = '".$db->escape($conforbooth->ip).
"'";
385 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
386 $resql = $db->query($sql);
388 $num = $db->num_rows($resql);
392 $obj = $db->fetch_object($resql);
393 $nb_post_ip = $obj->nb_confs;
398 $resultconforbooth = 0;
400 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
402 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
403 array_push($conforbooth->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
406 $resultconforbooth = $conforbooth->create($user);
408 if ($resultconforbooth <= 0) {
410 $errmsg .= $conforbooth->error;
413 $resultaddcontact = $conforbooth->add_contact($contact->id,
'RESPONSIBLE');
414 if ($resultaddcontact < 0) {
416 $errmsg .= $conforbooth->error;
419 if (!empty((
float) $project->price_booth)) {
420 $productforinvoicerow =
new Product($db);
421 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_BOOTH_LOCATION'));
422 if ($resultprod < 0) {
424 $errmsg .= $productforinvoicerow->error;
428 $facture->socid = $thirdparty->id;
431 $facture->cond_reglement_id = $contact->cond_reglement_id;
432 $facture->fk_project = $project->id;
434 if (empty($facture->cond_reglement_id)) {
435 $paymenttermstatic =
new PaymentTerm($contact->db);
436 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
437 if (empty($facture->cond_reglement_id)) {
439 $contact->error =
'ErrorNoPaymentTermRECEPFound';
440 $contact->errors[] = $contact->error;
443 $resultfacture = $facture->create($user);
444 if ($resultfacture <= 0) {
445 $contact->error = $facture->error;
446 $contact->errors = $facture->errors;
450 $facture->add_object_linked($conforbooth->element, $conforbooth->id);
456 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
457 $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);
459 $contact->error = $facture->error;
460 $contact->errors = $facture->errors;
481 $conforbooth->status = ConferenceOrBooth::STATUS_SUGGESTED;
482 $conforbooth->update($user);
493 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
494 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
498 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
500 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
502 $arraydefaultmessage =
null;
505 if (!empty($labeltouse)) {
506 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $labeltouse, 1,
'');
509 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
510 $subject = $arraydefaultmessage->topic;
511 $msg = $arraydefaultmessage->content;
520 $sendto = $thirdparty->email;
522 $urlback = $_SERVER[
"REQUEST_URI"];
523 $trackid =
'proj'.$project->id;
527 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid);
529 $result = $mailfile->sendfile();
531 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
533 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
537 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.
$id.
'&securekey='.$securekeyurl;
538 header(
"Location: ".$redirection);
550$form =
new Form($db);
556print
'<div align="center">';
557print
'<div id="divsubscribe">';
562print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
563print
load_fiche_titre($langs->trans(
"NewSuggestionOfBooth"),
'',
'', 0,
'',
'center');
565print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgRegistrationWelcomeMessage").
'</span>';
568print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $project->label).
'</span><br>';
573print
'<div class="justify subscriptionformhelptext">';
575if ($project->date_start_event || $project->date_end_event) {
576 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
578if ($project->date_start_event) {
580 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
581 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
586if ($project->date_start_event && $project->date_end_event) {
589if ($project->date_end_event) {
591 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
592 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
597if ($project->date_start_event || $project->date_end_event) {
600if ($project->location) {
601 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
603if ($project->note_public) {
604 print
'<br><!-- note public --><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';