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";
274 if ($type ==
'global') {
275 $filter =
"(t.fk_project:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
277 if ($type ==
'conf') {
278 $filter =
"(t.fk_actioncomm:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
282 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
284 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
286 $confattendee = array_shift($resultfetchconfattendee);
289 $confattendee->date_creation =
dol_now();
290 $confattendee->date_subscription =
dol_now();
291 $confattendee->email = $email;
292 $confattendee->fk_project = $project->id;
293 $confattendee->fk_actioncomm =
$id;
294 $confattendee->note_public = $note_public;
295 $confattendee->firstname = $firstname;
296 $confattendee->lastname = $lastname;
299 $extrafields->fetch_name_optionals_label($confattendee->table_element);
300 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
303 $errmsg .= $confattendee->error;
308 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
313 if ($nb_post_max > 0) {
314 $sql =
"SELECT COUNT(ref) as nb_attendee";
315 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
316 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
317 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
318 $resql = $db->query($sql);
320 $num = $db->num_rows($resql);
324 $obj = $db->fetch_object($resql);
325 $nb_post_ip = $obj->nb_attendee;
330 $resultconforbooth = -1;
332 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
334 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
335 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
338 $resultconfattendee = $confattendee->create($user);
340 if ($resultconfattendee < 0) {
342 $errmsg .= $confattendee->error;
343 $errors = array_merge($errors, $confattendee->errors);
351 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
353 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
355 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
360 header(
"Location: ".$redirection);
364 $resultfetchthirdparty = 0;
366 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
369 $thirdparty =
new Societe($db);
372 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
373 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
377 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
378 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
379 if ($resultfetchthirdparty > 0) {
381 $confattendee->fk_soc = $thirdparty->id;
382 $confattendee->update($user);
383 } elseif ($resultfetchthirdparty == -2) {
384 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
388 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
389 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
390 if ($resultfetchthirdparty > 0) {
392 $confattendee->fk_soc = $thirdparty->id;
393 $confattendee->update($user);
394 } elseif ($resultfetchthirdparty == -2) {
395 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
399 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
401 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
402 if ($resultfetchthirdparty > 0) {
404 $confattendee->fk_soc = $thirdparty->id;
405 $confattendee->update($user);
406 } elseif ($resultfetchthirdparty == -2) {
407 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
410 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
412 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
413 if ($resultfetchthirdparty > 0) {
415 $confattendee->fk_soc = $thirdparty->id;
416 $confattendee->update($user);
417 } elseif ($resultfetchthirdparty == -2) {
418 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
421 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
423 $resultfetchthirdparty = $thirdparty->fetch(
'', $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
424 if ($resultfetchthirdparty > 0) {
426 $confattendee->fk_soc = $thirdparty->id;
427 $confattendee->update($user);
428 } elseif ($resultfetchthirdparty == -2) {
429 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
435 if ($resultfetchthirdparty <= 0 && !empty($email)) {
437 $resultfetchcontact = $contact->fetch(
'',
null,
'', $email);
438 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
439 $thirdparty->fetch($contact->fk_soc);
440 $confattendee->fk_soc = $thirdparty->id;
441 $confattendee->update($user);
442 $resultfetchthirdparty = 1;
446 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
448 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
449 if ($resultfetchthirdparty > 0) {
451 $confattendee->fk_soc = $thirdparty->id;
452 $confattendee->update($user);
453 } elseif ($resultfetchthirdparty == -2) {
454 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
460 if (empty((
float) $project->price_registration)) {
461 $resultfetchthirdparty = 1;
464 if ($resultfetchthirdparty < 0) {
467 $errmsg .= $thirdparty->error;
468 $errors = array_merge($errors, $thirdparty->errors);
469 } elseif ($resultfetchthirdparty == 0) {
471 if (!empty($societe)) {
472 $thirdparty->name = $societe;
474 $thirdparty->name = $genericcompanyname;
476 $thirdparty->address =
GETPOST(
"address");
477 $thirdparty->zip =
GETPOST(
"zipcode");
478 $thirdparty->town =
GETPOST(
"town");
479 $thirdparty->client = $thirdparty::PROSPECT;
480 $thirdparty->fournisseur = 0;
481 $thirdparty->country_id =
GETPOSTINT(
"country_id");
482 $thirdparty->state_id =
GETPOSTINT(
"state_id");
483 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
487 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
488 $module = substr($module, 0,
dol_strlen($module) - 4);
490 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
491 foreach ($dirsociete as $dirroot) {
497 $modCodeClient =
new $module($db);
499 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
500 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
502 $thirdparty->code_client = $tmpcode;
504 $readythirdparty = $thirdparty->create($user);
505 if ($readythirdparty < 0) {
507 $errmsg .= $thirdparty->error;
508 $errors = array_merge($errors, $thirdparty->errors);
510 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
511 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
514 $confattendee->fk_soc = $thirdparty->id;
515 $confattendee->update($user);
522 if (!empty((
float) $project->price_registration)) {
523 $outputlangs = $langs;
527 $outputlangs->loadLangs(array(
"eventorganization"));
530 $productforinvoicerow =
new Product($db);
531 $productforinvoicerow->id = 0;
535 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
539 if ($resultprod < 0) {
541 $errmsg .= $productforinvoicerow->error;
542 $errors = array_merge($errors, $productforinvoicerow->errors);
545 if (empty($confattendee->fk_invoice)) {
547 $facture->socid = $thirdparty->id;
550 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
551 $facture->fk_project = $project->id;
554 if (empty($facture->cond_reglement_id)) {
555 $paymenttermstatic =
new PaymentTerm($confattendee->db);
556 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
557 if (empty($facture->cond_reglement_id)) {
559 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
560 $confattendee->errors[] = $confattendee->error;
563 $resultfacture = $facture->create($user);
564 if ($resultfacture <= 0) {
565 $confattendee->error = $facture->error;
566 $confattendee->errors = $facture->errors;
569 $confattendee->fk_invoice = $resultfacture;
570 $confattendee->update($user);
573 $facture->fetch($confattendee->fk_invoice);
584 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
586 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
587 if ($project->location) {
588 $labelforproduct .=
' - '.$project->location;
590 $date_start = $project->date_start_event;
591 $date_end = $project->date_end_event;
594 if (empty($facture->lines)) {
595 $pu_ttc = (float) $project->price_registration;
597 $price_base_type =
'TTC';
599 $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);
601 $confattendee->error = $facture->error;
602 $confattendee->errors = $facture->errors;
617 $sourcetouse =
'organizedeventregistration';
618 $reftouse = $facture->id;
619 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
622 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse,
'2');
624 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
628 header(
"Location: ".$redirection);
638 $confattendee->setStatut(1);
641 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
642 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
646 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
648 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
650 $arraydefaultmessage =
null;
653 if (!empty($labeltouse)) {
654 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
657 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
658 $subject = $arraydefaultmessage->topic;
659 $msg = $arraydefaultmessage->content;
668 $sendto = $thirdparty->email;
670 $urlback = $_SERVER[
"REQUEST_URI"];
674 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
676 $result = $mailfile->sendfile();
678 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
680 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
684 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
686 header(
"Location: ".$redirection);
701$form =
new Form($db);
707print
'<div align="center">';
708print
'<div id="divsubscribe">';
711print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
712print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0,
'',
'center');
714print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
717print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
721print
'<div class="justify subscriptionformhelptext">';
723if ($project->date_start_event || $project->date_end_event) {
724 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
726if ($project->date_start_event) {
728 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
729 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
734if ($project->date_start_event && $project->date_end_event) {
737if ($project->date_end_event) {
739 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
740 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
745if ($project->date_start_event || $project->date_end_event) {
748if ($project->location) {
749 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
751if ($project->note_public) {
752 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
759if ($conference->id > 0) {
775 $maxattendees = $project->max_attendees;
778if ($maxattendees && $currentnbofattendees >= $maxattendees) {
780 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
788if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
789 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
791 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
792 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
793 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
794 print
'<input type="hidden" name="action" value="add" />';
795 print
'<input type="hidden" name="type" value="' . $type .
'" />';
796 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
797 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
798 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
807 print
'<script type="text/javascript">
808 jQuery(document).ready(function () {
809 jQuery(document).ready(function () {
810 jQuery("#selectcountry_id").change(function() {
811 document.newmember.action.value="create";
812 document.newmember.submit();
818 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
821 print
'<tr><td><span class="fieldrequired">';
822 print $langs->trans(
"Firstname") .
'</span></td><td>';
823 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
824 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
827 print
'<tr><td><span class="fieldrequired">';
828 print $langs->trans(
"Lastname") .
'</span></td><td>';
829 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
830 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
833 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
834 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
835 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
838 print
'<tr id="trcompany" class="trcompany"><td>';
839 if (!empty((
float) $project->price_registration)) {
840 print
'<span class="fieldrequired">';
842 print $langs->trans(
"Company");
843 if (!empty((
float) $project->price_registration)) {
847 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
848 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";
851 if ($project->price_registration) {
852 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
853 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
854 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
858 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
859 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";
862 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
863 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
865 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
869 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
870 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
871 $country_id =
GETPOST(
'country_id');
873 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
875 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
879 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
881 if ($new_country_id) {
882 $country_id = $new_country_id;
886 $country_code =
getCountry($country_id,
'2', $db, $langs);
887 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
891 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
893 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
894 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
901 if ($project->price_registration) {
902 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
903 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
908 $parameters[
'tpl_context'] =
'public';
909 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
911 $notetoshow = $note_public;
912 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
914 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
916 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
926 print
'<div class="center">';
927 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
928 if (!empty($backtopage)) {
929 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
939 if ($project->status == $project::STATUS_DRAFT) {
940 print $langs->trans(
"ConferenceIsNotConfirmed");