252$parameters = array();
254$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
260if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
269 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
272 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
274 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
278 $langs->load(
"errors");
279 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
283 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
292 if ($type ==
'global') {
293 $filter =
"(t.fk_project:=:".((int)
$id).
") AND (t.email:=:'".
$db->escape($email).
"')";
295 if ($type ==
'conf') {
296 $filter =
"(t.fk_actioncomm:=:".((int)
$id).
") AND (t.email:=:'".
$db->escape($email).
"')";
300 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
302 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
304 $confattendee = array_shift($resultfetchconfattendee);
307 $confattendee->date_creation =
dol_now();
308 $confattendee->date_subscription =
dol_now();
309 $confattendee->email = $email;
310 $confattendee->fk_project = $project->id;
311 $confattendee->fk_actioncomm =
$id;
312 $confattendee->note_public = $note_public;
313 $confattendee->firstname = $firstname;
314 $confattendee->lastname = $lastname;
317 $extrafields->fetch_name_optionals_label($confattendee->table_element);
318 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
321 $errmsg .= $confattendee->error;
326 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
331 if ($nb_post_max > 0) {
332 $sql =
"SELECT COUNT(ref) as nb_attendee";
333 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
334 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
335 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
336 $resql =
$db->query($sql);
338 $num =
$db->num_rows($resql);
342 $obj =
$db->fetch_object($resql);
343 $nb_post_ip = $obj->nb_attendee;
348 $resultconfattendee = -1;
350 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
352 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
353 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
356 $resultconfattendee = $confattendee->create($user);
358 if ($resultconfattendee < 0) {
360 $errmsg .= $confattendee->error;
361 $errors = array_merge($errors, $confattendee->errors);
369 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
371 $redirection =
$dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
373 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
378 header(
"Location: ".$redirection);
382 $resultfetchthirdparty = 0;
384 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
390 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
391 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
395 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
396 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
397 if ($resultfetchthirdparty > 0) {
399 $confattendee->fk_soc = $thirdparty->id;
400 $confattendee->update($user);
401 } elseif ($resultfetchthirdparty == -2) {
402 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs",
$mysoc->email);
406 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
407 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
408 if ($resultfetchthirdparty > 0) {
410 $confattendee->fk_soc = $thirdparty->id;
411 $confattendee->update($user);
412 } elseif ($resultfetchthirdparty == -2) {
413 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs",
$mysoc->email);
417 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
419 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
420 if ($resultfetchthirdparty > 0) {
422 $confattendee->fk_soc = $thirdparty->id;
423 $confattendee->update($user);
424 } elseif ($resultfetchthirdparty == -2) {
425 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs",
$mysoc->email);
428 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
430 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
431 if ($resultfetchthirdparty > 0) {
433 $confattendee->fk_soc = $thirdparty->id;
434 $confattendee->update($user);
435 } elseif ($resultfetchthirdparty == -2) {
436 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs",
$mysoc->email);
439 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
441 $resultfetchthirdparty = $thirdparty->fetch(0, $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
442 if ($resultfetchthirdparty > 0) {
444 $confattendee->fk_soc = $thirdparty->id;
445 $confattendee->update($user);
446 } elseif ($resultfetchthirdparty == -2) {
447 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs",
$mysoc->email);
453 if ($resultfetchthirdparty <= 0 && !empty($email)) {
455 $resultfetchcontact = $contact->fetch(0,
null,
'', $email);
456 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
457 $thirdparty->fetch($contact->fk_soc);
458 $confattendee->fk_soc = $thirdparty->id;
459 $confattendee->update($user);
460 $resultfetchthirdparty = 1;
464 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
466 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
467 if ($resultfetchthirdparty > 0) {
469 $confattendee->fk_soc = $thirdparty->id;
470 $confattendee->update($user);
471 } elseif ($resultfetchthirdparty == -2) {
472 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
478 if (empty((
float) $project->price_registration)) {
479 $resultfetchthirdparty = 1;
482 if ($resultfetchthirdparty < 0) {
485 $errmsg .= $thirdparty->error;
486 $errors = array_merge($errors, $thirdparty->errors);
487 } elseif ($resultfetchthirdparty == 0) {
489 if (!empty($societe)) {
490 $thirdparty->name = $societe;
492 $thirdparty->name = $genericcompanyname;
494 $thirdparty->address =
GETPOST(
"address");
495 $thirdparty->zip =
GETPOST(
"zipcode");
496 $thirdparty->town =
GETPOST(
"town");
497 $thirdparty->client = $thirdparty::PROSPECT;
498 $thirdparty->fournisseur = 0;
499 $thirdparty->country_id =
GETPOSTINT(
"country_id");
500 $thirdparty->state_id =
GETPOSTINT(
"state_id");
501 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
505 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
506 $module = substr($module, 0,
dol_strlen($module) - 4);
508 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
509 foreach ($dirsociete as $dirroot) {
515 $modCodeClient =
new $module(
$db);
516 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
519 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
520 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
522 $thirdparty->code_client = $tmpcode;
524 $readythirdparty = $thirdparty->create($user);
525 if ($readythirdparty < 0) {
527 $errmsg .= $thirdparty->error;
528 $errors = array_merge($errors, $thirdparty->errors);
530 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2',
$db, $langs);
531 $thirdparty->country =
getCountry($thirdparty->country_code,
'',
$db, $langs);
534 $confattendee->fk_soc = $thirdparty->id;
535 $confattendee->update($user);
540 if (!$error && is_object($thirdparty)) {
542 if (!empty((
float) $project->price_registration)) {
543 $outputlangs = $langs;
547 $outputlangs->loadLangs(array(
"eventorganization"));
551 $productforinvoicerow->id = 0;
555 $resultprod = $productforinvoicerow->fetch(
getDolGlobalInt(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
560 if ($resultprod < 0) {
562 $errmsg .= $productforinvoicerow->error;
563 $errors = array_merge($errors, $productforinvoicerow->errors);
566 if (empty($confattendee->fk_invoice)) {
568 $facture->socid = $thirdparty->id;
571 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
572 $facture->fk_project = $project->id;
575 if (empty($facture->cond_reglement_id)) {
576 $paymenttermstatic =
new PaymentTerm($confattendee->db);
577 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
578 if (empty($facture->cond_reglement_id)) {
580 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
581 $confattendee->errors[] = $confattendee->error;
584 $resultfacture = $facture->create($user);
585 if ($resultfacture <= 0) {
586 $confattendee->error = $facture->error;
587 $confattendee->errors = $facture->errors;
590 $confattendee->fk_invoice = $resultfacture;
591 $confattendee->update($user);
594 $facture->fetch($confattendee->fk_invoice);
607 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
608 if ($project->location) {
609 $labelforproduct .=
' - '.$project->location;
612 $date_end = $project->date_end_event;
615 if (empty($facture->lines)) {
616 $pu_ttc = (float) $project->price_registration;
618 $price_base_type =
'TTC';
620 $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);
622 $confattendee->error = $facture->error;
623 $confattendee->errors = $facture->errors;
629 if (!$error && is_object($facture)) {
638 $sourcetouse =
'organizedeventregistration';
639 $reftouse = $facture->id;
640 $redirection =
$dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
642 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse,
'2');
645 header(
"Location: ".$redirection);
655 $confattendee->setStatut(1);
658 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
659 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
663 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
665 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
667 $arraydefaultmessage =
null;
669 $labeltouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
670 if (!empty($labeltouse)) {
671 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
674 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
675 $subject = $arraydefaultmessage->topic;
676 $msg = $arraydefaultmessage->content;
682 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
688 $sendto = !empty($thirdparty->email) ? $thirdparty->email :
689 $confattendee->email;
692 $urlback = $_SERVER[
"REQUEST_URI"];
696 if (!empty($sendto)) {
697 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
698 $result = $mailfile->sendfile();
700 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
702 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
707 $redirection =
$dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
709 header(
"Location: ".$redirection);
730print
'<div align="center">';
731print
'<div id="divsubscribe">';
734print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
735print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0,
'',
'center');
737print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
740print
'<span class="eventlabel large">'.dolPrintHTML($project->title .
' '. $conference->label).
'</span><br>';
744print
'<div class="justify subscriptionformhelptext">';
746if ($project->date_start_event || $project->date_end_event) {
747 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
749if ($project->date_start_event) {
751 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
752 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
757if ($project->date_start_event && $project->date_end_event) {
760if ($project->date_end_event) {
762 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
763 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
768if ($project->date_start_event || $project->date_end_event) {
771if ($project->location) {
772 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dolPrintHTML($project->location).
'<br>';
774if ($project->note_public) {
775 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
782if ($conference->id > 0) {
798 $maxattendees = $project->max_attendees;
801if ($maxattendees && $currentnbofattendees >= $maxattendees) {
803 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
811if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
812 if (empty($maxattendees) ||
813 ($currentnbofattendees < $maxattendees &&
814 (!
getDolGlobalString(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') || (
getDolGlobalString(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') ==
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED')))
817 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
818 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
819 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
820 print
'<input type="hidden" name="action" value="add" />';
821 print
'<input type="hidden" name="type" value="' . $type .
'" />';
822 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
823 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
824 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
825 if (
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED')) {
826 print
'<input type="hidden" name="EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED" value="' .
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') .
'" />';
836 print
'<script type="text/javascript">
837 jQuery(document).ready(function () {
838 jQuery(document).ready(function () {
839 jQuery("#selectcountry_id").change(function() {
840 document.newmember.action.value="create";
841 document.newmember.submit();
847 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
850 print
'<tr><td><span class="fieldrequired">';
851 print $langs->trans(
"Firstname") .
'</span></td><td>';
852 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
853 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
856 print
'<tr><td><span class="fieldrequired">';
857 print $langs->trans(
"Lastname") .
'</span></td><td>';
858 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
859 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
862 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
863 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
864 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
867 print
'<tr id="trcompany" class="trcompany"><td>';
868 if (!empty((
float) $project->price_registration)) {
869 print
'<span class="fieldrequired">';
871 print $langs->trans(
"Company");
872 if (!empty((
float) $project->price_registration)) {
876 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
877 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";
880 if ($project->price_registration) {
881 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
882 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
883 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
887 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
888 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";
891 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
892 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
894 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
898 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
899 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
900 $country_id =
GETPOST(
'country_id');
902 $country_id =
getCountry(
$conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2',
$db, $langs);
904 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
908 $new_country_id =
getCountry($country_code,
'3',
$db, $langs);
910 if ($new_country_id) {
911 $country_id = $new_country_id;
916 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
920 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
922 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
923 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
930 if ($project->price_registration) {
931 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
932 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
937 $parameters[
'tpl_context'] =
'public';
938 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
940 $notetoshow = $note_public;
941 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
943 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
945 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
955 print
'<div class="center">';
956 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
957 if (!empty($backtopage)) {
958 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
968 if ($project->status == $project::STATUS_DRAFT) {
969 print $langs->trans(
"ConferenceIsNotConfirmed");