Server side date range php not working
Server side date range php not working
Hi Allan,
I am having a serious trouble and its the server side date range please help me in this case. I will be grateful.
I am sending 2 custom variables to my ssp script
here is the code
$('#donations').dataTable( {
"processing": true,
"serverSide": true,
"displayLength": 25,
"jQueryUI": true,
"ajax": {
"url": "public/donations/server_processing.php",
"type": "GET",
"dataType":"json",
"data": function ( d ) {
d.mind = $('#min').val();
d.maxd = $('#max').val();
console.log(d.mind);
console.log(d.maxd);
// d.custom = $('#myInput').val();
// etc
}
and fortunattly they are visible in console but i am unable to catch it in my ssp php script by using $GET_['mind']; and $GET_['maxd']; respectively.
here is my php code please help as early as possible pleaseeeeee. :)
static function filter ( $request, $columns, &$bindings, $isJoin = false )
{
$globalSearch = array();
$columnSearch = array();
$dtColumns = SSP::pluck( $columns, 'dt' );
if ( isset($request['search']) && $request['search']['value'] != '' ) {
$str = $request['search']['value'];
//Start custom date-range search code
$mind=$_GET['mind'];
$maxd=$_GET['max'];
if ( isset($mind) && $mind != '' )
{
if ($mind != '' && $maxd == '')
{
// Return all dates newer than start date
$binding = SSP::bind( $bindings, $mind, PDO::PARAM_STR );
$columnSearch[] = "`".'ds.date'."` >= ".$binding;
}
else if ($mind == '' && $maxd != '')
{
// Return all dates prior to the end date
$binding = SSP::bind( $bindings, $maxd, PDO::PARAM_STR );
$columnSearch[] = "`".'ds.date'."` <= ".$binding;
}
else if ($mind != '' && $maxd != '')
{
// Return all dates within range
$binding = SSP::bind( $bindings, $mind, PDO::PARAM_STR );
$binding2 = SSP::bind( $bindings, $maxd, PDO::PARAM_STR );
$columnSearch[] = "`".'ds.date'."` BETWEEN ".$binding." AND ".$binding2;
}
}
//end custom date-range search code
for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
$requestColumn = $request['columns'][$i];
$columnIdx = array_search( $requestColumn['data'], $dtColumns );
$column = $columns[ $columnIdx ];
if ( $requestColumn['searchable'] == 'true' ) {
$binding = SSP::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
$globalSearch[] = ($isJoin) ? $column['db']." LIKE ".$binding : "`".$column['db']."` LIKE ".$binding;
}
}
}
// Individual column filtering
for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
$requestColumn = $request['columns'][$i];
$columnIdx = array_search( $requestColumn['data'], $dtColumns );
$column = $columns[ $columnIdx ];
$str = $requestColumn['search']['value'];
if ( $requestColumn['searchable'] == 'true' &&
$str != '' ) {
$binding = SSP::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
$columnSearch[] = ($isJoin) ? $column['db']." LIKE ".$binding : "`".$column['db']."` LIKE ".$binding;
}
}
Answers
Every this is great about this plugin but i am having this issue with date range since long now please help Allan.