|
|
|
|
@ -2486,10 +2486,7 @@ JAVASCRIPT; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$extraFieldsAll = $this->get_all( |
|
|
|
|
['visible_to_self = ? AND filter = ?' => [1, 1]], |
|
|
|
|
'option_order' |
|
|
|
|
); |
|
|
|
|
$extraFieldsAll = $this->get_all(['visible_to_self = ? AND filter = ?' => [1, 1]], 'option_order'); |
|
|
|
|
$extraFieldsType = array_column($extraFieldsAll, 'field_type', 'variable'); |
|
|
|
|
$extraFields = array_column($extraFieldsAll, 'variable'); |
|
|
|
|
$filter = new stdClass(); |
|
|
|
|
@ -2562,8 +2559,8 @@ JAVASCRIPT; |
|
|
|
|
*/ |
|
|
|
|
public function getExtraFieldRules($filters, $stringToSearch = 'extra_', $condition = 'OR') |
|
|
|
|
{ |
|
|
|
|
$extra_fields = []; |
|
|
|
|
$condition_array = []; |
|
|
|
|
$extraFields = []; |
|
|
|
|
$conditionArray = []; |
|
|
|
|
|
|
|
|
|
// Getting double select if exists |
|
|
|
|
$double_select = []; |
|
|
|
|
@ -2591,7 +2588,7 @@ JAVASCRIPT; |
|
|
|
|
// normal fields |
|
|
|
|
$field = $rule->field; |
|
|
|
|
if (isset($rule->data) && is_string($rule->data) && -1 != $rule->data) { |
|
|
|
|
$condition_array[] = $this->get_where_clause($field, $rule->op, $rule->data); |
|
|
|
|
$conditionArray[] = $this->get_where_clause($field, $rule->op, $rule->data); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Extra fields |
|
|
|
|
@ -2600,47 +2597,61 @@ JAVASCRIPT; |
|
|
|
|
$original_field = str_replace($stringToSearch, '', $rule->field); |
|
|
|
|
$field_option = $this->get_handler_field_info_by_field_variable($original_field); |
|
|
|
|
|
|
|
|
|
if (self::FIELD_TYPE_DOUBLE_SELECT == $field_option['field_type']) { |
|
|
|
|
if (isset($double_select[$rule->field])) { |
|
|
|
|
$data = explode('#', $rule->data); |
|
|
|
|
$rule->data = $data[1].'::'.$double_select[$rule->field]; |
|
|
|
|
} else { |
|
|
|
|
// only was sent 1 select |
|
|
|
|
if (is_string($rule->data)) { |
|
|
|
|
switch ($field_option['field_type']) { |
|
|
|
|
case self::FIELD_TYPE_DOUBLE_SELECT: |
|
|
|
|
if (isset($double_select[$rule->field])) { |
|
|
|
|
$data = explode('#', $rule->data); |
|
|
|
|
$rule->data = $data[1]; |
|
|
|
|
$rule->data = $data[1].'::'.$double_select[$rule->field]; |
|
|
|
|
} else { |
|
|
|
|
// only was sent 1 select |
|
|
|
|
if (is_string($rule->data)) { |
|
|
|
|
$data = explode('#', $rule->data); |
|
|
|
|
$rule->data = $data[1]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($rule->data)) { |
|
|
|
|
$condition_array[] = ' (' |
|
|
|
|
.$this->get_where_clause($rule->field, $rule->op, $rule->data) |
|
|
|
|
.') '; |
|
|
|
|
$extra_fields[] = ['field' => $rule->field, 'id' => $field_option['id']]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (isset($rule->data)) { |
|
|
|
|
if (isset($rule->data) && is_int($rule->data) && -1 == $rule->data) { |
|
|
|
|
continue; |
|
|
|
|
if (!isset($rule->data)) { |
|
|
|
|
$conditionArray[] = ' (' |
|
|
|
|
.$this->get_where_clause($rule->field, $rule->op, $rule->data) |
|
|
|
|
.') '; |
|
|
|
|
$extraFields[] = ['field' => $rule->field, 'id' => $field_option['id']]; |
|
|
|
|
} |
|
|
|
|
/*var_dump($rule->data); |
|
|
|
|
foreach ($rule->data as $option) { |
|
|
|
|
}*/ |
|
|
|
|
$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR'); |
|
|
|
|
$condition_array[] = " ( $where ) "; |
|
|
|
|
|
|
|
|
|
$extra_fields[] = [ |
|
|
|
|
'field' => $rule->field, |
|
|
|
|
'id' => $field_option['id'], |
|
|
|
|
'data' => $rule->data, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_TAG: |
|
|
|
|
if (isset($rule->data)) { |
|
|
|
|
if (is_int($rule->data) && -1 == $rule->data) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// Where will be injected in the parseConditions() |
|
|
|
|
//$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR'); |
|
|
|
|
//$conditionArray[] = " ( $where ) "; |
|
|
|
|
$extraFields[] = [ |
|
|
|
|
'field' => $rule->field, |
|
|
|
|
'id' => $field_option['id'], |
|
|
|
|
'data' => $rule->data, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
if (isset($rule->data)) { |
|
|
|
|
if (is_int($rule->data) && -1 == $rule->data) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR'); |
|
|
|
|
$conditionArray[] = " ( $where ) "; |
|
|
|
|
$extraFields[] = [ |
|
|
|
|
'field' => $rule->field, |
|
|
|
|
'id' => $field_option['id'], |
|
|
|
|
'data' => $rule->data, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$my_field = str_replace('_second', '', $rule->field); |
|
|
|
|
$original_field = str_replace($stringToSearch, '', $my_field); |
|
|
|
|
$field_option = $this->get_handler_field_info_by_field_variable($original_field); |
|
|
|
|
$extra_fields[] = [ |
|
|
|
|
$extraFields[] = [ |
|
|
|
|
'field' => $rule->field, |
|
|
|
|
'id' => $field_option['id'], |
|
|
|
|
]; |
|
|
|
|
@ -2649,17 +2660,7 @@ JAVASCRIPT; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*var_dump( |
|
|
|
|
[ |
|
|
|
|
'extra_fields' => $extra_fields, |
|
|
|
|
'condition_array' => $condition_array, |
|
|
|
|
] |
|
|
|
|
);*/ |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'extra_fields' => $extra_fields, |
|
|
|
|
'condition_array' => $condition_array, |
|
|
|
|
]; |
|
|
|
|
return ['extra_fields' => $extraFields, 'condition_array' => $conditionArray,]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -2737,7 +2738,7 @@ JAVASCRIPT; |
|
|
|
|
case self::FIELD_TYPE_DOUBLE_SELECT: |
|
|
|
|
$inject_extra_fields .= " fvo$counter.display_text as {$extra['field']}, "; |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_TAG: |
|
|
|
|
case self::FIELD_TYPE_TAG: |
|
|
|
|
// If using OR |
|
|
|
|
// If using AND |
|
|
|
|
$newCounter = 1; |
|
|
|
|
@ -2780,7 +2781,6 @@ JAVASCRIPT; |
|
|
|
|
$inject_joins = null; |
|
|
|
|
$inject_where = null; |
|
|
|
|
$where = null; |
|
|
|
|
|
|
|
|
|
if (!empty($options['where'])) { |
|
|
|
|
if (!empty($options['extra'])) { |
|
|
|
|
// Removing double 1=1 |
|
|
|
|
@ -2810,8 +2810,8 @@ JAVASCRIPT; |
|
|
|
|
break; |
|
|
|
|
case self::FIELD_TYPE_TAG: |
|
|
|
|
$newCounter = 1; |
|
|
|
|
$whereTag = []; |
|
|
|
|
if (isset($extra_info['data']) && !empty($extra_info['data'])) { |
|
|
|
|
$whereTag = []; |
|
|
|
|
foreach ($extra_info['data'] as $data) { |
|
|
|
|
$data = Database::escape_string($data); |
|
|
|
|
$key = $counter.$newCounter; |
|
|
|
|
@ -2827,10 +2827,9 @@ JAVASCRIPT; |
|
|
|
|
"; |
|
|
|
|
$newCounter++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($whereTag)) { |
|
|
|
|
$options['where'] = ' ('.implode(' AND ', $whereTag).') '; |
|
|
|
|
if (!empty($whereTag)) { |
|
|
|
|
$options['where'] .= ' AND ('.implode(' AND ', $whereTag).') '; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
@ -2849,11 +2848,11 @@ JAVASCRIPT; |
|
|
|
|
$where .= ' AND '.$options['where']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$order = null; |
|
|
|
|
$order = ''; |
|
|
|
|
if (!empty($options['order'])) { |
|
|
|
|
$order = ' ORDER BY '.$options['order']; |
|
|
|
|
} |
|
|
|
|
$limit = null; |
|
|
|
|
$limit = ''; |
|
|
|
|
if (!empty($options['limit'])) { |
|
|
|
|
$limit = ' LIMIT '.$options['limit']; |
|
|
|
|
} |
|
|
|
|
|