Fix: Missing column

Fix: Line was not added correctly
Fix: Missing message
This commit is contained in:
Laurent Destailleur 2013-11-05 11:17:54 +01:00
parent 0587ad5af8
commit 922929fffb
2 changed files with 53 additions and 40 deletions

View File

@ -1,28 +1,28 @@
<?php <?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*/ */
/** /**
* \file htdocs/core/lib/project.lib.php * \file htdocs/core/lib/project.lib.php
* \brief Functions used by project module * \brief Functions used by project module
* \ingroup project * \ingroup project
*/ */
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -473,19 +473,24 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr
print '</td>'; print '</td>';
// Planned Workload // Planned Workload
print '<td align="center">'; print '<td align="right">';
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'all'); if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin');
else print '--:--'; else print '--:--';
print '</td>'; print '</td>';
// Progress // Progress declared %
print '<td align="right">'; print '<td align="right">';
print $lines[$i]->progress.' %'; print $lines[$i]->progress.' %';
print '</td>'; print '</td>';
// Time spent // Time spent
print '<td align="right">'; print '<td align="right">';
if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,'all'); if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
print convertSecondToTime($lines[$i]->duration,'allhourmin');
print '</a>';
}
else print '--:--'; else print '--:--';
print "</td>\n"; print "</td>\n";

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 François Legastelois <flegastelois@teclib.com> * Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
* *
@ -56,35 +56,42 @@ if ($action == 'addtime' && $user->rights->projet->creer)
{ {
$task = new Task($db); $task = new Task($db);
$timespent_duration=0; $timespent_duration=array();
foreach($_POST as $key => $time) foreach($_POST as $key => $time)
{ {
if(intval($time)>0) if (intval($time) > 0)
{ {
// Hours or minutes // Hours or minutes
if(preg_match("/([0-9]+)(hour|min)/",$key,$matches)) if (preg_match("/([0-9]+)(hour|min)/",$key,$matches))
{ {
$id = $matches[1]; $id = $matches[1];
if ($id > 0)
// We store HOURS in seconds {
if($matches[2]=='hour') $timespent_duration += $time*60*60; // 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 += $time*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); foreach($timespent_duration as $key => $val)
$task->timespent_duration = $timespent_duration; {
$task->timespent_fk_user = $user->id; $task->fetch($key);
$task->timespent_date = dol_mktime(12,0,0,$_POST["{$id}month"],$_POST["{$id}day"],$_POST["{$id}year"]); $task->timespent_duration = $val;
$task->addTimeSpent($user); $task->timespent_fk_user = $user->id;
$task->timespent_date = dol_mktime(12,0,0,$_POST["{$key}month"],$_POST["{$key}day"],$_POST["{$key}year"]);
// header to avoid submit twice on back $task->addTimeSpent($user);
}
setEventMessage($langs->trans("RecordSaved"));
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:'')); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:''));
exit; exit;
} }
@ -144,6 +151,7 @@ print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>'; print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>'; print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>'; print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>'; print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';