diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 0fb148e0f40032116a12c92e4ccea51e4db16611..fef128888d2e208d619ade0cad30a3f8e33b372d 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1064,4 +1064,8 @@ CREATE TABLE llx_payment_salary ( --New 1074 : Stock mouvement link to origin ALTER TABLE llx_stock_mouvement ADD fk_origin INT NOT NULL ; -ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ; \ No newline at end of file +ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR( 32 ) NOT NULL ; + +--NEw 1300 : Add THM on user +ALTER TABLE llx_user ADD thm FLOAT NOT NULL ; +ALTER TABLE llx_projet_task_time ADD thm FLOAT NOT NULL ; \ No newline at end of file diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index e60aaa9a38a73e07d845c652244f9cb668333119..214c64b94f9bdddf08d083b5e7ccfef31d746dae 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -767,8 +767,8 @@ class Task extends CommonObject dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG); if ($this->db->query($sql) ) { - $task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); - $ret = $task_id; + $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); + $ret = $tasktme_id; if (! $notrigger) { @@ -793,6 +793,21 @@ class Task extends CommonObject $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'"; $sql.= " WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG); + if (! $this->db->query($sql) ) + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::addTimeSpent error -2 ".$this->error, LOG_ERR); + $ret = -2; + } + } + + if ($ret >= 0) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; + $sql.= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; + $sql.= " WHERE rowid = ".$tasktime_id; + dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql) ) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 09a458ff09911b10084210d7dd8f6ead773d0531..965088d73580ff7e6dd6126c41ff89a6c3ee8d24 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -100,6 +100,7 @@ class User extends CommonObject var $parentof; // To store an array of all parents for all ids. var $accountancy_code; // Accountancy code in prevision of the complete accountancy module + var $thm; // Average cost of employee /** @@ -154,6 +155,7 @@ class User extends CommonObject $sql.= " u.photo as photo,"; $sql.= " u.openid as openid,"; $sql.= " u.accountancy_code,"; + $sql.= " u.thm,"; $sql.= " u.ref_int, u.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -216,6 +218,7 @@ class User extends CommonObject $this->lang = $obj->lang; $this->entity = $obj->entity; $this->accountancy_code = $obj->accountancy_code; + $this->thm = $obj->thm; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); @@ -1135,6 +1138,7 @@ class User extends CommonObject $this->zip = empty($this->zip)?'':$this->zip; $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); + $this->thm = price2num($this->thm); // Check parameters if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -1165,6 +1169,7 @@ class User extends CommonObject $sql.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", thm = ".$this->thm; $sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null");