Differences
This shows you the differences between two versions of the page.
| — |
frifinans:programming_reports [2009/08/01 11:10] (current) kj created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Programming - Reportplugins ====== | ||
| + | This page will explain how to make a new report-plugin for FriFinans. | ||
| + | |||
| + | All report-plugins in placed on the server in the folder "ffserver/include/reports". A report-plugin extends the class "ServerReport". This is done in the begging of the report-file like this: | ||
| + | class MyReport extends ServerReport{ | ||
| + | //functions goes here. | ||
| + | } | ||
| + | |||
| + | The ServerReport-class will be included by default by the FriFinans subsystem. It will be included when loading the first report. | ||
| + | |||
| + | In the constructor you must define the title, the description and what kind of data the user should enter to get the report. If you want the user to enter a date, you should do like this: | ||
| + | class MyReport extends ServerReport{ | ||
| + | function __construct(){ | ||
| + | $this->data = array( | ||
| + | "title" => "My own special report", | ||
| + | "description" => "This report will show you all records from the specified date", | ||
| + | "options" => array( | ||
| + | array( | ||
| + | "id" => "date_from", | ||
| + | "title" => "Date", | ||
| + | "type" => "date", | ||
| + | "value" => time() | ||
| + | ) | ||
| + | ); | ||
| + | ); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | When the user selects your report, he will be prompted to enter a date, if he wants to execute your report. To make your report able to being executed, you must also add the Ok()-function. This function will be run upon execution of the report. Do it like this: | ||
| + | class MyReport extends ServerReport{ | ||
| + | function __construct(){ | ||
| + | ... | ||
| + | } | ||
| + | |||
| + | function Ok($options){ | ||
| + | $unix_timestamp = $options["date_from"]; //notice "date_from" is the "id" from the options-array. | ||
| + | |||
| + | $html = "Hello. <b>FriFinans</b> rocks."; | ||
| + | |||
| + | return array( | ||
| + | "type" => "html", | ||
| + | "html" => $html | ||
| + | ); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | When you save this in the the reports-folder ("ffserver/include/reports"), the report will show on the clients. Notice you properly have to restart the server-application to make the report active. | ||