diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8f941d094c7..52b00c7e592 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -155,3 +155,7 @@ PaymentConferenceAttendee = Conference attendee payment PaymentBoothLocation = Booth location payment RegistrationAndPaymentWereAlreadyRecorder=A registration and a payment were already recorded for the email %s +EmailAttendee=Attendee email +EmailCompanyForInvoice=Company email (for invoice, if different of attendee email) +ErrorSeveralCompaniesWithEmailContactUs=Several companies with this email has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation +ErrorSeveralCompaniesWithNameContactUs=Several companies with this name has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation \ No newline at end of file diff --git a/htdocs/public/eventorganization/attendee_register.php b/htdocs/public/eventorganization/attendee_register.php index 42a343b5a66..e8909d91814 100644 --- a/htdocs/public/eventorganization/attendee_register.php +++ b/htdocs/public/eventorganization/attendee_register.php @@ -71,13 +71,13 @@ global $dolibarr_main_url_root; // Init vars $errmsg = ''; -$num = 0; $error = 0; $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); $email = GETPOST("email"); $societe = GETPOST("societe"); +$emailcompany = GETPOST("emailcompany"); // Getting id from Post and decoding it $type = GETPOST('type', 'aZ09'); @@ -296,7 +296,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $resultfetchthirdparty = 0; - $genericcompanyname = $langs->trans('EventParticipant').' '.$email; // Keep this label simple so we can retreive same thirdparty for another event + $genericcompanyname = $langs->trans('EventParticipant').' '.($emailcompany ? $emailcompany : $email); // Keep this label simple so we can retreive same thirdparty for another event // Getting the thirdparty or creating it $thirdparty = new Societe($db); @@ -307,12 +307,47 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen } else { if (empty($conf->global->EVENTORGANIZATION_DISABLE_RETREIVE_THIRDPARTY_FROM_NAME)) { // Fetch using the field input by end user if we have just created the attendee - if ($resultfetchthirdparty <= 0 && !empty($societe)) { + if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($emailcompany)) { + $resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', $emailcompany); + if ($resultfetchthirdparty > 0) { + // We found a unique result with the name + emailcompany, so we set the fk_soc of attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); + } elseif ($resultfetchthirdparty == -2) { + $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); + } + } + // Fetch using the field input by end user if we have just created the attendee + if ($resultfetchthirdparty <= 0 && !empty($societe) && !empty($email) && $email != $emailcompany) { $resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', $email); if ($resultfetchthirdparty > 0) { // We found a unique result with the name + email, so we set the fk_soc of attendee $confattendee->fk_soc = $thirdparty->id; $confattendee->update($user); + } elseif ($resultfetchthirdparty == -2) { + $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); + } + } + if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) { + // Try to find thirdparty from the email only + $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany); + if ($resultfetchthirdparty > 0) { + // We found a unique result with that email only, so we set the fk_soc of attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); + } elseif ($resultfetchthirdparty == -2) { + $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email); + } + } + if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) { + // Try to find thirdparty from the email only + $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + if ($resultfetchthirdparty > 0) { + // We found a unique result with that email only, so we set the fk_soc of attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); + } elseif ($resultfetchthirdparty == -2) { + $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email); } } if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) { @@ -322,15 +357,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen // We found a unique result with that name + email, so we set the fk_soc of attendee $confattendee->fk_soc = $thirdparty->id; $confattendee->update($user); - } - } - if ($resultfetchthirdparty <= 0 && !empty($email)) { - // Try to find thirdparty from the email only - $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - if ($resultfetchthirdparty > 0) { - // We found a unique result with that email only, so we set the fk_soc of attendee - $confattendee->fk_soc = $thirdparty->id; - $confattendee->update($user); + } elseif ($resultfetchthirdparty == -2) { + $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); } } @@ -367,9 +395,10 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen } if ($resultfetchthirdparty < 0) { + // If an error was found $error++; $errmsg .= $thirdparty->error; - } elseif ($resultfetchthirdparty == 0) { + } elseif ($resultfetchthirdparty == 0) { // No thirdparty found + a payment is expected // Creation of a new thirdparty if (!empty($societe)) { $thirdparty->name = $societe; @@ -383,7 +412,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen $thirdparty->fournisseur = 0; $thirdparty->country_id = GETPOST("country_id", 'int'); $thirdparty->state_id = GETPOST("state_id", 'int'); - $thirdparty->email = $email; + $thirdparty->email = ($emailcompany ? $emailcompany : $email); // Load object modCodeTiers $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); @@ -648,7 +677,7 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print '
| ' . $langs->trans("Email") . '* | |
| ' . $langs->trans("EmailAttendee") . '* | |
| ' . $langs->trans("Company"); if (!empty(floatval($project->price_registration))) { @@ -657,6 +686,10 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO print ' | '; print img_picto('', 'company', 'class="pictofixedwidth"'); print ' |
| ' . $langs->trans("EmailCompanyForInvoice") . ' | |
| ' . $langs->trans("Address") . ' | ' . "\n"; print ' |
| '.$langs->trans("Attendee"); print ' | '; print $attendee->email; - print ($thirdparty->name ? ' ('.$thirdparty->name.')' : ''); + print ($thirdparty->name ? ' ('.$langs->trans("Company").' '.$thirdparty->name.')' : ''); print ''; print ' |