I'm trying to create a report which shows a table, that is exact match searchable using a Textbox. I have used the OrderList example as a template, and am trying to convert it from using the Multi Select to using a Simple Textbox input.
The orderList report, seems to use an array to store the input, but I'm not sure how to have it usea variable, and use the variable to search on.
Here's the Report.php
<?php
require_once "../../../load.koolreport.php";
use \koolreport\KoolReport;
class OrderList extends KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function defaultParamValues()
{
return
array(
//creates array I need to make a Textbox useable variable
"customers"=>array(),
);
}
protected function bindParamsToInputs()
{
return array(
"customers"=>"customers",
);
}
public function settings()
{
$config = include "../../../config.php";
return array(
"dataSources"=>array(
"automaker"=>$config["automaker"],
"delv"=>$config["delv"]
)
);
}
protected function setup()
{
$this->src('automaker')
->query("
SELECT
customers.customerName,
orders.orderNumber,
products.productName,
orderdetails.quantityOrdered*orderdetails.priceEach as amount,
orders.orderDate,
orders.status
FROM
orders
JOIN
customers
ON
customers.customerNumber = orders.customerNumber
".
(($this->params["customers"]!=array())?"AND customers.customerNumber IN (:customers)":"")
."
JOIN
orderdetails
ON
orders.orderNumber = orderdetails.orderNumber
JOIN
products
ON
products.productCode = orderdetails.productCode
")
->params(array(
":customers"=>$this->params["customers"]
))
->pipe($this->dataStore("result"));
$this->src("automaker")->query("
SELECT
customerNumber,
customerName
FROM
customers
ORDER BY customerName
")
->pipe($this->dataStore("customers"));
}
}
Here is the View.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\inputs\DateRangePicker;
use \koolreport\inputs\MultiSelect;
use \koolreport\inputs\TextBox;
?>
<div class="report-content">
<div class="text-center">
<h1>List of order</h1>
<p class="lead">Choose date ranges and customer to view orders</p>
</div>
<form method="post">
<div class="row">
<div class="col-md-8 offset-md-2">
//I'm trying to convert the Multiselect functionality to this Textbox
<div class="col-md-6 form-group">
<strong>TextBox</strong>
<?php TextBox::create(array(
"name"=>"customers",
"dataStore"=>$this->dataStore("customers"),
"attributes"=>array(
"class"=>"form-control",
"placeholder"=>"Enter any text"
)
));?>
</div>
<div class="form-group">
<?php
MultiSelect::create(array(
"name"=>"customers",
"dataStore"=>$this->dataStore("customers"),
"dataBind"=>array(
"text"=>"customerName",
"value"=>"customerNumber",
),
"attributes"=>array(
"class"=>"form-control",
"size"=>10,
)
));
?>
</div>
<div class="form-group text-center">
<button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load</button>
</div>
</div>
</div>
</form>
<?php
if($this->dataStore("result")->countData()>0)
{
Table::create(array(
"dataStore"=>$this->dataStore("result"),
"removeDuplicate"=>array("customerName","orderNumber"),
"cssClass"=>array(
"table"=>"table table-bordered"
),
"columns"=>array(
"customerName"=>array(
"label"=>"Customer",
),
"orderNumber"=>array(
"label"=>"#Order",
"type"=>"string",
),
"productName"=>array(
"label"=>"Product"
),
"amount"=>array(
"label"=>"Amount",
"prefix"=>"$",
),
"status"=>array(
"label"=>"Status",
)
)
));
}
else
{
?>
<div class="alert alert-warning">
<i class="glyphicon glyphicon-info-sign"></i> Sorry, we found no orders found
</div>
<?php
}
?>
</div>
I've been trying to reverse engineer how it works and swap it to a the Textbox, but have not had much success.