I'm looking for a web-based reporting framework which is PHP-based and works with MySQL.
Here's my problem (besides being too lazy to program this on my own): I have a large (50k+ rows) table which stores log data for multiple clients. These clients need to be able to sort and search and do all those grand things.
I'd really like something with a decent amount of power behind it, which is why I'm apprehensive about building one myself. This isn't a big enough need to merit putting an exorbitant amount of time into, but it is a necessary function for my clients.
Ideally, I would like some sort of framework which I can either pass data or it get the data itself with a templating engine (so it would do all the presentation). I could get the rendered presentation and drop it into my site.
Something so nice probably doesn't exist, but maybe I'll be lucky.
You may try the KoolReport.
Disclaimer: I am working on this project.
It is a php reporting framework, exactly what you look for. You may download framework through the website, clone project from github or use composer to install: composer require koolphp/koolreport
.
After installing, here is a basic example of creating a sale report
index.php
: This is bootstrap file
<?php
require_once "SalesByCustomer.php";
$salesByCustomer = new SalesByCustomer;
$salesByCustomer->run()->render();
SaleByCustomer.php
: This file defines data connection and data process
<?php
require_once "koolreport/autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
use \koolreport\processes\Sort;
class SalesByCustomer extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"sales"=>array(
"connectionString"=>"mysql:host=localhost;dbname=db_sales",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('sales')
->query("SELECT customerName,dollar_sales FROM customer_product_dollarsales")
->pipe(new Group(array(
"by"=>"customerName",
"sum"=>"dollar_sales"
)))
->pipe(new Sort(array(
"dollar_sales"=>"desc"
)))
->pipe(new Limit(array(10)))
->pipe($this->dataStore('sales_by_customer'));
}
}
SalesByCustomer.view.php
: This the view file where you can data visualized
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\BarChart;
?>
<div class="text-center">
<h1>Sales Report</h1>
<h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>
<?php
BarChart::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"width"=>"100%",
"height"=>"500px",
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"options"=>array(
"title"=>"Sales By Customer"
)
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
And here is the result.
Basically you can get data from many data sources at the same time, pipe them through processes then stored result into data store. The data in data store then will be available in the view to get visualization. The Google Charts is integrated inside framework so you can use right away to create beautiful charts and graphs.
Alright, here are some good links:
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With