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,5 +1,5 @@
<?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>
* *
@ -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,7 +56,7 @@ 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)
{ {
@ -66,25 +66,32 @@ if ($action == 'addtime' && $user->rights->projet->creer)
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 // We store HOURS in seconds
if($matches[2]=='hour') $timespent_duration += $time*60*60; if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60;
// We store MINUTES in seconds // We store MINUTES in seconds
if($matches[2]=='min') $timespent_duration += $time*60; 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->fetch($key);
$task->timespent_duration = $val;
$task->timespent_fk_user = $user->id; $task->timespent_fk_user = $user->id;
$task->timespent_date = dol_mktime(12,0,0,$_POST["{$id}month"],$_POST["{$id}day"],$_POST["{$id}year"]); $task->timespent_date = dol_mktime(12,0,0,$_POST["{$key}month"],$_POST["{$key}day"],$_POST["{$key}year"]);
$task->addTimeSpent($user); $task->addTimeSpent($user);
}
// header to avoid submit twice on back 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>';