phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4096 - in phpcompta/trunk: html include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4096 - in phpcompta/trunk: html include
Date: Sat, 14 May 2011 18:27:27 +0200 (CEST)

Author: danydb
Date: 2011-05-14 18:27:27 +0200 (Sat, 14 May 2011)
New Revision: 4096

Added:
   phpcompta/trunk/include/export_table_csv.php
Modified:
   phpcompta/trunk/html/export.php
   phpcompta/trunk/include/class_anc_table.php
Log:
Export to CSV for ANC Table



Modified: phpcompta/trunk/html/export.php
===================================================================
--- phpcompta/trunk/html/export.php     2011-05-14 16:08:42 UTC (rev 4095)
+++ phpcompta/trunk/html/export.php     2011-05-14 16:27:27 UTC (rev 4096)
@@ -23,7 +23,6 @@
 /*!\file
  * \brief manage all the export to CSV or PDF
  *   act can be 
- *    * CVS/histo
  *
  */
 
@@ -157,7 +156,10 @@
     require_once('export_balance_pdf.php');
     exit();
     break;
-
+  case 'CSV/AncTable':
+    require_once('export_table_csv.php');
+    exit();
+    break;
    default:
     alert('Action inconnue '.$_GET['act']);
     exit();

Modified: phpcompta/trunk/include/class_anc_table.php
===================================================================
--- phpcompta/trunk/include/class_anc_table.php 2011-05-14 16:08:42 UTC (rev 
4095)
+++ phpcompta/trunk/include/class_anc_table.php 2011-05-14 16:27:27 UTC (rev 
4096)
@@ -31,11 +31,23 @@
   {
     $this->cn=$p_cn;
   }
+  /**
+   address@hidden get the parameters
+   */
   function get_request()
   {
     parent::get_request();
     $this->card_poste=HtmlInput::default_value('card_poste',1,$_GET);
   }
+  /**
+   address@hidden display form to get the parameter 
+   *  - card_poste 1 by card, 2 by account
+   *  - from_poste 
+   *  - to_poste
+   *  - from from date
+   *  - to until date
+   *  - pa_id Analytic plan to use
+   */
   function display_form($p_hidden='')
   {
     $r=parent::display_form($p_hidden);
@@ -239,4 +251,51 @@
       }
 
   }
+  function export_csv()
+  {
+   bcscale(2);
+
+    if ( $this->card_poste=='1')
+      {
+       $this->load_card();
+
+       echo '"Fiche"';
+       foreach ($this->aheader as $h)
+         {
+           echo ';"'.$h['po_name'].'"';
+         }
+       echo ',"Total"';
+       printf("\r\n");
+       /*
+        * Show all the result
+        */
+
+       for ($i=0;$i<count($this->arow);$i++)
+         {
+
+           printf('"%s"',$this->arow[$i]['j_qcode'].' 
'.$this->arow[$i]['name']);
+           $tot_row=0;
+           for ($x=0;$x<count($this->aheader);$x++)
+             {
+               
$amount=$this->db->get_value($this->sql,array($this->arow[$i]['f_id'],$this->aheader[$x]['po_id']));
+               if ($amount==null)$amount=0;
+               if ( isset($tot_col[$x]))
+                 {
+                   $tot_col[$x]=bcadd($tot_col[$x],$amount);
+                 }
+               else
+                 {
+                   $tot_col[$x]=$amount;
+                 }
+               printf(";%s",nb($amount));
+               $tot_row=bcadd($tot_row,$amount);
+             }
+           printf(";%s",nb($tot_row));
+           printf("\r\n");
+                   
+
+         }
+      }
+   
+  }
 }
\ No newline at end of file

Added: phpcompta/trunk/include/export_table_csv.php
===================================================================
--- phpcompta/trunk/include/export_table_csv.php                                
(rev 0)
+++ phpcompta/trunk/include/export_table_csv.php        2011-05-14 16:27:27 UTC 
(rev 4096)
@@ -0,0 +1,34 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/*!\file
+ * \brief export the anc tables in CSV
+ */
+
+header('Pragma: public');
+header('Content-type: application/csv');
+header('Content-Disposition: attachment;filename="histo-export.csv"',FALSE);
+
+require_once('class_anc_table.php');
+$atable=new Anc_Table($cn);
+$atable->get_request();
+$atable->export_csv();
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]