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

fiche_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.8 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 header('Content-type: application/csv');
00026 header('Content-Disposition: attachment;filename="fiche.csv"',FALSE);
00027 include_once ("ac_common.php");
00028 include_once('class_fiche.php');
00029 include_once ("postgres.php");
00030 include_once("check_priv.php");
00031 if (  isset ($_REQUEST['with_amount']))  include_once("class_poste.php");
00032 $cn=DbConnect($_SESSION['g_dossier']);
00033 
00034 $rep=DbConnect();
00035 include ('class_user.php');
00036 $User=new cl_user($rep);
00037 $User->Check();
00038 
00039 if ($User->CheckAction($cn,FICHE_READ) == 0 )
00040   {
00041     /* Cannot Access */
00042     NoAccess();
00043   }
00044 
00045 if  ( isset ($_POST['fd_id'])) {
00046   $fiche_def=new fiche_def($cn,$_POST['fd_id']);
00047   $fiche=new fiche($cn);
00048   $e=$fiche->GetByType($fiche_def->id);
00049   $o=0;
00050   //  Heading
00051   $fiche_def->GetAttribut();
00052   foreach ($fiche_def->attribut as $attribut) {
00053           if ( $o == 0 ) {
00054                 printf("%s",$attribut->ad_text);
00055                 $o=1;
00056           }else {
00057             printf(";%s",$attribut->ad_text);
00058             if ( $attribut->ad_id == ATTR_DEF_ACCOUNT 
00059                  && isset ($_REQUEST['with_amount'])) 
00060               echo ";debit;credit;solde";
00061           }
00062     }
00063   printf("\n");
00064   $o=0;
00065   // Details
00066   // Save the accounting 
00067   foreach ($e as $detail) {
00068     foreach ( $detail->attribut as $dattribut ) {
00069           if ( $o == 0 ) {
00070                 printf("%s",$dattribut->av_text);
00071                 $o=1;
00072           } else {
00073             printf (";%s",$dattribut->av_text);
00074             // if solde resquested
00075             //--
00076             if ( $dattribut->ad_id == ATTR_DEF_ACCOUNT 
00077                  && isset ($_REQUEST['with_amount']))  {
00078               $account=new poste ($cn,$dattribut->av_text);
00079               $solde=$account->GetSoldeDetail("j_tech_per between ".$_REQUEST['from_periode'].
00080                                         " and ".
00081                                         $_REQUEST['to_periode']);
00082               
00083               printf(";% 10.2f;% 10.2f;% 10.2f",
00084                      $solde['debit'],
00085                      $solde['credit'],
00086                      $solde['solde']
00087                      );
00088             
00089 
00090             }
00091           }
00092       }
00093     printf("\n");
00094     $o=0;
00095     }
00096 
00097 
00098  }
00099   exit;
00100 ?>