Пример #1
0
<?php

$data[0] = array('company', 'region', 'district', 'store', 'sales');
$data[1] = array('Foo, Inc.', 'Region A', 'District X', 'Store #1', 1500.0);
$data[2] = array('Foo, Inc.', 'Region A', 'District X', 'Store #2', 1300.0);
$data[3] = array('Foo, Inc.', 'Region A', 'District Y', 'Store #3', 2000.0);
$data[4] = array('Foo, Inc.', 'Region A', 'District Y', 'Store #4', 1800.0);
$data[5] = array('Foo, Inc.', 'Region B', 'District M', 'Store #11', 2500.0);
$data[6] = array('Foo, Inc.', 'Region B', 'District M', 'Store #12', 2300.0);
$data[7] = array('Foo, Inc.', 'Region B', 'District N', 'Store #13', 3000.0);
$data[8] = array('Foo, Inc.', 'Region B', 'District N', 'Store #14', 2800.0);
$rlib = rlib_init();
rlib_version();
rlib_add_datasource_array($rlib, "local_array");
rlib_add_query_as($rlib, "local_array", "data", "data");
$output_format = 'xml';
if (isset($argv[1])) {
    $output_format = $argv[1];
}
rlib_add_report($rlib, "breaks.xml");
rlib_set_output_format_from_text($rlib, $output_format);
rlib_set_output_parameter($rlib, "debugging", "yes");
rlib_set_output_parameter($rlib, "only_quote_strings", "yes");
rlib_set_locale($rlib, "en_US");
rlib_execute($rlib);
// header(rlib_get_content_type($rlib));
rlib_spool($rlib);
rlib_free($rlib);
Пример #2
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;
 }