@SuppressWarnings("unchecked")
@Override
public JSONObject getChkListPagination(Filter filter, Login user) {
JSONObject success = new JSONObject();
// table view
String pg_sql = null;
int offset_value = (int) ((filter.getPgno() - 1) * filter.getLength());
String search_sql = "WHERE (ac.audit_cat_name LIKE '%"+filter.getSearchparam()+"%' OR ac.audit_cat_code LIKE '%"+filter.getSearchparam()+"%' OR ac.audit_cat_revno like '%"+filter.getSearchparam()+"%'\r\n"
+ "OR ac.comments LIKE '%"+filter.getSearchparam()+"%') \r\n";
String chklist_sql = "SELECT ac.audit_cat_id,ac.audit_cat_name,ac.audit_cat_code,ac.audit_cat_revno,ac.comments,ac.isactive,\r\n"
+ "case when ac.isactive = 1 then 'Active' ELSE 'Inactive' END AS 'status',\r\n"
+ "COUNT(a.audit_id) AS audit_count\r\n"
+ "\r\n"
+ "FROM im_audit_cat AS ac\r\n"
+ "LEFT JOIN it_audit AS a ON (a.audit_cat_id = ac.audit_cat_id)\r\n"
+ ""+search_sql+"\r\n"
+ "GROUP BY ac.audit_cat_id\r\n";
pg_sql = "ORDER BY " + filter.getSortby() + " " + filter.getSortord() + " \r\n" + "LIMIT "
+ filter.getLength() + " OFFSET " + offset_value + " \r\n" + "";
pg_sql = chklist_sql + pg_sql;
// System.out.println("pg_sql:"+pg_sql);
List<Map<String, Object>> cont_tb_view_list = jdbcTemplate.queryForList(pg_sql);
// tb view count
String count = "SELECT COUNT(*) AS count \r\n" + "from ( " + chklist_sql + " ) as b";
List<Map<String, Object>> count_result_tb = jdbcTemplate.queryForList(count);
success.put("count", count_result_tb);
success.put("data", cont_tb_view_list);
return success;
}