fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7576] bkbooking: update booking list with filter


From: Kjell Arne Espedal
Subject: [Fmsystem-commits] [7576] bkbooking: update booking list with filter
Date: Mon, 12 Sep 2011 13:21:23 +0000

Revision: 7576
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7576
Author:   kjell
Date:     2011-09-12 13:21:22 +0000 (Mon, 12 Sep 2011)
Log Message:
-----------
bkbooking: update booking list with filter

Modified Paths:
--------------
    trunk/booking/inc/class.sobooking.inc.php
    trunk/booking/inc/class.uibooking.inc.php

Modified: trunk/booking/inc/class.sobooking.inc.php
===================================================================
--- trunk/booking/inc/class.sobooking.inc.php   2011-09-12 06:37:51 UTC (rev 
7575)
+++ trunk/booking/inc/class.sobooking.inc.php   2011-09-12 13:21:22 UTC (rev 
7576)
@@ -443,6 +443,40 @@
                        return $this->db->f('name', false);
                }
 
+               function get_season($id)
+               {
+                       $this->db->limit_query("SELECT id FROM bb_season where 
id=" . intval($id), 0, __LINE__, __FILE__, 1);
+                       if(!$this->db->next_record())
+                       {
+                               return False;
+                       }
+                       return $this->db->f('id', false);
+               }
+
+               function get_group_of_organization($id)
+               {
+            $results = array();
+                       $this->db->query("SELECT id FROM bb_group WHERE active 
= 1 and organization_id=". intval($id), __LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = $this->db->f('id', false);
+                       }
+                       return $results;
+               }
+
+               function get_organizations()
+               {
+            $results = array();
+                       $results[] = array('id' =>  0,'name' => lang('Not 
selected'));
+                       $this->db->query("SELECT id, name FROM bb_organization 
WHERE active = 1 ORDER BY name ASC", __LINE__, __FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $results[] = array('id' => $this->db->f('id', 
false),
+                                                          'name' => 
$this->db->f('name', false));
+                       }
+                       return $results;
+               }
+
                public function find_expired() {
                        $table_name = $this->table_name;
                        $db = $this->db;

Modified: trunk/booking/inc/class.uibooking.inc.php
===================================================================
--- trunk/booking/inc/class.uibooking.inc.php   2011-09-12 06:37:51 UTC (rev 
7575)
+++ trunk/booking/inc/class.uibooking.inc.php   2011-09-12 13:21:22 UTC (rev 
7576)
@@ -45,6 +45,7 @@
                        if(phpgw::get_var('phpgw_return_as') == 'json') {
                                return $this->index_json();
                        }
+                       self::add_javascript('booking', 'booking', 
'allocation_list.js');
                        self::add_javascript('booking', 'booking', 
'datatable.js');
                        phpgwapi_yui::load_widget('datatable');
                        phpgwapi_yui::load_widget('paginator');
@@ -52,6 +53,24 @@
                                'form' => array(
                                        'toolbar' => array(
                                                'item' => array(
+                                                       array('type' => 
'autocomplete', 
+                                                               'name' => 
'building',
+                                                               'ui' => 
'building',
+                                                               'text' => 
lang('Building').':',
+                                                               'onItemSelect' 
=> 'updateBuildingFilter',
+                                                               
'onClearSelection' => 'clearBuildingFilter'
+                                                       ),
+                                                       array('type' => 
'autocomplete', 
+                                                               'name' => 
'season',
+                                                               'ui' => 
'season',
+                                                               'text' => 
lang('Season').':',
+                                                               
'requestGenerator' => 'requestWithBuildingFilter',
+                                                       ),
+                                                       array('type' => 
'filter', 
+                                                               'name' => 
'organizations',
+                                'text' => lang('Organization').':',
+                                'list' => $this->bo->so->get_organizations(),
+                                                       ),
                                                        array('type' => 'text', 
                                                                'name' => 
'query'
                                                        ),
@@ -115,13 +134,49 @@
                                                'href' => 
self::link(array('menuaction' => 'booking.uibooking.add'))
                                ));
                        }
-                       
+                       $data['filters'] = $this->export_filters;
                        self::render_template('datatable', $data);
                }
 
                public function index_json()
                {
-                       $bookings = $this->bo->read();
+                       if(isset($_SESSION['showall']))
+                       {
+                       unset($filters['building_name']);
+                unset($filters['group_id']);
+                unset($filters['season_id']);
+                       } else {
+                $testdata =  phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null);
+                if ($testdata != 0) {
+                    $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null));        
+                } else {
+                    unset($filters['building_name']);                
+                }
+                $testdata2 =  phpgw::get_var('organizations', 'int', 
'REQUEST', null);
+                if ($testdata2 != 0) {
+                    $filters['group_id'] = 
$this->bo->so->get_group_of_organization(phpgw::get_var('organizations', 'int', 
'REQUEST', null));        
+                } else {
+                           unset($filters['group_id']);
+                }
+                $testdata3 =  phpgw::get_var('filter_season_id', 'int', 
'REQUEST', null);
+                if ($testdata3 != 0 and $testdata3 != '') {
+                    $filters['season_id'] = 
$this->bo->so->get_season(phpgw::get_var('filter_season_id', 'int', 'REQUEST', 
null));        
+                } else {
+                    unset($filters['season_id']);                
+                }
+            }
+            
+                       $params = array(
+                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
+                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', null),
+                               'query' => phpgw::get_var('query'),
+                               'sort'  => phpgw::get_var('sort'),
+                               'dir'   => phpgw::get_var('dir'),
+                               'filters' => $filters
+                       );
+
+                       $bookings = $this->bo->so->read($params);
+
                        foreach($bookings['results'] as &$booking) {
                                $building = 
$this->building_bo->read_single($booking['building_id']);
                                $booking['building_name'] = $building['name'];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]