YADCF and formatters

YADCF and formatters

nlooijenlooije Posts: 6Questions: 1Answers: 0

We have integrated yadcf date range filter into Editor.php of the Datatables Editor PHP library and it works for simple cases.
However for the case where we have to use set/getFormatters for the dates we run into problems.
Is it somehow possible to use the setFormatter to convert the ranges passed by yadcf/dataTables?

// Column filters - Editor.php line 1739
for ( $i=0, $ien=count($http['columns']) ; $i<$ien ; $i++ ) {
    $column = $http['columns'][$i];
    $search = $column['search']['value'];

    if ( $search !== '' && $column['searchable'] == 'true' ) {

        // Added range filter for yadcf
        if (strpos($search, '-yadcf_delim-') !== false) {
            $limits = explode("-yadcf_delim-", $search);
            $limit_low = $limits[0];  // piece1
            $limit_high = $limits[1]; // piece2

                        // Need to convert according to setFormatter format
            $limit_low = (new DateTime($limit_low))->getTimestamp()*1000;
            $limit_high = (new DateTime($limit_high))->getTimestamp()*1000;
            
            if ($limit_low != '' && $limit_high != '') {
                $query->where($this->_ssp_field($http, $i), $limit_low, '>=');
                $query->where($this->_ssp_field($http, $i), $limit_high, '<=');
            } elseif ($limit_low != '') {
                $query->where($this->_ssp_field($http, $i), $limit_low, '>=');
            } elseif ($limit_high != '') {
                $query->where($this->_ssp_field($http, $i), $limit_high, '<=');
            }
        } else {
            $query->where($this->_ssp_field($http, $i), '%' . $search . '%' , 'like');
        }

    }
}
Sign In or Register to comment.