Hi, could you help me to organise the csv export correctly
I have a big report and would like to export a part of it.
I created a separate class report file for that stock_list_csv.php
and the export report file csv_export.php
So from my main report i call csv_export.php
via the form where with the post method i send the report parameters
The csv_export.php
<?php
require_once "stock_list_csv.php";
$report = new stock_list_csv;
//var_dump($_POST);
$report->run()->exportToCSV(array(
"dataStores" => array(
"stock_fact_names" => array(
"delimiter" => ",",
)
)
))->toBrowser("myreport.csv");
As you can see I use var_dump
to check how my form from the main file send the parameters and it looks ok.
/csv_export.php:8:
array (size=2)
'barmode' => string '1' (length=1)
'update_date' => string '62' (length=2)
The stock_list_csv.php
<?php
require_once "../../koolreport/core/autoload.php";
class stock_list_csv extends \koolreport\KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
use \koolreport\excel\CSVExportable;
function settings()
{
$config = include "../../config.php";
return array(
"dataSources" => array(
"quinos" => $config["quinos"],
)
);
}
function setup()
{
$query_fact = 'SELECT
item_id as id_f
, quantity
FROM mytbl_actual_stock
WHERE date_id in(:date_id) AND stock in(:stock)';
$this->src("quinos")
->query($query_fact)
->params(array(
":date_id" => $this->params["update_date"],
":stock" => (($this->params["barmode"]==1) ? array(3) : array(2)),
))
->pipe($this->dataStore("stock_fact_names"));
}
}
But as result I'm gettingt the empty table... so it looks like my stock_list_csv.php
does not have access to the parameters from the main file and csv_export.php
. if i set ":date_id"
and ":stock"
manually the report works...
Where is my mistake?