diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 92683af701b..cc5602920f8 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -47,51 +47,53 @@ if ($_GET["action"] == 'create_user' && $user->admin) // Creation user $nuser = new User($db); - $nuser->nom = $contact->nom; - $nuser->prenom = $contact->prenom; + $nuser->nom = $contact->name; + $nuser->prenom = $contact->firstname; $nuser->create_from_contact($contact); } if ($_POST["action"] == 'add') { + $contact = new Contact($db); + + $contact->socid = $_POST["socid"]; + + $contact->name = $_POST["name"]; + $contact->firstname = $_POST["firstname"]; + $contact->civilite_id = $_POST["civilite_id"]; + $contact->poste = $_POST["poste"]; + $contact->address = $_POST["address"]; + $contact->cp = $_POST["cp"]; + $contact->ville = $_POST["ville"]; + $contact->fk_pays = $_POST["pays_id"]; + $contact->email = $_POST["email"]; + $contact->phone_pro = $_POST["phone_pro"]; + $contact->phone_perso = $_POST["phone_perso"]; + $contact->phone_mobile = $_POST["phone_mobile"]; + $contact->fax = $_POST["fax"]; + $contact->jabberid = $_POST["jabberid"]; + + $contact->note = $_POST["note"]; + if (! $_POST["name"]) { array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Lastname"))); $_GET["action"]="create"; } +/* if (! $_POST["firstname"]) { array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Firstname"))); $_GET["action"]="create"; } - +*/ if ($_POST["name"] && $_POST["firstname"]) { - $contact = new Contact($db); - - $contact->socid = $_POST["socid"]; - - $contact->name = $_POST["name"]; - $contact->firstname = $_POST["firstname"]; - $contact->civilite_id = $_POST["civilite_id"]; - $contact->poste = $_POST["poste"]; - $contact->address = $_POST["address"]; - $contact->cp = $_POST["cp"]; - $contact->ville = $_POST["ville"]; - $contact->fk_pays = $_POST["pays_id"]; - $contact->email = $_POST["email"]; - $contact->phone_pro = $_POST["phone_pro"]; - $contact->phone_perso = $_POST["phone_perso"]; - $contact->phone_mobile = $_POST["phone_mobile"]; - $contact->fax = $_POST["fax"]; - $contact->jabberid = $_POST["jabberid"]; - - $contact->note = $_POST["note"]; - $id = $contact->create($user); if ($id > 0) { Header("Location: fiche.php?id=".$id); + exit; } $error=array($contact->error); @@ -108,6 +110,7 @@ if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') $result = $contact->delete($_GET["id"]); Header("Location: index.php"); + exit; } @@ -121,7 +124,7 @@ if ($_POST["action"] == 'update') $contact->socid = $_POST["socid"]; $contact->name = $_POST["name"]; $contact->firstname = $_POST["firstname"]; - $contact->civilite_id = $_POST["civilite_id"]; + $contact->civilite_id = $_POST["civilite_id"]; $contact->poste = $_POST["poste"]; $contact->address = $_POST["address"]; @@ -157,16 +160,8 @@ $form = new Form($db); if ($socid) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); -} - -// Affiche les erreurs -if (sizeof($error)) -{ - print "