From ae57395562dd62e7ccc6e664974a4188decc7438 Mon Sep 17 00:00:00 2001 From: alexis portable <alexis@atm-consulting.fr> Date: Tue, 9 May 2017 22:24:24 +0200 Subject: [PATCH] NEW get amount base on thm for ficheinter --- htdocs/fichinter/class/fichinter.class.php | 27 +++++++++++++++++++++- htdocs/projet/element.php | 7 +++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 2942a8903ab..b52dfdc904b 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -360,6 +360,8 @@ class Fichinter extends CommonObject $this->modelpdf = $obj->model_pdf; $this->fk_contrat = $obj->fk_contrat; + $this->user_creation= $obj->fk_user_author; + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -537,7 +539,30 @@ class Fichinter extends CommonObject } } - + /** + * Returns amount based on user thm + * + * @return float amount + */ + function getAmount() { + global $db; + + $amount = 0; + + $this->author = new User($db); + $this->author->fetch($this->user_creation); + + $thm = $this->author->thm; + + foreach($this->lines as &$line) { + + $amount+=$line->qty * $thm; + + } + + return $amount; + } + /** * Returns the label status * diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 09a3fecc4bd..02bf6c5a9ba 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -333,7 +333,8 @@ $listofreferent=array( 'class'=>'Fichinter', 'table'=>'fichinter', 'datefieldname'=>'date_valid', - 'disableamount'=>1, + 'disableamount'=>0, + 'margin'=>'minus', 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', @@ -559,6 +560,7 @@ foreach ($listofreferent as $key => $value) if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); + else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'projet_task') { if ($idofelementuser) @@ -583,6 +585,7 @@ foreach ($listofreferent as $key => $value) if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') { @@ -948,6 +951,7 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line=null; $othermessage=''; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); elseif (in_array($tablename, array('projet_task'))) { @@ -988,6 +992,7 @@ foreach ($listofreferent as $key => $value) { $total_ttc_by_line=null; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') { -- GitLab