236$parameters = array();
238$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
244if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
253 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
256 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
258 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
262 $langs->load(
"errors");
263 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
267 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
276 if ($type ==
'global') {
277 $filter =
"(t.fk_project:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
279 if ($type ==
'conf') {
280 $filter =
"(t.fk_actioncomm:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
284 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
286 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
288 $confattendee = array_shift($resultfetchconfattendee);
291 $confattendee->date_creation =
dol_now();
292 $confattendee->date_subscription =
dol_now();
293 $confattendee->email = $email;
294 $confattendee->fk_project = $project->id;
295 $confattendee->fk_actioncomm =
$id;
296 $confattendee->note_public = $note_public;
297 $confattendee->firstname = $firstname;
298 $confattendee->lastname = $lastname;
301 $extrafields->fetch_name_optionals_label($confattendee->table_element);
302 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
305 $errmsg .= $confattendee->error;
310 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
315 if ($nb_post_max > 0) {
316 $sql =
"SELECT COUNT(ref) as nb_attendee";
317 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
318 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
319 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
320 $resql = $db->query($sql);
322 $num = $db->num_rows($resql);
326 $obj = $db->fetch_object($resql);
327 $nb_post_ip = $obj->nb_attendee;
332 $resultconfattendee = -1;
334 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
336 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
337 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
340 $resultconfattendee = $confattendee->create($user);
342 if ($resultconfattendee < 0) {
344 $errmsg .= $confattendee->error;
345 $errors = array_merge($errors, $confattendee->errors);
353 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
355 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
357 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
362 header(
"Location: ".$redirection);
366 $resultfetchthirdparty = 0;
368 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
371 $thirdparty =
new Societe($db);
374 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
375 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
379 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
380 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
381 if ($resultfetchthirdparty > 0) {
383 $confattendee->fk_soc = $thirdparty->id;
384 $confattendee->update($user);
385 } elseif ($resultfetchthirdparty == -2) {
386 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
390 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
391 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
392 if ($resultfetchthirdparty > 0) {
394 $confattendee->fk_soc = $thirdparty->id;
395 $confattendee->update($user);
396 } elseif ($resultfetchthirdparty == -2) {
397 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
401 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
403 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
404 if ($resultfetchthirdparty > 0) {
406 $confattendee->fk_soc = $thirdparty->id;
407 $confattendee->update($user);
408 } elseif ($resultfetchthirdparty == -2) {
409 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
412 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
414 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
415 if ($resultfetchthirdparty > 0) {
417 $confattendee->fk_soc = $thirdparty->id;
418 $confattendee->update($user);
419 } elseif ($resultfetchthirdparty == -2) {
420 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
423 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
425 $resultfetchthirdparty = $thirdparty->fetch(0, $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
426 if ($resultfetchthirdparty > 0) {
428 $confattendee->fk_soc = $thirdparty->id;
429 $confattendee->update($user);
430 } elseif ($resultfetchthirdparty == -2) {
431 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
437 if ($resultfetchthirdparty <= 0 && !empty($email)) {
439 $resultfetchcontact = $contact->fetch(0,
null,
'', $email);
440 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
441 $thirdparty->fetch($contact->fk_soc);
442 $confattendee->fk_soc = $thirdparty->id;
443 $confattendee->update($user);
444 $resultfetchthirdparty = 1;
448 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
450 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
451 if ($resultfetchthirdparty > 0) {
453 $confattendee->fk_soc = $thirdparty->id;
454 $confattendee->update($user);
455 } elseif ($resultfetchthirdparty == -2) {
456 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
462 if (empty((
float) $project->price_registration)) {
463 $resultfetchthirdparty = 1;
466 if ($resultfetchthirdparty < 0) {
469 $errmsg .= $thirdparty->error;
470 $errors = array_merge($errors, $thirdparty->errors);
471 } elseif ($resultfetchthirdparty == 0) {
473 if (!empty($societe)) {
474 $thirdparty->name = $societe;
476 $thirdparty->name = $genericcompanyname;
478 $thirdparty->address =
GETPOST(
"address");
479 $thirdparty->zip =
GETPOST(
"zipcode");
480 $thirdparty->town =
GETPOST(
"town");
481 $thirdparty->client = $thirdparty::PROSPECT;
482 $thirdparty->fournisseur = 0;
483 $thirdparty->country_id =
GETPOSTINT(
"country_id");
484 $thirdparty->state_id =
GETPOSTINT(
"state_id");
485 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
489 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
490 $module = substr($module, 0,
dol_strlen($module) - 4);
492 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
493 foreach ($dirsociete as $dirroot) {
499 $modCodeClient =
new $module($db);
500 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
502 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
503 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
505 $thirdparty->code_client = $tmpcode;
507 $readythirdparty = $thirdparty->create($user);
508 if ($readythirdparty < 0) {
510 $errmsg .= $thirdparty->error;
511 $errors = array_merge($errors, $thirdparty->errors);
513 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
514 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
517 $confattendee->fk_soc = $thirdparty->id;
518 $confattendee->update($user);
523 if (!$error && is_object($thirdparty)) {
525 if (!empty((
float) $project->price_registration)) {
526 $outputlangs = $langs;
530 $outputlangs->loadLangs(array(
"eventorganization"));
533 $productforinvoicerow =
new Product($db);
534 $productforinvoicerow->id = 0;
538 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
543 if ($resultprod < 0) {
545 $errmsg .= $productforinvoicerow->error;
546 $errors = array_merge($errors, $productforinvoicerow->errors);
549 if (empty($confattendee->fk_invoice)) {
551 $facture->socid = $thirdparty->id;
554 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
555 $facture->fk_project = $project->id;
558 if (empty($facture->cond_reglement_id)) {
559 $paymenttermstatic =
new PaymentTerm($confattendee->db);
560 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
561 if (empty($facture->cond_reglement_id)) {
563 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
564 $confattendee->errors[] = $confattendee->error;
567 $resultfacture = $facture->create($user);
568 if ($resultfacture <= 0) {
569 $confattendee->error = $facture->error;
570 $confattendee->errors = $facture->errors;
573 $confattendee->fk_invoice = $resultfacture;
574 $confattendee->update($user);
577 $facture->fetch($confattendee->fk_invoice);
588 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
590 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
591 if ($project->location) {
592 $labelforproduct .=
' - '.$project->location;
594 $date_start = $project->date_start_event;
595 $date_end = $project->date_end_event;
598 if (empty($facture->lines)) {
599 $pu_ttc = (float) $project->price_registration;
601 $price_base_type =
'TTC';
603 $result = $facture->addline($labelforproduct, $pu_ht, 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, 0, $price_base_type, $pu_ttc, 1);
605 $confattendee->error = $facture->error;
606 $confattendee->errors = $facture->errors;
612 if (!$error && is_object($facture)) {
621 $sourcetouse =
'organizedeventregistration';
622 $reftouse = $facture->id;
623 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
626 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse,
'2');
628 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
632 header(
"Location: ".$redirection);
642 $confattendee->setStatut(1);
645 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
646 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
650 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
652 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
654 $arraydefaultmessage =
null;
657 if (!empty($labeltouse)) {
658 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
661 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
662 $subject = $arraydefaultmessage->topic;
663 $msg = $arraydefaultmessage->content;
675 $sendto = $thirdparty->email;
677 $urlback = $_SERVER[
"REQUEST_URI"];
681 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
683 $result = $mailfile->sendfile();
685 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
687 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
691 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
693 header(
"Location: ".$redirection);
708$form =
new Form($db);
714print
'<div align="center">';
715print
'<div id="divsubscribe">';
718print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
719print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0,
'',
'center');
721print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
724print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
728print
'<div class="justify subscriptionformhelptext">';
730if ($project->date_start_event || $project->date_end_event) {
731 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
733if ($project->date_start_event) {
735 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
736 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
741if ($project->date_start_event && $project->date_end_event) {
744if ($project->date_end_event) {
746 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
747 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
752if ($project->date_start_event || $project->date_end_event) {
755if ($project->location) {
756 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
758if ($project->note_public) {
759 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
766if ($conference->id > 0) {
782 $maxattendees = $project->max_attendees;
785if ($maxattendees && $currentnbofattendees >= $maxattendees) {
787 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
795if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
796 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
798 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
799 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
800 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
801 print
'<input type="hidden" name="action" value="add" />';
802 print
'<input type="hidden" name="type" value="' . $type .
'" />';
803 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
804 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
805 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
814 print
'<script type="text/javascript">
815 jQuery(document).ready(function () {
816 jQuery(document).ready(function () {
817 jQuery("#selectcountry_id").change(function() {
818 document.newmember.action.value="create";
819 document.newmember.submit();
825 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
828 print
'<tr><td><span class="fieldrequired">';
829 print $langs->trans(
"Firstname") .
'</span></td><td>';
830 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
831 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
834 print
'<tr><td><span class="fieldrequired">';
835 print $langs->trans(
"Lastname") .
'</span></td><td>';
836 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
837 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
840 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
841 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
842 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
845 print
'<tr id="trcompany" class="trcompany"><td>';
846 if (!empty((
float) $project->price_registration)) {
847 print
'<span class="fieldrequired">';
849 print $langs->trans(
"Company");
850 if (!empty((
float) $project->price_registration)) {
854 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
855 print
'<input type="text" name="societe" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'societe')) .
'"'.(empty((
float) $project->price_registration) ?
'' :
' required').
'></td></tr>' .
"\n";
858 if ($project->price_registration) {
859 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
860 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
861 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
865 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
866 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";
869 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
870 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
872 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
876 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
877 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
878 $country_id =
GETPOST(
'country_id');
880 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
882 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
886 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
888 if ($new_country_id) {
889 $country_id = $new_country_id;
893 $country_code =
getCountry($country_id,
'2', $db, $langs);
894 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
898 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
900 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
901 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
908 if ($project->price_registration) {
909 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
910 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
915 $parameters[
'tpl_context'] =
'public';
916 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
918 $notetoshow = $note_public;
919 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
921 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
923 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
933 print
'<div class="center">';
934 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
935 if (!empty($backtopage)) {
936 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
946 if ($project->status == $project::STATUS_DRAFT) {
947 print $langs->trans(
"ConferenceIsNotConfirmed");