fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8232]


From: Torstein
Subject: [Fmsystem-commits] [8232]
Date: Mon, 05 Dec 2011 08:59:53 +0000

Revision: 8232
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8232
Author:   vator
Date:     2011-12-05 08:59:52 +0000 (Mon, 05 Dec 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicheck_list_for_location.inc.php
    trunk/controller/inc/class.uicommon.inc.php
    trunk/controller/inc/class.uicontrol.inc.php

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2011-12-05 08:59:37 UTC 
(rev 8231)
+++ trunk/controller/inc/class.socontrol.inc.php        2011-12-05 08:59:52 UTC 
(rev 8232)
@@ -138,8 +138,10 @@
                        $control_id = $this->unmarshal($this->db->f('id', 
true), 'int');
                        $title = $this->unmarshal($this->db->f('title', true), 
'string');
                        $location_code = 
$this->unmarshal($this->db->f('location_code', true), 'int');
-                                               
-                       $controls_array[] = array("id" => $control_id, "title" 
=> $title, "location_code" => $location_code);
+                       
+                       $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
+                       
+                       $controls_array[] = array("id" => $control_id, "title" 
=> $title, "location_code" => $location_code, "loc1_name" => 
$location_array["loc1_name"]);
                }
                
                if( count( $controls_array ) > 0 ){

Modified: trunk/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2011-12-05 08:59:37 UTC (rev 8231)
+++ trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2011-12-05 08:59:52 UTC (rev 8232)
@@ -6,7 +6,6 @@
 
        class controller_uicheck_list_for_location extends controller_uicommon
        {
-               var $grants;
                var $cat_id;
                var $start;
                var $query;
@@ -22,15 +21,13 @@
        
                var $public_functions = array(
                                                                                
'index' => true,
+                                                                               
'add_location_to_control' => true
                                                                        );
 
                function __construct()
                {
                        parent::__construct();
                        
-                       $GLOBALS['phpgw_info']['flags']['nonavbar'] = true; // 
menus added where needed via bocommon::get_menu
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
-                       
                        $this->bo                                       = 
CreateObject('property.bolocation',true);
                        $this->bocommon                         = & 
$this->bo->bocommon;
                        $this->so_control_area          = 
CreateObject('controller.socontrol_area');
@@ -89,66 +86,120 @@
                        array_unshift ($responsibility_roles,$default_value);
                        
                        $control_areas_array = 
$this->so_control_area->get_control_areas_as_array();
+                       $controls_array = 
$this->so_control->get_controls_by_control_area($control_areas_array[0]['id']);
+                       $control_id = $control_areas_array[0]['id'];
                        
-                       $control_id = 186;
+                       if($control_id == null)
+                               $control_id = 0;
                        
-                       $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
-                                               
+                       $tabs = array( array(
+                                               'label' => 
lang('View_locations_for_control')
+                                       ), array(
+                                               'label' => 
lang('Add_locations_for_control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list_for_location.add_location_to_control'))
+                                       ));
                        
+                       $data = array(
+                               'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+                               'view'                                  => 
"view_locations_for_control",
+                               'control_area_array'    => $control_areas_array,
+                               'control_array'                 => 
$control_array,
+                               'locations_table' => array(
+                                       'source' => 
self::link(array('menuaction' => 
'controller.uicontrol.get_locations_for_control', 'control_id' => $control_id 
,'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => 
lang('ControlId'),
+                                                       'sortable'      => true,
+                                               ),
+                                               array(
+                                                       'key'   =>      'title',
+                                                       'label' =>      
lang('Property name'),
+                                                       'sortable'      =>      
false
+                                               ),
+                                               array(
+                                                       'key' => 
'location_code',
+                                                       'label' => 
lang('Address'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 'loc1_name',
+                                                       'label' => 
lang('Address'),
+                                                       'sortable'      => false
+                                               )
+                                       )
+                               )
+                       );
                        
                        
-               /*
-                       $lists = array
-                       (
-                               'building_types'                        => 
$building_types,
-                               'category_types'                        => 
$category_types,
-                               'district_list'                         => 
$district_list,
-                               'part_of_town_list'                     => 
$part_of_town_list,
-                               'responsibility_roles_list'     => 
$responsibility_roles_list,
-                               'control_area_list'                     => 
$control_areas_array,
-                       );
-*/
+                       phpgwapi_yui::load_widget('paginator');
+                       
+                       self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
 
+                       
self::render_template_xsl(array('control_location_tabs', 'common', 
'view_locations_for_control'), $data);               
+               }
+               
+               function add_location_to_control()
+               {
+                       if(phpgw::get_var('phpgw_return_as') == 'json') {
+                               return $this->query();
+                       }
+                       $building_types  = 
execMethod('property.soadmin_location.read',array());
+                       
+                       $type_id = 1;
+                       
+                       $category_types = 
$this->bocommon->select_category_list(array(
+                                                                               
                                                                
'format'=>'filter',
+                                                                               
                                                                'selected' => 
$this->cat_id,
+                                                                               
                                                                'type' 
=>'location',
+                                                                               
                                                                'type_id' 
=>$type_id,
+                                                                               
                                                                'order'=>'descr'
+                                                                               
                                                        ));
+                       
+                       $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
+                       $default_value = array ('id'=>'','name'=>lang('no 
district'));
+                       array_unshift($district_list,$default_value);
+                       
+                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
+                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
+                       array_unshift($part_of_town_list,$default_value);
+                       
+                       $_role_criteria = array
+                                       (
+                                               'type'          => 
'responsibility_role',
+                                               'filter'        => 
array('location' => ".location.{$type_id}"),
+                                               'order'         => 'name'
+                                       );
+
+                       $responsibility_roles_list =   
execMethod('property.sogeneric.get_list',$_role_criteria);
+                       $default_value = array ('id'=>'','name'=>lang('no 
role'));
+                       array_unshift ($responsibility_roles,$default_value);
+                       
+                       $control_areas_array = 
$this->so_control_area->get_control_areas_as_array();
+                       
+                       $tabs = array( array(
+                                               'label' => 
lang('View_locations_for_control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicheck_list_for_location.index'))
+                       
+                                       ), array(
+                                               'label' => 
lang('Add_locations_for_control')
+                                       ));
+                                       
                        $data = array(
-                               'form' => array(
-                                       'toolbar' => array(
-                                               'item' => array(
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'building_types',
-                                'text' => lang('Building_types').':',
-                                'list' => $building_types
-                                                       ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'cat_id',
-                                'text' => lang('Category_types').':',
-                                'list' => $category_types
-                                                       ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'district_id',
-                                'text' => lang('District_list').':',
-                                'list' => $district_list
-                                                       ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'part_of_town_list',
-                                'text' => lang('Part_of_town_list').':',
-                                'list' => $part_of_town_list
-                                                       ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'responsibility_roles_list',
-                                'text' => 
lang('responsibility_roles_list').':',
-                                'list' => $responsibility_roles_list
-                                                       ),
-                                                       array('type' => 'text', 
-                                  'name' => 'query'
-                                                       ),
-                                                       array(
-                                                               'type' => 
'submit',
-                                                               'name' => 
'search',
-                                                               'value' => 
lang('Search')
-                                                       ),
-                                               ),
-                                       ),
+                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                               'view'                                          
=> "add_location_to_control",
+                               'control_filters'                       => 
array(
+                                       'control_area_array'            => 
$control_areas_array,
+                                       'control_array'                         
=> $control_array
                                ),
+                               'filter_form'                           => 
array(
+                                       'building_types'                        
=> $building_types,
+                                       'category_types'                        
=> $category_types,
+                                       'district_list'                         
=> $district_list,
+                                       'part_of_town_list'             => 
$part_of_town_list
+                               ),
                                'datatable' => array(
                                        'source' => 
self::link(array('menuaction' => 'controller.uicheck_list_for_location.index', 
'phpgw_return_as' => 'json')),
                                        'field' => array(
@@ -161,7 +212,7 @@
                                                array(
                                                        'key'   =>      
'loc1_name',
                                                        'label' =>      
lang('Property name'),
-                                                       'sotrable'      =>      
false
+                                                       'sortable'      =>      
false
                                                ),
                                                array(
                                                        'key' => 'adresse1',
@@ -174,10 +225,6 @@
                                                        'sortable'      => false
                                                ),
                                                array(
-                                                       'key' => 'link',
-                                                       'hidden' => true
-                                               ),
-                                               array(
                                                        'key' => 'actions',
                                                        'hidden' => true
                                                ),
@@ -188,48 +235,49 @@
                                                array(
                                                        'key' => 'ajax',
                                                        'hidden' => true
-                                               ),
-                                               array(
-                                                       'key' => 'alert',
-                                                       'hidden' => true
-                                               )
+                                               )                               
                
                                        )
-                               ),
-                               'lists'                                 => 
$lists,
-                               'locations_for_control' => 
$locations_for_control_array,
-                               'control_area_list'             => 
$control_areas_array
-                       );                      
+                               )
+                       );
                        
-                       //self::add_javascript('controller', 'yahoo', 
'datatable.js');
-                       self::add_javascript('controller', 'controller', 
'controller_datatable_test.js');
+                       
+                       phpgwapi_yui::load_widget('paginator');
+                       
+                       self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
 
-                       //self::render_template_xsl('datatable', $data);
-                       self::render_template_xsl('locations', $data);          
+                       
self::render_template_xsl(array('control_location_tabs', 'common', 
'add_location_to_control'), $data);          
                }
                
                public function query(){
                                        
-                       $type_id = 1;
                        
+                       $type_id = phpgw::get_var('type_id');
+                       
+                       if( empty($type_id) | $type_id == "" ){
+                               $type_id = 1;
+                       }
+                       
                        $location_list = array();
 
                        $this->bo->sort = "ASC";
-                                               
+                       $this->bo->start = phpgw::get_var('startIndex');
+                       
                        $location_list = $this->bo->read(array('user_id' => 
$user_id, 'role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
                                                                                
                   'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run' 
=>$dry_run));
 
-                       $results = array();
-
+                       $rows_total = $this->bo->read(array('type_id' => 
$type_id, 'allrows' => true));
+                       
                        foreach($location_list as $location)
                        {
                                $results['results'][]= $location;       
                        }
                        
-                       $results['total_records'] = 10;
-                       $results['start'] = 1;
+                       $results['total_records'] = count($rows_total);
+                       $results['start'] = $this->start;
                        $results['sort'] = 'location_code';
+                       $results['dir'] = "ASC";
                                                
                        array_walk($results['results'], array($this, 
'add_actions'), array($type));
                                                        
@@ -249,7 +297,7 @@
                        $value['labels'][] = lang('show');
                        
                        $value['ajax'][] = true;
-                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uilocation_check_list', 'location_code' => 
$value['location_code'])));
+                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uicontrol.add_location_to_control', 'location_code' => 
$value['location_code'])));
                        $value['labels'][] = lang('add_location');
                }
        }
