diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index a35ae1afafb234967911fbac6f6e568eb34582fc..39c8cd80dd05098f34a50af5f950bf807ae73e97 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 '<td></td>'; print '<td></td>'; print '<td></td>'; - print '<td></td>'; + print '<td align="center" class="nowrap liste_total">'.convertSecondToTime($total_planned, 'allhourmin').'</td>'; print '<td></td>'; print '<td align="right" class="nowrap liste_total">'.convertSecondToTime($total, 'allhourmin').'</td>'; - print '<td></td>'; + print '<td align="right" class="nowrap liste_total">'; + if($total_planned) print round(100 * $total / $total_planned,2).' %'; + print '</td>'; if ($addordertick) print '<td class="hideonsmartphone"></td>'; print '</tr>'; } 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");