251$parameters = array();
253$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
259if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
268 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
271 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
273 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
277 $langs->load(
"errors");
278 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
282 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
291 if ($type ==
'global') {
292 $filter =
"(t.fk_project:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
294 if ($type ==
'conf') {
295 $filter =
"(t.fk_actioncomm:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
299 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
301 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
303 $confattendee = array_shift($resultfetchconfattendee);
306 $confattendee->date_creation =
dol_now();
307 $confattendee->date_subscription =
dol_now();
308 $confattendee->email = $email;
309 $confattendee->fk_project = $project->id;
310 $confattendee->fk_actioncomm =
$id;
311 $confattendee->note_public = $note_public;
312 $confattendee->firstname = $firstname;
313 $confattendee->lastname = $lastname;
316 $extrafields->fetch_name_optionals_label($confattendee->table_element);
317 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
320 $errmsg .= $confattendee->error;
325 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
330 if ($nb_post_max > 0) {
331 $sql =
"SELECT COUNT(ref) as nb_attendee";
332 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
333 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
334 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
335 $resql = $db->query($sql);
337 $num = $db->num_rows($resql);
341 $obj = $db->fetch_object($resql);
342 $nb_post_ip = $obj->nb_attendee;
347 $resultconfattendee = -1;
349 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
351 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
352 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
355 $resultconfattendee = $confattendee->create($user);
357 if ($resultconfattendee < 0) {
359 $errmsg .= $confattendee->error;
360 $errors = array_merge($errors, $confattendee->errors);
368 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
370 $redirection =
$dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
372 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
377 header(
"Location: ".$redirection);
381 $resultfetchthirdparty = 0;
383 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
386 $thirdparty =
new Societe($db);
389 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
390 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
394 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
395 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
396 if ($resultfetchthirdparty > 0) {
398 $confattendee->fk_soc = $thirdparty->id;
399 $confattendee->update($user);
400 } elseif ($resultfetchthirdparty == -2) {
401 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
405 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
406 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
407 if ($resultfetchthirdparty > 0) {
409 $confattendee->fk_soc = $thirdparty->id;
410 $confattendee->update($user);
411 } elseif ($resultfetchthirdparty == -2) {
412 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
416 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
418 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
419 if ($resultfetchthirdparty > 0) {
421 $confattendee->fk_soc = $thirdparty->id;
422 $confattendee->update($user);
423 } elseif ($resultfetchthirdparty == -2) {
424 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
427 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
429 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
430 if ($resultfetchthirdparty > 0) {
432 $confattendee->fk_soc = $thirdparty->id;
433 $confattendee->update($user);
434 } elseif ($resultfetchthirdparty == -2) {
435 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
438 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
440 $resultfetchthirdparty = $thirdparty->fetch(0, $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
441 if ($resultfetchthirdparty > 0) {
443 $confattendee->fk_soc = $thirdparty->id;
444 $confattendee->update($user);
445 } elseif ($resultfetchthirdparty == -2) {
446 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
452 if ($resultfetchthirdparty <= 0 && !empty($email)) {
454 $resultfetchcontact = $contact->fetch(0,
null,
'', $email);
455 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
456 $thirdparty->fetch($contact->fk_soc);
457 $confattendee->fk_soc = $thirdparty->id;
458 $confattendee->update($user);
459 $resultfetchthirdparty = 1;
463 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
465 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
466 if ($resultfetchthirdparty > 0) {
468 $confattendee->fk_soc = $thirdparty->id;
469 $confattendee->update($user);
470 } elseif ($resultfetchthirdparty == -2) {
471 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
477 if (empty((
float) $project->price_registration)) {
478 $resultfetchthirdparty = 1;
481 if ($resultfetchthirdparty < 0) {
484 $errmsg .= $thirdparty->error;
485 $errors = array_merge($errors, $thirdparty->errors);
486 } elseif ($resultfetchthirdparty == 0) {
488 if (!empty($societe)) {
489 $thirdparty->name = $societe;
491 $thirdparty->name = $genericcompanyname;
493 $thirdparty->address =
GETPOST(
"address");
494 $thirdparty->zip =
GETPOST(
"zipcode");
495 $thirdparty->town =
GETPOST(
"town");
496 $thirdparty->client = $thirdparty::PROSPECT;
497 $thirdparty->fournisseur = 0;
498 $thirdparty->country_id =
GETPOSTINT(
"country_id");
499 $thirdparty->state_id =
GETPOSTINT(
"state_id");
500 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
504 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
505 $module = substr($module, 0,
dol_strlen($module) - 4);
507 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
508 foreach ($dirsociete as $dirroot) {
514 $modCodeClient =
new $module($db);
515 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
517 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
518 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
520 $thirdparty->code_client = $tmpcode;
522 $readythirdparty = $thirdparty->create($user);
523 if ($readythirdparty < 0) {
525 $errmsg .= $thirdparty->error;
526 $errors = array_merge($errors, $thirdparty->errors);
528 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
529 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
532 $confattendee->fk_soc = $thirdparty->id;
533 $confattendee->update($user);
538 if (!$error && is_object($thirdparty)) {
540 if (!empty((
float) $project->price_registration)) {
541 $outputlangs = $langs;
545 $outputlangs->loadLangs(array(
"eventorganization"));
548 $productforinvoicerow =
new Product($db);
549 $productforinvoicerow->id = 0;
553 $resultprod = $productforinvoicerow->fetch(
getDolGlobalInt(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
558 if ($resultprod < 0) {
560 $errmsg .= $productforinvoicerow->error;
561 $errors = array_merge($errors, $productforinvoicerow->errors);
564 if (empty($confattendee->fk_invoice)) {
566 $facture->socid = $thirdparty->id;
569 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
570 $facture->fk_project = $project->id;
573 if (empty($facture->cond_reglement_id)) {
574 $paymenttermstatic =
new PaymentTerm($confattendee->db);
575 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
576 if (empty($facture->cond_reglement_id)) {
578 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
579 $confattendee->errors[] = $confattendee->error;
582 $resultfacture = $facture->create($user);
583 if ($resultfacture <= 0) {
584 $confattendee->error = $facture->error;
585 $confattendee->errors = $facture->errors;
588 $confattendee->fk_invoice = $resultfacture;
589 $confattendee->update($user);
592 $facture->fetch($confattendee->fk_invoice);
603 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
605 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
606 if ($project->location) {
607 $labelforproduct .=
' - '.$project->location;
609 $date_start = $project->date_start_event;
610 $date_end = $project->date_end_event;
613 if (empty($facture->lines)) {
614 $pu_ttc = (float) $project->price_registration;
616 $price_base_type =
'TTC';
618 $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);
620 $confattendee->error = $facture->error;
621 $confattendee->errors = $facture->errors;
627 if (!$error && is_object($facture)) {
636 $sourcetouse =
'organizedeventregistration';
637 $reftouse = $facture->id;
638 $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');
643 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
647 header(
"Location: ".$redirection);
657 $confattendee->setStatut(1);
660 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
661 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
665 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
667 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
669 $arraydefaultmessage =
null;
671 $labeltouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
672 if (!empty($labeltouse)) {
673 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
676 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
677 $subject = $arraydefaultmessage->topic;
678 $msg = $arraydefaultmessage->content;
684 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
690 $sendto = $thirdparty->email;
692 $urlback = $_SERVER[
"REQUEST_URI"];
696 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
698 $result = $mailfile->sendfile();
700 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
702 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);
723$form =
new Form($db);
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">'.dol_escape_htmltag($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>'.dol_escape_htmltag($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) || $currentnbofattendees < $maxattendees) {
813 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
814 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
815 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
816 print
'<input type="hidden" name="action" value="add" />';
817 print
'<input type="hidden" name="type" value="' . $type .
'" />';
818 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
819 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
820 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
829 print
'<script type="text/javascript">
830 jQuery(document).ready(function () {
831 jQuery(document).ready(function () {
832 jQuery("#selectcountry_id").change(function() {
833 document.newmember.action.value="create";
834 document.newmember.submit();
840 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
843 print
'<tr><td><span class="fieldrequired">';
844 print $langs->trans(
"Firstname") .
'</span></td><td>';
845 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
846 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
849 print
'<tr><td><span class="fieldrequired">';
850 print $langs->trans(
"Lastname") .
'</span></td><td>';
851 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
852 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
855 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
856 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
857 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
860 print
'<tr id="trcompany" class="trcompany"><td>';
861 if (!empty((
float) $project->price_registration)) {
862 print
'<span class="fieldrequired">';
864 print $langs->trans(
"Company");
865 if (!empty((
float) $project->price_registration)) {
869 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
870 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";
873 if ($project->price_registration) {
874 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
875 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
876 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
880 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
881 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";
884 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
885 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
887 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
891 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
892 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
893 $country_id =
GETPOST(
'country_id');
895 $country_id =
getCountry(
$conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
897 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
901 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
903 if ($new_country_id) {
904 $country_id = $new_country_id;
908 $country_code =
getCountry($country_id,
'2', $db, $langs);
909 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
913 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
915 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
916 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code);
923 if ($project->price_registration) {
924 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
925 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
930 $parameters[
'tpl_context'] =
'public';
931 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
933 $notetoshow = $note_public;
934 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
936 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
938 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
948 print
'<div class="center">';
949 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
950 if (!empty($backtopage)) {
951 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
961 if ($project->status == $project::STATUS_DRAFT) {
962 print $langs->trans(
"ConferenceIsNotConfirmed");