diff --git a/htdocs/telephonie/client/new.php b/htdocs/telephonie/client/new.php index 268395cba9c..4b208112023 100644 --- a/htdocs/telephonie/client/new.php +++ b/htdocs/telephonie/client/new.php @@ -56,6 +56,11 @@ if ($_POST["action"] == 'add') $verif = "ok"; $mesg = ''; + + $contact->name = $_POST["cnom"]; + $contact->firstname = $_POST["cprenom"]; + $contact->email = strtolower($_POST["cmail"]); + if (strlen(trim($_POST["nom"])) == 0) { $mesg = "Nom de société incorrect"; @@ -116,13 +121,20 @@ if ($_POST["action"] == 'add') if (strlen(trim($_POST["cmail"])) > 0 && $verif == 'ok') { - if (!ValidEmail(trim($_POST["cmail"])) && $verif == 'ok') + + if (strlen(trim($_POST["cnom"])) == 0 && $verif == 'ok') + { + $mesg = "Nom de contact manquant"; + $verif = "nok"; + } + + if (!ValidEmail(trim($contact->email)) && $verif == 'ok') { $mesg = "Email invalide"; $verif = "nok"; } - if (!check_mail(trim($_POST["cmail"])) && $verif == 'ok') + if (!check_mail(trim($contact->email)) && $verif == 'ok') { $mesg = "Email invalide (domaine invalide)"; $verif = "nok"; @@ -158,17 +170,16 @@ if ($_POST["action"] == 'add') if ($result == 0) { - + } else { + $mesg = nl2br($soc->error); $error++; } } - $contact->name = $_POST["cnom"]; - $contact->firstname = $_POST["cprenom"]; - $contact->email = $_POST["cmail"]; + if (!$error && $verif == "ok") { @@ -348,8 +359,8 @@ if ($user->rights->telephonie->ligne->creer) print "\n"; print '
| '.$langs->trans('Name').' | |
| '.$langs->trans('Firstname').' | |
| '.$langs->trans('Name').' | |
| '.$langs->trans('Firstname').' | |
| '.$langs->trans('Mail').' |