230$parameters = array();
232$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
238if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status==2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
247 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
250 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
252 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
256 $langs->load(
"errors");
257 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
261 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
270 if ($type ==
'global') {
271 $filter = array(
't.fk_project'=>((
int) $id),
'customsql'=>
't.email="'.$db->escape($email).
'"');
273 if ($type ==
'conf') {
274 $filter = array(
't.fk_actioncomm'=>((
int) $id),
'customsql'=>
't.email="'.$db->escape($email).
'"');
278 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
280 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
282 $confattendee = array_shift($resultfetchconfattendee);
285 $confattendee->date_creation =
dol_now();
286 $confattendee->date_subscription =
dol_now();
287 $confattendee->email = $email;
288 $confattendee->fk_project = $project->id;
289 $confattendee->fk_actioncomm = $id;
290 $confattendee->note_public = $note_public;
291 $confattendee->firstname = $firstname;
292 $confattendee->lastname = $lastname;
295 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
300 if ($nb_post_max > 0) {
301 $sql =
"SELECT COUNT(ref) as nb_attendee";
302 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
303 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
304 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
305 $resql = $db->query($sql);
307 $num = $db->num_rows($resql);
311 $obj = $db->fetch_object($resql);
312 $nb_post_ip = $obj->nb_attendee;
317 $resultconforbooth = -1;
319 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
321 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
322 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
325 $resultconfattendee = $confattendee->create($user);
327 if ($resultconfattendee < 0) {
329 $errmsg .= $confattendee->error;
330 $errors = array_merge($errors, $confattendee->errors);
338 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
340 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
342 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
347 Header(
"Location: ".$redirection);
351 $resultfetchthirdparty = 0;
353 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
356 $thirdparty =
new Societe($db);
359 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
360 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
364 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
365 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
366 if ($resultfetchthirdparty > 0) {
368 $confattendee->fk_soc = $thirdparty->id;
369 $confattendee->update($user);
370 } elseif ($resultfetchthirdparty == -2) {
371 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
375 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
376 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
377 if ($resultfetchthirdparty > 0) {
379 $confattendee->fk_soc = $thirdparty->id;
380 $confattendee->update($user);
381 } elseif ($resultfetchthirdparty == -2) {
382 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
386 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
388 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
389 if ($resultfetchthirdparty > 0) {
391 $confattendee->fk_soc = $thirdparty->id;
392 $confattendee->update($user);
393 } elseif ($resultfetchthirdparty == -2) {
394 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
397 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
399 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
400 if ($resultfetchthirdparty > 0) {
402 $confattendee->fk_soc = $thirdparty->id;
403 $confattendee->update($user);
404 } elseif ($resultfetchthirdparty == -2) {
405 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
408 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
410 $resultfetchthirdparty = $thirdparty->fetch(
'', $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
411 if ($resultfetchthirdparty > 0) {
413 $confattendee->fk_soc = $thirdparty->id;
414 $confattendee->update($user);
415 } elseif ($resultfetchthirdparty == -2) {
416 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
422 if ($resultfetchthirdparty <= 0 && !empty($email)) {
424 $resultfetchcontact = $contact->fetch(
'',
null,
'', $email);
425 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
426 $thirdparty->fetch($contact->fk_soc);
427 $confattendee->fk_soc = $thirdparty->id;
428 $confattendee->update($user);
429 $resultfetchthirdparty = 1;
433 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
435 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
436 if ($resultfetchthirdparty > 0) {
438 $confattendee->fk_soc = $thirdparty->id;
439 $confattendee->update($user);
440 } elseif ($resultfetchthirdparty == -2) {
441 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
447 if (empty((
float) $project->price_registration)) {
448 $resultfetchthirdparty = 1;
451 if ($resultfetchthirdparty < 0) {
454 $errmsg .= $thirdparty->error;
455 $errors = array_merge($errors, $thirdparty->errors);
456 } elseif ($resultfetchthirdparty == 0) {
458 if (!empty($societe)) {
459 $thirdparty->name = $societe;
461 $thirdparty->name = $genericcompanyname;
463 $thirdparty->address =
GETPOST(
"address");
464 $thirdparty->zip =
GETPOST(
"zipcode");
465 $thirdparty->town =
GETPOST(
"town");
466 $thirdparty->client = $thirdparty::PROSPECT;
467 $thirdparty->fournisseur = 0;
468 $thirdparty->country_id =
GETPOST(
"country_id",
'int');
469 $thirdparty->state_id =
GETPOST(
"state_id",
'int');
470 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
473 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
474 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
475 $module = substr($module, 0,
dol_strlen($module) - 4);
477 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
478 foreach ($dirsociete as $dirroot) {
484 $modCodeClient =
new $module($db);
486 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
487 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
489 $thirdparty->code_client = $tmpcode;
490 $readythirdparty = $thirdparty->create($user);
491 if ($readythirdparty < 0) {
493 $errmsg .= $thirdparty->error;
494 $errors = array_merge($errors, $thirdparty->errors);
496 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
497 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
500 $confattendee->fk_soc = $thirdparty->id;
501 $confattendee->update($user);
508 if (!empty((
float) $project->price_registration)) {
509 $outputlangs = $langs;
513 $outputlangs->loadLangs(array(
"eventorganization"));
516 $productforinvoicerow =
new Product($db);
517 $productforinvoicerow->id = 0;
521 $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION);
525 if ($resultprod < 0) {
527 $errmsg .= $productforinvoicerow->error;
528 $errors = array_merge($errors, $productforinvoicerow->errors);
531 if (empty($confattendee->fk_invoice)) {
533 $facture->socid = $thirdparty->id;
536 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
537 $facture->fk_project = $project->id;
540 if (empty($facture->cond_reglement_id)) {
541 $paymenttermstatic =
new PaymentTerm($confattendee->db);
542 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
543 if (empty($facture->cond_reglement_id)) {
545 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
546 $confattendee->errors[] = $confattendee->error;
549 $resultfacture = $facture->create($user);
550 if ($resultfacture <= 0) {
551 $confattendee->error = $facture->error;
552 $confattendee->errors = $facture->errors;
555 $confattendee->fk_invoice = $resultfacture;
556 $confattendee->update($user);
559 $facture->fetch($confattendee->fk_invoice);
570 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
572 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
573 if ($project->location) {
574 $labelforproduct .=
' - '.$project->location;
576 $date_start = $project->date_start_event;
577 $date_end = $project->date_end_event;
580 if (empty($facture->lines)) {
581 $pu_ttc = (float) $project->price_registration;
583 $price_base_type =
'TTC';
585 $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);
587 $confattendee->error = $facture->error;
588 $confattendee->errors = $facture->errors;
603 $sourcetouse =
'organizedeventregistration';
604 $reftouse = $facture->id;
605 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode($sourcetouse).
'&ref='.urlencode($reftouse);
608 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse, 2);
610 $redirection .=
'&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
614 Header(
"Location: ".$redirection);
624 $confattendee->setStatut(1);
627 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
628 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
632 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
634 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
636 $arraydefaultmessage =
null;
639 if (!empty($labeltouse)) {
640 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
643 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
644 $subject = $arraydefaultmessage->topic;
645 $msg = $arraydefaultmessage->content;
654 $sendto = $thirdparty->email;
655 $from = $conf->global->MAILING_EMAIL_FROM;
656 $urlback = $_SERVER[
"REQUEST_URI"];
660 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
662 $result = $mailfile->sendfile();
664 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
666 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
670 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
672 Header(
"Location: ".$redirection);
687$form =
new Form($db);
693print
'<div align="center">';
694print
'<div id="divsubscribe">';
697print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
698print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0, 0,
'center');
700print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
703print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
707print
'<div class="justify subscriptionformhelptext">';
709if ($project->date_start_event || $project->date_end_event) {
710 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
712if ($project->date_start_event) {
714 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
715 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
720if ($project->date_start_event && $project->date_end_event) {
723if ($project->date_end_event) {
725 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
726 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
731if ($project->date_start_event || $project->date_end_event) {
734if ($project->location) {
735 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
737if ($project->note_public) {
738 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
745if ($conference->id > 0) {
761 $maxattendees = $project->max_attendees;
764if ($maxattendees && $currentnbofattendees >= $maxattendees) {
766 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
774if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
775 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
777 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
778 print
'<input type="hidden" name="token" value="' . newToken() .
'" / >';
779 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
780 print
'<input type="hidden" name="action" value="add" />';
781 print
'<input type="hidden" name="type" value="' . $type .
'" />';
782 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
783 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
784 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
793 print
'<script type="text/javascript">
794 jQuery(document).ready(function () {
795 jQuery(document).ready(function () {
796 jQuery("#selectcountry_id").change(function() {
797 document.newmember.action.value="create";
798 document.newmember.submit();
804 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
807 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"Firstname") .
'</span></td><td>';
808 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
811 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"Lastname") .
'</span></td><td>';
812 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
815 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
816 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
817 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
820 print
'<tr id="trcompany" class="trcompany"><td>';
821 if (!empty((
float) $project->price_registration)) {
822 print
'<span class="fieldrequired">';
824 print $langs->trans(
"Company");
825 if (!empty((
float) $project->price_registration)) {
829 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
830 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";
833 if ($project->price_registration) {
834 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
835 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
836 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
840 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
841 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";
844 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
845 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
847 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
851 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
852 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
853 $country_id =
GETPOST(
'country_id');
855 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
857 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
861 $new_country_id =
getCountry($country_code, 3, $db, $langs);
863 if ($new_country_id) {
864 $country_id = $new_country_id;
868 $country_code =
getCountry($country_id, 2, $db, $langs);
869 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
873 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
875 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
876 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
883 if ($project->price_registration) {
884 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
885 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
889 $notetoshow = $note_public;
890 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
892 $notetoshow = str_replace(
'\n',
"\n", $conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION);
894 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
902 print
'<div class="center">';
903 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
904 if (!empty($backtopage)) {
905 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';