// filtering $filtering = array(); if (isset($_GET[CRM_CUSTOMER_DATATABLE_SEARCH]) && $_GET[CRM_CUSTOMER_DATATABLE_SEARCH] != "") { $wordToSearch = $db->escape_string($_GET[CRM_CUSTOMER_DATATABLE_SEARCH]); for ($i = 0; $i < count($columns); $i++) { if (isset($_GET[CRM_CUSTOMER_DATATABLE_SEARCHABLE . $i]) && $_GET[CRM_CUSTOMER_DATATABLE_SEARCHABLE . $i] == "true") { $columnToSearch = $columns[$i]; $filtering[$columnToSearch] = $wordToSearch; } } } // get data $result = $db->getAllCustomersOfType($customer_type, $numRows, $sorting, $filtering); if (!isset($result)) { fatal_error("Error retrieving data from the database."); } // data set length after filtering: $filteredRows = $db->unlimitedRowCount(); // total data set length $totalCustomers = $db->getNumberOfClientsFromTable($customer_type); // output $output = array("sEcho" => intval($_GET[CRM_CUSTOMER_DATATABLE_ECHO]), "iTotalRecords" => $totalCustomers, "iTotalDisplayRecords" => $filteredRows, "aaData" => array()); // build the data array foreach ($result as $customer) { $filtered = filteredResultsForCustomerColumn($customer, $customer_type); $filtered = array_values($filtered); $filtered[] = actionButtonToCustomer($customer, $customer_type, $db); $output['aaData'][] = $filtered; } ob_clean(); echo json_encode($output);