From bf11d35a0186eb582f3a7aee1414bc368e257f72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Oct 2005 13:15:58 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Corrections=20diverses=20sur=20gestrion?= =?UTF-8?q?=20du=20contact.=20Plus=20de=20perte=20des=20infos=20saisies=20?= =?UTF-8?q?si=20champ=20nom=20non=20renseign=E9.=20Trad:=20Traduction=20ci?= =?UTF-8?q?vilit=E9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/contact/fiche.php | 187 ++++++++++++++++++++------------------- 1 file changed, 98 insertions(+), 89 deletions(-) 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 "
"; - print join("
",$error); - print "
\n"; + $objsoc = new Societe($db); + $objsoc->fetch($socid); } @@ -175,33 +170,33 @@ if (sizeof($error)) */ if ($_GET["id"] > 0) { - // Si edition contact deja existant - - $contact = new Contact($db); - $return=$contact->fetch($_GET["id"], $user); - if ($return < 0) { - dolibarr_print_error('',$contact->error); - } - - $h=0; - $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("General"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("PersonalInformations"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("ExportImport"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("Info"); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); + // Si edition contact deja existant + $contact = new Contact($db); + $return=$contact->fetch($_GET["id"], $user); + if ($return < 0) + { + dolibarr_print_error('',$contact->error); + } + + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("General"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("PersonalInformations"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("ExportImport"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); } @@ -211,8 +206,8 @@ if ($_GET["id"] > 0) */ if ($_GET["action"] == 'delete') { - $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Źtes-vous sūr de vouloir supprimer ce contact ?","confirm_delete"); - print '
'; + $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Źtes-vous sūr de vouloir supprimer ce contact ?","confirm_delete"); + print '
'; } if ($_GET["action"] == 'create') @@ -222,8 +217,16 @@ if ($_GET["action"] == 'create') * */ print_fiche_titre($langs->trans("AddContact")); - print '
'; + // Affiche les erreurs + if (sizeof($error)) + { + print "
"; + print join("
",$error); + print "
\n"; + } + + print '
'; print '
'; print ''; print ''; @@ -248,16 +251,16 @@ if ($_GET["action"] == 'create') print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; @@ -270,13 +273,13 @@ if ($_GET["action"] == 'create') print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; + print ''; } else { - print ''; } @@ -319,8 +330,8 @@ elseif ($_GET["action"] == 'edit') print $form->select_civilite($contact->civilite_id); print ''; - print ''; - print ''; + print ''; + print ''; print ''; @@ -339,7 +350,7 @@ elseif ($_GET["action"] == 'edit') print ''; print ''; - print ''; + print ''; if ($conf->mailing->enabled) { $langs->load("mails"); @@ -352,10 +363,10 @@ elseif ($_GET["action"] == 'edit') } print ''; - print ''; + print ''; - print ''; @@ -373,7 +384,7 @@ elseif ($_GET["action"] == 'edit') print ""; } -else +elseif ($_GET["id"]) { /* * Fiche en mode visualisation @@ -396,14 +407,12 @@ else print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; print ''; @@ -446,7 +455,7 @@ else print ''; - print '';
'.$langs->trans("UserTitle").''; - print $form->select_civilite($obj->civilite); + print '
'.$langs->trans("UserTitle").''; + print $form->select_civilite($contact->civilite_id); print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
Poste/Fonction
'.$langs->trans("Address").'
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; print '
Tel Perso
Portable'.$langs->trans("Fax").'
'.$langs->trans("Fax").'
'.$langs->trans("Email").'
Jabberid
'.$langs->trans("Note").'
'.$langs->trans("Note").'
'.$langs->trans("BillingContact").''; print $form->selectyesno("facturation",$contact->facturation); @@ -287,13 +290,21 @@ if ($_GET["action"] == 'create') print ""; } -elseif ($_GET["action"] == 'edit') +elseif ($_GET["action"] == 'edit' && $_GET["id"]) { /* * Fiche en mode edition * */ + // Affiche les erreurs + if (sizeof($error)) + { + print "
"; + print join("
",$error); + print "
\n"; + } + print '
'; print ''; print ''; @@ -307,11 +318,11 @@ elseif ($_GET["action"] == 'edit') $objsoc = new Societe($db); $objsoc->fetch($contact->socid); - print '
'.$langs->trans("Company").''.$objsoc->nom_url.'
'.$langs->trans("Company").''.$objsoc->nom_url.'
'.$langs->trans("Company").''; + print '
'.$langs->trans("Company").''; print $langs->trans("ContactNotLinkedToCompany"); print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
Poste/Fonction
Portable'.$langs->trans("Fax").'
'.$langs->trans("EMail").'
'.$langs->trans("EMail").'
Jabberid
Jabberid
'.$langs->trans("Note").''; - print '
'.$langs->trans("UserTitle").''; - //TODO Aller chercher le libellé de la civilite a partir de l'id $contact->civilite_id - //print '
Titre : '.$contact->civilite."
"; - print $contact->civilite_id; + print '
'.$langs->trans("UserTitle").''; + print $form->civilite_name($contact->civilite_id); print '
'.$langs->trans("Lastname").''.$contact->name.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Lastname").''.$contact->name.''.$langs->trans("Firstname").''.$contact->firstname.'
Poste/Fonction'.$contact->poste.'
Jabberid'.$contact->jabberid.'
'.$langs->trans("Note").''; + print '
'.$langs->trans("Note").''; print nl2br($contact->note); print '