From 4efe0a4e3afc7432ade3a38679a5352eeb337899 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 18 Sep 2007 19:28:58 +0000 Subject: [PATCH] NEW Select a bilan --- html/bilan.php | 109 +++++++------------------------------------------ 1 file changed, 14 insertions(+), 95 deletions(-) diff --git a/html/bilan.php b/html/bilan.php index 24df77077..a0747d0f1 100644 --- a/html/bilan.php +++ b/html/bilan.php @@ -25,6 +25,7 @@ include_once("ac_common.php"); include_once("impress_inc.php"); include_once("postgres.php"); require_once ('header_print.php'); +require_once ('class_bilan.php'); include ('class_user.php'); require_once('class_dossier.php'); @@ -49,101 +50,19 @@ if ( $User->admin == 0 ) { } -// A rtf file is generated -header('Content-type: application/rtf'); - - // It will be called downloaded.pdf -header('Content-Disposition: attachment; filename="bilan.rtf"'); - +$bilan=new Bilan($cn); +$bilan->get_request_get(); +$bilan->load(); +/*\!bug the headers shouldn't be sent here, but it doesn't work + * a html header is send before, to fix asap */ +if ( $bilan->b_type=='odt') + { + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Cache-Control: must-revalidate"); + header('Content-type: "application/vnd.oasis.opendocument.text"'); + header('Content-Disposition: attachment;filename="'.$bilan->b_name.'.odt"',FALSE); + header("Accept-Ranges: bytes"); -// Variable -// Start periode -$start=( isset ($_POST['from_periode']))?$_POST['from_periode']:-1; -$end=( isset ($_POST['to_periode']))?$_POST['to_periode']:-1; - -// Variable if ok ? -if ( $start*$end < 0 ) { - echo_error("Missing Variable start = $start end=$end"); - exit (-1); - } -// Open forms -$bnb_form=fopen('document/fr_be/bnb.form','r'); -if ( $bnb_form == false) { - echo 'Cannot Open'; - exit(); - } -$col=array(); - -// read forms line per line -while (! feof ($bnb_form)) { - $buffer=trim(fgets($bnb_form)); - echo_debug(__FILE__.":".__LINE__." get buffer = ",$buffer); - // $a=(CheckFormula($buffer) == true)?"$buffer ok
":''.'Pas ok '.$buffer."
"; - // echo $a; - // blank line are skipped - if (strlen(trim($buffer))==0) - continue; - - // buffer contains a formula A$=.... - // We need to eval it - //ereg("\\$[a-zA-Z]+[0-9]*=",$buffer,$e); - // echo $e[0]; - //echo "
".$form; - $a=ParseFormula($cn,"$buffer",$buffer,$start,$end,false); - $b=str_replace("$","\$",$a); - echo_debug(__FILE__.":".__LINE__." evaluate ",$b); - - eval("$b;"); - - }// end read form line per line -// echo "
"; -fclose ($bnb_form); -//----------------------------------------------------- -// Open the rtf document in order to read it and to -// replace the <<>> by the appropriate values -// -// Open the rtf template -$bnb_rtf=fopen('document/fr_be/bnb.rtf','r'); -// $out=fopen('tmp/a.rtf','w+'); -// if ( $bnb_rtf == false) { -// echo 'Cannot Open rtf'; -// exit(); -// } -// Read it until the end -while ( !feof($bnb_rtf) ) { - $line_rtf=fgets($bnb_rtf); - if ( ereg('<
>',$line_rtf) ) { - // Create the header - $line_rtf=str_replace('<
>',header_txt($cn),$line_rtf); - echo $line_rtf; - continue; } - - // the line contains the magic << - if (ereg("<<\\$[a-zA-Z]*[0-9]*>>",$line_rtf,$f2) == true) { - // DEBUG - // echo $line_rtf.'
'; - - // the f2 array contains all the magic << in the line - foreach ($f2 as $f2_str) { - // DEBUG - // echo "single_f2 = $f2_str
"; - // replace single_f2 by its value - $f2_value=str_replace("<<","",$f2_str); - $f2_value=str_replace(">>","",$f2_value); - $f2_value=str_replace("$","",$f2_value); - // DEBUG - //echo "f2_value=$f2_value"; - $a=${"$f2_value"}; - // DEBUG echo " a = $a"; - $line_rtf=str_replace($f2_str,$a,$line_rtf); - - }// foreach end - } - // DEBUG - // fwrite($out,$line_rtf); - echo $line_rtf; - - - }// rtf file is read +$bilan->generate(); ?>