diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php index c1bd319f305..76f2b39f09c 100644 --- a/htdocs/projet/activity/list.php +++ b/htdocs/projet/activity/list.php @@ -66,9 +66,6 @@ if ($_POST["action"] == 'addtime' && $user->rights->projet->creer) { if ($time > 0) { - $time = intval($time)+(($time-intval($time))*(1+2/3)); - $time = price2num($time); - $id = str_replace("task","",$key); $task = new Task($db); diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php index 3946bb03987..63f3e6b61e5 100644 --- a/htdocs/projet/tasks/task.class.php +++ b/htdocs/projet/tasks/task.class.php @@ -596,17 +596,24 @@ class Task extends CommonObject function addTimeSpent($user, $notrigger=0) { $result = 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 ("; $sql.= "fk_task"; $sql.= ", task_date"; $sql.= ", task_duration"; $sql.= ", fk_user"; + $sql.= ", note"; $sql.= ") VALUES ("; $sql.= $this->id; $sql.= ", '".$this->db->idate($this->timespent_date)."'"; $sql.= ", ".$this->timespent_duration; $sql.= ", ".$user->id; + $sql.= ", ".(isset($this->timespent_note)?"'".addslashes($this->timespent_note)."'":"null"); $sql.= ")"; dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 601af23ed05..fea200ed241 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -33,6 +33,27 @@ if (!$user->rights->projet->lire) accessforbidden(); /* * Actions */ +if ($_POST["action"] == 'addtimespent' && $user->rights->projet->creer) +{ + if ($_POST["timespent_note"] && $_POST["timespent_duration"]) + { + $task = new Task($db); + $task->fetch($_POST["id"]); + + $task->timespent_note = $_POST["timespent_note"]; + $task->timespent_duration = $_POST["timespent_duration"]; + $task->timespent_date = dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); + + $task->addTimeSpent($user); + } + else + { + $langs->load("errors"); + $mesg='
| '.$langs->trans("Note").' | '; + print ''.$langs->trans("Date").' | '; + print ''.$langs->trans("Duration").' | '; + print "|
| '; + print ''; + print ' | '; + + // Date + print ''; + print $html->select_date('','time','','','',"timespent_date"); + print ' | '; + + // Duration + print ''; + print ''; + print ' | '; + + print ''; + print ''; + print ' |