00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 include_once("ac_common.php");
00025 include_once ("postgres.php");
00026 include ('class_user.php');
00027 include("class_rapport.php");
00028 include("impress_inc.php");
00029 header('Content-type: application/csv');
00030 header('Content-Disposition: attachment;filename="rapport.csv"',FALSE);
00031
00032
00033 $cn=DbConnect($_SESSION['g_dossier']);
00034
00035
00036 $User=new cl_user($cn);
00037 $User->Check();
00038
00039
00040 $Form=new rapport($cn,$_POST['form_id']);
00041 $Form->GetName();
00042
00043
00044 if ( $_POST['p_step'] == 0 )
00045 {
00046 $array=$Form->GetRow( $_POST['from_periode'],
00047 $_POST['to_periode']
00048 );
00049 if ( count($Form->row ) == 0 )
00050 exit;
00051
00052 echo "\"Mois,\"\t\"Description\"\t,".
00053 "\"Montant\"\t";
00054
00055
00056
00057 foreach ( $Form->row as $op ) {
00058 echo '"'.$op['desc'].'"'."\t,".
00059 sprintf("%8.2f",$op['montant'])."\t".
00060 "\n";
00061
00062 }
00063 }
00064 else
00065 {
00066
00067
00068 for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
00069 {
00070 $periode=getPeriodeName($cn,$e);
00071 if ( $periode == null ) continue;
00072 $array[]=$Form->GetRow($e,$e);
00073 $periode_name[]=$periode;
00074 }
00075
00076
00077 $x="";
00078 foreach ($array[0] as $e)
00079 {
00080 printf("%s%s",$x,$e['desc']);
00081 $x=";";
00082
00083 }
00084 printf("\n");
00085
00086
00087 $a=0;
00088 foreach ($array as $e )
00089 {
00090 print $periode_name[$a];
00091 $a++;
00092 foreach ($e as $elt)
00093 {
00094 printf(";%s",$elt['montant']);
00095 }
00096 printf("\n");
00097 }
00098 }
00099 exit;
00100 ?>