mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-04 10:14:13 +08:00
[Legacy] Fix Relate Field Issue
This commit is contained in:
parent
757221031a
commit
2321b0a934
3 changed files with 24 additions and 2 deletions
|
@ -949,6 +949,8 @@ class SugarBean
|
||||||
$replacement = substr_replace($query_array['select'], "SELECT count(", $select_position, 6);
|
$replacement = substr_replace($query_array['select'], "SELECT count(", $select_position, 6);
|
||||||
$query_rows = "( " . $replacement . ")" . $subquery['from_min']
|
$query_rows = "( " . $replacement . ")" . $subquery['from_min']
|
||||||
. $query_array['join'] . $subquery['where'] . ' )';
|
. $query_array['join'] . $subquery['where'] . ' )';
|
||||||
|
} elseif (!empty($subquery['params']['subpanel_relate_field_search'])) {
|
||||||
|
$query_rows = "( SELECT count(*)" . $subquery['from'] . $subquery['where'] . ' )';
|
||||||
} else {
|
} else {
|
||||||
//resort to default behavior.
|
//resort to default behavior.
|
||||||
$query_rows = "( SELECT count(*)" . $subquery['from_min']
|
$query_rows = "( SELECT count(*)" . $subquery['from_min']
|
||||||
|
@ -1171,8 +1173,10 @@ class SugarBean
|
||||||
|
|
||||||
if(!empty($union_related_list_columns) && array_key_exists($this_subpanel->name, $union_related_list_columns)) {
|
if(!empty($union_related_list_columns) && array_key_exists($this_subpanel->name, $union_related_list_columns)) {
|
||||||
$list_fields = $union_related_list_columns[$this_subpanel->name];
|
$list_fields = $union_related_list_columns[$this_subpanel->name];
|
||||||
}else{
|
}elseif($subpanel_def->isCollection()){
|
||||||
$list_fields = $this_subpanel->get_list_fields();
|
$list_fields = $this_subpanel->get_list_fields();
|
||||||
|
}else{
|
||||||
|
$list_fields = $submodule->field_defs;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($list_fields as $list_key => $list_field) {
|
foreach ($list_fields as $list_key => $list_field) {
|
||||||
|
@ -1209,6 +1213,16 @@ class SugarBean
|
||||||
$singleSelect = method_exists($submodule, 'is_relate_field')
|
$singleSelect = method_exists($submodule, 'is_relate_field')
|
||||||
? $submodule->is_relate_field($order_by) : null;
|
? $submodule->is_relate_field($order_by) : null;
|
||||||
|
|
||||||
|
if (!$singleSelect && !empty($this_subpanel->searchByFields) && method_exists($submodule, 'is_relate_field')){
|
||||||
|
foreach($this_subpanel->searchByFields as $field){
|
||||||
|
if ($submodule->is_relate_field($field)){
|
||||||
|
$singleSelect = true;
|
||||||
|
$params['subpanel_relate_field_search'] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$subquery = method_exists($submodule, 'create_new_list_query')
|
$subquery = method_exists($submodule, 'create_new_list_query')
|
||||||
? $submodule->create_new_list_query(
|
? $submodule->create_new_list_query(
|
||||||
'',
|
'',
|
||||||
|
@ -3956,7 +3970,7 @@ class SugarBean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($join['type'] == 'many-to-many') {
|
if ($join['type'] === 'many-to-many') {
|
||||||
if (empty($ret_array['secondary_select'])) {
|
if (empty($ret_array['secondary_select'])) {
|
||||||
$ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id ";
|
$ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id ";
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ class SearchForm
|
||||||
public $nbTabs = 0;
|
public $nbTabs = 0;
|
||||||
// hide saved searches drop and down near the search button
|
// hide saved searches drop and down near the search button
|
||||||
public $showSavedSearchesOptions = true;
|
public $showSavedSearchesOptions = true;
|
||||||
|
public $searchByFields = [];
|
||||||
|
|
||||||
public $displayType = 'searchView';
|
public $displayType = 'searchView';
|
||||||
|
|
||||||
|
@ -900,6 +901,7 @@ class SearchForm
|
||||||
global $timedate;
|
global $timedate;
|
||||||
|
|
||||||
$db = $this->seed->db;
|
$db = $this->seed->db;
|
||||||
|
$this->searchByFields = [];
|
||||||
$this->searchColumns = array();
|
$this->searchColumns = array();
|
||||||
$values = $this->searchFields;
|
$values = $this->searchFields;
|
||||||
|
|
||||||
|
@ -996,6 +998,8 @@ class SearchForm
|
||||||
$operator = strtolower($parms['operator']);
|
$operator = strtolower($parms['operator']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->searchByFields[] = $field;
|
||||||
|
|
||||||
if (is_array($parms['value'])) {
|
if (is_array($parms['value'])) {
|
||||||
$field_value = '';
|
$field_value = '';
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class aSubPanel
|
||||||
public $panel_definition ;
|
public $panel_definition ;
|
||||||
public $sub_subpanels ;
|
public $sub_subpanels ;
|
||||||
public $parent_bean ;
|
public $parent_bean ;
|
||||||
|
public $searchByFields = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can we display this subpanel?
|
* Can we display this subpanel?
|
||||||
|
@ -197,6 +199,8 @@ class aSubPanel
|
||||||
|
|
||||||
$where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
|
$where_clauses = $searchForm->generateSearchWhere(true, $seed->module_dir);
|
||||||
|
|
||||||
|
$this->searchByFields = $searchForm->searchByFields;
|
||||||
|
|
||||||
$GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
|
$GLOBALS['log']->info("Subpanel Where Clause: $this->search_query");
|
||||||
|
|
||||||
if (count($where_clauses) > 0) {
|
if (count($where_clauses) > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue