Exemplo n.º 1
0
 protected function GenerateReport_Rlib($param, $format, $query, $params = NULL)
 {
     freemed::acl_enforce('reporting', 'write');
     switch ($format) {
         case 'html':
             $outformat = 'html';
             $ext = 'html';
             break;
         case 'csv':
             $outformat = 'csv';
             $ext = 'csv';
             break;
         case 'text':
             $outformat = 'text';
             $ext = 'txt';
             break;
         case 'pdf':
             $outformat = 'pdf';
             $ext = 'pdf';
             break;
         default:
             $outformat = 'pdf';
             $ext = 'pdf';
             break;
     }
     // end switch format
     @dl("rlib.so");
     if (!function_exists('rlib_init')) {
         syslog(LOG_ERR, get_class($this) . "| rlib PHP extension not found");
     }
     // Global scope things to be passed into m.* namespace
     $GLOBALS['installation'] = INSTALLATION;
     $GLOBALS['generated_on'] = date('r');
     $rlib = rlib_init();
     rlib_add_datasource_mysql($rlib, "local_mysql", DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     rlib_add_query_as($rlib, "local_mysql", $query, "result");
     rlib_add_report_from_buffer($rlib, $param['report_formatting']);
     rlib_set_output_format_from_text($rlib, $outformat);
     rlib_execute($rlib);
     switch ($outformat) {
         case 'pdf':
             Header('Content-type: application/pdf');
             break;
         default:
             Header(rlib_get_content_type($rlib));
             break;
     }
     Header("Content-Disposition: inline; filename=\"" . mktime() . ".{$ext}\"");
     rlib_spool($rlib);
     rlib_free($rlib);
     die;
 }
Exemplo n.º 2
0
<?php

dl("rlib.so");
$hostname = "localhost";
$username = "******";
$password = "******";
$database = "rlib";
$rlib = rlib_init();
rlib_add_datasource_mysql($rlib, "local_mysql", $hostname, $username, $password, $database);
rlib_add_query_as($rlib, "local_mysql", "select * FROM products", "products");
rlib_add_report($rlib, "products.xml");
rlib_set_output_format_from_text($rlib, "pdf");
rlib_execute($rlib);
header(rlib_get_content_type($rlib));
rlib_spool($rlib);
rlib_free($rlib);