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="jrn.csv"',FALSE);
00027 include_once ("ac_common.php");
00028
00029 include_once ("postgres.php");
00030 include_once("check_priv.php");
00031 include("class_jrn.php");
00032 $cn=DbConnect($_SESSION['g_dossier']);
00033 $rep=DbConnect();
00034
00035 include ('class_user.php');
00036 $User=new cl_user($rep);
00037 $User->Check();
00038 if ( $User->CheckAction($cn,IMP) == 0 ||
00039 $User->AccessJrn($cn,$_GET['jrn_id']) == false){
00040
00041 NoAccess();
00042 }
00043
00044
00045 $p_cent=( isset ( $_GET['central']) )?$_GET['central']:'off';
00046
00047 $Jrn=new jrn($cn,$_GET['jrn_id']);
00048
00049 $Jrn->GetName();
00050
00051
00052 if ( $_GET['p_simple'] == 0 )
00053 {
00054 $Jrn->GetRow( $_GET['from_periode'],
00055 $_GET['to_periode'],
00056 $p_cent);
00057
00058 if ( count($Jrn->row) == 0)
00059 exit;
00060 foreach ( $Jrn->row as $op ) {
00061
00062 $desc=$op['description'];
00063 $desc=str_replace("<b>","",$desc);
00064 $desc=str_replace("</b>","",$desc);
00065 $desc=str_replace("<i>","",$desc);
00066 $desc=str_replace("</i>","",$desc);
00067 $desc=str_replace('"',"'",$desc);
00068
00069 printf("\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t%8.4f\t%8.4f\n",
00070 $op['j_id'],
00071 $op['internal'],
00072 $op['j_date'],
00073 $op['poste'],
00074 $desc,
00075 $op['cred_montant'],
00076 $op['deb_montant']
00077 );
00078
00079 }
00080 exit;
00081 }
00082 else
00083 {
00084 $Row=$Jrn->GetRowSimple($_GET['from_periode'],
00085 $_GET['to_periode'],
00086 $p_cent);
00087
00088 printf ('" operation "'.
00089 '"Date"'.
00090 '"commentaire"'.
00091 '"internal"'.
00092 '"montant"');
00093
00094 foreach ($Row as $line)
00095 {
00096 echo $line['num'].";";
00097 echo $line['date'].";";
00098 echo $line['comment'].";";
00099 echo $line['jr_internal'].";";
00100
00101
00102
00103
00104 if ( $line['jrn_def_type'] == 'FIN' ) {
00105 $positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
00106 " where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
00107 " and j_debit='f'");
00108
00109
00110 echo ( $positive != 0 )?sprintf("-%8.2f",$line['montant']):sprintf("%8.2f",$line['montant']);
00111 echo ";";
00112 }
00113 else
00114 {
00115 printf("% 8.2f",$line['montant']).";";
00116 }
00117
00118 printf("\r\n");
00119 }
00120
00121
00122 }
00123 ?>