I'm trying to add some input filters to the report. However, when I add a Select2 input, and reload the page the page reloads to /[object%20Object] on the end, causing a 404. I can't access the actual page. However, I did successfully added an input connected to on of my fields, which didn't cause the error/redirect.
The error seems to only occur when I change the name to that of location, which is the new input I created in myreport.view and in defaultparamters() and bindtoInputs(). It is strange as, it previously did the same thing when trying to make the select input which, now exists in the report without problems. It just worked one time.
Here is the MyReport.php
<?php
//Step 1: Load KoolReport
require_once "../../load.koolreport.php";
//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function settings()
{
$config = include "../../config.php";
return array(
"dataSources"=>$config
);
}
protected function defaultParamValues()
{
$date=date_create("2021-07-16");
date_add($date,date_interval_create_from_date_string("-42 days"));
$sd = date_format($date,"Y-m-d");
return array(
"startDatePicker"=>date($sd . " 00:00:00"),
"endDatePicker"=>date("Y-m-d 23:59:59"),
"select"=>"",
"location"=>"",
);
}
//Binds report names to input controls eg. "years" = "years"=>"years",
protected function bindParamsToInputs()
{
return array(
"startDatePicker",
"endDatePicker",
"select",
"location"
);
}
protected function setup()
{
$this->src('dealhackdb')
->query('Select
tbl_dealhack.id,
tbl_profile.user_id AS UserID,
hack_description AS Decription,
created_date AS "Created",
attachment_location AS "Attachment Location",
uploaded_date AS Uploaded ,
Company,
TribeName AS "Tribe Name"
From tbl_dealhack
left join tbl_dealhack_attachments on tbl_dealhack_attachments.dealhack_id = tbl_dealhack.id
left join tbl_profile on tbl_profile.user_id = tbl_dealhack.user_id
Left join tbl_attachment_type on tbl_attachment_type.id = tbl_dealhack_attachments.attachment_type_id
left join tbl_companytribe on tbl_companytribe.id = tbl_profile.TribeID
WHERE created_date BETWEEN :start AND :end
AND attachment_type_id = 4
;
')
//-- AND TribeName LIKE :tribe
->params(array(
":start"=>$this->params["startDatePicker"],
":end"=>$this->params["endDatePicker"],
//":tribe"=>$this->params["select"]
))
->pipe($this->dataStore("sales"));
//Date( Transaction.Open_Date ) >= DATE_ADD(CurDate(), INTERVAL -6 WEEK)
}
}
Here is the MyReport.view.php
<?php
use \koolreport\datagrid\DataTables;
use \koolreport\inputs\DateTimePicker;
use \koolreport\inputs\Select2;
?>
<div class="report-content">
<div class="text-center">
<h1>Deal Hack</h1>
<p class="lead">
Link Details
</p>
</div>
<!-- Filters for Page 3 (Stocktake)
Filter by location (first part of the URL)
Filter by user/Tribe/Company
Filter by deal hack type
Filter by date
-->
<!-- DATE TO DATE FROM INPUT -->
<form method="post">
<div class="col-md-12 form-group">
<strong>DateTimePicker</strong>
<div class="row">
<div class="col-md-6">
From Date:
<?php
DateTimePicker::create(array(
"name"=>"startDatePicker",
"maxDate"=>"@endDatePicker",
"format"=>"DD/MM/YYYY HH:mm",
"themeBase"=>"bs4",
));
?>
</div>
<div class="col-md-6">
To Date:
<?php
DateTimePicker::create(array(
"name"=>"endDatePicker",
"minDate"=>"@startDatePicker",
"format"=>"DD/MM/YYYY HH:mm",
"themeBase"=>"bs4",
));
?>
</div>
</div>
<div class="row">
<!-- TRIBE FILTER FROM INPUT-->
<div class="col-md-6">
Tribe:
<?php
Select2::create(array(
"name"=>"select",
"dataStore"=>$this->dataStore("sales"),
"dataBind"=>"Tribe Name",
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
<div class="col-md-6">
URL Location:
<?php
Select2::create(array(
//***if i change this select to location, it causes the redirect error***
"name"=>"select",
"dataStore"=>$this->dataStore("sales"),
"dataBind"=>"Tribe Name",
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
</div>
</div>
<div class="form-group text-center " style="margin-top:30px;" >
<button class="btn btn-lg btn-primary">Submit form</button>
</div>
</form>
<?php
DataTables::create(array(
"dataSource"=>$this->dataStore("sales"),
"options"=>array(
"paging"=>true),
"themeBase"=>"bs4", // Optional option to work with Bootsrap 4
"cssClass"=>array(
"table"=>"table table-striped table-bordered "
)
));
?>
</div>