Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi,
Please find full code.
Thank you for supporting. Vittorio
index.php
<?php
$tourop= $_POST["tourop"];
$incstaff=$_POST["incstaff"];
$anno=$_POST['anno'];
$dayarr = $_POST["dayarr"];
$montharr = $_POST["montharr"];
$yeararr=$_POST["yeararr"];
$dep=$_POST["arr"];
//echo $arr;
$datadep=$dep;
//echo $datadep;
require_once "Departures.php";
$report = new Departures(array(
"datasel"=>$datadep,
"tourop"=>$tourop,
"anno"=>$anno
));
$report->run()->render();
?>
Arrivals.php
<?php
require_once "../koolreport/core/autoload.php";
use \koolreport\KoolReport;
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
//Define the class
class Arrivals extends \koolreport\KoolReport
{
use \koolreport\amazing\Theme;
use \koolreport\export\Exportable;
public function settings()
{
return array(
"dataSources"=>array(
"arrivals"=>array(
'connectionString' => 'connString',
'username' => 'uid',
'password' => 'pwd',
'charset' => 'utf8',
))
);
}
protected function setup()
{
//Select the data source then pipe data through various process
//until it reach the end which is the dataStore named "arrivals".
$this->src('arrivals')
->query("
SELECT
`rclientiprenota2021`.`idprenota`,
group_concat(`clienti`.`cognome` separator ' / ') AS `Names`,
`prenota2021`.`idappartamenti`,
`periodi2021`.`datainizio` ,
`periodi20211`.`datafine` ,
SUBSTRING(`prenota2021`.`cat_persone`,LOCATE('<0>',`prenota2021`.`cat_persone`)+3,1) as Adu,
SUBSTRING(`prenota2021`.`cat_persone`,LOCATE('<1>',`prenota2021`.`cat_persone`)+3,1) as Chd,
SUBSTRING(`prenota2021`.`cat_persone`,LOCATE('<2>',`prenota2021`.`cat_persone`)+3,1) as Inf,
SUBSTRING_INDEX(`prenota2021`.`commento`,'Treatment<',-1) as Arr,
`prenota2021`.`origine` AS Origin,
SUBSTRING_INDEX(`prenota2021`.`commento`,'>>>Treatment<',1) as Notes,
IF (ISNULL(`prenota2021`.`checkin`),
'',
DATE_FORMAT(`prenota2021`.`checkin`,'%h:%i %p')) As CheckIn
FROM
`rclientiprenota2021`
INNER JOIN `clienti` ON (`rclientiprenota2021`.`idclienti` = `clienti`.`idclienti`)
INNER JOIN `prenota2021` ON (`rclientiprenota2021`.`idprenota` = `prenota2021`.`idprenota`)
INNER JOIN `periodi2021` ON (`prenota2021`.`iddatainizio` = `periodi2021`.`idperiodi`)
INNER JOIN `periodi2021` `periodi20211` ON (`prenota2021`.`iddatafine` = `periodi20211`.`idperiodi`)
WHERE
`periodi2021`.`datainizio` =:datasel
GROUP BY
`rclientiprenota2021`.`idprenota`,
`prenota2021`.`idappartamenti`,
`periodi2021`.`datainizio`,
`periodi20211`.`datafine`,
`prenota2021`.`num_persone`,
`prenota2021`.`origine`,
`prenota2021`.`commento`,
`prenota2021`.`checkin`
ORDER BY
`prenota2021`.`idappartamenti`,
`periodi2021`.`datainizio`
")
->params(array(
":datasel"=>$this->params["datasel"]
))
->pipe($this->dataStore('result'));
}
}
?>
ArrivalsPdf.Vieew.php
<?php
use \koolreport\widgets\koolphp\Table;
//use \koolreport\widgets\google\ColumnChart;
?>
<html>
<body style="margin:0.5in 1in 0.5in 1in">
<link rel="stylesheet" href="../../../assets/bs3/bootstrap.min.css" />
<link rel="stylesheet" href="../../../assets/bs3/bootstrap-theme.min.css" />
<div class="page-header" style="text-align:right"><i>Sakila Rental Report</i></div>
<div class="page-footer" style="text-align:right">{pageNum}</div>
<div class="text-center">
<h1>Cash In Report</h1>
<h4>This report show the cash-in report per month</h4>
</div>
<hr/>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('result'),
"columns"=>array(
"Names"=>array(
"label"=>"Names"
),
"idappartamenti"=>array(
"label"=>"Room"
),
"datainizio"=>array(
"label"=>"Arrival"
),
"datafine"=>array(
"label"=>"Departure"
),
"Origin"=>array(
"label"=>"Origin"
),
"Adu"=>array(
"label"=>"ADU"
),
"Chd"=>array(
"label"=>"CHD"
),
"Inf"=>array(
"label"=>"INF"
),
"Arr"=>array(
"label"=>"Arr"
),
"Notes"=>array(
"label"=>"Note"
),
"CheckIn"=>array(
"label"=>"Check-In"
),
),
));
?>
</body>
</html>
export.php
<?php
require_once "Arrivals.php";
$report = new Arrivals;
$report->run()
->export('ArrivalsPdf')
->pdf(array(
"headerCallback" => "function(headerContent, pageNum, numPages){
if (pageNum == 1) return ''; //don't show header for 1st page
return headerContent;
}",
"footerCallback" => "function(footerContent, pageNum, numPages){
if (pageNum == 1) return footerContent;
return ''; //don't show header for pages other than 1st one
}",
"format"=>"A4",
"orientation"=>"lansdscape",
//"zoom"=>2
))
->toBrowser("Arrivals.pdf");
?>
The 500 is very general, so could you please turn on error reporting with error_reporting(E_ALL)
to know what went wrong. You should not test the page with export but try to run this:
$report->run()->render("ArrivalsPdf");
Until you receive no error then you move to export the ArrivalsPdf view to pdf.
I have enables erros catc. This is the result when I try to launch PDF:
Fatal error: Uncaught exception 'Exception' with message 'Could not find phantomjs executed file in bin folder' in /volume1/web/seven2021_koolreport/koolreport/export/Handler.php:55 Stack trace: #0 /volume1/web/seven2021_koolreport/koolreport/export/Handler.php(277): koolreport\export\Handler->runPhantom('/volume1/web/se...', '/var/services/t...', '/var/services/t...', 'eyJoZWFkZXJDYWx...') #1 /volume1/web/seven2021_koolreport/arrivals/export.php(20): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /volume1/web/seven2021_koolreport/koolreport/export/Handler.php on line 55
I see, could you please download the phantomjs, here is the instruction.
Same error, just handler.php line now is 71. I use PHP 5.6
Fatal error: Uncaught exception 'Exception' with message 'Could not execute phantomjs' in /volume1/web/seven2021_koolreport/koolreport/export/Handler.php:71 Stack trace: #0 /volume1/web/seven2021_koolreport/koolreport/export/Handler.php(277): koolreport\export\Handler->runPhantom('/volume1/web/se...', '/var/services/t...', '/var/services/t...', 'eyJoZWFkZXJDYWx...') #1 /volume1/web/seven2021_koolreport/arrivals/export.php(20): koolreport\export\Handler->pdf(Array) #2 {main} thrown in /volume1/web/seven2021_koolreport/koolreport/export/Handler.php on line 71
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo