I looked through that other thread and wasn't able to find anything else that might be thwarting me. So, here is the code. I appreciate you taking a look!
index.php:
<?php
require_once "topRestaurants.php";
$report = new topRestaurants;
$report->run();
?>
<!DOCTYPE >
<html>
<head>
<title>Athlete Spending</title>
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="/assets/css/example.css" />
<style>
.box-container { max-width: 100%; }
</style>
</head>
<body>
<div class="container box-container">
<?php $report->render();?>
</div>
</body>
</html>
topRestaurants.php:
<?php
require_once ($_SERVER['DOCUMENT_ROOT']."/koolreport/autoload.php");
use \koolreport\KoolReport;
class topRestaurants extends KoolReport
{
use \koolreport\export\Exportable;
use \koolreport\clients\Bootstrap;
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
use \koolreport\excel\ExcelExportable;
public function settings()
{
//Get default connection from config.php
$config = include ($_SERVER['DOCUMENT_ROOT']."/config.php");
return array(
"dataSources"=>array(
"spend_data"=>$config["camp-dashboard"]
),
);
}
protected function defaultParamValues()
{
return array(
"select"=>"",
"chooseOrg"=>"",
"startDatePicker"=>date("Y-m-d 00:00:00"),
"endDatePicker"=>date("Y-m-d 23:59:59"),
"dateRange"=>array(date("Y-m-d 00:00:00"),date("Y-m-d 23:59:59")),
);
}
protected function bindParamsToInputs()
{
return array(
"dateRange"=>"dateRange",
"select",
"multiSelect",
"textBox",
"radioList",
"checkBoxList"=>"isActive",
"startDatePicker",
"endDatePicker",
"singleSelect2",
"multipleSelect2",
"singleBSelect",
"multipleBSelect",
"rangeSliderOne",
"rangeSliderTwo",
"account_plan"=>"choosePlan",
"active"=>"isActive",
"chooseOrg",
);
}
protected function setup()
{
$this->src('spend_data')
->params(array(
":orgid"=>$this->params["chooseOrg"],
":start"=>$this->params["dateRange"][0],
":end"=>$this->params["dateRange"][1],
))
->query("SELECT sum(a.amount) as rest_total, b.name, b.city FROM Transaction a, Restaurant b WHERE a.transaction_timestamp >= :start AND transaction_timestamp <= :end AND a.restaurant_id = b.id AND b.organization_id = :orgid AND b.active > 0 AND b.performance_table = 0 AND b.fueling_station = 0 GROUP BY a.restaurant_id ORDER BY rest_total DESC")
->pipe($this->dataStore('restaurant_spending'));
$this->src("spend_data")
->query("select id, name, timezone from Organizations ORDER BY name ASC")
->pipe($this->dataStore("selectOrg"));
}
}
topRestaurants.view.php:
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\PieChart;
use \koolreport\inputs\Select;
use \koolreport\inputs\DateRangePicker;
?>
<html>
<head>
<title>List of Athletes</title>
<script type="text/javascript">
function doExport()
{
var _form = document.getElementById("parameterForm");
_form.action = "export.php";
_form.submit();
_form.action = "index.php";
}
</script>
</head>
<body>
<link rel="stylesheet" href="/assets/css/example.css" />
<div class="text-center" style="padding-bottom:0.8em;">
<h1>Top Restaurant Spending</h1>
</div>
<form method="post" id="parameterForm">
<fieldset>
<div class="row">
<div class="col-md-6 form-group">
<label>School Name</label>
<?php
Select::create(array(
"name"=>"chooseOrg",
"dataStore"=>$this->dataStore("selectOrg"),
"defaultOption"=>array("Choose School"=>""),
"dataBind"=>array("text"=>"name","value"=>"id"),
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
<div class="col-md-6 form-group">
<label>DateRangePicker</label>
<?php
DateRangePicker::create(array(
"name"=>"dateRange",
));
?>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary">Submit</button>
</div>
</fieldset>
</form>
<?php
PieChart::create(array(
"dataStore"=>$this->dataStore('restaurant_spending'),
//"width"=>"600px",
//"height"=>"600px",
"columns"=>array(
"name"=>array(
"label"=>"Name",
"type"=>"string",
),
"rest_total"=>array(
"label"=>"Amount",
"type"=>"number",
"prefix"=>"$",
)
),
"options"=>array(
"title"=>"Top Restaurant Spending"
)
))
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('restaurant_spending'),
"columns"=>array(
"name"=>array(
"label"=>"Name",
"type"=>"string",
),
"city"=>array(
"label"=>"City",
"type"=>"string",
),
"rest_total"=>array(
"label"=>"Amount",
"type"=>"number",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
<div class="text-center" style="padding-bottom:0.8em;">
<a href="export.php" class="btn btn-primary" onclick="doExport()">Download PDF</a><br />
</div>
</body>
</html>
And, finally, the export.php:
<?php
require_once "topRestaurants.php";
$report = new topRestaurants;
$report->run()
->export('topRestaurantsPdf')
->pdf(array(
"format"=>"Letter",
"orientation"=>"portrait"
))
->toBrowser("topRestaurants.pdf")
;
Thanks again!!