From 922929fffbb48ee17bcdcaddb840883b0d252b08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2013 11:17:54 +0100 Subject: [PATCH] Fix: Missing column Fix: Line was not added correctly Fix: Missing message --- htdocs/core/lib/project.lib.php | 49 ++++++++++++++++++--------------- htdocs/projet/activity/list.php | 44 +++++++++++++++++------------ 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 1f8f380e494..5e096760fce 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1,28 +1,28 @@ +/* Copyright (C) 2006-2013 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 -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* or see http://www.gnu.org/ -*/ + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ /** * \file htdocs/core/lib/project.lib.php * \brief Functions used by project module * \ingroup project -*/ + */ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -473,19 +473,24 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr print ''; // Planned Workload - print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'all'); + print ''; + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); else print '--:--'; print ''; - // Progress + // Progress declared % print ''; print $lines[$i]->progress.' %'; print ''; // Time spent print ''; - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); + if ($lines[$i]->duration) + { + print ''; + print convertSecondToTime($lines[$i]->duration,'allhourmin'); + print ''; + } else print '--:--'; print "\n"; diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php index 5d5eacfcbda..e9cb8568b65 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 François Legastelois * @@ -56,35 +56,42 @@ if ($action == 'addtime' && $user->rights->projet->creer) { $task = new Task($db); - $timespent_duration=0; + $timespent_duration=array(); foreach($_POST as $key => $time) { - if(intval($time)>0) + if (intval($time) > 0) { // Hours or minutes - if(preg_match("/([0-9]+)(hour|min)/",$key,$matches)) + if (preg_match("/([0-9]+)(hour|min)/",$key,$matches)) { $id = $matches[1]; - - // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration += $time*60*60; - - // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration += $time*60; + if ($id > 0) + { + // We store HOURS in seconds + if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + + // We store MINUTES in seconds + if($matches[2]=='min') $timespent_duration[$id] += $time*60; + } } } } - if ($timespent_duration > 0) + if (count($timespent_duration) > 0) { - $task->fetch($id); - $task->timespent_duration = $timespent_duration; - $task->timespent_fk_user = $user->id; - $task->timespent_date = dol_mktime(12,0,0,$_POST["{$id}month"],$_POST["{$id}day"],$_POST["{$id}year"]); - $task->addTimeSpent($user); - - // header to avoid submit twice on back + foreach($timespent_duration as $key => $val) + { + $task->fetch($key); + $task->timespent_duration = $val; + $task->timespent_fk_user = $user->id; + $task->timespent_date = dol_mktime(12,0,0,$_POST["{$key}month"],$_POST["{$key}day"],$_POST["{$key}year"]); + $task->addTimeSpent($user); + } + + setEventMessage($langs->trans("RecordSaved")); + + // Redirect to avoid submit twice on back header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:'')); exit; } @@ -144,6 +151,7 @@ print ''.$langs->trans("RefTask").''; print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("DateStart").''; print ''.$langs->trans("DateEnd").''; +print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("Progress").''; print ''.$langs->trans("TimeSpent").''; print ''.$langs->trans("AddDuration").'';