I'm trying to setup exporting to PDF via Chrome Headless, but I'm getting the following PHP exception:
Fatal error: Uncaught RuntimeException: Directory name must not be empty. in C:\wamp64\www\LegalBillingAPI\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 46
Here are the files I created for this report...
index.php
<?php
require_once "MatterTotalsByAccount.php";
$mattertotalsbyaccount = new MatterTotalsByAccount;
$mattertotalsbyaccount
->cloudExport("MatterTotalsByAccount")
->chromeHeadlessio("my token")
->pdf(array(
"format"=>"A4",
"landscape"=>false
))
->toBrowser("MatterTotalsByAccount.pdf");
MatterTotalsByAccount
<?php
// Require autoload.php from koolreport library
require_once "../../koolreport/core/autoload.php";
//Specify some data processes that will be used to process
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
//Define the class
class MatterTotalsByAccount extends \koolreport\KoolReport
{
use \koolreport\cloudexport\Exportable;
protected function settings()
{
//Define the "matter_totals_by_account" data source which is the result of the MySQL Stored Procedure
return array(
"dataSources"=>array(
"matter_totals_by_account"=>array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'databasename',
'charset' => 'utf8',
'class' => "\koolreport\datasources\MySQLDataSource"
),
)
);
}
protected function setup()
{
$this->src('matter_totals_by_account')
->query("CALL MatterTotalsByAccount('2019-01-01','2019-12-31')")
//Select the data source then pipe data through various process
//until it reach the end which is the dataStore named "sales_by_customer".
->pipe(new Group(array(
"by"=>array("accountName","matter"),
"sum"=>"total"
)))
->pipe(new Sort(array(
"accountName","matter"=>"asc"
)))
//->pipe(new Limit(array(10)))
->pipe($this->dataStore('totals_by_matter_and_account'));
}
}
MatterTotalsByAccount.view.php
<?php
use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
<div class="text-center">
<h1>Legal Fees Paid: xx/xx/xxxx to xx/xx/xxxx</h1>
<p class="lead">Sorted by Account Name, Matter</p>
</div>
<?php
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('totals_by_matter_and_account'),
"grouping"=>array(
"accountName"=>array(
"calculate"=>array(
"{sumAmount}"=>array("sum","total")
),
"top"=>"<b>{accountName}</b>",
"bottom"=>"<td align='right'><b>Total:</b></td><td align='right'><b>{sumAmount}</b></td>",
//"bottom"=>"<td><b>{accountName} TOTAL:</b></td><td><b>{sumAmount}</b></td>",
),
),
"sorting"=>array(
"matter"=>"asc"
),
"showHeader"=>false,
"showFooter"=>true,
"columns"=>array(
/*
"accountName"=>array(
"label"=>"Account",
),
*/
"matter"=>array(
"label"=>"Matter",
"cssStyle"=>"padding-left: 50px"
),
"total"=>array(
"type"=>"number",
"label"=>"Total",
"prefix"=>"$",
"decimals"=>2,
"cssStyle"=>"text-align:right",
"footer"=>"sum",
"footerText" =>"<b><i>TOTAL FEES PAID</i></b>: <b>@value</b>"
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
</div>