Skip to content
Snippets Groups Projects
Commit e51a002c authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: management of time spent in task card

Fix: Update time spent in seconds
parent d9fabf96
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,7 @@ class Task extends CommonObject
var $timespent_id;
var $timespent_duration;
var $timespent_old_duration;
var $timespent_date;
var $timespent_fk_user;
var $timespent_note;
......@@ -597,8 +598,6 @@ class Task extends CommonObject
$ret = 0;
// Clean parameters
$this->timespent_duration = intval($this->timespent_duration)+(($this->timespent_duration-intval($this->timespent_duration))*(1+2/3));
$this->timespent_duration = price2num($this->timespent_duration);
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (";
......@@ -713,8 +712,6 @@ class Task extends CommonObject
$ret = 0;
// Clean parameters
$this->timespent_duration = intval($this->timespent_duration)+(($this->timespent_duration-intval($this->timespent_duration))*(1+2/3));
$this->timespent_duration = price2num($this->timespent_duration);
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
......@@ -744,14 +741,16 @@ class Task extends CommonObject
dol_syslog(get_class($this)."::updateTimeSpent error -1 ".$this->error,LOG_ERR);
$ret = -1;
}
/*
if ($ret >= 0)
if ($ret == 1 && ($this->timespent_old_duration != $this->timespent_duration))
{
$newDuration = $this->timespent_duration - $this->timespent_old_duration;
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'";
$sql.= " SET duration_effective = duration_effective + '".$newDuration."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::updateTimeSpent sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql) )
{
$this->error=$this->db->lasterror();
......@@ -759,7 +758,7 @@ class Task extends CommonObject
$ret = -2;
}
}
*/
return $ret;
}
......@@ -800,7 +799,7 @@ class Task extends CommonObject
if (! $error)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET duration_effective = duration_effective - '".price2num($this->timespent_duration)."'";
$sql.= " SET duration_effective = duration_effective - '".$this->timespent_duration."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delTimeSpent sql=".$sql, LOG_DEBUG);
......
......@@ -79,7 +79,7 @@ if ($_POST["action"] == 'updateline' && ! $_POST["cancel"] && $user->rights->pro
{
$error=0;
if (empty($_POST["timespent_duration_linehour"]) && empty($_POST["timespent_duration_linemin"]))
if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"]))
{
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")).'</div>';
$error++;
......@@ -88,11 +88,13 @@ if ($_POST["action"] == 'updateline' && ! $_POST["cancel"] && $user->rights->pro
if (! $error)
{
$task = new Task($db);
$task->fetch($_POST["id"]);
$task->timespent_id = $_POST["lineid"];
$task->timespent_note = $_POST["timespent_note_line"];
$task->timespent_duration = $_POST["timespent_duration_linehour"]*60*60; // We store duration in seconds
$task->timespent_duration+= $_POST["timespent_duration_linemin"]*60; // We store duration in seconds
$task->timespent_old_duration = $_POST["old_duration"];
$task->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds
$task->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds
$task->timespent_date = dol_mktime(12,0,0,$_POST["timelinemonth"],$_POST["timelineday"],$_POST["timelineyear"]);
$task->timespent_fk_user = $_POST["userid_line"];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment