I am using a DataTables SSP script with a Where clause that is preventing accurate individual column searching.
When I remove the Where clause, column filtering works as designed.
Any thoughts?
<?php
/*
* DataTables server-side processing custom script.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
date_default_timezone_set('America/Chicago'); // CDT
$today = date("Y-m-d");
$archiveDate = date('Ymd', strtotime('-1 year'));
include('i5db2connect.php');
// DB table to use
$table = 'NWFF.FCMASTER left outer join NWFO.LOCNAMES on LOCLOC = FCMLOC';
//Used for optional WHERE clauses that will be appended to the SQL string
$extraWhere = "FCSTAT not in
('Closed-Deducted',
'Closed-Overpaid',
'Closed-Paid',
'Closed-PWO',
'Closed-Rejected',
'Closed-WO',
'Closed-WO/Ded mix',
'Declined',
'Rejected',
'Removed')
or
FCSTAT in
( 'Deduction Pending',
'Partial Pending',
'Reinstated',
'Pending-WO taken' )
and FCMCRD >= '" . $archiveDate . "'";
// Table's primary key
$primaryKey = 'FCCLMN';
$columns = array(
array( 'db' => 'FCCLMN', 'dt' => 'claim_number' ),
array( 'db' => 'FCCLMN', 'dt' => 'claim_number_link',
'formatter' => function($d, $row){
return ' <a id="myLink" class="link" onclick="editFreightClaim('.$d.');return false;">' . $d . '</a>';
}
),
array( 'db' => 'LOCDES', 'dt' => 'location',
'formatter' => function( $d, $row ) {
return substr( $d, 4, strlen($d));
}
),
array( 'db' => 'FCDNAM', 'dt' => 'department_name' ),
array( 'db' => 'FCCVNM', 'dt' => 'vendor_customer' ),
array( 'db' => 'FCMPRO', 'dt' => 'pro_number' ),
array( 'db' => 'FCMNAM', 'dt' => 'carrier_name' ),
array( 'db' => 'FCPAMT', 'dt' => 'claim_amount' ),
array( 'db' => 'FCFACL', 'dt' => 'freight_claim_amount' ),
array( 'db' => 'FCTOTL', 'dt' => 'total_claim_amount'),
array( 'db' => 'FCMPAM', 'dt' => 'amount_paid'),
array( 'db' => 'FCSTAT', 'dt' => 'status' ),
array( 'db' => 'FCMSHP', 'dt' => 'ship_date',
'formatter' => function( $d, $row ) {
if ($d > 0)
{
$dt = DateTime::createFromFormat('Ymd', $d);
return $dt->format('m/d/Y');
}
else
{
return '';
}
}
),
array( 'db' => 'FCMREC', 'dt' => 'received_date',
'formatter' => function( $d, $row ) {
if ($d > 0)
{
$dt = DateTime::createFromFormat('Ymd', $d);
return $dt->format('m/d/Y');
}
else
{
return '';
}
}
),
array( 'db' => 'FCLMTP', 'dt' => 'claim_type',
'formatter' => function( $d, $row ) {
if (trim($d) == 'I') {
return "Inbound";
} else {
return "Outbound";
}
}
),
array( 'db' => 'FCMCRD', 'dt' => 'created_age',
'formatter' => function( $d, $row ) {
if ($d > 0 ){
$createdOn = substr($d,0,4).'-'.substr($d,4,2).'-'.substr($d,6,2);
$createdOn = date_create($createdOn);
$today = date_create($today);
$diff=date_diff($createdOn,$today);
if($diff->format('%y') !== '0'){
$created_age = $diff->format('%y Year %m Month %d Day');
}else if($diff->format('%m') !== '0'){
$created_age = $diff->format('%m Month %d Day');
}else{
$created_age = $diff->format('%d Day');
}
return $created_age;
} else {
return '';
}
}
),
array( 'db' => 'FCMCLM', 'dt' => 'filed_age',
'formatter' => function( $d, $row ) {
if ($d > 0 && trim($row[FCSTAT]) == 'Filed'){
$createdOn = substr($d,0,4).'-'.substr($d,4,2).'-'.substr($d,6,2);
$createdOn = date_create($createdOn);
$today = date_create($today);
$diff=date_diff($createdOn,$today);
if($diff->format('%y') !== '0'){
$filed_age = $diff->format('%y Year %m Month %d Day');
}else if($diff->format('%m') !== '0'){
$filed_age = $diff->format('%m Month %d Day');
}else{
$filed_age = $diff->format('%d Day');
}
return $filed_age;
} else {
return '';
}
}
),
array( 'db' => 'FCMPAM', 'dt' => 'amount_due',
'formatter' => function( $d, $row ) {
$amountDue = $row[FCTOTL] - $row[FCMPAM];
$amountDue = number_format((float)$amountDue, 2, '.', '');
return $amountDue;
}
),
);
require( 'ssp.class_Template.php' );
//var_dump($connection);
echo json_encode(
SSP::simple( $_GET, $connection, $select, $table, $primaryKey, $columns, $extraWhere)
);