230$parameters = array();
232$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
238if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status==2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
247 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
250 if (!
GETPOST(
"societe") && !empty(floatval($project->price_registration))) {
252 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
256 $langs->load(
"errors");
257 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
261 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
270 if ($type ==
'global') {
271 $filter = array(
't.fk_project'=>((
int) $id),
'customsql'=>
't.email="'.$db->escape($email).
'"');
273 if ($type ==
'conf') {
274 $filter = array(
't.fk_actioncomm'=>((
int) $id),
'customsql'=>
't.email="'.$db->escape($email).
'"');
278 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
280 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
282 $confattendee = array_shift($resultfetchconfattendee);
285 $confattendee->date_creation =
dol_now();
286 $confattendee->date_subscription =
dol_now();
287 $confattendee->email = $email;
288 $confattendee->fk_project = $project->id;
289 $confattendee->fk_actioncomm = $id;
290 $confattendee->note_public = $note_public;
291 $confattendee->firstname = $firstname;
292 $confattendee->lastname = $lastname;
295 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
300 if ($nb_post_max > 0) {
301 $sql =
"SELECT COUNT(ref) as nb_attendee";
302 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
303 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
304 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
305 $resql = $db->query($sql);
307 $num = $db->num_rows($resql);
311 $obj = $db->fetch_object($resql);
312 $nb_post_ip = $obj->nb_attendee;
317 $resultconforbooth = -1;
319 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
321 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
322 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
325 $resultconfattendee = $confattendee->create($user);
327 if ($resultconfattendee < 0) {
329 $errmsg .= $confattendee->error;
330 $errors = array_merge($errors, $confattendee->errors);
338 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
339 $securekeyurl =
dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.
'conferenceorbooth'.$id,
'master');
340 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
342 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
347 Header(
"Location: ".$redirection);
351 $resultfetchthirdparty = 0;
353 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
356 $thirdparty =
new Societe($db);
359 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
360 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
362 if (empty($conf->global->EVENTORGANIZATION_DISABLE_RETREIVE_THIRDPARTY_FROM_NAME)) {
364 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
365 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
366 if ($resultfetchthirdparty > 0) {
368 $confattendee->fk_soc = $thirdparty->id;
369 $confattendee->update($user);
370 } elseif ($resultfetchthirdparty == -2) {
371 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
375 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
376 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
377 if ($resultfetchthirdparty > 0) {
379 $confattendee->fk_soc = $thirdparty->id;
380 $confattendee->update($user);
381 } elseif ($resultfetchthirdparty == -2) {
382 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
386 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
388 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
389 if ($resultfetchthirdparty > 0) {
391 $confattendee->fk_soc = $thirdparty->id;
392 $confattendee->update($user);
393 } elseif ($resultfetchthirdparty == -2) {
394 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
397 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
399 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
400 if ($resultfetchthirdparty > 0) {
402 $confattendee->fk_soc = $thirdparty->id;
403 $confattendee->update($user);
404 } elseif ($resultfetchthirdparty == -2) {
405 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
408 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
410 $resultfetchthirdparty = $thirdparty->fetch(
'', $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
411 if ($resultfetchthirdparty > 0) {
413 $confattendee->fk_soc = $thirdparty->id;
414 $confattendee->update($user);
415 } elseif ($resultfetchthirdparty == -2) {
416 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
422 if ($resultfetchthirdparty <= 0 && !empty($email)) {
424 $resultfetchcontact = $contact->fetch(
'',
null,
'', $email);
425 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
426 $thirdparty->fetch($contact->fk_soc);
427 $confattendee->fk_soc = $thirdparty->id;
428 $confattendee->update($user);
429 $resultfetchthirdparty = 1;
433 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
435 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
436 if ($resultfetchthirdparty > 0) {
438 $confattendee->fk_soc = $thirdparty->id;
439 $confattendee->update($user);
440 } elseif ($resultfetchthirdparty == -2) {
441 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
447 if (empty(floatval($project->price_registration))) {
448 $resultfetchthirdparty = 1;
451 if ($resultfetchthirdparty < 0) {
454 $errmsg .= $thirdparty->error;
455 $errors = array_merge($errors, $thirdparty->errors);
456 } elseif ($resultfetchthirdparty == 0) {
458 if (!empty($societe)) {
459 $thirdparty->name = $societe;
461 $thirdparty->name = $genericcompanyname;
463 $thirdparty->address =
GETPOST(
"address");
464 $thirdparty->zip =
GETPOST(
"zipcode");
465 $thirdparty->town =
GETPOST(
"town");
466 $thirdparty->client = $thirdparty::PROSPECT;
467 $thirdparty->fournisseur = 0;
468 $thirdparty->country_id =
GETPOST(
"country_id",
'int');
469 $thirdparty->state_id =
GETPOST(
"state_id",
'int');
470 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
473 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
474 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
475 $module = substr($module, 0,
dol_strlen($module) - 4);
477 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
478 foreach ($dirsociete as $dirroot) {
484 $modCodeClient =
new $module($db);
486 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
487 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
489 $thirdparty->code_client = $tmpcode;
490 $readythirdparty = $thirdparty->create($user);
491 if ($readythirdparty < 0) {
493 $errmsg .= $thirdparty->error;
494 $errors = array_merge($errors, $thirdparty->errors);
496 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
497 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
500 $confattendee->fk_soc = $thirdparty->id;
501 $confattendee->update($user);
508 if (!empty(floatval($project->price_registration))) {
509 $outputlangs = $langs;
514 $productforinvoicerow =
new Product($db);
515 $productforinvoicerow->id = 0;
518 if ($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION > 0) {
519 $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION);
523 if ($resultprod < 0) {
525 $errmsg .= $productforinvoicerow->error;
526 $errors = array_merge($errors, $productforinvoicerow->errors);
529 if (empty($confattendee->fk_invoice)) {
531 $facture->socid = $thirdparty->id;
534 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
535 $facture->fk_project = $project->id;
538 if (empty($facture->cond_reglement_id)) {
539 $paymenttermstatic =
new PaymentTerm($confattendee->db);
540 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
541 if (empty($facture->cond_reglement_id)) {
543 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
544 $confattendee->errors[] = $confattendee->error;
547 $resultfacture = $facture->create($user);
548 if ($resultfacture <= 0) {
549 $confattendee->error = $facture->error;
550 $confattendee->errors = $facture->errors;
553 $confattendee->fk_invoice = $resultfacture;
554 $confattendee->update($user);
557 $facture->fetch($confattendee->fk_invoice);
568 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
570 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
571 if ($project->location) {
572 $labelforproduct .=
' - '.$project->location;
574 $date_start = $project->date_start_event;
575 $date_end = $project->date_end_event;
578 if (empty($facture->lines)) {
579 $pu_ttc = floatval($project->price_registration);
581 $price_base_type =
'TTC';
583 $result = $facture->addline($labelforproduct, $pu_ht, 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0,
'', $price_base_type, $pu_ttc, 1);
585 $confattendee->error = $facture->error;
586 $confattendee->errors = $facture->errors;
601 $sourcetouse =
'organizedeventregistration';
602 $reftouse = $facture->id;
603 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode($sourcetouse).
'&ref='.urlencode($reftouse);
604 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
605 if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
606 $redirection .=
'&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $sourcetouse . $reftouse, 2);
608 $redirection .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
612 Header(
"Location: ".$redirection);
622 $confattendee->setStatut(1);
625 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
626 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
630 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
632 $outputlangs->loadLangs(array(
"main",
"members"));
634 $arraydefaultmessage =
null;
637 if (!empty($labeltouse)) {
638 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
641 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
642 $subject = $arraydefaultmessage->topic;
643 $msg = $arraydefaultmessage->content;
652 $sendto = $thirdparty->email;
653 $from = $conf->global->MAILING_EMAIL_FROM;
654 $urlback = $_SERVER[
"REQUEST_URI"];
658 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
660 $result = $mailfile->sendfile();
662 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
664 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
667 $securekeyurl =
dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.
'conferenceorbooth'.$id, 2);
668 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
670 Header(
"Location: ".$redirection);
685$form =
new Form($db);
691print
'<div align="center">';
692print
'<div id="divsubscribe">';
695print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
696print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0, 0,
'center');
698print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
701print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
705print
'<div class="justify subscriptionformhelptext">';
707if ($project->date_start_event || $project->date_end_event) {
708 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
710if ($project->date_start_event) {
712 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
713 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
718if ($project->date_start_event && $project->date_end_event) {
721if ($project->date_end_event) {
723 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
724 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
729if ($project->date_start_event || $project->date_end_event) {
732if ($project->location) {
733 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
735if ($project->note_public) {
736 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
743if ($conference->id > 0) {
759 $maxattendees = $project->max_attendees;
762if ($maxattendees && $currentnbofattendees >= $maxattendees) {
764 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
772if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
773 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
775 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
776 print
'<input type="hidden" name="token" value="' . newToken() .
'" / >';
777 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
778 print
'<input type="hidden" name="action" value="add" />';
779 print
'<input type="hidden" name="type" value="' . $type .
'" />';
780 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
781 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
782 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
791 print
'<script type="text/javascript">
792 jQuery(document).ready(function () {
793 jQuery(document).ready(function () {
794 jQuery("#selectcountry_id").change(function() {
795 document.newmember.action.value="create";
796 document.newmember.submit();
802 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
805 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"Firstname") .
'</span></td><td>';
806 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required></td></tr>' .
"\n";
809 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"Lastname") .
'</span></td><td>';
810 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
813 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
814 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
815 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
818 print
'<tr id="trcompany" class="trcompany"><td>';
819 if (!empty(floatval($project->price_registration))) {
820 print
'<span class="fieldrequired">';
822 print $langs->trans(
"Company");
823 if (!empty(floatval($project->price_registration))) {
827 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
828 print
'<input type="text" name="societe" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'societe')) .
'"'.(empty(floatval($project->price_registration)) ?
'' :
' required').
'></td></tr>' .
"\n";
831 if ($project->price_registration) {
832 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
833 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
834 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
838 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
839 print
'<textarea name="address" id="address" wrap="soft" class="centpercent" rows="' . ROWS_2 .
'">' .
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1) .
'</textarea></td></tr>' .
"\n";
842 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
843 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
845 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
849 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
850 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
851 $country_id =
GETPOST(
'country_id');
852 if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
853 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
855 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
859 $new_country_id =
getCountry($country_code, 3, $db, $langs);
861 if ($new_country_id) {
862 $country_id = $new_country_id;
866 $country_code =
getCountry($country_id, 2, $db, $langs);
867 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
870 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
871 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
873 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
874 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
881 if ($project->price_registration) {
882 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
883 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
887 $notetoshow = $note_public;
888 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
889 if (!empty($conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION)) {
890 $notetoshow = str_replace(
'\n',
"\n", $conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION);
892 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
900 print
'<div class="center">';
901 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
902 if (!empty($backtopage)) {
903 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';