235$parameters = array();
237$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
243if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
252 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
255 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
257 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
261 $langs->load(
"errors");
262 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
266 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
273 if ($type ==
'global') {
274 $filter =
"(t.fk_project:=:".((int) $id).
") AND (t.email:=:'".$db->escape($email).
"')";
276 if ($type ==
'conf') {
277 $filter =
"(t.fk_actioncomm:=:".((int) $id).
") AND (t.email:=:'".$db->escape($email).
"')";
281 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
283 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
285 $confattendee = array_shift($resultfetchconfattendee);
288 $confattendee->date_creation =
dol_now();
289 $confattendee->date_subscription =
dol_now();
290 $confattendee->email = $email;
291 $confattendee->fk_project = $project->id;
292 $confattendee->fk_actioncomm = $id;
293 $confattendee->note_public = $note_public;
294 $confattendee->firstname = $firstname;
295 $confattendee->lastname = $lastname;
298 $extrafields->fetch_name_optionals_label($confattendee->table_element);
299 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
302 $errmsg .= $confattendee->error;
307 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
312 if ($nb_post_max > 0) {
313 $sql =
"SELECT COUNT(ref) as nb_attendee";
314 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
315 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
316 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
317 $resql = $db->query($sql);
319 $num = $db->num_rows($resql);
323 $obj = $db->fetch_object($resql);
324 $nb_post_ip = $obj->nb_attendee;
329 $resultconforbooth = -1;
331 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
333 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
334 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
337 $resultconfattendee = $confattendee->create($user);
339 if ($resultconfattendee < 0) {
341 $errmsg .= $confattendee->error;
342 $errors = array_merge($errors, $confattendee->errors);
350 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
352 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
354 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
359 header(
"Location: ".$redirection);
363 $resultfetchthirdparty = 0;
365 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
368 $thirdparty =
new Societe($db);
371 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
372 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
376 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
377 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
378 if ($resultfetchthirdparty > 0) {
380 $confattendee->fk_soc = $thirdparty->id;
381 $confattendee->update($user);
382 } elseif ($resultfetchthirdparty == -2) {
383 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
387 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
388 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
389 if ($resultfetchthirdparty > 0) {
391 $confattendee->fk_soc = $thirdparty->id;
392 $confattendee->update($user);
393 } elseif ($resultfetchthirdparty == -2) {
394 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
398 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
400 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
401 if ($resultfetchthirdparty > 0) {
403 $confattendee->fk_soc = $thirdparty->id;
404 $confattendee->update($user);
405 } elseif ($resultfetchthirdparty == -2) {
406 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
409 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
411 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
412 if ($resultfetchthirdparty > 0) {
414 $confattendee->fk_soc = $thirdparty->id;
415 $confattendee->update($user);
416 } elseif ($resultfetchthirdparty == -2) {
417 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
420 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
422 $resultfetchthirdparty = $thirdparty->fetch(
'', $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
423 if ($resultfetchthirdparty > 0) {
425 $confattendee->fk_soc = $thirdparty->id;
426 $confattendee->update($user);
427 } elseif ($resultfetchthirdparty == -2) {
428 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
434 if ($resultfetchthirdparty <= 0 && !empty($email)) {
436 $resultfetchcontact = $contact->fetch(
'',
null,
'', $email);
437 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
438 $thirdparty->fetch($contact->fk_soc);
439 $confattendee->fk_soc = $thirdparty->id;
440 $confattendee->update($user);
441 $resultfetchthirdparty = 1;
445 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
447 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
448 if ($resultfetchthirdparty > 0) {
450 $confattendee->fk_soc = $thirdparty->id;
451 $confattendee->update($user);
452 } elseif ($resultfetchthirdparty == -2) {
453 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
459 if (empty((
float) $project->price_registration)) {
460 $resultfetchthirdparty = 1;
463 if ($resultfetchthirdparty < 0) {
466 $errmsg .= $thirdparty->error;
467 $errors = array_merge($errors, $thirdparty->errors);
468 } elseif ($resultfetchthirdparty == 0) {
470 if (!empty($societe)) {
471 $thirdparty->name = $societe;
473 $thirdparty->name = $genericcompanyname;
475 $thirdparty->address =
GETPOST(
"address");
476 $thirdparty->zip =
GETPOST(
"zipcode");
477 $thirdparty->town =
GETPOST(
"town");
478 $thirdparty->client = $thirdparty::PROSPECT;
479 $thirdparty->fournisseur = 0;
480 $thirdparty->country_id =
GETPOSTINT(
"country_id");
481 $thirdparty->state_id =
GETPOSTINT(
"state_id");
482 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
486 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
487 $module = substr($module, 0,
dol_strlen($module) - 4);
489 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
490 foreach ($dirsociete as $dirroot) {
496 $modCodeClient =
new $module($db);
498 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
499 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
501 $thirdparty->code_client = $tmpcode;
503 $readythirdparty = $thirdparty->create($user);
504 if ($readythirdparty < 0) {
506 $errmsg .= $thirdparty->error;
507 $errors = array_merge($errors, $thirdparty->errors);
509 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
510 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
513 $confattendee->fk_soc = $thirdparty->id;
514 $confattendee->update($user);
521 if (!empty((
float) $project->price_registration)) {
522 $outputlangs = $langs;
526 $outputlangs->loadLangs(array(
"eventorganization"));
529 $productforinvoicerow =
new Product($db);
530 $productforinvoicerow->id = 0;
534 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
538 if ($resultprod < 0) {
540 $errmsg .= $productforinvoicerow->error;
541 $errors = array_merge($errors, $productforinvoicerow->errors);
544 if (empty($confattendee->fk_invoice)) {
546 $facture->socid = $thirdparty->id;
549 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
550 $facture->fk_project = $project->id;
553 if (empty($facture->cond_reglement_id)) {
554 $paymenttermstatic =
new PaymentTerm($confattendee->db);
555 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
556 if (empty($facture->cond_reglement_id)) {
558 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
559 $confattendee->errors[] = $confattendee->error;
562 $resultfacture = $facture->create($user);
563 if ($resultfacture <= 0) {
564 $confattendee->error = $facture->error;
565 $confattendee->errors = $facture->errors;
568 $confattendee->fk_invoice = $resultfacture;
569 $confattendee->update($user);
572 $facture->fetch($confattendee->fk_invoice);
583 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
585 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
586 if ($project->location) {
587 $labelforproduct .=
' - '.$project->location;
589 $date_start = $project->date_start_event;
590 $date_end = $project->date_end_event;
593 if (empty($facture->lines)) {
594 $pu_ttc = (float) $project->price_registration;
596 $price_base_type =
'TTC';
598 $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);
600 $confattendee->error = $facture->error;
601 $confattendee->errors = $facture->errors;
616 $sourcetouse =
'organizedeventregistration';
617 $reftouse = $facture->id;
618 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
621 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse, 2);
623 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
627 header(
"Location: ".$redirection);
637 $confattendee->setStatut(1);
640 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
641 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
645 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
647 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
649 $arraydefaultmessage =
null;
652 if (!empty($labeltouse)) {
653 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
656 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
657 $subject = $arraydefaultmessage->topic;
658 $msg = $arraydefaultmessage->content;
667 $sendto = $thirdparty->email;
669 $urlback = $_SERVER[
"REQUEST_URI"];
673 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
675 $result = $mailfile->sendfile();
677 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
679 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
683 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
685 header(
"Location: ".$redirection);
700$form =
new Form($db);
706print
'<div align="center">';
707print
'<div id="divsubscribe">';
710print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
711print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0, 0,
'center');
713print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
716print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
720print
'<div class="justify subscriptionformhelptext">';
722if ($project->date_start_event || $project->date_end_event) {
723 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
725if ($project->date_start_event) {
727 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
728 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
733if ($project->date_start_event && $project->date_end_event) {
736if ($project->date_end_event) {
738 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
739 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
744if ($project->date_start_event || $project->date_end_event) {
747if ($project->location) {
748 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
750if ($project->note_public) {
751 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
758if ($conference->id > 0) {
774 $maxattendees = $project->max_attendees;
777if ($maxattendees && $currentnbofattendees >= $maxattendees) {
779 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
787if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
788 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
790 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
791 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
792 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
793 print
'<input type="hidden" name="action" value="add" />';
794 print
'<input type="hidden" name="type" value="' . $type .
'" />';
795 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
796 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
797 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
806 print
'<script type="text/javascript">
807 jQuery(document).ready(function () {
808 jQuery(document).ready(function () {
809 jQuery("#selectcountry_id").change(function() {
810 document.newmember.action.value="create";
811 document.newmember.submit();
817 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
820 print
'<tr><td><span class="fieldrequired">';
821 print $langs->trans(
"Firstname") .
'</span></td><td>';
822 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
823 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
826 print
'<tr><td><span class="fieldrequired">';
827 print $langs->trans(
"Lastname") .
'</span></td><td>';
828 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
829 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
832 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
833 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
834 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
837 print
'<tr id="trcompany" class="trcompany"><td>';
838 if (!empty((
float) $project->price_registration)) {
839 print
'<span class="fieldrequired">';
841 print $langs->trans(
"Company");
842 if (!empty((
float) $project->price_registration)) {
846 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
847 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";
850 if ($project->price_registration) {
851 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
852 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
853 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
857 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
858 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";
861 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
862 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
864 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
868 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
869 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
870 $country_id =
GETPOST(
'country_id');
872 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
874 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
878 $new_country_id =
getCountry($country_code, 3, $db, $langs);
880 if ($new_country_id) {
881 $country_id = $new_country_id;
885 $country_code =
getCountry($country_id, 2, $db, $langs);
886 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
890 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
892 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
893 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
900 if ($project->price_registration) {
901 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
902 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
907 $parameters[
'tpl_context'] =
'public';
908 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
910 $notetoshow = $note_public;
911 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
913 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
915 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
925 print
'<div class="center">';
926 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
927 if (!empty($backtopage)) {
928 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
938 if ($project->status == $project::STATUS_DRAFT) {
939 print $langs->trans(
"ConferenceIsNotConfirmed");