Here is another solution:
You create an Invoice report which receive invoiceId as parameter, the usage will be like this:
//index.php
$invoiceId = 3; // Let say you want to print invoice number 3
$invoice = new Invoice([
"invoiceId"=>$invoiceId,
]);
$invoice->export()->pdf()->saveAs("invoice_$i.pdf");
So you create Invoice.php
like this:
class Invoice extends \koolreport\KoolReport
{
use \koolreport\export\Exportable;
protected function settings()
{
// return your datasources here
}
protected function setup()
{
//Simple flow to get single record
$this->src("mydb")
->query("select * from invoices where invoiceId=:invoiceId")
->params([
":invoiceId"=>$this->params["invoiceId"]
])
->pipe($this->dataStore("result"));
}
}
Here is the Invoice.view.php
file:
<?php
$invoiceRow = $this->dataStore("result")->get(0); // Get the data row in form of associate array
//Base on the
?>
<html>
<body>
<!-- You design your own invoice table html here and you have your data from $invoiceRow -->
</body>
</html>
Let me know if you need further assistance.