Sebastian,
Ok, I managed to get this working (sort of) by doing the following:
The button for the PDF download is not inside a form; I created a function which builds up a GET string and then sets the window.location.href to export.php.
in export.php I call the report like this:
$report = new Payroll(array(
"store"=>$_GET['store'],
"employees"=>$_GET['employees'],
"mindt"=>$_GET['mindt'],
"maxdt"=>$_GET['maxdt']
));
and then to export:
$report->run()
->export('PayrollRptPdf',array(
"store"=>$_GET['store'],
"employees"=>$_GET['employees'],
"mindt"=>$_GET['mindt'],
"maxdt"=>$_GET['maxdt']
))
->pdf(array(
"format"=>"letter",
"orientation"=>"portrait"
))
->toBrowser($filename);
This is now showing the datatable with data in pdf form. Almost done! Now the datatable in the export pdf has data BUT... the datatable is not rendering the grouping and rows at all:
DataTables::create(array(
"name" => "payrollbyemp",
"dataStore"=>$this->dataStore("paybyp"),
"options"=>array(
'autoWidth' => false,
array(1,"asc"), //Sort by first column desc
array(2,"asc"), //Sort by second column asc
"method"=>"post",
"columns"=> [
"STR_ID"=>[
"label"=>"Store",
"format"=>"string"],
"USR_ID"=>[
"label"=>"User ID",
],
"HAS_COMMNTS"=>[
"label"=>"comments",
'formatValue'=>function($value, $row, $cKey) {
if($row["IsHoliday"] == 1){
return $row["HolidayText"];
}else{
return $row["HAS_COMMNTS"];
}
}
],
"PERIOD_DT"=>[
"label"=>"Clock Date",
"displayFormat"=>"m-d-Y"
],
"CLOCK_IN"=>[
"label"=>"Clock In"],
"CLOCK_OUT"=>[
"label"=>"Clock Out"],
"PD_HRS"=>[
"label"=>"Paid Hours"],
"TTL"=>[
"label"=>"Total Hours",
"formatValue" => function($value, $row, $cKey) {
return max(number_format($value, 2, '.', ' '),0);
},
],
"USRNAME"=>[
"label"=>"user",
"visible"=>false
],
"PD_TIM"=>[
"label"=>"user",
"visible"=>false
],
],
"clientRowGroup" => [
"USRNAME" => [
'calculate' => [
'pdhrsAmount' => [
'sum', //'sum', 'count', 'avg', 'min', 'max'
'PD_HRS',
],
'totalhoursAmount' => [
'sum',
'TTL',
"format" => "function(value) {return value.toFixed(2);}",
],
],
"top"=>"",
"bottom"=>"<td></td><td></td><td></td><td></td><td colspan=\"2\"><b>Total for user {USRNAME}</b></td><td><b>{pdhrsAmount}</b></td><td><b>{totalhoursAmount}</b></td>"
],
],
"cssClass"=>array(
"table"=>"table table-striped table-bordered",
"tr"=>function($row,$columnName)
{
//Base on $row["{column_name}"], you return correct css class to add css class
if($row["HAS_COMMNTS"]=="*"){ return "blueCss";}
if($row["PTO"]=="*"){ return "yellowCss";}
if($row["IsHoliday"]==1){ return "orangeCss";}
}
)//end css class
));//End Table::create
Any idea why the grouping/sum is not working?