noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_fiche_detail_csv.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS 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  *   NOALYSS 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 NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /*! \file
00021  * \brief Send the poste list in csv
00022  */
00023 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00024 include_once("ac_common.php");
00025 require_once('class_database.php');
00026 require_once("class_fiche.php");
00027 header('Content-type: application/csv');
00028 
00029 header('Pragma: public');
00030 header('Content-Disposition: attachment;filename="poste.csv"',FALSE);
00031 require_once('class_dossier.php');
00032 $gDossier=dossier::id();
00033 
00034 /* Admin. Dossier */
00035 $cn=new Database($gDossier);
00036 
00037 
00038 $Fiche=new Fiche($cn,$_REQUEST['f_id']);
00039 $Fiche->getName();
00040 list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date(
00041                                     $_GET['from_periode'],
00042                                     $_GET['to_periode'],
00043                                     $_GET['ople']
00044                                 );
00045 if ( count($Fiche->row ) == 0 )
00046 {
00047     echo "Aucune donnée";
00048     return;
00049 }
00050 
00051 
00052 if ( ! isset ($_REQUEST['oper_detail']))
00053 {
00054     echo '"Qcode";'.
00055     "\"Date\";".
00056       "\"n° pièce\";".
00057     "\"Code interne\";".
00058     "\"Description\";".
00059     "\"Débit\";".
00060     "\"Crédit\";".
00061     "\"Prog.\";".
00062     "\"Let.\""     ;
00063     printf("\n");
00064     $progress=0;
00065     foreach ( $Fiche->row as $op )
00066     {
00067         $progress+=$op['deb_montant']-$op['cred_montant'];
00068 
00069         echo '"'.$op['j_qcode'].'";'.
00070           '"'.$op['j_date_fmt'].'"'.";".
00071           '"'.$op['jr_pj_number'].'"'.";".
00072           '"'.$op['jr_internal'].'"'.";".
00073           '"'.$op['description'].'"'.";".
00074           nb($op['deb_montant']).";".
00075           nb($op['cred_montant']).";".
00076           nb(abs($progress)).';'.
00077           '"'.(($op['letter']==-1)?'':strtoupper(base_convert($op['letter'],10,36))).'"';
00078         printf("\n");
00079 
00080     }
00081 }
00082 else
00083 {
00084     echo '"Poste";"Qcode";"date";"ref";"internal";';
00085     echo    "\"Description\";".
00086     "\"Montant\";".
00087     "\"D/C\"";
00088 
00089     printf("\r\n");
00090 
00091     foreach ( $Fiche->row as $op )
00092     {
00093         $acc=new Acc_Operation($cn);
00094         $acc->jr_id=$op['jr_id'];
00095         $result= $acc->get_jrnx_detail();
00096 
00097         foreach ( $result as $r)
00098         {
00099             printf('"%s";"%s";"%s";"%s";"%s";%s;%s;"%s"',
00100                    $r['j_poste'],
00101                    $r['j_qcode'],
00102                    $r['jr_date'],
00103                    $op['jr_pj_number'],
00104                    $r['jr_internal'],
00105                    $r['description'],
00106                    nb($r['j_montant']),
00107                    $r['debit']);
00108             printf("\r\n");
00109 
00110         }
00111 
00112 
00113 
00114     }
00115 }
00116 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
00117 $diff=abs($tot_deb-$tot_cred);
00118 printf(
00119     '"'."$solde_type".'"'.";".
00120     nb($diff).";".
00121     nb($tot_deb).";".
00122     nb($tot_cred)."\n");
00123 
00124 exit;
00125 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations