Session list filter now works! see BT#4872 be careful, select "contains" (is like a LIKE in mysql )instead of "equal" (something like "===") those parameters can be removed too

skala
Julio Montoya 12 years ago
parent 6c6933463c
commit 95010974df
  1. 7
      main/admin/session_list.php
  2. 43
      main/inc/ajax/model.ajax.php
  3. 6
      main/inc/lib/session_field.lib.php
  4. 2
      main/inc/lib/session_field_option.lib.php
  5. 4
      main/inc/lib/sessionmanager.lib.php

@ -114,7 +114,7 @@ if (!empty($fields)) {
$column_model[] = array(
'name' => $field['field_variable'],
'index' => $field['field_variable'],
'index' => 'extra_'.$field['field_variable'],
'width' => '100',
'hidden' => 'true',
'search' => 'true',
@ -122,8 +122,9 @@ if (!empty($fields)) {
'searchoptions' => $search_options
);
$columns[] = $field['field_display_text'];
$rules[] = array('field' => $field['field_variable'], 'op' => 'eq', 'data' => '');
$rules[] = array('field' => 'extra_'.$field['field_variable'], 'op' => 'eq', 'data' => '');
}
$groups = array(
'groupOp'=> 'OR',
'rules' => $rules
@ -140,8 +141,6 @@ $extra_params['height'] = 'auto';
$extra_params['rowList'] = array(10, 20 ,30);
$extra_params['postData'] =array (
'filters' => array(
"groupOp" => "AND",

@ -66,29 +66,46 @@ $search_string = isset($_REQUEST['searchString']) ? $_REQUEST['searchString']
if ($_REQUEST['_search'] == 'true') {
$where_condition = ' 1 = 1 ';
$where_condition_in_form = get_where_clause($search_field, $search_oper, $search_string);
$extra_conditions = '';
$where_condition_in_form = get_where_clause($search_field, $search_oper, $search_string);
if (!empty($where_condition_in_form)) {
$where_condition .= ' AND '.$where_condition_in_form;
}
$filters = isset($_REQUEST['filters']) ? json_decode($_REQUEST['filters']) : false;
$filters = isset($_REQUEST['filters']) ? json_decode($_REQUEST['filters']) : false;
$session_field = new SessionField();
if (!empty($filters)) {
$where_condition .= ' AND ( ';
$where_condition .= ' AND ( ';
$rules = array();
$extra_rules = array();
$counter = 0;
foreach ($filters->rules as $key => $rule) {
$where_condition .= get_where_clause($rule->field, $rule->op, $rule->data);
if ($counter < count($filters->rules) -1) {
foreach ($filters->rules as $rule) {
if (strpos($rule->field, 'extra_') === false) {
$field = $rule->field;
$where_condition .= get_where_clause($field, $rule->op, $rule->data);
} else {
$original_field = str_replace('extra_', '', $rule->field);
$session_field_option = $session_field->get_session_field_info_by_field_variable($original_field);
//var_dump($session_field_option);
$field = 'field_value';
$where_condition .= ' ('.get_where_clause('field_id', 'eq', $session_field_option['id']);
$where_condition .= ' AND ';
$where_condition .= get_where_clause($field, $rule->op, $rule->data).') ';
}
if ($counter < count($filters->rules) -1) {
$where_condition .= $filters->groupOp;
}
$counter++;
}
$where_condition .= ' ) ';
$counter++;
}
$where_condition .= ' ) ';
}
}
if (isset($_REQUEST['search_form'])) {
}
// get index row - i.e. user click to sort $sord = $_GET['sord'];
// get the direction

@ -41,9 +41,9 @@ class SessionField extends Model {
return $order;
}
public function get_session_field_info_by_field_variable($field) {
$field = Database::escape_string($field);
$sql_field = "SELECT * FROM {$this->table} WHERE field_variable = '$field'";
public function get_session_field_info_by_field_variable($field_variable) {
$field_variable = Database::escape_string($field_variable);
$sql_field = "SELECT * FROM {$this->table} WHERE field_variable = '$field_variable'";
$result = Database::query($sql_field);
if (Database::num_rows($result)) {
$r_field = Database::fetch_array($result, 'ASSOC');

@ -18,7 +18,7 @@ class SessionFieldOption extends Model {
$new_options = array();
if (!empty($options)) {
foreach ($options as $option) {
$new_options[] = $option['id'].':'.$option['option_value'];
$new_options[] = $option['option_value'].':'.$option['option_value'];
}
$string = implode(';', $new_options);
return $string;

@ -321,6 +321,8 @@ class SessionManager {
display_end_date,
s.visibility,
u.user_id,
fv.field_id,
fv.field_value,
s.id";
$query = "$select FROM $tbl_session s LEFT JOIN $tbl_session_field_values fv ON (fv.session_id = s.id)
@ -352,6 +354,8 @@ class SessionManager {
$query .= " ORDER BY ".$options['order']." LIMIT ".$options['limit'];
}
//var_dump($query);
$result = Database::query($query);
$formatted_sessions = array();
if (Database::num_rows($result)) {

Loading…
Cancel
Save