Let's see as in example how quickly you can develop easy report
0.Include class
include 'repdesigner.php';
1.We create instance
$rd = new RepDesigner();
We select some data, data is array of associative array values
example
$row['A'] = 'Field value';
$row['B'] = '1';
$row['C'] = '2';
$data[]=$row;
....
$data[]=$row;
ans so on
We setting this array to a source
$rd->SetSourceData($data);
!Important noe! You can use Cache! Or select each time data again, cache saved as post data on the web page of user
turn on cache
$rd->cache_on = true;
if(!$rd->ValidateCache())
{
\Then selkect data again , cache_ttl is regulating minutes to live
$rd->SetSourceData($data);
}
We assign key table rows
$rd->SetHorizontal(["month","city"]);
We assign key table cols
$rd->SetVertical(["salesman","product"]);
We assign data cells
$rd->SetData(["qty","sum"]);
Labels for data cells
$rd->labels['qty'] = 'pcs';
$rd->labels['sum'] = 'usd';
title and Description
$rd->title = 'PHP reportDesigner Demo';
$rd->description = 'Demo report';
Call operation controller (you must provide css file and path to mpdf lib to download pdf reports)
$rd->PerformIfAction('./reporter.css','','','./pdf/mpdf.php');
Transforming data
$rd->TransformData();
Now write html , do not forget prerequisites (JQUERY,JS for repdesigner,CSS file)
<link rel="stylesheet" href="./css/reporter.css"/>
<script type="text/javascript" src="./js/jq.js"></script>
<script type="text/javascript" src="./js/repdesigner.js"></script>
12. Just out the table
<?php
echo $rd->DrawTb();
?>
DONE!
|