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.= ''; + 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;$i