W swoim /modules/Cases/Case.php, Zastąp funkcję create_new_list_query, aby dostosować zapytanie wyszukiwania.
Jak ten poniżej:
function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false){
if (isset($_REQUEST['action']) && $_REQUEST['action'] != 'DetailView' && $_REQUEST['module'] == 'Cases') {
date_default_timezone_set("Asia/Manila");
//$lvso = (isset($_REQUEST['lvso'])) ? $_REQUEST['lvso'] : 'desc';
$lvso = 'desc';
$case_number = (isset($_REQUEST['case_number_basic'])) ? $_REQUEST['case_number_basic'] : '';
$case_date_from = (isset($_REQUEST['case_date_from_c_basic']) && !empty($_REQUEST['case_date_from_c_basic'])) ? date('Y-m-d', strtotime($_REQUEST['case_date_from_c_basic'])) : '';
$case_date_to = (isset($_REQUEST['case_date_to_c_basic']) && !empty($_REQUEST['case_date_from_c_basic'])) ? date('Y-m-d', strtotime($_REQUEST['case_date_to_c_basic'])) : '';
//$case_date_from = (isset($_REQUEST['case_date_from_c_basic']) && !empty($_REQUEST['case_date_from_c_basic'])) ? date('Y-m-d', strtotime(convertTimezoneToUtc($_REQUEST['case_date_from_c_basic']))) : '';
//$case_date_to = (isset($_REQUEST['case_date_to_c_basic']) && !empty($_REQUEST['case_date_from_c_basic'])) ? date('Y-m-d', strtotime(convertTimezoneToUtc($_REQUEST['case_date_to_c_basic']))) : '';
$case_subject = (isset($_REQUEST['name_basic'])) ? $_REQUEST['name_basic'] : '';
$application_id = (isset($_REQUEST['account_id_basic'])) ? $_REQUEST['account_id_basic'] : '';
$case_current_status_c_basic = (isset($_REQUEST['case_current_status_c_basic'])) ? $_REQUEST['case_current_status_c_basic'] : '';
$case_source_c_basic = (isset($_REQUEST['case_source_c_basic'])) ? $_REQUEST['case_source_c_basic'][0] : '';
$assigned_user_id_basic = (isset($_REQUEST['assigned_user_id_basic'])) ? $_REQUEST['assigned_user_id_basic'][0] : '';
$open_cases_only_basic = (isset($_REQUEST['open_cases_only_basic'])) ? $_REQUEST['open_cases_only_basic'] : '';
$sdtool_c_basic = (isset($_REQUEST['sdtool_c_basic'])) ? $_REQUEST['sdtool_c_basic'] : '';
$created_by_basic = (isset($_REQUEST['created_by_basic'])) ? $_REQUEST['created_by_basic'][0] : '';
$support_type_basic = (isset($_REQUEST['type_basic'])) ? $_REQUEST['type_basic'][0] : '';
//Build where clause query
$where_clause = " WHERE ";
$where_clause .= !empty($case_number) ? "case_number = $case_number AND " : "";
$where_clause .= !empty($sdtool_c_basic)? "sdtool_c LIKE '%$sdtool_c_basic%' AND " : "";
$where_clause .= !empty($case_date_from) ? "date(cases.date_entered) >= '$case_date_from' AND " : "";
$where_clause .= !empty($case_date_to) ? "date(cases.date_entered) <= '$case_date_to' AND " : "";
$where_clause .= !empty($case_subject) ? "case_subject_c LIKE '%$case_subject%' AND " : "";
$where_clause .= !empty($application_id) ? "account_id = '$application_id' AND " : "";
$where_clause .= !empty($case_current_status_c_basic) ? "case_current_status_c LIKE '%$case_current_status_c_basic%' AND " : "";
$where_clause .= !empty($case_source_c_basic) ? "case_source_c LIKE '%$case_source_c_basic%' AND " : "";
$where_clause .= !empty($assigned_user_id_basic) ? "cases.assigned_user_id = '$assigned_user_id_basic' AND " : "";
$where_clause .= (!empty($open_cases_only_basic) && $open_cases_only_basic == 1)? "case_current_status_c <> 'Closed' AND " : "";
$where_clause .= !empty($created_by_basic) ? "cases.created_by = '$created_by_basic' AND " : "";
$where_clause .= !empty($support_type_basic) ? "cases.type = '$support_type_basic' AND " : "";
//Check if conditions are appended
//$where_clause = (strlen($where_clause) > 7) ? rtrim($where_clause, " AND ") : "";
$deleted_clause = " cases.deleted = 0 ";
$where_clause .= $deleted_clause;
$ret_array["select"] = "SELECT cases.id ,cases_cstm.sdtool_c,cases_cstm.case_subject_c,cases_cstm.case_current_status_c,cases_cstm.case_due_datetime_c,cases_cstm.case_priority_c,cases_cstm.case_source_c, cases_cstm.case_report_due_date_c,
cases.case_number , accounts.name account_name , accounts.assigned_user_id account_name_owner , 'Accounts' account_name_mod, cases.account_id , LTRIM(RTRIM(CONCAT(IFNULL(jt1.first_name,''),' ',
IFNULL(jt1.last_name,'')))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'Users' assigned_user_name_mod , LTRIM(RTRIM(CONCAT(IFNULL(jt2.first_name,''),' ',
IFNULL(jt2.last_name,'')))) created_by_name , jt2.created_by created_by_name_owner , 'Users' created_by_name_mod, cases.date_entered , LTRIM(RTRIM(CONCAT(IFNULL(jt3.first_name,''),' ',
IFNULL(jt3.last_name,'')))) modified_by_name , jt3.created_by modified_by_name_owner , 'Users' modified_by_name_mod, cases.date_modified , cases.assigned_user_id , cases.created_by ";
$ret_array["from"] = "FROM cases LEFT JOIN cases_cstm ON cases.id = cases_cstm.id_c LEFT JOIN accounts accounts ON cases.account_id=accounts.id AND accounts.deleted=0 AND accounts.deleted=0
LEFT JOIN users jt1 ON cases.assigned_user_id=jt1.id AND jt1.deleted=0 AND jt1.deleted=0
LEFT JOIN users jt2 ON cases.created_by=jt2.id AND jt2.deleted=0 AND jt2.deleted=0
LEFT JOIN users jt3 ON cases.modified_user_id=jt3.id AND jt3.deleted=0 AND jt3.deleted=0";
$ret_array["from_min"] = " FROM cases";
$ret_array["secondary_from"] =" FROM cases";
$ret_array["where"] = $where_clause;
$ret_array['order_by'] = " ORDER BY case_number $lvso";
$ret_array['limit'] = "";
return $ret_array;
}
else {
return parent::create_new_list_query($order_by, $where,$filter,$params, $show_deleted,$join_type, $return_array,$parentbean, $singleSelect);
}
}
Osobiście stworzyłem ten, więc wiem, że to działa. Dzięki.