diff --git a/html/test.php b/html/test.php index 738f64081..825ecdd1a 100644 --- a/html/test.php +++ b/html/test.php @@ -79,18 +79,18 @@ Bud_Data::test_me(); +require_once ('class_bud_synthese_acc.php'); +Bud_Synthese_Acc::test_me(); + + require_once ('class_bud_synthese_hypo.php'); Bud_Synthese_Hypo::test_me(); -require_once ('class_bud_synthese_group.php'); -Bud_Synthese_Group::test_me(); - - require_once ('class_bud_synthese_anc.php'); Bud_Synthese_Anc::test_me(); */ -require_once ('class_bud_synthese_acc.php'); -Bud_Synthese_Acc::test_me(); +require_once ('class_bud_synthese_group.php'); +Bud_Synthese_Group::test_me(); diff --git a/include/class_bud_synthese_group.php b/include/class_bud_synthese_group.php index 98c539761..e5053d3b7 100644 --- a/include/class_bud_synthese_group.php +++ b/include/class_bud_synthese_group.php @@ -168,6 +168,7 @@ class Bud_Synthese_Group extends Bud_Synthese { " and $per ". " group by pcm_val,p_id,bc_price_unit order by pcm_val,p_id"; $res=get_array($this->cn,$sql); + echo_debug(__FILE__.':'.__LINE__.'- load','$res',$res); $pcm_val=""; $old="XX"; $sub=array(); @@ -180,15 +181,17 @@ class Bud_Synthese_Group extends Bud_Synthese { } if ( $pcm_val == $old ) { $per='BD_'.$row['p_id']; - $sub[$per]=$row['amount']*$row['bc_price_unit']; + $sub[$per]=(isset($sub[$per]))?$sub[$per]:0; + $sub[$per]+=$row['amount']*$row['bc_price_unit']; } else { // save the array $array[$old]=$sub; $old=$pcm_val; - $per=$row['p_id']; + $per='BD_'.$row['p_id']; // reinitialize array $sub=array(); - $sub[$per]=$row['amount']*$row['bc_price_unit']; + $sub[$per]=(isset($sub[$per]))?$sub[$per]:0; + $sub[$per]+=$row['amount']*$row['bc_price_unit']; } } @@ -292,32 +295,75 @@ Array $head=array(); // get the initial value from anc_hypo $hypo=new Bud_Hypo($this->cn); + $hypo->bh_id=$this->bh_id; $hypo->load(); $initial=$hypo->bh_saldo; + $per=get_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') as d". + " from parm_periode ". + " where p_id between ".$this->from.' and '. + $this->to." order by p_start" ); + echo_debug(__FILE__.':'.__LINE__.'- head_foot','hypo',$hypo); // the key is the pcm_val and the amount is an array - foreach ($p_array as $key=>$amount) { - $foot[$key]=$key; - $previous=$initial; - foreach ($amount as $periode=>$value) { - if ( strpos($periode,'BD_') !== 0 ) continue; - $head[$periode]=$previous; - $foot[$periode]=(isset($foot[$periode]))?$foot[$periode]:0; - $foot[$periode]+=$value; - $previous=$foot[$periode]; - } - $previous=0; - foreach ($amount as $periode=>$value) { - if ( strpos($periode,'AC_') !== 0 ) continue; - $head[$periode]=$previous; - $foot[$periode]=(isset($foot[$periode]))?$foot[$periode]:0; - $foot[$periode]+=$value; - $previous=$foot[$periode]; - } - - } - + $bud_previous=$initial; return array($head,$foot); } + + + function display_html($p_array) { + $r=""; + list ($head,$foot)=$this->head_foot($p_array); + $per=get_array($this->cn,"select p_id,to_char(p_start,'MM.YYYY') as d". + " from parm_periode ". + " where p_id between ".$this->from.' and '. + $this->to." order by p_start" ); + $r.='
| CE | "; + foreach( $per as $c) { + $heading.=''.$c['d'].' | '; + $heading.='CE'.$c['d'].' | '; + } + $heading.="Tot. Cout | "; + $heading.="Resultat | '; + foreach ($per as $c) { + $idx_bud='BD_'.$c['p_id']; + $idx_acc='AC_'.$c['p_id']; + $r.=' | '.sprintf('% 10.2f',$head[$idx_bud]).' | '; + $r.=''.sprintf('% 10.2f',$head[$idx_acc]).' | '; + } + $r.=''; + $r.=' | '; + $r.=''; + // content + + foreach ($p_array as $key => $value ){ + $r.=' |
|---|---|---|---|---|
| '.$key.' | '; + foreach ( $per as $c) { + $ix_acc='AC_'.$c['p_id']; + $ix_bud='BD_'.$c['p_id']; + $r.=sprintf('% 10.2f | ',$value[$ix_bud]); + $r.=sprintf('% 10.2f | ',$value[$ix_acc]); + } + $r.=sprintf('% 10.2f | ',$value['total_bud']); + $r.=sprintf('% 10.2f | ',$value['total_acc']); + $r.='
| '; + foreach ($per as $c) { + $idx_bud='BD_'.$c['p_id']; + $idx_acc='AC_'.$c['p_id']; + $r.=' | '.sprintf('% 10.2f',$foot[$idx_bud]).' | '; + $r.=''.sprintf('% 10.2f',$foot[$idx_acc]).' | '; + } + $r.='