From dfe59ee4e71a3dc3071dd1f74fe84c4eaa20d287 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 17 Nov 2011 14:20:15 +0000 Subject: [PATCH] add export CSV to ANC grand livre --- html/export.php | 5 +- include/class_anc_grandlivre.php | 70 ++++++++++++++++++++++++++- include/class_database.php | 39 +++++++++++++++ include/class_impress.php | 39 +++++++++++++++ include/export_anc_grandlivre_csv.php | 17 +++++++ sql/anc-grandlivre.sql | 15 ++++++ 6 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 include/export_anc_grandlivre_csv.php create mode 100644 sql/anc-grandlivre.sql diff --git a/html/export.php b/html/export.php index e3818a176..8fa7d0c7e 100644 --- a/html/export.php +++ b/html/export.php @@ -39,7 +39,7 @@ $act=$user->check_dossier($gDossier); if ( $act=='X' || ! isset($_GET['act']) || $user->check_print($_GET['act'])==0 ) { echo alert('Accès interdit'); - redirect("do.php?".dossier::get()); + redirect("do.php?".dossier::get()); exit(); } @@ -156,6 +156,9 @@ if ( $act=='X' || ! isset($_GET['act']) || $user->check_print($_GET['act'])==0 ) require_once 'export_bilan_oth.php'; exit(); break; + case 'CSV:AncGrandLivre': + require_once 'export_anc_grandlivre_csv.php'; + break; default: alert('Action inconnue '.$_GET['act']); exit(); diff --git a/include/class_anc_grandlivre.php b/include/class_anc_grandlivre.php index 852daa84c..67cde880f 100644 --- a/include/class_anc_grandlivre.php +++ b/include/class_anc_grandlivre.php @@ -24,6 +24,7 @@ * \brief show the Grand Livre for analytic */ require_once('class_anc_print.php'); +require_once 'class_impress.php'; class Anc_GrandLivre extends Anc_Print { @@ -63,7 +64,7 @@ class Anc_GrandLivre extends Anc_Print 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; } @@ -149,4 +150,71 @@ class Anc_GrandLivre extends Anc_Print $r.= ''; return $r; } + /*! + * \brief Show the button to export in PDF or CSV + * \param $url_csv url of the csv + * \param $url_pdf url of the pdf + * \param $p_string hidden data to include in the form + * + * + * \return string with the button + */ + function show_button($p_string="") + { + $r=""; + /* $r.= '
'; + $r.= $p_string; + $r.= dossier::hidden(); + $r.= HtmlInput::hidden("to",$this->to); + $r.= HtmlInput::hidden("act","PDF:AncGrandLivre"); + + $r.= HtmlInput::hidden("from",$this->from); + $r.= HtmlInput::hidden("pa_id",$this->pa_id); + $r.= HtmlInput::hidden("from_poste",$this->from_poste); + $r.= HtmlInput::hidden("to_poste",$this->to_poste); + $r.=HtmlInput::submit('bt_pdf',"Export en PDF"); + $r.= '
'; +*/ + $r.= '
'; + $r.= HtmlInput::hidden("act","CSV:AncGrandLivre"); + $r.= HtmlInput::hidden("to",$this->to); + $r.= HtmlInput::hidden("from",$this->from); + $r.= HtmlInput::hidden("pa_id",$this->pa_id); + $r.= HtmlInput::hidden("from_poste",$this->from_poste); + $r.= HtmlInput::hidden("to_poste",$this->to_poste); + $r.= $p_string; + $r.= dossier::hidden(); + $r.=HtmlInput::submit('bt_csv',"Export en CSV"); + $r.= '
'; + return $r; + } + function display_csv() + { + $r=""; + //---Html + $array=$this->load(); + if ( is_array($array) == false ) + { + return $array; + + } + + if ( empty($array) ) + { + $r.= _("aucune donnée"); + return $r; + } + + $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'); + Impress::array_to_csv($array, $aheader); + } } \ No newline at end of file diff --git a/include/class_database.php b/include/class_database.php index 54458a29c..3a8ea0eca 100644 --- a/include/class_database.php +++ b/include/class_database.php @@ -846,6 +846,45 @@ class Database { return pg_transaction_status($this->db); } + /** + * with the handle of a successull query, echo each row into CSV and + * send it directly + * @param type $ret handle to a query + * @param type $aheader double array, each item of the array contains + * a key type (num) and a key title + */ + function query_to_csv($ret,$aheader) + { + $seq=""; + for ($i=0;$iget_request(); +echo $gl->display_csv(); + + + + +?> diff --git a/sql/anc-grandlivre.sql b/sql/anc-grandlivre.sql new file mode 100644 index 000000000..1f24ab4c1 --- /dev/null +++ b/sql/anc-grandlivre.sql @@ -0,0 +1,15 @@ +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) +values ( 'CSV:AncGrandLivre', NULL, 1 , 'P', 0); +