Reporting Library

lib_reporting.inc

  • lib_reporting.inc is a sahana library which enables module developers to generate module specific reports in ods, pdf, and xhtml file formats.
  • Include the function to the script,
include_once $global['approot']."/inc/reporting/lib_reporting.inc";

Generate reports

Starting a report

shn_report_fopen($file_format,$file_name,$keyword_in,$dynamic_enable);
  • parameters :
  1. $file_format – (data type = String) - File format of the report. OpenDocument Spreadsheet = ods, PDF = pdf, MS EXCEL = xls and XHTML = xhtml
  2. $file_name – (data type = String) - File name of the report. This is used when the report is downloaded.
  3. $keyword_in – (data Type = Array) - This can be used to specify keywords for the report. This keywords would be helpful to search reports later.
  4. $dynamic_enable – (data type = String) - This is to specify whether this report is dynamically generated one or not.
eg: shn_report_fopen('pdf',“myreport”,array('key1'=>'myreport','mod'=>'catalogue'),false);

Add a title to the report

shn_report_add_title($title);
  • parameters :
  1. $title – (data type = String) - This is to specify the title of the report.
eg:shn_report_add_title('Inventory Report')

Add a table to the report

shn_report_add_table($headerArray,$dataArray);
  • parameters :
  1. $headerArray – (data type = Array) - This is to specify headers of the table
  2. $dataArray – (data type = Array) - This is to specify the data of the table. Each row of the table is represented by an array and all those arrays should be pushed in to one array.
eg:$headerArray = array('column1header','column2header','column3header');
$dataArray = array(
array('row1data1','row1data2','row1data3'),
array('row2data1','row2data2','row2data3'),
array('row3data1','row3data2','row3data3'),);
shn_report_add_table($headerArray,$dataArray);

Add a paragraph to the report

shn_report_add_summary($summary);
  • parameters :
  1. $summery – (data type = String) - This is to insert paragraphs, summaries to the report.
eg: $summary= “This is an example for inserting a summary/paragraph to the report”;
shn_report_add_summary($summary);

Close the report

shn_report_close();
  • This function call will complete the report creation.

Report Download link

report_download_link($report_id);
  • parameters :
  1. $report_id – (data type = String) returns the report download link.

Navigation
  • Navigate