Dear Team,I have problem with the code of sub report i.e i am using ajax loading concept sub report.when i am selecting date time picker value i am unable to pass that value into the query of ListOrders file.so could you please help me on how to pass that value and below is the code which i am using.
This is the view code of selecting options
<?php
use \koolreport\inputs\Select;
use \koolreport\inputs\BSelect;
use \koolreport\inputs\DateTimePicker;
use \koolreport\inputs\DateRangePicker;
?>
<div class="row" style="text-align:center;">
<div class="col-sm-2"></div>
<div class="col-sm-3 form-group">
<label>Select State:</label>
<?php
Select::create(array(
"name"=>"statename",
"dataStore"=>$this->dataStore("result1"),
"defaultOption"=>array("--"=>null),
"dataBind"=>"statename",
"clientEvents"=>array(
"change"=>"function(){
subReport.update('srcreportselect',{
statename:$('#statename').val(),
});
subReport.update('srcreportOrders');
}",
),
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
<?php
if($this->params["statename"])
{
?>
<div class="col-sm-4 form-group">
<label>Select Branch<?php //echo $this->params["statename"]; ?>:</label>
<?php
BSelect::create(array(
"name"=>"brnchName",
"multiple"=>true,
"dataStore"=>$this->dataStore("result2"),
"dataBind"=>"brnchName",
"options"=>array(
'numberDisplayed' => 5,
'includeSelectAllOption' => true,
),
"clientEvents"=>array(
"change"=>"function(){
subReport.update('srcreportselect',{
statename:$('#statename').val(),
brnchName:$('#brnchName').val(),
});
}",
),
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
<div class="col-sm-4 form-group">
<label>Select Source<?php //echo $this->params["statename"]; ?>:</label>
<?php
BSelect::create(array(
"name"=>"srcName",
"multiple"=>true,
"dataStore"=>$this->dataStore("result3"),
"dataBind"=>"srcName",
"options"=>array(
'numberDisplayed' => 5,
'includeSelectAllOption' => true,
),
"clientEvents"=>array(
"change"=>"function(){
subReport.update('srcreportselect',{
statename:$('#statename').val(),
brnchName:$('#brnchName').val(),
srcName:$('#srcName').val(),
});
}",
),
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
<div class="col-md-12 form-group">
<strong>DateTimePicker</strong>
From Date:
<?php
DateTimePicker::create(array(
"name"=>"startDatePicker",
// "maxDate"=>"@endDatePicker",
"format"=>"DD-MM-YYYY",
"clientEvents"=>array(
"change"=>"function(){
subReport.update('srcreportselect',{
statename:$('#statename').val(),
brnchName:$('#brnchName').val(),
srcName:$('#srcName').val(),
startDatePicker:$('#startDatePicker').val(),
});
}",
),
"attributes"=>array(
"class"=>"form-control",
) ));
?>
</div>
<div class="form-group" style="margin-top:20px;">
<button onclick="srcreportorders()" class="btn btn-success">submit</button>
</div>
<?php
}
?>
<div class="col-sm-1">
<?php
if(isset($this->params["brnchName"]) && $this->params["brnchName"]!=null)
{
?>
<!--<div class="form-group" style="margin-top:20px;">
<button onclick="srcreportorders()" class="btn btn-success">submit</button>
</div>-->
<?php
}
?>
</div>
<div class="col-sm-2"></div>
</div>
<script type="text/javascript">
function srcreportorders()
{
subReport.update("srcreportorders",{
"brnchName":$('#brnchName').val(),
//"dateRange":$('#dateRange').val(),
//"end":$('#end').val(),
startDatePicker:$('#startDatePicker').val(),
endDatePicker:$('#endDatePicker').val(),
"srcName":$('#srcName').val(),
});
}
</script>
ListOrders.php
if(isset($this->params["brnchName"]))
{
$this->src("db name")
->query("
SELECT *
FROM tblname
WHERE brnchName=:brnchName AND custCreatedDate>=:startDatePicker AND custCreatedDate<=:endDatePickerAND srcName=:srcName
")
->params(array(
":brnchName"=>$this->params["brnchName"],
":startDatePicker"=>$this->params["startDatePicker"],
":endDatePicker"=>$this->params["endDatePicker"],
//":start"=>$this->params["dateRange"][0],
//":end"=>$this->params["dateRange"][1],
":srcName"=>$this->params["srcName"],
))
->pipe($this->dataStore("data"));
}
When i am selecting the date in the date time picker that date is automatically get back to today date and if i am clicking submit button that today date also not passed to query