Merge pull request #1488 from atm-maxime/mko1300
Add task 1300 : Add thm field on user and time spent to be able to calculate employee cost
This commit is contained in:
commit
58add21719
@ -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>';
|
||||
}
|
||||
|
||||
@ -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 ;
|
||||
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 ;
|
||||
@ -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) )
|
||||
{
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user