231$parameters = array();
233$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
239if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
248 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
251 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
253 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
257 $langs->load(
"errors");
258 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
262 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
271 if ($type ==
'global') {
272 $filter =
"(t.fk_project:=:".((int) $id).
") AND (t.email:=:'".$db->escape($email).
"')";
274 if ($type ==
'conf') {
275 $filter =
"(t.fk_actioncomm:=:".((int) $id).
") AND (t.email:=:'".$db->escape($email).
"')";
279 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
281 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
283 $confattendee = array_shift($resultfetchconfattendee);
286 $confattendee->date_creation =
dol_now();
287 $confattendee->date_subscription =
dol_now();
288 $confattendee->email = $email;
289 $confattendee->fk_project = $project->id;
290 $confattendee->fk_actioncomm = $id;
291 $confattendee->note_public = $note_public;
292 $confattendee->firstname = $firstname;
293 $confattendee->lastname = $lastname;
296 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
301 if ($nb_post_max > 0) {
302 $sql =
"SELECT COUNT(ref) as nb_attendee";
303 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
304 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
305 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
306 $resql = $db->query($sql);
308 $num = $db->num_rows($resql);
312 $obj = $db->fetch_object($resql);
313 $nb_post_ip = $obj->nb_attendee;
318 $resultconforbooth = -1;
320 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
322 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
323 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
326 $resultconfattendee = $confattendee->create($user);
328 if ($resultconfattendee < 0) {
330 $errmsg .= $confattendee->error;
331 $errors = array_merge($errors, $confattendee->errors);
339 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
341 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
343 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
348 header(
"Location: ".$redirection);
352 $resultfetchthirdparty = 0;
354 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
357 $thirdparty =
new Societe($db);
360 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
361 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
365 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
366 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
367 if ($resultfetchthirdparty > 0) {
369 $confattendee->fk_soc = $thirdparty->id;
370 $confattendee->update($user);
371 } elseif ($resultfetchthirdparty == -2) {
372 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
376 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
377 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
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($emailcompany)) {
389 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
390 if ($resultfetchthirdparty > 0) {
392 $confattendee->fk_soc = $thirdparty->id;
393 $confattendee->update($user);
394 } elseif ($resultfetchthirdparty == -2) {
395 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
398 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
400 $resultfetchthirdparty = $thirdparty->fetch(
'',
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
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($genericcompanyname)) {
411 $resultfetchthirdparty = $thirdparty->fetch(
'', $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
412 if ($resultfetchthirdparty > 0) {
414 $confattendee->fk_soc = $thirdparty->id;
415 $confattendee->update($user);
416 } elseif ($resultfetchthirdparty == -2) {
417 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
423 if ($resultfetchthirdparty <= 0 && !empty($email)) {
425 $resultfetchcontact = $contact->fetch(
'',
null,
'', $email);
426 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
427 $thirdparty->fetch($contact->fk_soc);
428 $confattendee->fk_soc = $thirdparty->id;
429 $confattendee->update($user);
430 $resultfetchthirdparty = 1;
434 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
436 $resultfetchthirdparty = $thirdparty->fetch(
'', $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
437 if ($resultfetchthirdparty > 0) {
439 $confattendee->fk_soc = $thirdparty->id;
440 $confattendee->update($user);
441 } elseif ($resultfetchthirdparty == -2) {
442 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
448 if (empty((
float) $project->price_registration)) {
449 $resultfetchthirdparty = 1;
452 if ($resultfetchthirdparty < 0) {
455 $errmsg .= $thirdparty->error;
456 $errors = array_merge($errors, $thirdparty->errors);
457 } elseif ($resultfetchthirdparty == 0) {
459 if (!empty($societe)) {
460 $thirdparty->name = $societe;
462 $thirdparty->name = $genericcompanyname;
464 $thirdparty->address =
GETPOST(
"address");
465 $thirdparty->zip =
GETPOST(
"zipcode");
466 $thirdparty->town =
GETPOST(
"town");
467 $thirdparty->client = $thirdparty::PROSPECT;
468 $thirdparty->fournisseur = 0;
469 $thirdparty->country_id =
GETPOSTINT(
"country_id");
470 $thirdparty->state_id =
GETPOSTINT(
"state_id");
471 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
475 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
476 $module = substr($module, 0,
dol_strlen($module) - 4);
478 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
479 foreach ($dirsociete as $dirroot) {
485 $modCodeClient =
new $module($db);
487 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
488 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
490 $thirdparty->code_client = $tmpcode;
491 $readythirdparty = $thirdparty->create($user);
492 if ($readythirdparty < 0) {
494 $errmsg .= $thirdparty->error;
495 $errors = array_merge($errors, $thirdparty->errors);
497 $thirdparty->country_code =
getCountry($thirdparty->country_id, 2, $db, $langs);
498 $thirdparty->country =
getCountry($thirdparty->country_code, 0, $db, $langs);
501 $confattendee->fk_soc = $thirdparty->id;
502 $confattendee->update($user);
509 if (!empty((
float) $project->price_registration)) {
510 $outputlangs = $langs;
514 $outputlangs->loadLangs(array(
"eventorganization"));
517 $productforinvoicerow =
new Product($db);
518 $productforinvoicerow->id = 0;
522 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
526 if ($resultprod < 0) {
528 $errmsg .= $productforinvoicerow->error;
529 $errors = array_merge($errors, $productforinvoicerow->errors);
532 if (empty($confattendee->fk_invoice)) {
534 $facture->socid = $thirdparty->id;
537 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
538 $facture->fk_project = $project->id;
541 if (empty($facture->cond_reglement_id)) {
542 $paymenttermstatic =
new PaymentTerm($confattendee->db);
543 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
544 if (empty($facture->cond_reglement_id)) {
546 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
547 $confattendee->errors[] = $confattendee->error;
550 $resultfacture = $facture->create($user);
551 if ($resultfacture <= 0) {
552 $confattendee->error = $facture->error;
553 $confattendee->errors = $facture->errors;
556 $confattendee->fk_invoice = $resultfacture;
557 $confattendee->update($user);
560 $facture->fetch($confattendee->fk_invoice);
571 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
573 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
574 if ($project->location) {
575 $labelforproduct .=
' - '.$project->location;
577 $date_start = $project->date_start_event;
578 $date_end = $project->date_end_event;
581 if (empty($facture->lines)) {
582 $pu_ttc = (float) $project->price_registration;
584 $price_base_type =
'TTC';
586 $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);
588 $confattendee->error = $facture->error;
589 $confattendee->errors = $facture->errors;
604 $sourcetouse =
'organizedeventregistration';
605 $reftouse = $facture->id;
606 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
609 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse, 2);
611 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
615 header(
"Location: ".$redirection);
625 $confattendee->setStatut(1);
628 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
629 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
633 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
635 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
637 $arraydefaultmessage =
null;
640 if (!empty($labeltouse)) {
641 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
644 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
645 $subject = $arraydefaultmessage->topic;
646 $msg = $arraydefaultmessage->content;
655 $sendto = $thirdparty->email;
657 $urlback = $_SERVER[
"REQUEST_URI"];
661 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
663 $result = $mailfile->sendfile();
665 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
667 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
671 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int) $id).
'&securekey='.urlencode($securekeyurl);
673 header(
"Location: ".$redirection);
688$form =
new Form($db);
694print
'<div align="center">';
695print
'<div id="divsubscribe">';
698print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
699print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0, 0,
'center');
701print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
704print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
708print
'<div class="justify subscriptionformhelptext">';
710if ($project->date_start_event || $project->date_end_event) {
711 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
713if ($project->date_start_event) {
715 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
716 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
721if ($project->date_start_event && $project->date_end_event) {
724if ($project->date_end_event) {
726 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
727 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
732if ($project->date_start_event || $project->date_end_event) {
735if ($project->location) {
736 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
738if ($project->note_public) {
739 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
746if ($conference->id > 0) {
762 $maxattendees = $project->max_attendees;
765if ($maxattendees && $currentnbofattendees >= $maxattendees) {
767 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
775if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
776 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
778 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
779 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
780 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
781 print
'<input type="hidden" name="action" value="add" />';
782 print
'<input type="hidden" name="type" value="' . $type .
'" />';
783 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
784 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
785 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
794 print
'<script type="text/javascript">
795 jQuery(document).ready(function () {
796 jQuery(document).ready(function () {
797 jQuery("#selectcountry_id").change(function() {
798 document.newmember.action.value="create";
799 document.newmember.submit();
805 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
808 print
'<tr><td><span class="fieldrequired">';
809 print $langs->trans(
"Firstname") .
'</span></td><td>';
810 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
811 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
814 print
'<tr><td><span class="fieldrequired">';
815 print $langs->trans(
"Lastname") .
'</span></td><td>';
816 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
817 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
820 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
821 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
822 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
825 print
'<tr id="trcompany" class="trcompany"><td>';
826 if (!empty((
float) $project->price_registration)) {
827 print
'<span class="fieldrequired">';
829 print $langs->trans(
"Company");
830 if (!empty((
float) $project->price_registration)) {
834 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
835 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";
838 if ($project->price_registration) {
839 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
840 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
841 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
845 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
846 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";
849 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
850 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
852 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
856 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
857 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
858 $country_id =
GETPOST(
'country_id');
860 $country_id =
getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
862 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
866 $new_country_id =
getCountry($country_code, 3, $db, $langs);
868 if ($new_country_id) {
869 $country_id = $new_country_id;
873 $country_code =
getCountry($country_id, 2, $db, $langs);
874 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
878 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
880 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
881 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
888 if ($project->price_registration) {
889 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
890 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
894 $notetoshow = $note_public;
895 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
897 $notetoshow = str_replace(
'\n',
"\n", $conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION);
899 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
907 print
'<div class="center">';
908 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
909 if (!empty($backtopage)) {
910 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
920 if ($project->status == $project::STATUS_DRAFT) {
921 print $langs->trans(
"ConferenceIsNotConfirmed");