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("impress_inc.php");
00026 include_once("postgres.php");
00027
00028
00029 include ('class_user.php');
00030
00031 $cn=DbConnect($_SESSION['g_dossier']);
00032
00033 $User=new cl_user($cn);
00034 $User->Check();
00035
00036
00037
00038 if ( $User->admin == 0 ) {
00039 if ($User->CheckAction($cn,IMP)
00040 ==0
00041 )
00042 {
00043
00044 NoAccess();
00045 }
00046
00047 }
00048
00049
00050 header('Content-type: application/rtf');
00051
00052
00053 header('Content-Disposition: attachment; filename="bilan.rtf"');
00054
00055
00056
00057
00058 $start=( isset ($_POST['from_periode']))?$_POST['from_periode']:-1;
00059 $end=( isset ($_POST['to_periode']))?$_POST['to_periode']:-1;
00060
00061
00062 if ( $start*$end < 0 ) {
00063 echo_error("Missing Variable start = $start end=$end");
00064 exit (-1);
00065 }
00066
00067 $bnb_form=fopen('document/fr_be/bnb.form','r');
00068 if ( $bnb_form == false) {
00069 echo 'Cannot Open';
00070 exit();
00071 }
00072 $col=array();
00073
00074
00075 while (! feof ($bnb_form)) {
00076 $buffer=trim(fgets($bnb_form));
00077
00078
00079
00080 if (strlen(trim($buffer))==0)
00081 continue;
00082
00083
00084
00085
00086
00087
00088 $a=ParseFormula($cn,"$buffer",$buffer,$start,$end,false);
00089 $b=str_replace("$","\$",$a);
00090
00091
00092 eval("$b;");
00093
00094
00095 }
00096
00097 fclose ($bnb_form);
00098
00099
00100
00101
00102
00103 $bnb_rtf=fopen('document/fr_be/bnb.rtf','r');
00104
00105
00106
00107
00108
00109
00110 while ( !feof($bnb_rtf) ) {
00111 $line_rtf=fgets($bnb_rtf);
00112
00113 if (ereg("<<\\$[a-zA-Z]*[0-9]*>>",$line_rtf,$f2) == true) {
00114
00115
00116
00117
00118 foreach ($f2 as $f2_str) {
00119
00120
00121
00122 $f2_value=str_replace("<<","",$f2_str);
00123 $f2_value=str_replace(">>","",$f2_value);
00124 $f2_value=str_replace("$","",$f2_value);
00125
00126
00127 $a=${"$f2_value"};
00128
00129 $line_rtf=str_replace($f2_str,$a,$line_rtf);
00130
00131 }
00132 }
00133
00134
00135 echo $line_rtf;
00136
00137
00138 }
00139 ?>