From aafc56e7f41b71115821bf5740dcba986340179e Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 14 Jul 2011 15:37:37 +0000 Subject: [PATCH] Proyects: Add Total time to tasks tables --- htdocs/lib/project.lib.php | 17 +++++++++++++++-- htdocs/projet/tasks/time.php | 14 ++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 2d5ec19e880..ce197938ea7 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * 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 @@ -22,7 +23,7 @@ * \file htdocs/lib/project.lib.php * \brief Functions used by project module * \ingroup project - * \version $Id: project.lib.php,v 1.68 2011/07/04 09:01:38 eldy Exp $ + * \version $Id: project.lib.php,v 1.69 2011/07/14 15:37:37 simnandez Exp $ */ require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); @@ -98,7 +99,7 @@ function project_prepare_head($object) * \file htdocs/lib/project.lib.php * \brief Ensemble de fonctions de base pour le module projet * \ingroup societe - * \version $Id: project.lib.php,v 1.68 2011/07/04 09:01:38 eldy Exp $ + * \version $Id: project.lib.php,v 1.69 2011/07/14 15:37:37 simnandez Exp $ */ function task_prepare_head($object) { @@ -375,6 +376,9 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole $projectsArrayId=explode(',',$projectsListId); $numlines=sizeof($lines); + + $total=0; + for ($i = 0 ; $i < $numlines ; $i++) { if ($parent == 0) $level = 0; @@ -485,6 +489,7 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole $level++; if ($lines[$i]->id) PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId); $level--; + $total += $lines[$i]->duration; } } else @@ -493,6 +498,14 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole } } + if ($total>0) + { + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''.ConvertSecondToTime($total).''; + } + return $inc; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index bf80c36e7ed..ad10c1b51d8 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 2010 Regis Houssin + * Copyright (C) 2011 Juanjo Menent * * 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 @@ -22,7 +23,7 @@ * \file htdocs/projet/tasks/time.php * \ingroup projet * \brief Page to add new time spent on a task - * \version $Id$ + * \version $Id: time.php,v 1.32 2011/07/14 15:37:37 simnandez Exp $ */ require("../../main.inc.php"); @@ -307,7 +308,8 @@ if ($_GET["id"] > 0) print ''.$langs->trans("Duration").''; print ' '; print "\n"; - + + $total = 0; foreach ($tasks as $task_time) { $var=!$var; @@ -389,8 +391,12 @@ if ($_GET["id"] > 0) print ''; print "\n"; + $total += $task_time->task_duration; } - + print ''.$langs->trans("Total").''; + print ''.ConvertSecondToTime($total).' '; + print ''; + print ""; print ""; } @@ -398,5 +404,5 @@ if ($_GET["id"] > 0) $db->close(); -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/07/14 15:37:37 $ - $Revision: 1.32 $'); ?>