diff --git a/ChangeLog b/ChangeLog index 6e28faee427..70b14ebc579 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ For users: - Show greyed lines for not allowed export filters. - Add nature in product fields (manufactured product or not). - Add export filters for category module. +- Can choose login of dolibarr account created when create from contact For translators: - The errors language file contains only error or warning messages with diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index b0c564b242f..ba1961d6840 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -51,37 +51,32 @@ $result = restrictedArea($user, 'contact', $contactid, 'socpeople'); */ // Creation utilisateur depuis contact -if ($user->rights->user->user->creer) +if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) { - if ($_GET["action"] == 'create_user') + // Recuperation contact actuel + $contact = new Contact($db); + $result = $contact->fetch($_GET["id"]); + + if ($result > 0) { - // Recuperation contact actuel - $contact = new Contact($db); - $result = $contact->fetch($_GET["id"]); + // Creation user + $nuser = new User($db); + $result=$nuser->create_from_contact($contact,$_POST["login"]); - if ($result > 0) + if ($result < 0) { - // Creation user - $nuser = new User($db); - $result=$nuser->create_from_contact($contact); - - if ($result < 0) - { - $msg=$nuser->error; - } - } - else - { - $msg=$contact->error; + $msg=$nuser->error; } } + else + { + $msg=$contact->error; + } } // Creation contact -if ($user->rights->societe->contact->creer) +if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer) { - if ($_POST["action"] == 'add') - { $contact = new Contact($db); $contact->socid = $_POST["socid"]; @@ -124,67 +119,60 @@ if ($user->rights->societe->contact->creer) $_GET["action"] = 'create'; } } - } } -if ($user->rights->societe->contact->supprimer) +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->contact->supprimer) { - if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') + $contact = new Contact($db); + $result=$contact->fetch($_GET["id"]); + + $contact->old_name = $_POST["old_name"]; + $contact->old_firstname = $_POST["old_firstname"]; + + $result = $contact->delete(); + + Header("Location: index.php"); + exit; +} + +if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) +{ + $contact = new Contact($db); + + $contact->old_name = $_POST["old_name"]; + $contact->old_firstname = $_POST["old_firstname"]; + + $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->priv = $_POST["priv"]; + + $contact->note = $_POST["note"]; + + $result = $contact->update($_POST["contactid"], $user); + + if ($result > 0) { - $contact = new Contact($db); - $result=$contact->fetch($_GET["id"]); - - $contact->old_name = $_POST["old_name"]; - $contact->old_firstname = $_POST["old_firstname"]; - - $result = $contact->delete(); - - Header("Location: index.php"); - exit; + $contact->old_name=''; + $contact->old_firstname=''; } -} - -if ($user->rights->societe->contact->creer) -{ - if ($_POST["action"] == 'update' && ! $_POST["cancel"]) + else { - $contact = new Contact($db); - - $contact->old_name = $_POST["old_name"]; - $contact->old_firstname = $_POST["old_firstname"]; - - $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->priv = $_POST["priv"]; - - $contact->note = $_POST["note"]; - - $result = $contact->update($_POST["contactid"], $user); - - if ($result > 0) - { - $contact->old_name=''; - $contact->old_firstname=''; - } - else - { - $error = $contact->error; - } + $error = $contact->error; } } @@ -484,8 +472,24 @@ if ($_GET["id"] && $_GET["action"] != 'edit') * Fiche en mode visualisation * */ - if ($msg) print '