From: Bob D. <bd...@si...> - 2004-12-03 15:14:33
|
On Fri, 2004-12-03 at 08:55 +0100, Matteo Ligabue wrote: > First of all, thank to all you guys for your wonderful job on the class ... > After some trouble I get it working on PHP .. what a wonderful tool ... Thanks! > > Some points to spot: > > 1) There should be an option, in the report tag, to set reportheader > behaviour, something like: > -don't print page header on first page use suppressPageHeaderFirstPage = yes > -print page header before report header This could be an option > -print report header before page header (deafult, actual behaviour). > this could be very useful if you want to print logos and header in > each page, and include only in the first a report header The Report header comes out once before the page header. But for what you want to do you could just not use the report header and put everything in the page header > > 2) The XML should be obtained by a socket web request (like fopen in > PHP) so you cna handle them dinamically. If you try the beta release there is a new api function (1.3.0) rlib_add_report_from_buffer(r, some_string) So you can make a dynamic report and pass it in > 3) There should really be a way to show errors in PHP pages ... it's > very frustrating this way ... We agree. Error Reporting doesn't get passed up to the language bindings nicley > > Anyway, this tool is going to change my work ... thank you very much ... > > > # ========================================================================= > # PHP CLASS : RReport > # > # Supported (in XML ): > # <!-- include report.xml --> > # Should be alone on a line, includes the named report. Included > report can include others ... > # #, // at the beginning of a line let the parser ignore the line > > <?php > > dl("librlib.so"); > > include_once( "class.dbengine.php" ); > > > $REPORT_DIR = "reports"; > $REPORT_CACHE_DIR = "reports/cache"; > > class RReport{ > > var $_rh; > var $dbinit; > > var $debug; > > var $formato; > var $parametri = Array( ); > > function RReport( $formato = 'pdf', $debug = 0 ) > { > $this->_rh = rlib_init( ); > $this->formato = $formato; > $this->dbinit = 0; > $this->debug = 1; > } > > function qbe( $queryname, $table, $example, $limitstart = "", $limitsize = "" ) > { > global $db; > > $this->query( $queryname, $db->_qbequery( $table, $example), > $limitstart, $limitsize ); > > } > > function query( $queryname, $sql ) > { > global $db; > > if( $this->dbinit == 0 ){ > rlib_add_datasource_mysql($this->_rh, > "local_mysql", $db->_dbhost, $db->_dbuser, $db->_dbpass, $db->_dbname > ); > $this->dbinit = 1; > } > rlib_add_query_as($this->_rh, "local_mysql", $sql, $queryname ); > } > > function addParameter( $name, $value ) > { > > $this->parametri[$name] = $value; > } > > function addReport( $fn ) > { > global $REPORT_CACHE_DIR; > > if( $this->debug || !file_exists( $REPORT_CACHE_DIR . "/" . $fn ) ){ > $f = fopen( $REPORT_CACHE_DIR . "/" . $fn, "w" ); > fputs( $f, $this->_parseReport( $fn ) ); > fclose( $f ); > } > rlib_add_report( $this->_rh, $REPORT_CACHE_DIR . "/" . $fn ); > } > > function _parseReport( $fn ) > { > global $REPORT_DIR; > global $REPORT_CACHE_DIR; > > $righe = file( $REPORT_DIR . "/" . $fn ); > $ret = ""; > for( $i = 0; $i < sizeof( $righe ); $i++ ) > { > $riga = trim( $righe[$i] ); > # ESCLUDO I COMMENTI > if( substr( $riga,0,1 ) != "#" && substr( $riga, 0, 2 ) != "//" ) > { > if( substr( $riga, 0, 4 ) == "<!--" && substr( $riga, -3 ) == "-->" ) > { > #riga di comando, estraggo ... > $words = split( " ", trim( substr( $riga, 4, strlen( $riga ) - 7 ) ) ); > switch( strtolower( $words[ 0 ] ) ) > { > case "include": > $ret .= $this->_parseReport( trim( $words[ 1 ] ) ); > break; > > } > } > else > { > $ret .= $riga . "\n"; > } > } > > } > return $ret; > } > > function render( $fn = "stampa.pdf" ) > { > $pars = array_keys( $this->parametri ); > for( $i = 0; $i < sizeof( $pars ); $i++ ){ > rlib_add_parameter( $this->_rh, $pars[ $i ], $this->parametri[$pars[$i]] ); > } > rlib_set_output_format_from_text($this->_rh, $this->formato ); > rlib_execute($this->_rh); > > header(rlib_get_content_type($this->_rh ) ); > if( $this->formato == "pdf" ){ > header("Content-Disposition: inline; filename=" . $fn ); > } > rlib_spool($this->_rh); > rlib_free($this->_rh); > } > } > > > ?> > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Rlib-users mailing list > Rli...@li... > https://lists.sourceforge.net/lists/listinfo/rlib-users |