Bläddra i källkod

Some fixes in the queries see BT#3368

Julio Montoya 13 år sedan
förälder
incheckning
7d6bdf400b
2 ändrade filer med 22 tillägg och 13 borttagningar
  1. 6 2
      main/admin/session_list.php
  2. 16 11
      main/inc/ajax/model.ajax.php

+ 6 - 2
main/admin/session_list.php

@@ -56,8 +56,12 @@ $column_model   = array(
                         array('name'=>'date_end',       'index'=>'date_end',      'width'=>'40',   'align'=>'left', 'search' => 'true'),
                         array('name'=>'coach_name',     'index'=>'coach_name',     'width'=>'80',   'align'=>'left', 'search' => 'false'),                        
                         
-                        array('name'=>'status',         'index'=>'session_active',  'width'=>'40',   'align'=>'left', 'search' => 'true'
-                        ,'stype'=>'select', 'editoptions' =>array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))),            
+                        array('name'=>'status',         'index'=>'session_active',  'width'=>'40',   'align'=>'left', 'search' => 'true', 'stype'=>'select',
+                                //for the top bar 
+                              'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')),
+                              //for the bottom bar
+                              'searchoptions' => array('value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive'))),
+                                          
                                    
                         array('name'=>'visibility',     'index'=>'visibility',      'width'=>'40',   'align'=>'left', 'search' => 'false'),                        
                         array('name'=>'actions',        'index'=>'actions',         'width'=>'100',  'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false')

+ 16 - 11
main/inc/ajax/model.ajax.php

@@ -61,21 +61,26 @@ $search_string   = isset($_REQUEST['searchString']) ? $_REQUEST['searchString']
 
 if ($_REQUEST['_search'] == 'true') {
     $where_condition = ' 1 = 1 ';
-    $where_condition .= get_where_clause($search_field, $search_oper, $search_string);
+    $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;
-    
-    $where_condition .= ' AND ( ';
-    $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) {     
-            $where_condition .= $filters->groupOp;
+    if (!empty($filters)) {
+        $where_condition .= ' AND ( ';
+        $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) {     
+                $where_condition .= $filters->groupOp;
+            }
+            $counter++;
         }
-        $counter++;
+        $where_condition .= ' ) ';
     }
-    $where_condition .= ' ) ';
         
 }