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

export_ouv.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$ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 include_once ("ac_common.php");
00026 require_once("class_poste.php");
00027 header('Content-type: application/csv');
00028 header('Content-Disposition: attachment;filename="export_ouv.csv"',FALSE);
00029 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00030   echo "You must choose a Dossier ";
00031   exit -2;
00032 }
00033 include_once ("postgres.php");
00034 /* Admin. Dossier */
00035 $rep=DbConnect();
00036 include_once ("class_user.php");
00037 $User=new cl_user($rep);
00038 $User->Check();
00039 
00040 include_once ("check_priv.php");
00041 
00042 include_once ("user_menu.php");
00043 
00044 $cn=DbConnect($_SESSION['g_dossier']);
00045 // TODO : add a check for permission
00046 if ( $User->CheckAction($cn,EXP_IMP_ECR) == 0 ) {
00047   /* Cannot Access */
00048   NoAccess();
00049   exit -1;                      
00050  }
00051 if ( !isset ($_GET['p_periode'])) {
00052         echo 'Erreur : aucune periode demandée';
00053         exit(0);
00054 }
00055 $sql_from=GetArray($cn,"select min(p_id) from parm_periode where p_exercice=".$_GET['p_periode']);
00056 
00057 $sql_to=GetArray($cn,"select max(p_id) from parm_periode where p_exercice=".$_GET['p_periode']);
00058 
00059 $ret=GetArray($cn,"select distinct j_poste::text 
00060                 from jrnx inner join tmp_pcmn on (pcm_val=j_poste)
00061                 where 
00062                 j_tech_per >= ".$sql_from[0]['min']." and 
00063                 j_tech_per <= ".$sql_to[0]['max']." and j_poste not like '7%'
00064                 and j_poste not like '6%'
00065                  order by j_poste::text");
00066 if ( $ret == null ) {echo 'Rien à exporter'; exit();}
00067 printf ("OUVERTURE\n");
00068 foreach ($ret as $poste_id) {
00069 //var_dump($poste_id); echo "<br>";
00070         $Poste=new poste($cn,$poste_id['j_poste']);
00071         $sql="j_tech_per >=". $sql_from[0]['min']." and j_tech_per <=".$sql_to[0]['max'];
00072         $result=$Poste->GetSoldeDetail($sql );
00073         if ( $result['solde'] == 0 ) continue;
00074         if ( $result['debit'] > $result ['credit'] ) {
00075                 printf ("d;%d;%12.4f\n",$Poste->id,$result['solde']);
00076         } else {
00077                 printf ("c;%d;%12.4f\n",$Poste->id,$result['solde']);
00078         }
00079 }
00080 
00081 ?>

Generated on Fri Jun 23 00:12:45 2006 for phpcompta by  doxygen 1.4.4