Author: danydb Date: 2014-02-07 22:06:51 +0100 (Fri, 07 Feb 2014) New Revision: 695
Modified: trunk/transform/raw.php Log: Add Export CSV Modified: trunk/transform/raw.php =================================================================== --- trunk/transform/raw.php 2014-02-07 21:05:39 UTC (rev 694) +++ trunk/transform/raw.php 2014-02-07 21:06:51 UTC (rev 695) @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder [email protected] $act = HtmlInput::default_value_get('act', null); - +global $cn; switch ($act) { case 'listing_assujetti_xml': @@ -33,17 +33,22 @@ require_once 'include/class_transform_declarant.php'; require_once 'include/class_transform_representative.php'; require_once 'include/class_transform_intervat.php'; + require_once 'include/class_transform_client.php'; $declarant = new Transform_Declarant(); $representative = new Transform_Representative; $declarant->from_db($request_id); $representative->from_db($request_id); + $client = new Transform_Client; + + $xml = new Transform_Intervat; $xml->append_root(); - if ( $representative->name != "") { + if ($representative->name != "") + { $xml->append_representative($representative); } $xml->append_client_listing($declarant); @@ -57,4 +62,32 @@ $in = fread($file_xml, filesize($ref)); echo $in; break; + case 'listing_assujetti_csv': + $request_id = HtmlInput::default_value_get('r_id', null); + + if ($request_id == null) + { + throw new Exception(_('Accès directe incorrecte'), 15); + } + $aclient=$cn->get_array("select + c_name,c_vatnumber,c_amount_vat,c_amount_novat + from + transform.intervat_client join transform.intervat_declarant using (d_id) + where + r_id=$1" + ,array($request_id) + ); + + $file = "listing_assujetti" . date('d.m.y.hi') . ".csv"; + $ref = $_ENV['TMP'] . "/" . $file; + header('Content-type: application/csv'); + header('Pragma: public'); + header('Content-Disposition: attachment;filename="' . $file . '"', FALSE); + $nb=count($aclient); + $handle_file=fopen('php://output','w'); + for ($i=0;$i<$nb;$i++) + { + fputcsv($handle_file, $aclient[$i], ";"); + } + break; } --- PhpCompta est un logiciel de comptabilitĂ© libre en ligne (full web) Projet opensource http://www.phpcompta.eu _______________________________________________ Phpcompta est un logiciel libre de comptabilité en ligne (http://www.phpcompta.eu) Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
