247$parameters = array();
249$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
255if (empty($reshook) && $action ==
'add' && (!empty($conference->id) && $conference->status == 2 || !empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
264 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Email")).
"<br>\n";
267 if (!
GETPOST(
"societe") && !empty((
float) $project->price_registration)) {
269 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Company")).
"<br>\n";
273 $langs->load(
"errors");
274 $errmsg .= $langs->trans(
"ErrorBadEMail",
GETPOST(
"email")).
"<br>\n";
278 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Country")).
"<br>\n";
287 if ($type ==
'global') {
288 $filter =
"(t.fk_project:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
290 if ($type ==
'conf') {
291 $filter =
"(t.fk_actioncomm:=:".((int)
$id).
") AND (t.email:=:'".$db->escape($email).
"')";
295 $resultfetchconfattendee = $confattendee->fetchAll(
'',
'', 0, 0, $filter);
297 if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
299 $confattendee = array_shift($resultfetchconfattendee);
302 $confattendee->date_creation =
dol_now();
303 $confattendee->date_subscription =
dol_now();
304 $confattendee->email = $email;
305 $confattendee->fk_project = $project->id;
306 $confattendee->fk_actioncomm =
$id;
307 $confattendee->note_public = $note_public;
308 $confattendee->firstname = $firstname;
309 $confattendee->lastname = $lastname;
312 $extrafields->fetch_name_optionals_label($confattendee->table_element);
313 $ret = $extrafields->setOptionalsFromPost(
null, $confattendee);
316 $errmsg .= $confattendee->error;
321 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
326 if ($nb_post_max > 0) {
327 $sql =
"SELECT COUNT(ref) as nb_attendee";
328 $sql .=
" FROM ".MAIN_DB_PREFIX.
"eventorganization_conferenceorboothattendee";
329 $sql .=
" WHERE ip = '".$db->escape($confattendee->ip).
"'";
330 $sql .=
" AND date_creation > '".$db->idate($minmonthpost).
"'";
331 $resql = $db->query($sql);
333 $num = $db->num_rows($resql);
337 $obj = $db->fetch_object($resql);
338 $nb_post_ip = $obj->nb_attendee;
343 $resultconfattendee = -1;
345 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
347 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
348 array_push($confattendee->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
351 $resultconfattendee = $confattendee->create($user);
353 if ($resultconfattendee < 0) {
355 $errmsg .= $confattendee->error;
356 $errors = array_merge($errors, $confattendee->errors);
364 if (!empty($confattendee->date_subscription) && !empty($confattendee->amount)) {
366 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
368 $mesg = $langs->trans(
"RegistrationAndPaymentWereAlreadyRecorded", $email);
373 header(
"Location: ".$redirection);
377 $resultfetchthirdparty = 0;
379 $genericcompanyname = $langs->trans(
'EventParticipant').
' '.($emailcompany ? $emailcompany : $email);
382 $thirdparty =
new Societe($db);
385 if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
386 $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
390 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) {
391 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
392 if ($resultfetchthirdparty > 0) {
394 $confattendee->fk_soc = $thirdparty->id;
395 $confattendee->update($user);
396 } elseif ($resultfetchthirdparty == -2) {
397 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
401 if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) {
402 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'', $email);
403 if ($resultfetchthirdparty > 0) {
405 $confattendee->fk_soc = $thirdparty->id;
406 $confattendee->update($user);
407 } elseif ($resultfetchthirdparty == -2) {
408 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
412 if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
414 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $emailcompany);
415 if ($resultfetchthirdparty > 0) {
417 $confattendee->fk_soc = $thirdparty->id;
418 $confattendee->update($user);
419 } elseif ($resultfetchthirdparty == -2) {
420 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
423 if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
425 $resultfetchthirdparty = $thirdparty->fetch(0,
'',
'',
'',
'',
'',
'',
'',
'',
'', $email);
426 if ($resultfetchthirdparty > 0) {
428 $confattendee->fk_soc = $thirdparty->id;
429 $confattendee->update($user);
430 } elseif ($resultfetchthirdparty == -2) {
431 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
434 if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
436 $resultfetchthirdparty = $thirdparty->fetch(0, $genericcompanyname,
'',
'',
'',
'',
'',
'',
'',
'',
'');
437 if ($resultfetchthirdparty > 0) {
439 $confattendee->fk_soc = $thirdparty->id;
440 $confattendee->update($user);
441 } elseif ($resultfetchthirdparty == -2) {
442 $thirdparty->error = $langs->trans(
"ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
448 if ($resultfetchthirdparty <= 0 && !empty($email)) {
450 $resultfetchcontact = $contact->fetch(0,
null,
'', $email);
451 if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
452 $thirdparty->fetch($contact->fk_soc);
453 $confattendee->fk_soc = $thirdparty->id;
454 $confattendee->update($user);
455 $resultfetchthirdparty = 1;
459 if ($resultfetchthirdparty <= 0 && !empty($societe)) {
461 $resultfetchthirdparty = $thirdparty->fetch(0, $societe,
'',
'',
'',
'',
'',
'',
'',
'',
'');
462 if ($resultfetchthirdparty > 0) {
464 $confattendee->fk_soc = $thirdparty->id;
465 $confattendee->update($user);
466 } elseif ($resultfetchthirdparty == -2) {
467 $thirdparty->error =
"ErrorSeveralCompaniesWithNameContactUs";
473 if (empty((
float) $project->price_registration)) {
474 $resultfetchthirdparty = 1;
477 if ($resultfetchthirdparty < 0) {
480 $errmsg .= $thirdparty->error;
481 $errors = array_merge($errors, $thirdparty->errors);
482 } elseif ($resultfetchthirdparty == 0) {
484 if (!empty($societe)) {
485 $thirdparty->name = $societe;
487 $thirdparty->name = $genericcompanyname;
489 $thirdparty->address =
GETPOST(
"address");
490 $thirdparty->zip =
GETPOST(
"zipcode");
491 $thirdparty->town =
GETPOST(
"town");
492 $thirdparty->client = $thirdparty::PROSPECT;
493 $thirdparty->fournisseur = 0;
494 $thirdparty->country_id =
GETPOSTINT(
"country_id");
495 $thirdparty->state_id =
GETPOSTINT(
"state_id");
496 $thirdparty->email = ($emailcompany ? $emailcompany : $email);
500 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
501 $module = substr($module, 0,
dol_strlen($module) - 4);
503 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
504 foreach ($dirsociete as $dirroot) {
510 $modCodeClient =
new $module($db);
511 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
513 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
514 $tmpcode = $modCodeClient->getNextValue($thirdparty, 0);
516 $thirdparty->code_client = $tmpcode;
518 $readythirdparty = $thirdparty->create($user);
519 if ($readythirdparty < 0) {
521 $errmsg .= $thirdparty->error;
522 $errors = array_merge($errors, $thirdparty->errors);
524 $thirdparty->country_code =
getCountry($thirdparty->country_id,
'2', $db, $langs);
525 $thirdparty->country =
getCountry($thirdparty->country_code,
'', $db, $langs);
528 $confattendee->fk_soc = $thirdparty->id;
529 $confattendee->update($user);
534 if (!$error && is_object($thirdparty)) {
536 if (!empty((
float) $project->price_registration)) {
537 $outputlangs = $langs;
541 $outputlangs->loadLangs(array(
"eventorganization"));
544 $productforinvoicerow =
new Product($db);
545 $productforinvoicerow->id = 0;
549 $resultprod = $productforinvoicerow->fetch(
getDolGlobalString(
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'));
554 if ($resultprod < 0) {
556 $errmsg .= $productforinvoicerow->error;
557 $errors = array_merge($errors, $productforinvoicerow->errors);
560 if (empty($confattendee->fk_invoice)) {
562 $facture->socid = $thirdparty->id;
565 $facture->cond_reglement_id = $confattendee->cond_reglement_id;
566 $facture->fk_project = $project->id;
569 if (empty($facture->cond_reglement_id)) {
570 $paymenttermstatic =
new PaymentTerm($confattendee->db);
571 $facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
572 if (empty($facture->cond_reglement_id)) {
574 $confattendee->error =
'ErrorNoPaymentTermRECEPFound';
575 $confattendee->errors[] = $confattendee->error;
578 $resultfacture = $facture->create($user);
579 if ($resultfacture <= 0) {
580 $confattendee->error = $facture->error;
581 $confattendee->errors = $facture->errors;
584 $confattendee->fk_invoice = $resultfacture;
585 $confattendee->update($user);
588 $facture->fetch($confattendee->fk_invoice);
599 $vattouse =
get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
601 $labelforproduct = $outputlangs->trans(
"EventFee", $project->title);
602 if ($project->location) {
603 $labelforproduct .=
' - '.$project->location;
605 $date_start = $project->date_start_event;
606 $date_end = $project->date_end_event;
609 if (empty($facture->lines)) {
610 $pu_ttc = (float) $project->price_registration;
612 $price_base_type =
'TTC';
614 $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);
616 $confattendee->error = $facture->error;
617 $confattendee->errors = $facture->errors;
623 if (!$error && is_object($facture)) {
632 $sourcetouse =
'organizedeventregistration';
633 $reftouse = $facture->id;
634 $redirection = $dolibarr_main_url_root.
'/public/payment/newpayment.php?source='.urlencode((
string) ($sourcetouse)).
'&ref='.urlencode((
string) ($reftouse));
637 $redirection .=
'&securekey='.dol_hash(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN') . $sourcetouse . $reftouse,
'2');
639 $redirection .=
'&securekey='.urlencode(
getDolGlobalString(
'PAYMENT_SECURITY_TOKEN'));
643 header(
"Location: ".$redirection);
653 $confattendee->setStatut(1);
656 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
657 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
661 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
663 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
665 $arraydefaultmessage =
null;
668 if (!empty($labeltouse)) {
669 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'eventorganization_send', $user, $outputlangs, $labeltouse, 1,
'');
672 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
673 $subject = $arraydefaultmessage->topic;
674 $msg = $arraydefaultmessage->content;
686 $sendto = $thirdparty->email;
688 $urlback = $_SERVER[
"REQUEST_URI"];
692 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, ($ishtml ? 1 : 0));
694 $result = $mailfile->sendfile();
696 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
698 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
702 $redirection = $dolibarr_main_url_root.
'/public/eventorganization/subscriptionok.php?id='.((int)
$id).
'&securekey='.urlencode($securekeyurl);
704 header(
"Location: ".$redirection);
719$form =
new Form($db);
725print
'<div align="center">';
726print
'<div id="divsubscribe">';
729print
'<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
730print
load_fiche_titre($langs->trans(
"NewRegistration"),
'',
'', 0,
'',
'center');
732print
'<span class="opacitymedium">'.$langs->trans(
"EvntOrgWelcomeMessage").
'</span>';
735print
'<span class="eventlabel large">'.dol_escape_htmltag($project->title .
' '. $conference->label).
'</span><br>';
739print
'<div class="justify subscriptionformhelptext">';
741if ($project->date_start_event || $project->date_end_event) {
742 print
'<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
744if ($project->date_start_event) {
746 $tmparray =
dol_getdate($project->date_start_event,
false,
'');
747 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
752if ($project->date_start_event && $project->date_end_event) {
755if ($project->date_end_event) {
757 $tmparray =
dol_getdate($project->date_end_event,
false,
'');
758 if ($tmparray[
'hours'] || $tmparray[
'minutes'] || $tmparray[
'minutes']) {
763if ($project->date_start_event || $project->date_end_event) {
766if ($project->location) {
767 print
'<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).
'<br>';
769if ($project->note_public) {
770 print
'<br><span class="opacitymedium">'.dol_htmlentitiesbr($project->note_public).
'</span><br>';
777if ($conference->id > 0) {
793 $maxattendees = $project->max_attendees;
796if ($maxattendees && $currentnbofattendees >= $maxattendees) {
798 print
'<div class="warning">'.$langs->trans(
"MaxNbOfAttendeesReached").
'</div>';
806if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status ==
Project::STATUS_VALIDATED)) {
807 if (empty($maxattendees) || $currentnbofattendees < $maxattendees) {
809 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="newmember">' .
"\n";
810 print
'<input type="hidden" name="token" value="' .
newToken() .
'" / >';
811 print
'<input type="hidden" name="entity" value="' . $entity .
'" />';
812 print
'<input type="hidden" name="action" value="add" />';
813 print
'<input type="hidden" name="type" value="' . $type .
'" />';
814 print
'<input type="hidden" name="id" value="' . $conference->id .
'" />';
815 print
'<input type="hidden" name="fk_project" value="' . $project->id .
'" />';
816 print
'<input type="hidden" name="securekey" value="' . $securekeyreceived .
'" />';
825 print
'<script type="text/javascript">
826 jQuery(document).ready(function () {
827 jQuery(document).ready(function () {
828 jQuery("#selectcountry_id").change(function() {
829 document.newmember.action.value="create";
830 document.newmember.submit();
836 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">' .
"\n";
839 print
'<tr><td><span class="fieldrequired">';
840 print $langs->trans(
"Firstname") .
'</span></td><td>';
841 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
842 print
'<input type="text" name="firstname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($firstname) .
'" required autofocus></td></tr>' .
"\n";
845 print
'<tr><td><span class="fieldrequired">';
846 print $langs->trans(
"Lastname") .
'</span></td><td>';
847 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
848 print
'<input type="text" name="lastname" maxlength="255" class="minwidth200 maxwidth300" value="' .
dol_escape_htmltag($lastname) .
'" required></td></tr>' .
"\n";
851 print
'<tr><td><span class="fieldrequired">' . $langs->trans(
"EmailAttendee") .
'</span></td><td>';
852 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
853 print
'<input type="text" name="email" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'email')) .
'" required></td></tr>' .
"\n";
856 print
'<tr id="trcompany" class="trcompany"><td>';
857 if (!empty((
float) $project->price_registration)) {
858 print
'<span class="fieldrequired">';
860 print $langs->trans(
"Company");
861 if (!empty((
float) $project->price_registration)) {
865 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
866 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";
869 if ($project->price_registration) {
870 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"EmailCompany"), $langs->trans(
"EmailCompanyForInvoice")) .
'</td><td>';
871 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
872 print
'<input type="text" name="emailcompany" maxlength="255" class="minwidth200 widthcentpercentminusx maxwidth300" value="' .
dol_escape_htmltag(
GETPOST(
'emailcompany')) .
'"></td></tr>' .
"\n";
876 print
'<tr><td>' . $langs->trans(
"Address") .
'</td><td>' .
"\n";
877 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";
880 print
'<tr><td>' . $langs->trans(
'Zip') .
' / ' . $langs->trans(
'Town') .
'</td><td>';
881 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6, 1);
883 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
887 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Country').
'</span></td><td>';
888 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
889 $country_id =
GETPOST(
'country_id');
891 $country_id =
getCountry(
$conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,
'2', $db, $langs);
893 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
897 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
899 if ($new_country_id) {
900 $country_id = $new_country_id;
904 $country_code =
getCountry($country_id,
'2', $db, $langs);
905 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth200 widthcentpercentminusx maxwidth300');
909 print
'<tr><td>' . $langs->trans(
'State') .
'</td><td>';
911 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
912 print $formcompany->select_state(
GETPOST(
"state_id"), $country_code);
919 if ($project->price_registration) {
920 print
'<tr><td>' . $langs->trans(
'Price') .
'</td><td>';
921 print
'<span class="amount price-registration">'.price($project->price_registration, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
926 $parameters[
'tpl_context'] =
'public';
927 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
929 $notetoshow = $note_public;
930 print
'<tr><td>' . $langs->trans(
'Note') .
'</td><td>';
932 $notetoshow = str_replace(
'\n',
"\n",
getDolGlobalString(
'EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION'));
934 print
'<textarea name="note_public" class="centpercent" rows="'.ROWS_9.
'">'.
dol_escape_htmltag($notetoshow, 0, 1).
'</textarea>';
944 print
'<div class="center">';
945 print
'<input type="submit" value="' . $langs->trans(
"Submit") .
'" id="submitsave" class="button">';
946 if (!empty($backtopage)) {
947 print
' <input type="submit" value="' . $langs->trans(
"Cancel") .
'" id="submitcancel" class="button button-cancel">';
957 if ($project->status == $project::STATUS_DRAFT) {
958 print $langs->trans(
"ConferenceIsNotConfirmed");