Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

poste_csv.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 1.5 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00024 include_once("ac_common.php");
00025 include_once ("postgres.php");
00026 include ('class_user.php');
00027 include("class_poste.php");
00028 header('Content-type: application/csv');
00029 header('Content-Disposition: attachment;filename="poste.csv"',FALSE);
00030 
00031 /* Admin. Dossier */
00032 $cn=DbConnect($_SESSION['g_dossier']);
00033 
00034 
00035 $User=new cl_user($cn);
00036 $User->Check();
00037 
00038 
00039 $Poste=new poste($cn,$_POST['poste_id']);
00040 $Poste->GetName();
00041 list($array,$tot_deb,$tot_cred)=$Poste->GetRow( $_POST['from_periode'],
00042                                                 $_POST['to_periode']
00043                                                 );
00044 if ( count($Poste->row ) == 0 ) 
00045   exit;
00046 
00047  echo "\"Code interne\";".
00048      "\"Date\";".
00049       "\"Description\";".
00050       "\"Débit\";".
00051       "\"Crédit\"";
00052 printf("\n");
00053 
00054 
00055   foreach ( $Poste->row as $op ) { 
00056       echo '"'.$op['jr_internal'].'"'.";".
00057         '"'.$op['j_date'].'"'.";".
00058         '"'.$op['description'].'"'.";".
00059         sprintf("%8.4f",$op['deb_montant']).";".
00060         sprintf("%8.4f",$op['cred_montant']);
00061       printf("\n");
00062 
00063     
00064   }
00065   $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
00066   $diff=abs($tot_deb-$tot_cred);
00067 printf(
00068     '"'."$solde_type".'"'.";".
00069     sprintf("%8.4f",$diff).";".
00070     sprintf("%8.4f",$tot_deb).";".
00071   sprintf("%8.4f",$tot_cred)."\n");
00072 
00073   exit;
00074 ?>