From b00558ee26ee265c0ebe43c6254e5eb22336d469 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 28 Mar 2021 15:21:47 +0200 Subject: [PATCH] =?UTF-8?q?Task=20#0001904:=20Previsions=20et=20budgets=20?= =?UTF-8?q?Ajout=20montant=20initial=20and=20estimation=20cumul=C3=A9e=20p?= =?UTF-8?q?our=20avoir=20=C3=A9volution=20passif/actif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/anticipation.class.php | 3 +- include/class/forecast_item_mtable.class.php | 2 + include/database/forecast_item_sql.class.php | 62 ++++++++-------- include/sql/patch/upgrade153.sql | 2 + include/template/anticipation-display.php | 73 +++++++++++++------ .../template/forecast_item_mtable-input.php | 13 ++++ 6 files changed, 101 insertions(+), 54 deletions(-) diff --git a/include/class/anticipation.class.php b/include/class/anticipation.class.php index 67360c17b..a8abf88a5 100644 --- a/include/class/anticipation.class.php +++ b/include/class/anticipation.class.php @@ -220,7 +220,8 @@ EOF; for ($j = 0; $j < count($aCat); $j++) { // Item of the category, estimation for a specific month - $aItem[$j] = $this->cn->get_array('select fi_card,fi_account,fi_text,fi_amount,fi_debit + $aItem[$j] = $this->cn->get_array('select fi_card,fi_account,fi_text,fi_amount,fi_debit , + fi_amount_initial from forecast_item where fc_id=$1 and fi_pid=0 order by fi_order ', array($aCat[$j]['fc_id'])); diff --git a/include/class/forecast_item_mtable.class.php b/include/class/forecast_item_mtable.class.php index f65913430..cbb4364b3 100644 --- a/include/class/forecast_item_mtable.class.php +++ b/include/class/forecast_item_mtable.class.php @@ -187,6 +187,8 @@ class Forecast_Item_MTable extends Manage_Table_SQL $object_sql->setp("fi_amount",$http->post('fi_amount',"number")); $object_sql->setp("fi_pid",$http->post('fi_pid',"number")); $object_sql->setp("fi_debit",$http->post('fi_debit')); + $object_sql->setp("fi_amount_initial",$http->post("fi_amount_initial","number")); + $card=trim($http->post("fi_card")); if ( $card !="") { $f_id=$object_sql->cn->get_value("select f_id from fiche_detail where ad_value=upper($1) and ad_id=23",[$card]); diff --git a/include/database/forecast_item_sql.class.php b/include/database/forecast_item_sql.class.php index a86063a37..0bafd8cfe 100644 --- a/include/database/forecast_item_sql.class.php +++ b/include/database/forecast_item_sql.class.php @@ -18,9 +18,8 @@ * along with NOALYSS; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once NOALYSS_INCLUDE . '/lib/noalyss_sql.class.php'; -require_once NOALYSS_INCLUDE . '/class/database.class.php'; - +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php'; +require_once NOALYSS_INCLUDE.'/class/database.class.php'; /** * class_forecast_item_sql.php @@ -31,47 +30,48 @@ require_once NOALYSS_INCLUDE . '/class/database.class.php'; class Forecast_Item_SQL extends Noalyss_SQL { - function __construct(DatabaseCore $p_cn, $p_id = -1) + function __construct(DatabaseCore $p_cn, $p_id=-1) { - $this->table = "public.forecast_item"; - $this->primary_key = "fi_id"; + $this->table="public.forecast_item"; + $this->primary_key="fi_id"; /* * List of columns */ - $this->name = array( - "fi_id" => "fi_id" - , "fi_text" => "fi_text" - , "fi_account" => "fi_account" - , "fi_card" => "fi_card" - , "fi_order" => "fi_order" - , "fc_id" => "fc_id" - , "fi_amount" => "fi_amount" - , "fi_debit" => "fi_debit" - , "fi_pid" => "fi_pid" + $this->name=array( + "fi_id"=>"fi_id" + , "fi_text"=>"fi_text" + , "fi_account"=>"fi_account" + , "fi_card"=>"fi_card" + , "fi_order"=>"fi_order" + , "fc_id"=>"fc_id" + , "fi_amount"=>"fi_amount" + , "fi_debit"=>"fi_debit" + , "fi_pid"=>"fi_pid" + , "fi_amount_initial"=>"fi_amount_initial" ); /* * Type of columns */ - $this->type = array( - "fi_id" => "numeric" - , "fi_text" => "text" - , "fi_account" => "text" - , "fi_card" => "numeric" - , "fi_order" => "numeric" - , "fc_id" => "numeric" - , "fi_amount" => "numeric" - , "fi_debit" => "char" - , "fi_pid" => "numeric" + $this->type=array( + "fi_id"=>"numeric" + , "fi_text"=>"text" + , "fi_account"=>"text" + , "fi_card"=>"numeric" + , "fi_order"=>"numeric" + , "fc_id"=>"numeric" + , "fi_amount"=>"numeric" + , "fi_debit"=>"char" + , "fi_pid"=>"numeric" + , "fi_amount_initial"=>"numeric" ); - $this->default = array( - "fi_id" => "auto" + $this->default=array( + "fi_id"=>"auto" ); - $this->date_format = "DD.MM.YYYY"; + $this->date_format="DD.MM.YYYY"; parent::__construct($p_cn, $p_id); } - -} \ No newline at end of file +} diff --git a/include/sql/patch/upgrade153.sql b/include/sql/patch/upgrade153.sql index 03a276697..82ae3b042 100644 --- a/include/sql/patch/upgrade153.sql +++ b/include/sql/patch/upgrade153.sql @@ -1,5 +1,7 @@ begin ; alter table forecast_cat rename to forecast_category; alter table forecast_category alter f_id set not null; +alter table forecast_item add fi_amount_initial numeric(20,4); +alter table forecast_item alter fi_amount_initial set default 0; insert into version (val,v_description) values (154,'Rewriting of FORECAST'); commit; \ No newline at end of file diff --git a/include/template/anticipation-display.php b/include/template/anticipation-display.php index 393df5a86..203a5dc6a 100644 --- a/include/template/anticipation-display.php +++ b/include/template/anticipation-display.php @@ -7,7 +7,7 @@ Période du à
- + @@ -39,9 +39,14 @@ Période du à 2) { + if (DEBUGNOALYSS>1) { printf (" \$aItem [$i] [$e] = %s",$aItem[$i][$e]['fi_amount']); echo p("\$aPeriode[$h]['p_id']==\$aPerMonth[$i][$x]['fi_pid'] ". $aPeriode[$h]['p_id']."==".$aPerMonth[$i][$x]['fi_pid'] ); @@ -85,10 +90,11 @@ if (count($aPerMonth[$i]) != 0 ){ } } } +$amount=bcadd($amount,$amount_initial); $estm[$i][$e][$h]=$amount; echo nbm( $amount); - $tot_estm=bcadd($tot_estm,$amount); +$tot_cum_estm[$h]=$tot_estm; $tot_cat_estm=bcadd($amount,$tot_cat_estm); ?> @@ -99,13 +105,15 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm); + - @@ -113,24 +121,40 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm); - - - + + + + + + + + + - $tot_cat_real = 0; - ?> - - - - - - + + + + $tot_cat_real = 0; + ?> + + + + + + + + @@ -139,7 +163,8 @@ $tot_cat_estm=bcadd($amount,$tot_cat_estm); 0)) +if ( ( $aItem[$i][$e]['fi_card']!="" && $aItem[$i][$e]['fi_debit'] == 'C' && $diff < 0) + || ($aItem[$i][$e]['fi_card'] && $aItem[$i][$e]['fi_debit'] == 'D' && $diff > 0)) { echo ''; } @@ -147,10 +172,14 @@ else if ($diff==0) { echo ''; } -else +elseif ( $aItem[$i][$e]['fi_account']!="" && $diff > 0 ) { echo ''; } + elseif ( $aItem[$i][$e]['fi_account']!="" && $diff < 0 ) { + echo ''; + + } echo nbm( $diff); ?> diff --git a/include/template/forecast_item_mtable-input.php b/include/template/forecast_item_mtable-input.php index 4a72c98ac..b133da5df 100644 --- a/include/template/forecast_item_mtable-input.php +++ b/include/template/forecast_item_mtable-input.php @@ -98,6 +98,11 @@ $isDebit->selected=$object->getp("fi_debit"); $isPeriode = new ISelect('fi_pid'); $isPeriode->value = $aPeriode; $isPeriode->selected = $object->getp("fi_pid"); + +$amount_initial= new INum("fi_amount_initial"); +$amount_initial->value=$object->getp("fi_amount_initial"); +$amount_initial->value=($amount_initial->value=='')?0:$amount_initial->value; + ?> @@ -146,5 +151,13 @@ $isPeriode->selected = $object->getp("fi_pid"); + + + +
input(); ?>
+ + + input()?> +