Hi,
Thanks for pointing out that values were not being posted to export.php
here is the index.php
<?php
require_once "OrderPerMonth.php";
$report= new OrderPerMonth(array(
"siteId"=>$_SESSION["QB_SITEID"]
));
$report->run()->render();
here is the export.php
<?php
include "OrderPerMonth.php";
$report = new OrderPerMonth;
// //excel generator
$report->run();
$report->exportToExcel('OrderPerMonthExcel')->toBrowser("MyOrdersReport.xlsx");
here is the OrderPerMonthExcel.view.php
<div sheet-name="Order Report">
<div>
<?php
\koolreport\excel\Table::create(array(
"dataSource"=>$this->dataStore("orderspermonth"),
))
?>
</div>
</div>
view.php
<form method="post">
<?php Select::create(array(
"name"=>"years",
"dataStore"=>$this->dataStore("years"),
"dataBind"=>"years",
"attributes"=>array(
"class"=>"form-control",
)
));
?>
<div class="form-group text-center m-2">
<button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load </button>
<button type="submit" class="btn btn-primary" formaction="/export.php">Download Excel</button>
</div>
</form>
<?php
Table::create(array(
"dataSource"=>$this->dataStore("orderspermonth"),
"cssClass"=>array(
"table"=>"table-bordered table-striped table-hover"
),
"columns"=>array(
"month"=>array(
"label"=>"Month"
),
"order"=>array(
"label"=>"Order",
"type"=>"number",
)
)
))
?>
main.php
use \koolreport\export\Exportable;
use \koolreport\excel\ExcelExportable;
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function defaultParamValues()
{
return array(
"years"=> date("Y",strtotime("-1 year"))
);
}
protected function bindParamsToInputs()
{
return array(
"years",
);
}
protected function setup(){
$this->src('quickbrand')
->query("
SELECT monthname(OrderTS) as month,count(Order) as 'order'
from orders
where YEAR(OrderTS) = :years and website=:siteid
group by MONTH(OrderTS)
")
->params(array(
":years"=>$this->params["years"],
":siteid"=>$this->params["siteId"]
))
->pipe($this->dataStore("orderspermonth"));
$this->src('quickbrand')
->query("
SELECT year(OrderTS) as years
from orders
where website=:siteid
group by year(OrderTS)
")
->params(array(
":siteid"=>$this->params["siteId"]
))
->pipe($this->dataStore("years"));
I checked the headers that was being sent to export.php and realized that siteid parameter is not being sent.
How can that be done?