From d1381a6cbf43b839557a5b4ab1aa2b39aab1addf Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 17 Nov 2011 20:28:19 +0000 Subject: [PATCH] expprt GrandLivre Analytique --- include/anc_great_ledger.inc.php | 4 +- include/class_anc_grandlivre.php | 64 ++++++++++++++++++++++++-------- include/class_impress.php | 42 ++++++++++++--------- sql/anc-grandlivre.sql | 11 +----- sql/upgrade.sql | 2 +- 5 files changed, 77 insertions(+), 46 deletions(-) diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php index 692afef95..e838a8809 100644 --- a/include/anc_great_ledger.inc.php +++ b/include/anc_great_ledger.inc.php @@ -9,8 +9,8 @@ echo '

' . HtmlInput::submit('Recherche', 'Recherche') . '

'; echo ''; if (isset($_GET['result'])) { - echo $gl->display_button(); + echo $gl->show_button(); echo $gl->display_html(); - echo $gl->display_button(); + echo $gl->show_button(); } ?> diff --git a/include/class_anc_grandlivre.php b/include/class_anc_grandlivre.php index 67cde880f..527cc09f5 100644 --- a/include/class_anc_grandlivre.php +++ b/include/class_anc_grandlivre.php @@ -44,7 +44,7 @@ class Anc_GrandLivre extends Anc_Print $pa_id_cond=""; if ( isset ( $this->pa_id) && $this->pa_id !='') $pa_id_cond= "pa_id=".$this->pa_id." and"; - $array=$this->db->get_array(" select oa_id, + $array=$this->db->get_array(" select oa_id, po_name, oa_description, po_description, @@ -52,22 +52,53 @@ class Anc_GrandLivre extends Anc_Print to_char(oa_date,'DD.MM.YYYY') as oa_date, oa_amount, oa_group, - j_id , - jr_internal, - jr_id, + j_id , + jr_internal, + jr_id, jr_comment, j_poste, jrnx.f_id, ( select ad_value from fiche_Detail where f_id=jrnx.f_id and ad_id=23) as qcode - from operation_analytique as B join poste_analytique using(po_id) + from operation_analytique as B join poste_analytique using(po_id) left join jrnx using (j_id) left join jrn on (j_grpt=jr_grpt_id) where $pa_id_cond oa_amount <> 0.0 $cond_poste order by po_name,oa_date ,qcode,j_poste"); - - + + return $array; } + + function load_csv() + { + $filter_date=$this->set_sql_filter(); + $cond_poste=''; + if ($this->from_poste != "" ) + $cond_poste=" and upper(po_name) >= upper('".$this->from_poste."')"; + if ($this->to_poste != "" ) + $cond_poste.=" and upper(po_name) <= upper('".$this->to_poste."')"; + $pa_id_cond=""; + if ( isset ( $this->pa_id) && $this->pa_id !='') + $pa_id_cond= "pa_id=".$this->pa_id." and"; + $array=$this->db->get_array(" select + po_name, + to_char(oa_date,'DD.MM.YYYY') as oa_date, + j_poste, + ( select ad_value from fiche_Detail where f_id=jrnx.f_id and ad_id=23) as qcode, + jr_comment, + jr_internal, + case when oa_debit='t' then 'D' else 'C' end, + oa_amount + from operation_analytique as B join poste_analytique using(po_id) + left join jrnx using (j_id) + left join jrn on (j_grpt=jr_grpt_id) + where $pa_id_cond oa_amount <> 0.0 $cond_poste + order by po_name,oa_date ,qcode,j_poste"); + + + return $array; + } + /*! * \brief compute the html display * @@ -120,7 +151,7 @@ class Anc_GrandLivre extends Anc_Print $prev=$row['po_name']; $ix++; } - + $r.= ''; $detail=($row['jr_id'] != null)?HtmlInput::detail_op($row['jr_id'],$row['jr_internal']):''; $post_detail=($row['j_poste'] != null)?HtmlInput::history_account($row['j_poste'],$row['j_poste']):''; @@ -192,7 +223,7 @@ class Anc_GrandLivre extends Anc_Print { $r=""; //---Html - $array=$this->load(); + $array=$this->load_csv(); if ( is_array($array) == false ) { return $array; @@ -208,13 +239,14 @@ class Anc_GrandLivre extends Anc_Print $ix=0;$prev='xx'; $tot_deb=$tot_cred=0; $aheader=array(); - $aheader=array("title"=>'Date','type'=>'string'); - $aheader=array("title"=>'Poste','type'=>'string'); - $aheader=array("title"=>'Quick_Code','type'=>'string'); - $aheader=array("title"=>'libelle','type'=>'string'); - $aheader=array("title"=>'Num.interne','type'=>'string'); - $aheader=array("title"=>'Debit','type'=>'num'); - $aheader=array("title"=>'Credit','type'=>'num'); + $aheader[]=array("title"=>'Imp. Analytique','type'=>'string'); + $aheader[]=array("title"=>'Date','type'=>'string'); + $aheader[]=array("title"=>'Poste','type'=>'string'); + $aheader[]=array("title"=>'Quick_Code','type'=>'string'); + $aheader[]=array("title"=>'libelle','type'=>'string'); + $aheader[]=array("title"=>'Num.interne','type'=>'string'); + $aheader[]=array("title"=>'Debit','type'=>'string'); + $aheader[]=array("title"=>'Credit','type'=>'num'); Impress::array_to_csv($array, $aheader); } } \ No newline at end of file diff --git a/include/class_impress.php b/include/class_impress.php index 2e378df00..b09f8e592 100644 --- a/include/class_impress.php +++ b/include/class_impress.php @@ -29,7 +29,7 @@ require_once('class_periode.php'); class Impress { /*! \brief Purpose Parse a formula - * + * * \param $p_cn connexion * \param $p_label * \param $p_formula @@ -233,39 +233,47 @@ class Impress * with the handle of a successull query, echo each row into CSV and * send it directly * @param type $array of data - * @param type $aheader double array, each item of the array contains + * @param type $aheader double array, each item of the array contains * a key type (num) and a key title */ static function array_to_csv($array,$aheader) { $seq=""; - for ($i=0;$i$value) { - switch ($aheader[$e]['type']) - { - case 'num': - echo nb($row[$e]).$sep2; - break; - default: - echo '"'.$row[$e].'"'.$sep2; - } - $sep2=";"; + if ($e > count($aheader)) $e=0; + + if ( isset ($aheader[$e]['type'])) + { + switch ($aheader[$e]['type']) + { + case 'num': + echo $sep2.nb($value); + break; + default: + echo $sep2.'"'.$value.'"'; + } + } else { + echo '"'.$value.'"'.$sep2; + } + $sep2=";";$e++; } - printf("\n\r"); + printf("\r"); } } } \ No newline at end of file diff --git a/sql/anc-grandlivre.sql b/sql/anc-grandlivre.sql index 1f24ab4c1..e9ffdb533 100644 --- a/sql/anc-grandlivre.sql +++ b/sql/anc-grandlivre.sql @@ -1,15 +1,6 @@ insert into menu_ref(me_code,me_menu,me_file,me_description,me_type) values ('CSV:AncGrandLivre','Impression Grand-Livre',null,null,'PR'); -CREATE TABLE profile_menu ( - pm_id integer NOT NULL, - me_code text, - me_code_dep text, - p_id integer, - p_order integer, - p_type_display text NOT NULL, - pm_default integer -); -insert into profile_menu(me_code,me_code_dep,p_id,pm_default) +insert into profile_menu(me_code,me_code_dep,p_id,p_type_display,pm_default) values ( 'CSV:AncGrandLivre', NULL, 1 , 'P', 0); diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 5e6c2f496..753837918 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -29,7 +29,7 @@ script SQL to run \i mode_paiement.sql \i anc-modularity-imp.sql - +\i anc-grandlivre.sql create unique index qcode_idx on fiche_detail (ad_value) where ad_id=23;