Make file PDF export example with headers and footers on all pages except for the first one.
<?php
require_once "SakilaRental.php";
$report = new SakilaRental;
$report->run()->render();
<?php
require_once "SakilaRental.php";
$report = new SakilaRental;
$report->run()
->export('SakilaRentalPDF')
->pdf(array(
"headerCallback" => "function(headerContent, pageNum, numPages){
if (pageNum == 1) return ''; //don't show header for the 1st page
return headerContent;
}",
"footerCallback" => "function(footerContent, pageNum, numPages){
if (pageNum == 1) return ''; //don't show footer for the 1st page
return footerContent.replace('{pageNum}', pageNum - 1);
}",
"format"=>"A4",
"orientation"=>"portrait",
//"zoom"=>2
))
->toBrowser("SakilaRentalPDF.pdf");
<?php
require_once "../../../load.koolreport.php";
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
class SakilaRental extends KoolReport
{
use \koolreport\export\Exportable;
public function settings()
{
return array(
"dataSources"=>array(
"export1"=>array(
"class"=>'\koolreport\datasources\CSVDataSource',
'filePath'=>dirname(__FILE__)."/dataSakila.csv",
)
)
);
}
protected function setup()
{
$this->src('export1')
->pipe(new TimeBucket(array(
"payment_date"=>"month"
)))
->pipe(new Group(array(
"by"=>"payment_date",
"sum"=>"amount"
)))
->pipe($this->dataStore('sale_by_month'));
}
}
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\ColumnChart;
use \koolreport\widgets\google\PieChart;
?>
<div class="report-content" style="width : 80%; padding: 0 auto; margin : 0 auto; text-align: center;">
<div class="text-center">
<h1>Cash In Report</h1>
<p class="lead">This example shows how to set PDF's custom header and footer</p>
<a href="export.php" class="btn btn-primary">Download PDF</a>
</div>
<hr/>
<?php
ColumnChart::create(array(
"dataStore"=>$this->dataStore('sale_by_month'),
"columns"=>array(
"payment_date"=>array(
"label"=>"Month",
"type"=>"datetime",
"format"=>"Y-n",
"displayFormat"=>"F, Y",
),
"amount"=>array(
"label"=>"Amount",
"type"=>"number",
"prefix"=>"$",
)
),
"width"=>"100%",
));
?>
<?php
PieChart::create(array(
"title"=>"Sale Report",
"dataStore"=>$this->dataStore('sale_by_month'),
"columns"=>array(
"payment_date"=>array(
"label"=>"Month",
"type"=>"datetime",
"format"=>"Y-n",
"displayFormat"=>"F, Y",
),
"amount"=>array(
"label"=>"Amount",
"type"=>"number",
"prefix"=>"$",
)
),
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('sale_by_month'),
"columns"=>array(
"payment_date"=>array(
"label"=>"Month",
"type"=>"datetime",
"format"=>"Y-n",
"displayFormat"=>"F, Y",
),
"amount"=>array(
"label"=>"Amount",
"type"=>"number",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
</div>
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\ColumnChart;
use \koolreport\widgets\google\PieChart;
?>
<html>
<style>
.title {
text-align: center;
border: 3px solid green;
}
</style>
<body style="margin-top:2cm;margin-right:2cm;margin-bottom:2cm;margin-left:3cm;width:100%; margin-top :2cm">
<link rel="stylesheet" href="../../../assets/bs3/bootstrap.min.css" />
<link rel="stylesheet" href="../../../assets/bs3/bootstrap-theme.min.css" />
<div class="title">
<h1>Report Title</h1>
<h2>Report Subtitle</h3>
</div>
<div class="page-break"></div>
<div class='page-header' style='height: 50px;'>
<span style="text-align: center;">Report Header</span>
</div>
<div class='page-footer'>
<span style="text-align: center;">Report Footer - Page {pageNum}</span>
</div>
<div class="text-center">
<h1>Example PDF Custom Header / Footer</h1>
<h4>This report show the cash-in report per month</h4>
</div>
<hr />
<?php
ColumnChart::create(array(
"dataStore" => $this->dataStore('sale_by_month'),
"columns" => array(
"payment_date" => array(
"label" => "Month",
"type" => "datetime",
"format" => "Y-n",
"displayFormat" => "F, Y",
),
"amount" => array(
"label" => "Amount",
"type" => "number",
"prefix" => "$",
)
),
"width" => "100%",
));
?>
<?php
PieChart::create(array(
"title" => "Sale Report",
"dataStore" => $this->dataStore('sale_by_month'),
"columns" => array(
"payment_date" => array(
"label" => "Month",
"type" => "datetime",
"format" => "Y-n",
"displayFormat" => "F, Y",
),
"amount" => array(
"label" => "Amount",
"type" => "number",
"prefix" => "$",
)
),
));
?>
<div class="page-break"></div>
<?php
Table::create(array(
"dataStore" => $this->dataStore('sale_by_month'),
"columns" => array(
"payment_date" => array(
"label" => "Month",
"type" => "datetime",
"format" => "Y-n",
"displayFormat" => "F, Y",
),
"amount" => array(
"label" => "Amount",
"type" => "number",
"prefix" => "$",
)
),
"cssClass" => array(
"table" => "table table-hover table-bordered"
)
));
?>
</body>
</html>