diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index a35ae1afafb..39c8cd80dd0 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -223,6 +223,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$numlines=count($lines);
$total=0;
+ $total_planned=0;
for ($i = 0 ; $i < $numlines ; $i++)
{
@@ -391,6 +392,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--;
$total += $lines[$i]->duration;
+ $total_planned += $lines[$i]->planned_workload;
+ // TODO fix totals in recursive calls
}
}
else
@@ -407,10 +410,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '
| ';
print ' | ';
print ' | ';
- print ' | ';
+ print ''.convertSecondToTime($total_planned, 'allhourmin').' | ';
print ' | ';
print ''.convertSecondToTime($total, 'allhourmin').' | ';
- print ' | ';
+ print '';
+ if($total_planned) print round(100 * $total / $total_planned,2).' %';
+ print ' | ';
if ($addordertick) print ' | ';
print '';
}
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 0fb148e0f40..fef128888d2 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 e60aaa9a38a..214c64b94f9 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 09a458ff099..965088d7358 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");