Complete the synthese part of the budget module
This commit is contained in:
parent
1fff6efe78
commit
08dfcf3101
3 changed files with 199 additions and 23 deletions
|
|
@ -82,6 +82,15 @@ Bud_Data::test_me();
|
|||
require_once ('class_bud_synthese_hypo.php');
|
||||
Bud_Synthese_Hypo::test_me();
|
||||
|
||||
*/
|
||||
|
||||
|
||||
require_once ('class_bud_synthese_acc.php');
|
||||
Bud_Synthese_Acc::test_me();
|
||||
|
||||
require_once ('class_bud_synthese_anc.php');
|
||||
Bud_Synthese_Anc::test_me();
|
||||
*/
|
||||
|
||||
|
||||
require_once ('class_bud_synthese_group.php');
|
||||
Bud_Synthese_Group::test_me();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
|
|
@ -22,22 +21,62 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
*
|
||||
*/
|
||||
/*!
|
||||
* \brief Manage the hypothese for the budget module
|
||||
* synthese
|
||||
*/
|
||||
/*!
|
||||
\brief Manage the hypothese for the budget module
|
||||
*/
|
||||
require_once ('class_bud_synthese.php');
|
||||
require_once ('class_anc_account.php');
|
||||
require_once ('class_acc_account.php');
|
||||
|
||||
class Bud_Synthese_Acc extents Bud_Synthese {
|
||||
|
||||
class Bud_Synthese_Acc extends Bud_Synthese {
|
||||
var $po_from;
|
||||
var $po_to;
|
||||
function from_array($p_array) {
|
||||
parent::from_array($p_array);
|
||||
foreach (array('acc_from','acc_to') as $r) {
|
||||
$this->$r=(isset($p_array[$r]))?$p_array[$r]:"";
|
||||
}
|
||||
// swap po_from and po_to if po_from is > to
|
||||
if ( $this->acc_from > $this->acc_to ){
|
||||
$swap=$this->acc_to;
|
||||
$this->acc_to=$this->acc_from;
|
||||
$this->acc_from=$swap;
|
||||
}
|
||||
}
|
||||
|
||||
function select_hypo() {
|
||||
$hypo=make_array($this->cn,'select bh_id, bh_name from bud_hypothese '.
|
||||
' where pa_id is not null order by bh_name');
|
||||
$wSelect = new widget('select');
|
||||
$wSelect->name='bh_id';
|
||||
$wSelect->value=$hypo;
|
||||
|
||||
$r="Hypothèse :".$wSelect->IOValue();
|
||||
$r.=dossier::hidden();
|
||||
return $r;
|
||||
}
|
||||
function form() {
|
||||
$obj=new Bud_Hypo($this->cn);
|
||||
$obj->bh_id=$this->bh_id;
|
||||
$obj->load();
|
||||
$r.='<h2 class="info">'.$obj->bh_name.'</h2>';
|
||||
/* 2nd Step
|
||||
*/
|
||||
if ( $this->bh_id == 0 )
|
||||
throw new Exception ("bh_id n'est pas sélectionné");
|
||||
$hypo=new Bud_Hypo($this->cn);
|
||||
$hypo->bh_id=$this->bh_id;
|
||||
$hypo->load();
|
||||
$acc_value=make_array($this->cn,'select pcm_val,pcm_val from bud_detail where bh_id='.$this->bh_id." order by pcm_val::text ");
|
||||
$wAcc_from=new widget("select");
|
||||
$wAcc_from->name="acc_from";
|
||||
$wAcc_from->value=$acc_value;
|
||||
|
||||
$wAcc_to=new widget("select");
|
||||
$wAcc_to->name="acc_to";
|
||||
$wAcc_to->value=$acc_value;
|
||||
|
||||
$per=make_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') ".
|
||||
" from periode order by p_start,p_end");
|
||||
" from parm_periode order by p_start,p_end");
|
||||
|
||||
$wFrom=new widget('select');
|
||||
$wFrom->name='from';
|
||||
|
|
@ -46,14 +85,138 @@ class Bud_Synthese_Acc extents Bud_Synthese {
|
|||
$wto=new widget('select');
|
||||
$wto->name='to';
|
||||
$wto->value=$per;
|
||||
$r="";
|
||||
$r.="Periode de ".$wFrom->IOValue()." à ".$wto->IOValue();
|
||||
|
||||
$r.="Poste comptable de ".$wAcc_from->IOValue()." à ".$wAcc_to->IOValue();
|
||||
$r.=dossier::hidden();
|
||||
return $r;
|
||||
}
|
||||
/*!\brief return all the data (raw format) in a array
|
||||
* \return Array
|
||||
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[bc_id] => 4
|
||||
[price_unit] => 1.0000
|
||||
[bc_code] => FICHE_1
|
||||
[bc_description] =>
|
||||
[pcm_val] => 6040002
|
||||
[unit] => 1
|
||||
[amount] => 1
|
||||
[amount_unit] => Array
|
||||
(
|
||||
[79] => 1.0000
|
||||
)
|
||||
|
||||
[acc_name] => Loyer
|
||||
[acc_amount] => 0
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[bc_id] => 7
|
||||
[price_unit] => 1.0000
|
||||
[bc_code] => FICHE4
|
||||
[bc_description] =>
|
||||
[pcm_val] => 6510
|
||||
[unit] => 2
|
||||
[amount] => 2
|
||||
[amount_unit] => Array
|
||||
(
|
||||
[79] => 2.0000
|
||||
)
|
||||
|
||||
[acc_name] => Dotations
|
||||
[acc_amount] => 0
|
||||
)
|
||||
|
||||
)
|
||||
*
|
||||
*/
|
||||
function load() {
|
||||
$per=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id');
|
||||
$per_acc=sql_filter_per($this->cn,$this->from,$this->to,'p_id','j_tech_per');
|
||||
|
||||
// get all the bud_card.bc_id
|
||||
$sql="select distinct bc_id,bc_code,bc_description,bc_price_unit ".
|
||||
" from bud_card join bud_detail using (bc_id) ".
|
||||
"join poste_analytique using(po_id) where pcm_val >= $1 and ".
|
||||
"pcm_val <=$2 and bud_card.bh_id=$3";
|
||||
$res=ExecSqlParam($this->cn,$sql,array($this->acc_from,$this->acc_to,$this->bh_id));
|
||||
$aBudCard=pg_fetch_all($res);
|
||||
$array=array();
|
||||
$cn=DbConnect(dossier::id());
|
||||
pg_prepare($cn,"sql_detail","select distinct pcm_val from bud_detail ".
|
||||
" where bc_id=$1");
|
||||
pg_prepare($cn,"sql_detail_periode","select sum(bdp_amount) as amount,".
|
||||
"p_id from bud_card join bud_detail using (bc_id)".
|
||||
" join bud_detail_periode using (bd_id) ".
|
||||
" join parm_periode using (p_id) ".
|
||||
" where bc_id=$1 and $per and pcm_val=$2 group by p_id,p_start order by p_start");
|
||||
|
||||
// foreach card get the detail per pcm_val and periode
|
||||
foreach ($aBudCard as $rBudCard) {
|
||||
$line=array();
|
||||
$line['bc_id']=$rBudCard['bc_id'];
|
||||
$line['price_unit']=$rBudCard['bc_price_unit'];
|
||||
$line['bc_code']=$rBudCard['bc_code'];
|
||||
$line['bc_description']=$rBudCard['bc_description'];
|
||||
$res=pg_execute("sql_detail",array($line['bc_id']));
|
||||
$row=pg_fetch_all($res);
|
||||
foreach ($row as $col) {
|
||||
$pcm_val=$col['pcm_val'];
|
||||
$line['pcm_val']=$pcm_val;
|
||||
$periode=array();
|
||||
$res2=pg_execute("sql_detail_periode",array($rBudCard['bc_id'],$pcm_val));
|
||||
$col_per=pg_fetch_all($res2);
|
||||
$line['unit']=0;
|
||||
foreach ($col_per as $cPer) {
|
||||
$p_id=$cPer['p_id'];
|
||||
$periode[$p_id]=$cPer['amount'];
|
||||
$line['unit']+=$cPer['amount'];
|
||||
}
|
||||
$line['amount']=$line['unit']*$line['price_unit'];
|
||||
$line['amount_unit']=$periode;
|
||||
|
||||
$acc_account=new Acc_Account($this->cn,$pcm_val);
|
||||
$acc_account->load();
|
||||
$line['acc_name']=$acc_account->label;
|
||||
$line['acc_amount']=$acc_account->get_solde($per_acc);
|
||||
}
|
||||
$array[]=$line;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
function test_me() {
|
||||
|
||||
|
||||
static function test_me() {
|
||||
|
||||
$cn=DbConnect(dossier::id());
|
||||
$obj=new Bud_Synthese_Acc($cn);
|
||||
echo '<form method="GET">';
|
||||
echo $obj->select_hypo();
|
||||
echo widget::submit_button('recherche','recherche');
|
||||
echo '</form>';
|
||||
if ( isset($_GET['recherche'])) {
|
||||
$obj->from_array($_GET);
|
||||
echo '<form method="GET">';
|
||||
echo $obj->form();
|
||||
echo widget::hidden('bh_id',$obj->bh_id);
|
||||
echo widget::submit_button('recherche2','recherche');
|
||||
echo '</form>';
|
||||
}
|
||||
if ( isset($_GET['recherche2'])){
|
||||
print_r($_GET);
|
||||
$obj->from_array($_GET);
|
||||
|
||||
echo 'ICI';
|
||||
print_r($obj->load());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,14 +93,17 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
}
|
||||
/*!\brief return all the data (raw format) in a array
|
||||
\return Array structure
|
||||
ICIArray
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[bc_id] => 4
|
||||
[price_unit] => 1.0000
|
||||
[bc_code] => FICHE_1
|
||||
[bc_description] =>
|
||||
[pcm_val] => 6040002
|
||||
[unit] => 48
|
||||
[amount] => 48
|
||||
[unit] => 25
|
||||
[amount] => 25
|
||||
[amount_unit] => Array
|
||||
(
|
||||
[79] => 1.0000
|
||||
|
|
@ -113,8 +116,6 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
[86] => 0.0000
|
||||
[87] => 9.0000
|
||||
[88] => 10.0000
|
||||
[89] => 11.0000
|
||||
[90] => 12.0000
|
||||
)
|
||||
|
||||
[acc_name] => Loyer
|
||||
|
|
@ -125,6 +126,8 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
(
|
||||
[bc_id] => 7
|
||||
[price_unit] => 1.0000
|
||||
[bc_code] => FICHE4
|
||||
[bc_description] =>
|
||||
[pcm_val] => 6510
|
||||
[unit] => 74
|
||||
[amount] => 74
|
||||
|
|
@ -140,23 +143,21 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
[86] => 7.0000
|
||||
[87] => 0.0000
|
||||
[88] => 0.0000
|
||||
[89] => 0.0000
|
||||
[90] => 0.0000
|
||||
)
|
||||
|
||||
[acc_name] => Dotations
|
||||
[acc_amount] => 0
|
||||
)
|
||||
|
||||
|
||||
|
||||
)
|
||||
*/
|
||||
function load() {
|
||||
$per=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id');
|
||||
$per_acc=sql_filter_per($this->cn,$this->from,$this->to,'p_id','j_tech_per');
|
||||
|
||||
// get all the bud_card.bc_id
|
||||
$sql="select distinct bc_id,bc_price_unit from bud_card join bud_detail using (bc_id) ".
|
||||
$sql="select distinct bc_id,bc_price_unit,bc_code,bc_description ".
|
||||
" from bud_card join bud_detail using (bc_id) ".
|
||||
"join poste_analytique using(po_id) where po_name >= $1 and ".
|
||||
"po_name <=$2 and bud_card.bh_id=$3";
|
||||
$res=ExecSqlParam($this->cn,$sql,array($this->po_from,$this->po_to,$this->bh_id));
|
||||
|
|
@ -176,6 +177,9 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
$line=array();
|
||||
$line['bc_id']=$rBudCard['bc_id'];
|
||||
$line['price_unit']=$rBudCard['bc_price_unit'];
|
||||
$line['bc_code']=$rBudCard['bc_code'];
|
||||
$line['bc_description']=$rBudCard['bc_description'];
|
||||
|
||||
$res=pg_execute("sql_detail",array($line['bc_id']));
|
||||
$row=pg_fetch_all($res);
|
||||
foreach ($row as $col) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue