From 252fd66be7596e447a3e0833ab7d93eec91d7119 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 28 Dec 2007 18:46:53 +0000 Subject: [PATCH] start with bud_synthese --- html/test.php | 6 +- include/class_bud_hypo.php | 6 +- include/class_bud_synthese_acc.php | 73 ++++++++++++++++++++ include/class_bud_synthese_group.php | 29 ++++++++ include/class_bud_synthese_hypo.php | 96 +++++++++++++++++++++++++++ include/class_bud_synthese_simple.php | 75 +++++++++++++++++++++ 6 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 include/class_bud_synthese_acc.php create mode 100644 include/class_bud_synthese_group.php create mode 100644 include/class_bud_synthese_hypo.php create mode 100644 include/class_bud_synthese_simple.php diff --git a/html/test.php b/html/test.php index 0adc94b83..0f1e2b7b3 100644 --- a/html/test.php +++ b/html/test.php @@ -72,8 +72,12 @@ Bud_Hypo::testme(); require_once ('class_bud_detail_periode.php'); Bud_Detail_Periode::test_me(); -*/ + require_once ('class_bud_data.php'); Bud_Data::test_me(); +*/ + +require_once ('class_bud_synthese_hypo.php'); +Bud_Synthese_Hypo::test_me(); diff --git a/include/class_bud_hypo.php b/include/class_bud_hypo.php index 115d58d60..61c84ca72 100644 --- a/include/class_bud_hypo.php +++ b/include/class_bud_hypo.php @@ -165,7 +165,11 @@ class Bud_Hypo { } - + function has_plan() { + $this->load(); + if ( isNumber($this->pa_id)==1) return 1; + else return 0; + } static function test_me() { $cn=DbConnect (dossier::id()); ExecSql($cn,"delete from bud_hypothese"); diff --git a/include/class_bud_synthese_acc.php b/include/class_bud_synthese_acc.php new file mode 100644 index 000000000..de0621bbe --- /dev/null +++ b/include/class_bud_synthese_acc.php @@ -0,0 +1,73 @@ + +cn); + $obj->bh_id=$this->bh_id; + $obj->load(); + $r.='

'.$obj->bh_name.'

'; + $per=make_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') ". + " from periode order by p_start,p_end"); + + $wFrom=new widget('select'); + $wFrom->name='from'; + $wFrom->value=$per; + + $wto=new widget('select'); + $wto->name='to'; + $wto->value=$per; + $r.="Periode de ".$wFrom->IOValue()." à ".$wto->IOValue(); + + } + function load() { + $per=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id'); + $sql="select sum(bdp_amount),ga_id,pcm_val,pcm_lib ". + " from bud_detail_periode join bud_detail using (bd_id) " + " join bud_hypothese using (bh_id) ". + " join tmp_pcmn using (pcm_val) ". + " join plan_analytique using (pa_id) ". + " join groupe_analytique using(pa_id) ". + " where bh_id= ".$this->bh_id.' and '.$per. + " group by ga_id,pcm_lib,pcm_val "; + + } + function test_me() { + + } +} diff --git a/include/class_bud_synthese_group.php b/include/class_bud_synthese_group.php new file mode 100644 index 000000000..86d9adb29 --- /dev/null +++ b/include/class_bud_synthese_group.php @@ -0,0 +1,29 @@ + +name='bh_id'; + $wSelect->value=Bud_Synthese_Hypo::make_array($this->cn); + + $r="Hypothèse :".$wSelect->IOValue(); + + $per=make_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') ". + " from parm_periode order by p_start,p_end"); + + $wFrom=new widget('select'); + $wFrom->name='from'; + $wFrom->value=$per; + + $wto=new widget('select'); + $wto->name='to'; + $wto->value=$per; + $r.="Periode de ".$wFrom->IOValue()." à ".$wto->IOValue(); + $r.=dossier::hidden(); + return $r; + } + function load() { + $per=sql_filter_per($this->cn,$this->from,$this->to,'p_id','p_id'); + /* $sql="select sum(bdp_amount),ga_id,pcm_val,pcm_lib ". + " from bud_detail_periode join bud_detail using (bd_id) ". + " join bud_hypothese using (bh_id) ". + " join tmp_pcmn using (pcm_val) ". + " join plan_analytique using (pa_id) ". + " join groupe_analytique using(pa_id) ". + " where bh_id= ".$this->bh_id.' and '.$per. + " group by ga_id,pcm_lib,pcm_val "; + */ + $sql="select bd_id, pcm_val,pcm_lib,po_id,ga_id ". + " from bud_detail join tmp_pcmn using (pcm_val) join poste_analytique using (po_id)". + " where bh_id = ".$this->bh_id.' order by pcm_val '; + $array=get_array($this->cn,$sql); + + + + return $array; + } + static function test_me() { + $cn=DbConnect(dossier::id()); + $obj=new Bud_Synthese_Hypo($cn); + echo '
'; + echo $obj->form(); + echo widget::submit_button('recherche','Recherche'); + echo '
'; + print_r($_GET); + if ( isset ($_GET['recherche'])) { + $obj->from_array($_GET); + print_r( $obj->load()); + } + } +} diff --git a/include/class_bud_synthese_simple.php b/include/class_bud_synthese_simple.php new file mode 100644 index 000000000..acb881c90 --- /dev/null +++ b/include/class_bud_synthese_simple.php @@ -0,0 +1,75 @@ +$l=isset($p_array[$l])?$p_array[$l]:''; + } + } + + function form() { + $r=""; + $obj=new Bud_Hypo($this->cn); + $obj->bh_id=$this->bh_id; + if ( $obj->has_plan () == 1 ) { + /* show the analytic account of this plan */ + $po=new widget('select'); + $po->name='from_po'; + $value=make_array($this->cn,'select po_id,po_name from poste_analytique '. + ' where pa_id = '.$this->bh_id.' order by po_name'); + $po->value=$value; + $po_to=new widget('select'); + $po_to->name='to'; + $po_to->value=$value; + $r.='Plage de poste analytique '.$po->IOValue().' à '.$po_to->IOValue(); + } + $per=make_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') ". + " from periode order by p_start,p_end"); + + $wFrom=new widget('select'); + $wFrom->name='from'; + $wFrom->value=$per; + + $wto=new widget('select'); + $wto->name='to'; + $wto->value=$per; + $r.="Periode de ".$wFrom->IOValue()." à ".$wto->IOValue(); + } + + function load_all() { + + + } + static function test_me() { + + } +}