Add user affected to action

Add user that did action
Add user that modified action in log
This commit is contained in:
Laurent Destailleur 2008-02-11 15:51:03 +00:00
parent 4e4d659667
commit 850a62a660
6 changed files with 137 additions and 48 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* $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;

View File

@ -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 <EFBFBD> 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 '</td></tr>';
// Si la societe est impos<EFBFBD>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 '<tr><td nowrap>'.$langs->trans("ActionAffectedTo").'</td><td>';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($_REQUEST["affectedto"],'affectedto',1);
print '</td></tr>';
// Realise par
print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td>';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($_REQUEST["doneby"],'doneby',1);
print '</td></tr>';
// Date planification
@ -430,7 +457,7 @@ if ($_GET["action"] == 'create')
print '<table class="border" width="100%">';
// Type d'action actifs
print '<tr><td>'.$langs->trans("Type").'</td><td>';
print '<tr><td><b>'.$langs->trans("Type").'*</b></td><td>';
if ($_GET["actioncode"])
{
print '<input type="hidden" name="actioncode" value="'.$_GET["actioncode"].'">'."\n";
@ -470,12 +497,12 @@ if ($_GET["action"] == 'create')
// Affecte a
print '<tr><td nowrap>'.$langs->trans("ActionAffectedTo").'</td><td>';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($_REQUEST["affectedto"],'affectedto',1);
print '</td></tr>';
// Realise par
print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td>';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($_REQUEST["doneby"],'doneby',1);
print '</td></tr>';
// 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<61>tre est le login, hors seul l'id est charg<72>.
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 '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
print '<input type="text" name="priority" value="'.$act->priority.'" size="5">';
print '</td></tr>';
// Affecte a
print '<tr><td nowrap>'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($act->usertodo->id,'affectedto',1);
print '</td></tr>';
// Realise par
print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
$html->select_users($act->userdone->id,'doneby',1);
print '</td></tr>';
// Date planification
@ -707,17 +739,17 @@ if ($_GET["id"])
// Priorite
print '<tr><td nowrap>'.$langs->trans("Priority").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
print $act->priority;
print '</td></tr>';
// Affecte a
print '<tr><td nowrap>'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
if ($act->usertodo->id) print $act->usertodo->getNomUrl(1);
print '</td></tr>';
// Realise par
print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td colspan="3">';
print $langs->trans("FeatureNotYetSupported");
if ($act->userdone->id) print $act->userdone->getNomUrl(1);
print '</td></tr>';
// Date planification

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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");

View File

@ -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 '<link rel="stylesheet" type="text/css" title="default" href="'.DOL_URL_ROOT.'/'.$conf->css.'">'."\n";
print '<link rel="stylesheet" type="text/css" media="print" href="'.DOL_URL_ROOT.'/theme/print.css">'."\n";
if (is_array($arrayofcss))
{
foreach($arrayofcss as $cssfile)
{
print '<link rel="stylesheet" type="text/css" title="default" href="'.DOL_URL_ROOT.'/'.$cssfile.'">'."\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 '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
print '<link rel="author" title="Dolibarr Development Team" href="http://www.dolibarr.org">'."\n";
// Output javascript links
if (! $disablejs && $conf->use_javascript_ajax)
{
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n";
@ -707,6 +718,13 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0)
//print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/window/tooltip.js"></script>'."\n";
}
}
if (is_array($arrayofjs))
{
foreach($arrayofjs as $jsfile)
{
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/'.$jsfile.'"></script>'."\n";
}
}
print "</head>\n";
}
@ -774,13 +792,15 @@ function top_menu($head, $title="", $target="")
if (! isset($_SERVER["REMOTE_USER"]) || ! $_SERVER["REMOTE_USER"])
{
$title=$langs->trans("Logout").'<br>';
$title.='<br><b>'.$langs->trans("User").'</b>: '.$user->fullname;
$title.='<br><u>'.$langs->trans("User").'</u>';
$title.='<br><b>'.$langs->trans("Name").'</b>: '.$user->fullname;
$title.='<br><b>'.$langs->trans("Login").'</b>: '.$user->login;
$title.='<br><b>'.$langs->trans("Administrator").'</b>: '.yn($user->admin);
$title.='<br><b>'.$langs->trans("Type").'</b>: '.($user->societe_id?$langs->trans("External"):$langs->trans("Internal"));
$title.='<br>';
$title.='<br><u>'.$langs->trans("Connection").'</u>';
$title.='<br><b>'.$langs->trans("ConnectedSince").'</b>: '.dolibarr_print_date($user->datelastlogin,"dayhour");
$title.='<br><b>'.$langs->trans("PreviousConnexion").'</b>: '.dolibarr_print_date($user->datepreviouslogin,"dayhour");
if ($dolibarr_main_authentication) $title.='<br><b>'.$langs->trans("AuthenticationMode").'</b>: '.$dolibarr_main_authentication;
$text='';

View File

@ -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

View File

@ -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,