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';
518 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
519 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
521 $thirdparty->code_client = $tmpcode;
523 $readythirdparty = $thirdparty->create($user);
524 if ($readythirdparty < 0) {
526 $errmsg .= $thirdparty->error;
527 $errors = array_merge($errors, $thirdparty->errors);
529 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2',
$db, $langs);
530 $thirdparty->country =
getCountry($thirdparty->country_code,
'',
$db, $langs);
533 $confattendee->fk_soc = $thirdparty->id;
534 $confattendee->update($user);
539 if (!$error && is_object($thirdparty)) {
541 if (!empty((
float) $project->price_registration)) {
542 $outputlangs = $langs;
546 $outputlangs->loadLangs(array(
"eventorganization"));
550 $productforinvoicerow->id = 0;
554 $resultprod = $productforinvoicerow->fetch(
getDolGlobalInt(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
559 if ($resultprod < 0) {
561 $errmsg .= $productforinvoicerow->error;
562 $errors = array_merge($errors, $productforinvoicerow->errors);
565 if (empty($confattendee->fk_invoice)) {
567 $facture->socid = $thirdparty->id;
570 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
571 $facture->fk_project = $project->id;
574 if (empty($facture->cond_reglement_id)) {
575 $paymenttermstatic =
new PaymentTerm($confattendee->db);
576 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
577 if (empty($facture->cond_reglement_id)) {
579 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
580 $confattendee->errors[] = $confattendee->error;
583 $resultfacture = $facture->create($user);
584 if ($resultfacture <= 0) {
585 $confattendee->error = $facture->error;
586 $confattendee->errors = $facture->errors;
589 $confattendee->fk_invoice = $resultfacture;
590 $confattendee->update($user);
593 $facture->fetch($confattendee->fk_invoice);
606 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
607 if ($project->location) {
608 $labelforproduct .=
' - '.$project->location;
611 $date_end = $project->date_end_event;
614 if (empty($facture->lines)) {
615 $pu_ttc = (float) $project->price_registration;
617 $price_base_type =
'TTC';
619 $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);
621 $confattendee->error = $facture->error;
622 $confattendee->errors = $facture->errors;
628 if (!$error && is_object($facture)) {
637 $sourcetouse =
'organizedeventregistration';
638 $reftouse = $facture->id;
639 $redirection =
$dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
641 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse,
'2');
644 header(
"Location: ".$redirection);
654 $confattendee->setStatut(1);
657 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
658 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
662 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
664 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
666 $arraydefaultmessage =
null;
668 $labeltouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
669 if (!empty($labeltouse)) {
670 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
673 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
674 $subject = $arraydefaultmessage->topic;
675 $msg = $arraydefaultmessage->content;
681 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
687 $sendto = !empty($thirdparty->email) ? $thirdparty->email :
688 $confattendee->email;
691 $urlback = $_SERVER[
"REQUEST_URI"];
695 if (!empty($sendto)) {
696 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
697 $result = $mailfile->sendfile();
699 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
701 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
706 $redirection =
$dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
708 header(
"Location: ".$redirection);
729print
'<div align="center">';
730print
'<div id="divsubscribe">';
733print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
734print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0,
'',
'center');
736print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
739print
'<span class="eventlabel large">'.dolPrintHTML($project->title .
' '. $conference->label).
'</span><br>';
743print
'<div class="justify subscriptionformhelptext">';
745if ($project->date_start_event || $project->date_end_event) {
746 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
748if ($project->date_start_event) {
750 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
751 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
756if ($project->date_start_event && $project->date_end_event) {
759if ($project->date_end_event) {
761 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
762 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
767if ($project->date_start_event || $project->date_end_event) {
770if ($project->location) {
771 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dolPrintHTML($project->location).
'<br>';
773if ($project->note_public) {
774 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
781if ($conference->id > 0) {
797 $maxattendees = $project->max_attendees;
800if ($maxattendees && $currentnbofattendees >= $maxattendees) {
802 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
810if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
811 if (empty($maxattendees) ||
812 ($currentnbofattendees < $maxattendees &&
813 (!
getDolGlobalString(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') || (
getDolGlobalString(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') ==
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED')))
816 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
817 print
'<input type="hidden" name="token" value="' . newToken() .
'" / >';
818 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
819 print
'<input type="hidden" name="action" value="add" />';
820 print
'<input type="hidden" name="type" value="' . $type .
'" />';
821 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
822 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
823 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
824 if (
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED')) {
825 print
'<input type="hidden" name="EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED" value="' .
GETPOST(
'EVENTORGANIZATION_ALLOW_REGISTRATION_WHEN_MAX_REACHED') .
'" />';
835 print
'<script type="text/javascript">
836 jQuery(document).ready(function () {
837 jQuery(document).ready(function () {
838 jQuery("#selectcountry_id").change(function() {
839 document.newmember.action.value="create";
840 document.newmember.submit();
846 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
849 print
'<tr><td><span class="fieldrequired">';
850 print $langs->trans(
"Firstname") .
'</span></td><td>';
851 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
852 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
855 print
'<tr><td><span class="fieldrequired">';
856 print $langs->trans(
"Lastname") .
'</span></td><td>';
857 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
858 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
861 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
862 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
863 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
866 print
'<tr id="trcompany" class="trcompany"><td>';
867 if (!empty((
float) $project->price_registration)) {
868 print
'<span class="fieldrequired">';
870 print $langs->trans(
"Company");
871 if (!empty((
float) $project->price_registration)) {
875 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
876 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";
879 if ($project->price_registration) {
880 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
881 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
882 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
886 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
887 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";
890 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
891 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
893 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
897 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
898 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
899 $country_id =
GETPOST(
'country_id');
901 $country_id =
getCountry(
$conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2',
$db, $langs);
903 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
907 $new_country_id =
getCountry($country_code,
'3',
$db, $langs);
909 if ($new_country_id) {
910 $country_id = $new_country_id;
915 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
919 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
921 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
922 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
929 if ($project->price_registration) {
930 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
931 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
936 $parameters[
'tpl_context'] =
'public';
937 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
939 $notetoshow = $note_public;
940 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
942 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
944 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
954 print
'<div class="center">';
955 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
956 if (!empty($backtopage)) {
957 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
967 if ($project->status == $project::STATUS_DRAFT) {
968 print $langs->trans(
"ConferenceIsNotConfirmed");