00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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
00066
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
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 ?>