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 $f_id=HtmlInput::default_value_request("f_id", "-");
00028 if ( $f_id == "-") {
00029      throw new Exception ('Invalid parameter');
00030 }
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,$f_id);
00039 $qcode=$Fiche->get_quick_code();
00040 
00041 header('Content-type: application/csv');
00042 
00043 header('Pragma: public');
00044 header('Content-Disposition: attachment;filename="fiche-'.$qcode.'.csv"',FALSE);
00045 $Fiche->getName();
00046 list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date(
00047                                     $_GET['from_periode'],
00048                                     $_GET['to_periode'],
00049                                     $_GET['ople']
00050                                 );
00051 if ( count($Fiche->row ) == 0 )
00052 {
00053     echo "Aucune donnée";
00054     return;
00055 }
00056 
00057 
00058 if ( ! isset ($_REQUEST['oper_detail']))
00059 {
00060     echo '"Qcode";'.
00061     "\"Date\";".
00062       "\"n° pièce\";".
00063     "\"Code interne\";".
00064     '"Code journal";'.
00065     '"Nom journal";'.
00066     "\"Description\";".
00067     "\"Débit\";".
00068     "\"Crédit\";".
00069     "\"Prog.\";".
00070     "\"Let.\""     ;
00071     printf("\n");
00072     $progress=0;
00073     $current_exercice="";
00074     $tot_deb=0;$tot_cred=0; 
00075     bcscale(2);
00076     foreach ( $Fiche->row as $op )
00077     {
00078         /*
00079              * separation per exercice
00080              */
00081             if ( $current_exercice == "") $current_exercice=$op['p_exercice'];
00082             
00083             if ( $current_exercice != $op['p_exercice']) {
00084                 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
00085                 $diff=abs($tot_deb-$tot_cred);
00086                 printf(
00087                      ";;;".
00088                      '"'._('total').'";'.
00089                      '"'.$current_exercice.'";;'.
00090                 '"'."$solde_type".'"'.";".
00091                 nb($tot_deb).";".
00092                 nb($tot_cred).";".
00093                 nb($diff).";"."\n");
00094                 /*
00095                 * reset total and current_exercice
00096                 */
00097                 $progress=0;
00098                 $current_exercice=$op['p_exercice'];
00099                 $tot_deb=0;$tot_cred=0;    
00100             }
00101         $diff=bcsub($op['deb_montant'],$op['cred_montant']);
00102         $progress=bcadd($progress,$diff);
00103         $tot_deb=bcadd($tot_deb,$op['deb_montant']);
00104         $tot_cred=bcadd($tot_cred,$op['cred_montant']);
00105         echo '"'.$op['j_qcode'].'";'.
00106           '"'.$op['j_date_fmt'].'"'.";".
00107           '"'.$op['jr_pj_number'].'"'.";".
00108           '"'.$op['jr_internal'].'"'.";".
00109           '"'.$op['jrn_def_code'].'"'.";".
00110           '"'.$op['jrn_def_name'].'"'.";".
00111           '"'.$op['description'].'"'.";".
00112           nb($op['deb_montant']).";".
00113           nb($op['cred_montant']).";".
00114           nb(abs($progress)).';'.
00115           '"'.(($op['letter']==-1)?'':strtoupper(base_convert($op['letter'],10,36))).'"';
00116         printf("\n");
00117 
00118     }
00119 }
00120 else
00121 {
00122     echo '"Poste";"Qcode";"date";"ref";"internal";';
00123     echo    "\"Description\";".
00124     "\"Montant\";".
00125     "\"D/C\"";
00126 
00127     printf("\r\n");
00128 
00129     foreach ( $Fiche->row as $op )
00130     {
00131         $acc=new Acc_Operation($cn);
00132         $acc->jr_id=$op['jr_id'];
00133         $result= $acc->get_jrnx_detail();
00134 
00135         foreach ( $result as $r)
00136         {
00137             printf('"%s";"%s";"%s";"%s";"%s";%s;%s;"%s"',
00138                    $r['j_poste'],
00139                    $r['j_qcode'],
00140                    $r['jr_date'],
00141                    $op['jr_pj_number'],
00142                    $r['jr_internal'],
00143                    $r['description'],
00144                    nb($r['j_montant']),
00145                    $r['debit']);
00146             printf("\r\n");
00147 
00148         }
00149 
00150 
00151 
00152     }
00153 }
00154 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
00155 $diff=abs($tot_deb-$tot_cred);
00156 printf(
00157     '"'."$solde_type".'"'.";".
00158     nb($diff).";".
00159     nb($tot_deb).";".
00160     nb($tot_cred)."\n");
00161 
00162 exit;
00163 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations