// 1st Courbe_Prev15j.php
<?php
require_once "CourbePrev15j.php";
$CourbePrev15j = new CourbePrev15j(array(
"data"=>$data_source,));
$CourbePrev15j->run()->render();
?>
// 2nd CourbePrev15j.php
<?php
require_once "koolreport/core/autoload.php";
use \koolreport\KoolReport;
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
class CourbePrev15j extends KoolReport
{
use \koolreport\export\Exportable;
use \koolreport\bootstrap4\Theme;
public function settings()
{
return array(
"dataSources"=>array(
"mydata"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"data"=>$this->params["data"],
"dataFormat"=>"associate",
)
)
);
}
public function setup()
{
$this->src('mydata')
->pipe(new Sort(array("date"=>"asc",)))
->pipe($this->dataStore('courbe_prev15j'));
}
}
?>
// 3rd CourbePrev15j.view.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\LineChart;
?>
<?php
LineChart::create(array(
"title"=>"",
"dataSource"=>$this->dataStore('courbe_prev15j'),
"options"=>array(
"curveType"=>"function"
),
"columns"=>array(
"date"=>array(
"type"=>"date",
"xFormat"=>"%Y%m%d",
"xDisplayFormat"=>"%B %d, %Y"),
"predic"=>array(
"label"=>"Prevision",
"type"=>"number",
"prefix"=>"W"
),
)
));
?>
// 4th export_prev15j.php
<?php
require_once "report/CourbePrev15j.php";
$report = new CourbePrev15j(array(
"data"=>$data_source,));
$report->run()
->export('CourbePrev15jPdf')
->settings([
"useLocalTempFolder" => true,
"serverLocalAddress" => "127.0.0.1",
])
->pdf(array(
"format"=>"A4",
"orientation"=>"portrait",
//"zoom"=>2
))
//->toBrowser("courbe_predic.pdf",true);
->saveAs("tmp/courbe_predic.pdf");
?>
// 5th CourbePrev15jPdf.view.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\LineChart;
use \koolreport\bootstrap4\Theme;
?>
<html>
<head>
<style>
* {
-webkit-print-color-adjust: exact !important;
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
}
</style>
</head>
<body style="margin:1in">
<?php
LineChart::create(array(
"title"=>"",
"dataSource"=>$this->dataStore('courbe_prev15j'),
"options"=>array(
"curveType"=>"function"
),
"columns"=>array(
"date" =>array(
"type"=>"date",
"xFormat"=>"%Y%m%d",
"xDisplayFormat"=>"%B %d, %Y"),
"predic"=>array(
"label"=>"Prevision",
"type"=>"number",
"prefix"=>"W"
),
)
));
?>
<hr/>
<?php
Table::create(array(
"dataStore"=>$this->dataStore("courbe_prev15j"),
"columns"=>array(
"date"=>array(
"label"=>"Date"
),
"predic"=>array(
"label"=>"Prévision"
)
),
"cssClass"=>array(
"table"=>"table",
"thead"=>"thead-dark"
)
));
?>
</body>
</html>