\ No newline at end of file

Modified: trunk/controller/inc/class.uicommon.inc.php
===================================================================
--- trunk/controller/inc/class.uicommon.inc.php 2011-12-05 08:59:37 UTC (rev 
8231)
+++ trunk/controller/inc/class.uicommon.inc.php 2011-12-05 08:59:52 UTC (rev 
8232)
@@ -462,20 +462,20 @@
 
                // Build a YUI result style array
                public function yui_results($results)
-               {
-                       if (!$results) {
+               { 
+                       if (!$results) { 
                                $results['total_records'] = 0;
                                $result['results'] = array();
                        }
 
                        return array(   
                                'ResultSet' => array(
-                                       'totalResultsAvailable' => 
$results['total_records'],
-                                       'recordsReturned'               => 
count($results['results']),
-                                       'startIndex' => $results['start'], 
-                                       'sortKey' => $results['sort'], 
-                                       'sortDir' => $results['dir'], 
-                                       'Result' => $results['results']
+                                       'totalRecords'          => 
$results['total_records'],
+                                       'recordsReturned'       => 
count($results['results']),
+                                       'startIndex'            => 
$results['start'], 
+                                       'sortKey'                       => 
$results['sort'], 
+                                       'sortDir'                       => 
$results['dir'], 
+                                       'Result'                        => 
$results['results']
                                )   
                        );  
                }

Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php        2011-12-05 08:59:37 UTC 
(rev 8231)
+++ trunk/controller/inc/class.uicontrol.inc.php        2011-12-05 08:59:52 UTC 
(rev 8232)
@@ -41,7 +41,9 @@
                        'view_check_list'                                       
=>      true,
                        'generate_check_lists_for_control'      =>      true,
                        'view_check_lists_for_control'          =>      true,
-                       'get_controls_by_control_area'          =>      true
+                       'get_controls_by_control_area'          =>      true,
+                       'get_locations_for_control'                     =>      
true,
+                       'add_location_to_control'                       =>      
true
                );
 
                public function __construct()
@@ -624,6 +626,34 @@
                                return null;
                }
                
+               // Returns locations for a control
+               public function get_locations_for_control()
+               {
+                       $control_id = phpgw::get_var('control_id');
+                       $locations_for_control_array = 
$this->so->get_locations_for_control($control_id);
+                       
+                       foreach($locations_for_control_array as $location)
+                       {
+                               $results['results'][]= $location;       
+                       }
+                       
+                       $results['total_records'] = count( 
$locations_for_control_array );
+                       $results['start'] = 1;
+                       $results['sort'] = 'location_code';
+                                               
+                       array_walk($results['results'], array($this, 
'add_actions'), array($type));
+                                                       
+                       return $this->yui_results($results);
+               }
+               
+               public function add_location_to_control()
+               {
+                       $control_id = phpgw::get_var('control_id');
+                       $location_code = phpgw::get_var('location_code');
+                       
+                       $this->so->add_location_to_control($control_id, 
$location_code);
+               }
+               
                public function query()
                {
                        $params = array(




reply via email to

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