From 850a62a6607d514e6eab988a111704565c89ac2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Feb 2008 15:51:03 +0000 Subject: [PATCH] Add user affected to action Add user that did action Add user that modified action in log --- htdocs/actioncomm.class.php | 62 +++++++++++++++++++++++------ htdocs/comm/action/fiche.php | 70 ++++++++++++++++++++++++--------- htdocs/comm/action/info.php | 9 ++--- htdocs/main.inc.php | 36 +++++++++++++---- mysql/migration/2.2.0-2.4.0.sql | 4 +- mysql/tables/llx_actioncomm.sql | 4 +- 6 files changed, 137 insertions(+), 48 deletions(-) diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index a7a07d00f6c..a785a8acd39 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * $Id$ * $Source$ @@ -24,7 +24,7 @@ \file htdocs/actioncomm.class.php \ingroup commercial \brief Fichier de la classe des actions commerciales - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT.'/cactioncomm.class.php'); @@ -45,19 +45,26 @@ class ActionComm var $id; var $label; + var $datec; // Date creation enregistrement (datec) var $datem; // Date modif enregistrement (tms) + var $author; // User that create action + var $usermod; // User that modified action + var $datep; // Date action planifie debut (datep) var $datef; // Date action planifie fin var $date; // Date action realise completement (datea) var $priority; - var $user; - var $author; + + var $usertodo; // User that must do action + var $userdone; // User that did action + var $societe; var $contact; var $note; var $percentage; + /** * \brief Constructeur * \param db Handler d'accès base de donnée @@ -67,6 +74,9 @@ class ActionComm $this->db = $db; $this->societe = new Societe($db); $this->author = new User($db); + $this->usermod = new User($db); + $this->usertodo = new User($db); + $this->userdone = new User($db); if (class_exists("Contact")) { $this->contact = new Contact($db); @@ -115,14 +125,21 @@ class ActionComm $sql.= "(datec,"; if ($this->datep) $sql.= "datep,"; if ($this->date) $sql.= "datea,"; - $sql.= "fk_action,fk_soc,note,fk_contact,fk_user_author,fk_user_action,label,percent,priority,"; + $sql.= "fk_action,fk_soc,note,fk_contact,"; + $sql.= "fk_user_author,"; + $sql.= "fk_user_action,"; + $sql.= "fk_user_done,"; + $sql.= "label,percent,priority,"; $sql.= "fk_facture,propalrowid,fk_commande)"; $sql.= " VALUES (now(),"; if ($this->datep) $sql.= "'".$this->db->idate($this->datep)."',"; if ($this->date) $sql.= "'".$this->db->idate($this->date)."',"; $sql.= "'".$this->type_id."', '".$this->societe->id."' ,'".addslashes($this->note)."',"; $sql.= ($this->contact->id?$this->contact->id:"null").","; - $sql.= "'$author->id', '".$this->user->id ."', '".addslashes($this->label)."','".$this->percentage."','".$this->priority."',"; + $sql.= "'".$author->id."',"; + $sql.= ($this->usertodo->id?"'".$this->usertodo->id."'":"null").","; + $sql.= ($this->userdone->id?"'".$this->userdone->id."'":"null").","; + $sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."',"; $sql.= ($this->facid?$this->facid:"null").","; $sql.= ($this->propalrowid?$this->propalrowid:"null").","; $sql.= ($this->orderrowid?$this->orderrowid:"null"); @@ -168,12 +185,16 @@ class ActionComm $sql.= " ".$this->db->pdate("a.datep")." as datep,"; $sql.= " ".$this->db->pdate("a.datec")." as datec, tms as datem,"; $sql.= " a.note, a.label, a.fk_action as type_id,"; - $sql.= " fk_soc, fk_user_author, fk_contact, fk_facture, a.percent as percentage, a.fk_commande,"; + $sql.= " a.fk_soc,"; + $sql.= " a.fk_user_author, a.fk_user_mod,"; + $sql.= " a.fk_user_action, a.fk_user_done,"; + $sql.= " a.fk_contact, a.fk_facture, a.percent as percentage, a.fk_commande,"; + $sql.= " a.priority,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c"; $sql.= " WHERE a.id=".$id." AND a.fk_action=c.id"; - dolibarr_syslog("ActionComm.class::fetch sql=".$sql); + dolibarr_syslog("ActionComm::fetch sql=".$sql); $resql=$this->db->query($sql); if ($resql) @@ -196,7 +217,13 @@ class ActionComm $this->note =$obj->note; $this->percentage =$obj->percentage; $this->societe->id = $obj->fk_soc; - $this->author->id = $obj->fk_user_author; + $this->author->id = $obj->fk_user_author; + $this->usermod->id = $obj->fk_user_mod; + + $this->usertodo->id = $obj->fk_user_action; + $this->userdone->id = $obj->fk_user_done; + $this->priority = $obj->priority; + $this->contact->id = $obj->fk_contact; $this->fk_facture = $obj->fk_facture; if ($this->fk_facture) @@ -253,7 +280,7 @@ class ActionComm * Si percentage = 100, on met a jour date 100% * \return int <0 si ko, >0 si ok */ - function update() + function update($user) { $this->label=trim($this->label); $this->note=trim($this->note); @@ -266,8 +293,13 @@ class ActionComm $sql.= ", datea = ".($this->date ? "'".$this->db->idate($this->date)."'" : 'null'); if ($this->note) $sql.= ", note = '".addslashes($this->note)."'"; if ($this->contact->id) $sql.= ", fk_contact =". $this->contact->id; + $sql.= ", priority = '".$this->priority."'"; + $sql.= ", fk_user_mod = '".$user->id."'"; + $sql.= ", fk_user_action='".$this->usertodo->id."'"; + $sql.= ", fk_user_done='".$this->userdone->id."'"; $sql.= " WHERE id=".$this->id; + dolibarr_syslog("ActionComm::update sql=".$sql); if ($this->db->query($sql)) { return 1; @@ -323,10 +355,12 @@ class ActionComm { $sql = 'SELECT a.id, '.$this->db->pdate('a.datec').' as datec,'; $sql.= ' '.$this->db->pdate('tms').' as datem,'; - $sql.= ' fk_user_author'; + $sql.= ' fk_user_author,'; + $sql.= ' fk_user_mod'; $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; $sql.= ' WHERE a.id = '.$id; + dolibarr_syslog("ActionComm::info sql=".$sql); $result=$this->db->query($sql); if ($result) { @@ -340,6 +374,12 @@ class ActionComm $cuser->fetch(); $this->user_creation = $cuser; } + if ($obj->fk_user_mod) + { + $muser = new User($this->db, $obj->fk_user_mod); + $muser->fetch(); + $this->user_modification = $muser; + } $this->date_creation = $obj->datec; $this->date_modification = $obj->datem; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 40a4509610b..997357502d5 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -17,15 +17,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ */ /** \file htdocs/comm/action/fiche.php \ingroup commercial \brief Page de la fiche action - \version $Revision$ + \version $Id$ */ require_once("./pre.inc.php"); @@ -157,7 +155,20 @@ if ($_POST["action"] == 'add_action') $actioncomm->percentage = isset($_POST["percentage"])?$_POST["percentage"]:0; } $actioncomm->duree=(($_POST["dureehour"] * 60) + $_POST["dureemin"]) * 60; - $actioncomm->user = $user; + + $usertodo=new User($db,$_POST["affectedto"]); + if ($_POST["affectedto"]) + { + $usertodo->fetch(); + } + $actioncomm->usertodo = $usertodo; + $userdone=new User($db,$_POST["doneby"]); + if ($_POST["doneby"]) + { + $userdone->fetch(); + } + $actioncomm->userdone = $userdone; + $actioncomm->note = trim($_POST["note"]); if (isset($_POST["contactid"])) $actioncomm->contact = $contact; if (isset($_REQUEST["socid"]) && $_REQUEST["socid"] > 0) @@ -232,7 +243,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') } /* - * Action mise � jour de l'action + * Action mise a jour de l'action * */ if ($_POST["action"] == 'update') @@ -263,13 +274,29 @@ if ($_POST["action"] == 'update') //print $actioncomm->datep; $actioncomm->label = $_POST["label"]; $actioncomm->percentage = $_POST["percentage"]; + $actioncomm->priority = $_POST["priority"]; $actioncomm->contact->id = $_POST["contactid"]; $actioncomm->note = $_POST["note"]; if ($actioncomm->type_code == 'AC_RDV' && $actioncomm->percentage == 100 && ! $actioncomm->date) { $actioncomm->date = $actioncomm->datep; } - $result=$actioncomm->update(); + + // Users + $usertodo=new User($db,$_POST["affectedto"]); + if ($_POST["affectedto"]) + { + $usertodo->fetch(); + } + $actioncomm->usertodo = $usertodo; + $userdone=new User($db,$_POST["doneby"]); + if ($_POST["doneby"]) + { + $userdone->fetch(); + } + $actioncomm->userdone = $userdone; + + $result=$actioncomm->update($user); } if ($result < 0) @@ -343,7 +370,7 @@ if ($_GET["action"] == 'create') } print ''; - // Si la societe est impos�e, on propose ces contacts + // Si la societe est imposee, on propose ces contacts if ($_REQUEST["socid"]) { $contactid = $_REQUEST["contactid"]?$_REQUEST["contactid"]:''; @@ -354,12 +381,12 @@ if ($_GET["action"] == 'create') // Affecte a print ''.$langs->trans("ActionAffectedTo").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($_REQUEST["affectedto"],'affectedto',1); print ''; // Realise par print ''.$langs->trans("ActionDoneBy").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($_REQUEST["doneby"],'doneby',1); print ''; // Date planification @@ -430,7 +457,7 @@ if ($_GET["action"] == 'create') print ''; // Type d'action actifs - print ''; // Realise par print ''; // Avancement @@ -566,7 +593,12 @@ if ($_GET["id"]) $act = new ActionComm($db); $act->fetch($_GET["id"]); $res=$act->societe->fetch($act->societe->id); - $res=$act->author->fetch(); // Le param�tre est le login, hors seul l'id est charg�. + + if ($act->author->id) $res=$act->author->fetch(); // Le parametre est le login, hors seul l'id est charge. + if ($act->usermod->id) $res=$act->usermod->fetch(); + if ($act->usertodo->id) $res=$act->usertodo->fetch(); + if ($act->userdone->id) $res=$act->userdone->fetch(); + $res=$act->contact->fetch($act->contact->id); /* @@ -619,17 +651,17 @@ if ($_GET["id"]) // Priorite print ''; // Affecte a print ''; // Realise par print ''; // Date planification @@ -707,17 +739,17 @@ if ($_GET["id"]) // Priorite print ''; // Affecte a print ''; // Realise par print ''; // Date planification diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index ab62bb43565..e2caa1e315c 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,16 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/comm/action/info.php - \ingroup core + \ingroup agenda \brief Page des informations d'une action - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bddf79c5087..95996d846e9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -619,12 +619,15 @@ function dol_loginfunction($langs,$conf,$mysoc) /** - * \brief Affiche en-tete HTML - * \param head Lignes d'en-tete head optionnelles - * \param title Titre page web - * \param disablejs N'affiche pas les liens vers les js (Ex: qd fonction utilisee par sous formulaire Ajax) + * \brief Show HTML header + * \param head Optionnal head lines + * \param title Web page title + * \param disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax) + * \param disablehead Do not output head section + * \param arrayofjs Array of js files to add in header + * \param arrayofcss Array of css files to add in header */ -function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) +function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') { global $user, $conf, $langs, $db; @@ -666,9 +669,16 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) } print "\n"; - // Affiche style sheets et link + // Output style sheets print ''."\n"; print ''."\n"; + if (is_array($arrayofcss)) + { + foreach($arrayofcss as $cssfile) + { + print ''."\n"; + } + } // Definition en alternate style sheet des feuilles de styles les plus maintenues // Les navigateurs qui supportent sont rares. Plus aucun connu. @@ -682,6 +692,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) print ''."\n"; print ''."\n"; + // Output javascript links if (! $disablejs && $conf->use_javascript_ajax) { print ''."\n"; @@ -707,6 +718,13 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0) //print ''."\n"; } } + if (is_array($arrayofjs)) + { + foreach($arrayofjs as $jsfile) + { + print ''."\n"; + } + } print "\n"; } @@ -774,13 +792,15 @@ function top_menu($head, $title="", $target="") if (! isset($_SERVER["REMOTE_USER"]) || ! $_SERVER["REMOTE_USER"]) { $title=$langs->trans("Logout").'
'; - $title.='
'.$langs->trans("User").': '.$user->fullname; + $title.='
'.$langs->trans("User").''; + $title.='
'.$langs->trans("Name").': '.$user->fullname; $title.='
'.$langs->trans("Login").': '.$user->login; $title.='
'.$langs->trans("Administrator").': '.yn($user->admin); $title.='
'.$langs->trans("Type").': '.($user->societe_id?$langs->trans("External"):$langs->trans("Internal")); + $title.='
'; + $title.='
'.$langs->trans("Connection").''; $title.='
'.$langs->trans("ConnectedSince").': '.dolibarr_print_date($user->datelastlogin,"dayhour"); $title.='
'.$langs->trans("PreviousConnexion").': '.dolibarr_print_date($user->datepreviouslogin,"dayhour"); - if ($dolibarr_main_authentication) $title.='
'.$langs->trans("AuthenticationMode").': '.$dolibarr_main_authentication; $text=''; diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql index 2a4dceee511..84d837d733a 100644 --- a/mysql/migration/2.2.0-2.4.0.sql +++ b/mysql/migration/2.2.0-2.4.0.sql @@ -172,8 +172,8 @@ ALTER TABLE llx_element_element ALTER TABLE llx_element_element ADD INDEX idx_element_element_targetid (targetid); -ALTER TABLE llx_actioncomm add column fk_user_create integer; -ALTER TABLE llx_actioncomm add column fk_user_mod integer; +ALTER TABLE llx_actioncomm add column fk_user_mod integer after fk_user_author; +ALTER TABLE llx_actioncomm add column fk_user_done integer after fk_user_action; create table llx_events diff --git a/mysql/tables/llx_actioncomm.sql b/mysql/tables/llx_actioncomm.sql index 4e6c9a8e0b0..1ce9451faf8 100644 --- a/mysql/tables/llx_actioncomm.sql +++ b/mysql/tables/llx_actioncomm.sql @@ -34,7 +34,7 @@ create table llx_actioncomm datec datetime, -- date creation tms timestamp, -- date modif - fk_user_create integer, -- id user qui a cree l'action + fk_user_author integer, -- id user qui a cree l'action fk_user_mod integer, -- id dernier user qui a modifier l'action fk_project integer, @@ -43,7 +43,7 @@ create table llx_actioncomm fk_parent integer NOT NULL default 0, fk_user_action integer, -- id de la personne qui doit effectuer l'action - fk_user_author integer, -- id de la personne qui a effectue l'action + fk_user_done integer, -- id de la personne qui a effectue l'action priority smallint, punctual smallint NOT NULL default 1, percent smallint NOT NULL default 0,
'.$langs->trans("Type").''; + print '
'.$langs->trans("Type").'*'; if ($_GET["actioncode"]) { print ''."\n"; @@ -470,12 +497,12 @@ if ($_GET["action"] == 'create') // Affecte a print '
'.$langs->trans("ActionAffectedTo").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($_REQUEST["affectedto"],'affectedto',1); print '
'.$langs->trans("ActionDoneBy").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($_REQUEST["doneby"],'doneby',1); print '
'.$langs->trans("Priority").''; - print $langs->trans("FeatureNotYetSupported"); + print ''; print '
'.$langs->trans("ActionAffectedTo").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($act->usertodo->id,'affectedto',1); print '
'.$langs->trans("ActionDoneBy").''; - print $langs->trans("FeatureNotYetSupported"); + $html->select_users($act->userdone->id,'doneby',1); print '
'.$langs->trans("Priority").''; - print $langs->trans("FeatureNotYetSupported"); + print $act->priority; print '
'.$langs->trans("ActionAffectedTo").''; - print $langs->trans("FeatureNotYetSupported"); + if ($act->usertodo->id) print $act->usertodo->getNomUrl(1); print '
'.$langs->trans("ActionDoneBy").''; - print $langs->trans("FeatureNotYetSupported"); + if ($act->userdone->id) print $act->userdone->getNomUrl(1); print '