[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r612 - in trunk/rapport_avance: . include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r612 - in trunk/rapport_avance: . include |
Date: |
Wed, 11 Dec 2013 19:00:16 +0100 (CET) |
Author: danydb
Date: 2013-12-11 19:00:16 +0100 (Wed, 11 Dec 2013)
New Revision: 612
Modified:
trunk/rapport_avance/include/class_rapav_listing_compute.php
trunk/rapport_avance/raw.php
Log:
task #0000940: Listing : export CSV
Export CSV mais sans Historique
Task #940 - Listing : export CSV
Modified: trunk/rapport_avance/include/class_rapav_listing_compute.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-11 17:43:05 UTC (rev 611)
+++ trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-11 18:00:16 UTC (rev 612)
@@ -298,5 +298,54 @@
echo '</form>';
}
-
+ /**
+ * @brief export to CSV
+ */
+ function to_csv()
+ {
+ $title = mb_strtolower($this->listing->data->l_name, 'UTF-8');
+ $title = str_replace(array('/', '*', '<', '>', '*', '.', '+', ':',
'?', '!', " ", ";"), "_", $title);
+
+ $out = fopen("php://output", "w");
+ header('Pragma: public');
+ header('Content-type: application/csv');
+ header('Content-Disposition: attachment;filename="' . $title .
'.csv"', FALSE);
+ $ofiche=new RAPAV_Listing_Compute_Fiche_SQL();
+ $r_fiche=$ofiche->seek (" where lc_id = $1",array($this->data->lc_id));
+ $nb_fiche=Database::num_row($r_fiche);
+
+ /* For each card */
+ for ($i = 0;$i < $nb_fiche;$i++)
+ {
+ $fiche=$ofiche->next($r_fiche,$i);
+
+ $odetail=new RAPAV_Listing_Compute_Detail_SQL();
+ $r_detail=$odetail->seek(" where lf_id=$1 order by
lc_order",array($fiche->lf_id));
+ $nb_detail=Database::num_row($r_detail);
+ // table header
+ if ($nb_detail > 0 && $i == 0)
+ {
+ $col=array();
+ for ($e=0;$e<$nb_detail;$e++)
+ {
+ $detail=$odetail->next($r_detail,$e);
+ $col[]=$detail->lc_code;
+ }
+ fputcsv($out, $col, ";", '"');
+ }
+ /** for each detail */
+ $det_csv=array();
+ for ($e=0;$e <$nb_detail;$e++)
+ {
+ $detail=$odetail->next($r_detail,$e);
+ $value= (($detail->ld_value_numeric !==
null)?nb($detail->ld_value_numeric):"");
+ $value.=(($detail->ld_value_text !==
null)?$detail->ld_value_text:"");
+ $value.=(($detail->ld_value_date!==
null)?$detail->ld_value_date:"");
+ $det_csv[]=$value;
+ }
+ fputcsv($out, $det_csv, ';', '"');
+ }
+
+ }
+
}
Modified: trunk/rapport_avance/raw.php
===================================================================
--- trunk/rapport_avance/raw.php 2013-12-11 17:43:05 UTC (rev 611)
+++ trunk/rapport_avance/raw.php 2013-12-11 18:00:16 UTC (rev 612)
@@ -27,6 +27,7 @@
require_once 'include/class_formulaire_param.php';
require_once 'include/class_rapav_declaration.php';
require_once 'include/class_rapav_listing_compute_fiche.php';
+require_once 'include/class_rapav_listing_compute.php';
extract($_REQUEST);
if ($act == 'rapav_form_export')
@@ -133,11 +134,10 @@
}
if ($act == 'export_listing_csv')
{
- /**
- * @todo
- * to finish
- */
- echo 'export-listing-csv';
+ $decl = new RAPAV_Listing_Compute();
+ $decl->load($lc_id);
+ $decl->to_csv();
+ exit();
}
/**
* Show generated file
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r612 - in trunk/rapport_avance: . include,
phpcompta-dev <=