From 44e2cd21940b14092363f8f66c5903427ec4d24f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 01:20:03 +0200 Subject: [PATCH] Prepare code to manage task_datehour with task_date. --- htdocs/install/mysql/migration/repair.sql | 2 ++ htdocs/projet/class/task.class.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index fbc1572a2ab..57a89440343 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -149,6 +149,8 @@ UPDATE llx_actioncomm set fk_user_action = fk_user_done where fk_user_done > 0 a UPDATE llx_actioncomm set fk_user_action = fk_user_author where fk_user_author > 0 and (fk_user_action is null or fk_user_action = 0); +UPDATE llx_projet_task_time set task_datehour = task_date where task_datehour IS NULL and task_date IS NOT NULL; + -- Requests to clean old tables or external modules tables diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 2449d638405..2f25e2f3c2c 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -60,6 +60,7 @@ class Task extends CommonObject var $timespent_duration; var $timespent_old_duration; var $timespent_date; + var $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) var $timespent_fk_user; var $timespent_note; @@ -744,18 +745,21 @@ class Task extends CommonObject // Clean parameters if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); - + if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time ("; $sql.= "fk_task"; $sql.= ", task_date"; + $sql.= ", task_datehour"; $sql.= ", task_duration"; $sql.= ", fk_user"; $sql.= ", note"; $sql.= ") VALUES ("; $sql.= $this->id; $sql.= ", '".$this->db->idate($this->timespent_date)."'"; + $sql.= ", '".$this->db->idate($this->timespent_datehour)."'"; $sql.= ", ".$this->timespent_duration; $sql.= ", ".$this->timespent_fk_user; $sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); @@ -919,12 +923,14 @@ class Task extends CommonObject $ret = 0; // Clean parameters + if (empty($this->timespent_datehour)) $this->timespent_datehour = $this->timespent_date; if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note); - + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; $sql.= " task_date = '".$this->db->idate($this->timespent_date)."',"; + $sql.= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; $sql.= " task_duration = ".$this->timespent_duration.","; $sql.= " fk_user = ".$this->timespent_fk_user.","; $sql.= " note = ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null");