fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10252] controller: generalize


From: Sigurd Nes
Subject: [Fmsystem-commits] [10252] controller: generalize
Date: Wed, 17 Oct 2012 13:29:53 +0000

Revision: 10252
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10252
Author:   sigurdne
Date:     2012-10-17 13:29:52 +0000 (Wed, 17 Oct 2012)
Log Message:
-----------
controller: generalize

Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicontrol_register_to_component.inc.php
    trunk/controller/js/controller/ajax.js
    trunk/controller/js/controller/ajax_control_to_component.js
    trunk/controller/setup/phpgw_no.lang
    
trunk/controller/templates/base/control_location/register_control_to_location.xsl

Added Paths:
-----------
    trunk/controller/inc/class.uicontrol_register_to_location.inc.php
    trunk/controller/js/controller/ajax_control_to_location.js

Removed Paths:
-------------
    trunk/controller/inc/class.uicontrol_location.inc.php

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2012-10-17 10:50:39 UTC (rev 
10251)
+++ trunk/controller/inc/class.menu.inc.php     2012-10-17 13:29:52 UTC (rev 
10252)
@@ -61,7 +61,7 @@
                                                                                
        'location_for_check_list' => array
                                                                                
        (
                                                                                
                'text'  => lang('location_connections'),
-                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_location.index') ),
+                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_register_to_location.index') ),
                                                                                
                'image' => array('property', 'location_1')
                                                                                
        ),
                                                                                
        'component_for_check_list' => array

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-10-17 10:50:39 UTC 
(rev 10251)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-10-17 13:29:52 UTC 
(rev 10252)
@@ -551,58 +551,7 @@
                        }
                }
                
-               public function register_control_to_location($control_id, $data)
-               {
 
-                       $control_id = (int) $control_id;
-                       $delete_location = array();
-                       $add_location = array();
-                       foreach($data['control_location_orig'] as 
$location_code)
-                       {
-                               if(!in_array($location_code, 
$data['control_location']))
-                               {
-                                       $delete_location[] = $location_code;
-                               }
-                       }
-
-                       foreach($data['control_location'] as $location_code)
-                       {
-                               if(!in_array($location_code, 
$data['control_location_orig']))
-                               {
-                                       $add_location[] = $location_code;
-                               }
-                       }
-
-                       $this->db->transaction_begin();
-                       foreach ($delete_location as $location_code)
-                       {
-                               $sql  = "DELETE FROM 
controller_control_location_list ";
-                               $sql .= "WHERE control_id = {$control_id} ";
-                               $sql .= "AND location_code = 
'{$location_code}'";
-                               
-                               $this->db->query($sql);
-                       }
-
-                       foreach ($add_location as $location_code)
-                       {
-                               $sql  = "SELECT * ";
-                               $sql .= "FROM controller_control_location_list 
";
-                               $sql .= "WHERE control_id = {$control_id} ";
-                               $sql .= "AND location_code = '$location_code'";
-                               
-                               $this->db->query($sql, __LINE__, __FILE__);
-                       
-                               if(!$this->db->next_record())
-                               {
-                                       $sql  = "INSERT INTO 
controller_control_location_list (control_id, location_code) ";
-                                       $sql .= "VALUES ( {$control_id}, 
'{$location_code}')";
-                                       $this->db->query($sql);
-                               }
-                       }
-
-                       return $this->db->transaction_commit();
-               }
-
                public function check_control_component($control_id, 
$location_id, $component_id)
                {
                        $control_id             = (int) $control_id;
@@ -620,6 +569,77 @@
                }
 
                /**
+                * Register that a control should be carried out on a location
+                *
+                * @param $data['control_id'] control id
+                * @param $data['component_id'] component id
+                * @param $data['location_id'] component id
+                * @return true or false if the execution was successful  
+               */
+               function register_control_to_location($data)
+               {
+
+                       $delete_component = array();
+                       $add_component = array();
+                       $this->db->transaction_begin();
+
+                       if(isset($data['register_location']) && 
is_array($data['register_location']))
+                       {
+                               foreach($data['register_location'] as 
$location_info)
+                               {
+                                       $location_arr = explode('_', 
$location_info);
+                                       if(count($location_arr)!=2)
+                                       {
+                                               continue;
+                                       }
+                                       
+                                       $control_id             = (int) 
$location_arr[0];
+                                       $location_code  = $location_arr[1];
+
+                                       if(!$control_id)
+                                       {
+                                               return false;
+                                       }
+
+                                       $sql  = "SELECT * ";
+                                       $sql .= "FROM 
controller_control_location_list ";
+                                       $sql .= "WHERE control_id = 
{$control_id} ";
+                                       $sql .= "AND location_code = 
'{$location_code}' ";
+                                       
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                       
+                                       if(!$this->db->next_record())
+                                       {
+                                               $sql =  "INSERT INTO 
controller_control_location_list (control_id, location_code) ";
+                                               $sql .= "VALUES ( 
{$control_id}, '{$location_code}')";
+                                               
+                                               $this->db->query($sql);
+                                       }
+                               }
+                       }
+
+                       if(isset($data['delete']) && is_array($data['delete']))
+                       {
+                               foreach($data['delete'] as $location_info)
+                               {
+                                       $location_arr = explode('_', 
$location_info);
+                                       if(count($location_arr)!=2)
+                                       {
+                                               continue;
+                                       }
+                                       
+                                       $control_id             = (int) 
$location_arr[0];
+                                       $location_code  = $location_arr[1];
+                               
+                                       $sql =  "DELETE FROM 
controller_control_location_list WHERE control_id = {$control_id} AND 
location_code = '{$location_code}'";
+                                       $this->db->query($sql);
+                               }
+                       }
+
+                       return $this->db->transaction_commit();
+               }
+
+               /**
                 * Register that a control should be carried out on a component
                 *
                 * @param $data['control_id'] control id

Deleted: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-10-17 
10:50:39 UTC (rev 10251)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-10-17 
13:29:52 UTC (rev 10252)
@@ -1,508 +0,0 @@
-<?php
-       /**
-       * phpGroupWare - controller: a part of a Facilities Management System.
-       *
-       * @author Erink Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare is free software; you can redistribute it and/or modify
-       * it under the terms of the GNU General Public License as published by
-       * the Free Software Foundation; either version 2 of the License, or
-       * (at your option) any later version.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
-       * @package property
-       * @subpackage controller
-       * @version $Id: class.uicheck_list.inc.php 8628 2012-01-21 10:42:05Z 
vator $
-       */
-       
-       phpgw::import_class('phpgwapi.yui');
-
-       /**
-       * Import the jQuery class
-       */
-       phpgw::import_class('phpgwapi.jquery');
-
-       phpgw::import_class('phpgwapi.uicommon');
-       
-       include_class('controller', 'check_list', 'inc/model/');
-       include_class('controller', 'date_generator', 'inc/component/');
-       include_class('controller', 'check_list_status_updater', 'inc/helper/');
-               
-       class controller_uicontrol_location extends phpgwapi_uicommon
-       {
-               var $cat_id;
-               var $start;
-               var $query;
-               var $sort;
-               var $order;
-               var $filter;
-               var $currentapp;
-               var $type_id;
-               var $location_code;
-               
-               private $so_control;
-               private $so_check_list;
-               private $so_control_item;
-               private $so_check_item;
-               private $so_procedure;
-       
-               var $public_functions = array
-               (
-                       'index'                                                 
        => true,
-                       'view_locations_for_control'            => true,
-                       'register_control_to_location'          => true,
-                       'register_control_to_location_2'        => true,
-                       'get_locations_for_control'             => true,
-                       'get_location_category'                         => true,
-                       'get_district_part_of_town'                     => true,
-                       'get_category_by_entity'                        => true,
-                       'get_entity_table_def'                          => true,
-                       'get_locations'                                         
=> true,
-                       'get_location_type_category'            => true
-               );
-
-               function __construct()
-               {
-                       parent::__construct();
-                       
-                       $this->bo                                       = 
CreateObject('property.bolocation',true);
-                       $this->bocommon                         = & 
$this->bo->bocommon;
-                       $this->so_control                       = 
CreateObject('controller.socontrol');
-                       $this->so_check_list            = 
CreateObject('controller.socheck_list');
-                       $this->so_control_item          = 
CreateObject('controller.socontrol_item');
-                       $this->so_check_item            = 
CreateObject('controller.socheck_item');
-                       $this->so_procedure                     = 
CreateObject('controller.soprocedure');
-                       
-                       $this->type_id                          = 
$this->bo->type_id;
-                       
-                       $this->start                            = 
$this->bo->start;
-                       $this->query                            = 
$this->bo->query;
-                       $this->sort                                     = 
$this->bo->sort;
-                       $this->order                            = 
$this->bo->order;
-                       $this->filter                           = 
$this->bo->filter;
-                       $this->cat_id                           = 
$this->bo->cat_id;
-                       $this->part_of_town_id          = 
$this->bo->part_of_town_id;
-                       $this->district_id                      = 
$this->bo->district_id;
-                       $this->status                           = 
$this->bo->status;
-                       $this->allrows                          = 
$this->bo->allrows;
-                       $this->lookup                           = 
$this->bo->lookup;
-                       $this->location_code            = 
$this->bo->location_code;
-                       
-                       
self::set_active_menu('controller::control::location_for_check_list');
-               }       
-       
-               function index()
-               {
-                       $control_id = phpgw::get_var('control_id');
-                       if(phpgw::get_var('save_location'))
-                       {
-                               $values = phpgw::get_var('values');
-                               //add component to control using component item 
ID
-                               $values['control_location'] = 
isset($values['control_location']) && $values['control_location'] ? 
array_unique($values['control_location']) : array();
-                               $values['control_location_orig'] = 
isset($values['control_location_orig']) && $values['control_location_orig'] ? 
array_unique($values['control_location_orig']) : array();
-
-                               $ok = 
$this->so_control->register_control_to_location($control_id, $values);
-
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_location.index', 'control_id' => 
$control_id));
-                       }
-                       else
-                       {
-                               if(phpgw::get_var('phpgw_return_as') == 'json') 
{
-                                       return $this->query();
-                               }
-                               $building_types  = 
execMethod('property.soadmin_location.read',array());
-                               //$type_id=phpgw::get_var('type_id');
-                               //if(!isset($type_id))
-                               $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'
-                                                                               
                                                                ));
-                               $default_value = array 
('id'=>'','name'=>lang('no category selected'));
-                               array_unshift($category_types,$default_value);
-                                                                               
                                                                
-                               $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_level' => (int)$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);
-                               
-                               $cats   = CreateObject('phpgwapi.categories', 
-1, 'controller', '.control');
-                               $cats->supress_info     = true;
-                               
-                               $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
-                                                               
-                               $control_areas_array = array();
-                               foreach($control_areas['cat_list'] as $cat_list)
-                               {
-                                       $control_areas_array[] = array
-                                       (
-                                               'id'    => $cat_list['cat_id'],
-                                               'name'  => $cat_list['name'],
-                                       );              
-                               }
-                               
-                               $control = $this->so_control->get_single( 
$control_id ); 
-                               $current_control_area_id = 
$control->get_control_area_id();
-                               $controls_array = 
$this->so_control->get_controls_by_control_area( $current_control_area_id );    
      
-                               
-                               $data = array(
-                                       'view'                                  
                                        => "register_control_to_location",
-                                       'control_areas_array'                   
=> $control_areas_array,
-                                 'controls_array'                          => 
$controls_array,
-                                 'current_control_id'                  => 
$control_id,
-                                       'current_control_area_id' => 
$current_control_area_id,
-                                       '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.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 
'register_control','control_id_init'    => $control_id)),
-                                               'field' => array(
-                                                       array(
-                                                               'key' => 
'location_registered',
-                                                               'hidden' => true
-                                                       ),
-                                                       array(
-                                                               'key' => 
'location_code',
-                                                               'label' => 
lang('Property'),
-                                                               'sortable'      
=> true,
-                                                               'formatter' => 
'YAHOO.portico.formatLink'
-                                                       ),
-                                                       array(
-                                                               'key'   =>      
'loc1_name',
-                                                               'label' =>      
lang('Property name'),
-                                                               'sortable'      
=>      false
-                                                       ),
-                                                       array(
-                                                               'key' => 
'adresse1',
-                                                               'label' => 
lang('Address'),
-                                                               'sortable'      
=> false
-                                                       ),
-                                                       array(
-                                                               'key' => 
'postnummer',
-                                                               'label' => 
lang('Zip code'),
-                                                               'sortable'      
=> false
-                                                       ),
-                                                       array(
-                                                               'key' => 
'control_name',
-                                                               'label' => 
lang('control'),
-                                                               'sortable'      
=> false
-                                                       ),
-                                                       array(
-                                                                       'key' 
=> 'checked',
-                                                                       'label' 
=> 'Velg',
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'formatterCheckLocation',
-                                                                       
'className' => 'mychecks'
-                                                       ),
-                                                       array(
-                                                               'key' => 
'actions',
-                                                               'hidden' => true
-                                                       ),
-                                                       array(
-                                                               'key' => 
'labels',
-                                                               'hidden' => true
-                                                       ),
-                                                       array(
-                                                               'key' => 'ajax',
-                                                               'hidden' => true
-                                                       ),array(
-                                                               'key' => 
'parameters',
-                                                               'hidden' => true
-                                                       )                       
                        
-                                               )
-                                       )
-                               );
-                               
-                               phpgwapi_yui::load_widget('paginator');
-                               
-                               phpgwapi_jquery::load_widget('core');
-
-//                             self::add_javascript('controller', 
'controller', 'jquery.js');
-                               self::add_javascript('controller', 
'controller', 'ajax.js');
-                               self::add_javascript('controller', 'yahoo', 
'register_control_to_location.js');
-       
-                               
self::render_template_xsl(array('control_location/control_location_tabs', 
'control_location/register_control_to_location', 'common'), $data);
-                       }               
-               }
-               
-               // Returns locations for a control
-               public function get_locations_for_control()
-               {
-                       $control_id = phpgw::get_var('control_id');
-                       
-                       if(is_numeric($control_id) & $control_id > 0)
-                       {
-                               $locations_for_control_array = 
$this->so_control->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';
-                       }
-                       else
-                       {
-                               $results['total_records'] = 0;
-                       }                               
-                       
-                       return $this->yui_results($results);
-               }
-               
-               public function query()
-               {
-                       $type_id = phpgw::get_var('type_id', 'int');
-                       $control_id = phpgw::get_var('control_id', 'int');
-                       $control_id_init = phpgw::get_var('control_id_init', 
'int');
-                       $control_area_id = phpgw::get_var('control_area_id', 
'int');
-
-                       $control_id = $control_id ? $control_id : 
$control_id_init;
-                       
-                       if($control_area_id && 
!execMethod('controller.socontrol.get_controls_by_control_area',$control_area_id))
-                       {
-                               $control_id = 0;
-                       }
-
-                       $control_info = 
execMethod('controller.socontrol.get_single', $control_id);
-                       $control_name = '';
-                       if($control_info)
-                       {
-                               $control_name = $control_info->get_title();
-                       }
-
-                       $view_type = phpgw::get_var('view_type');
-                       $return_results = phpgw::get_var('results', 'int', 
'REQUEST', 0);
-                       
-                       $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' => $return_results));
-
-                       foreach($location_list as &$location)
-                       {
-                               $location['control_name'] = $control_name;
-                               $location['location_registered'] = 
!!$this->so_control->get_control_location($control_id, 
$location['location_code']);
-                               $results['results'][]= $location;       
-                       }
-                       
-                       $results['total_records'] = $this->bo->total_records;
-                       $results['start'] = $this->start;
-                       $results['sort'] = 'location_code';
-                       $results['dir'] = "ASC";
-                                               
-                       array_walk($results['results'], array($this, 
'add_links'), array($type));
-                                                       
-                       return $this->yui_results($results);
-               }
-
-               public function register_control_to_location_2()
-               {
-                       $control_id = phpgw::get_var('control_id');
-                       $location_code = phpgw::get_var('location_code');
-                       
-                       $control_location  = null;
-                       $control_location_id = 0;
-                       
-                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code);
-                       
-                       if($control_location == null ){
-                               
-                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code);
-                       }
-                       
-                       if($control_location_id > 0)
-                               return json_encode( array( "status" => "saved" 
) );
-                       else
-                               return json_encode( array( "status" => 
"not_saved" ) );
-               }
-               
-               public function add_actions(&$value, $key, $params)
-               {
-                       unset($value['query_location']);
-                       
-                       $value['ajax'] = array();
-                       $value['actions'] = array();
-                       $value['labels'] = array();
-                       $value['parameters'] = array();
-               }
-               
-               /*
-                * Return categories based on chosen location
-                */
-               public function get_location_category()
-               {
-                       $type_id = phpgw::get_var('type_id');
-                       $category_types = 
$this->bocommon->select_category_list(array(
-                                                                               
                                                                
'format'=>'filter',
-                                                                               
                                                                'selected' => 0,
-                                                                               
                                                                'type' 
=>'location',
-                                                                               
                                                                'type_id' 
=>$type_id,
-                                                                               
                                                                'order'=>'descr'
-                                                                               
                                                        ));
-                       $default_value = array ('id'=>'','name'=>lang('no 
category selected'));
-                       array_unshift($category_types,$default_value);
-                       return json_encode( $category_types );
-               }
-               
-               /*
-                * Return parts of town based on chosen district
-                */
-               public function get_district_part_of_town()
-               {
-                       $district_id = phpgw::get_var('district_id');
-                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',null,$district_id);
-                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
-                       array_unshift($part_of_town_list,$default_value);
-
-                       return json_encode( $part_of_town_list );
-               }
-
-
-               /*
-
-                * Return parts of town based on chosen district
-                */
-               public function get_category_by_entity()
-               {
-                       $entity_id              = phpgw::get_var('entity_id');
-                       $entity                 = 
CreateObject('property.soadmin_entity');
-
-                       $category_list = 
$entity->read_category(array('allrows'=>true,'entity_id'=>$entity_id));
-
-                       return $category_list;
-               }
-
-
-               public function get_location_type_category()
-               {
-                       $location_type                  = 
phpgw::get_var('location_type', 'int');
-
-                       $values  = $this->bocommon->select_category_list(array
-                                       (
-                                               'format'=>'filter',
-                                       //      'selected' => $this->cat_id,
-                                               'type' =>'location',
-                                               'type_id' =>$location_type,
-                                               'order'=>'descr'
-                                       )
-                               );
-
-                       return $values;
-               }
-
-
-               public function get_entity_table_def()
-               {
-                       $entity_id                      = 
phpgw::get_var('entity_id', 'int');
-                       $cat_id                         = 
phpgw::get_var('cat_id', 'int');
-                       $boentity       = 
CreateObject('property.boentity',false, 'entity');
-                       $boentity->read(array('dry_run' => true));
-                       $uicols = $boentity->uicols;
-                       $columndef = array();
-
-                       $columndef[] = array
-                       (
-                               'key'           => 'select',
-                               'label'         => lang('select'),
-                               'sortable'      => false,
-                               'formatter'     => false,
-                               'hidden'        => false,
-                               'formatter' => '',
-                               'className' => ''
-                       );
-
-                       $columndef[] = array
-                       (
-                               'key'           => 'delete',
-                               'label'         => lang('delete'),
-                               'sortable'      => false,
-                               'formatter'     => false,
-                               'hidden'        => false,
-                               'formatter' => '',
-                               'className' => ''
-                       );
-
-                       $count_fields = count($uicols['name']);
-
-                       for ($i=0;$i<$count_fields;$i++)
-                       {
-                               if( $uicols['name'][$i])
-                               {
-                                       $columndef[] = array
-                                       (
-                                               'key'           => 
$uicols['name'][$i],
-                                               'label'         => 
$uicols['descr'][$i],
-                                               'sortable'      => 
$uicols['sortable'][$i],
-                                               'formatter'     => 
$uicols['formatter'][$i],
-                                               'hidden'        => 
$uicols['input_type'][$i] == 'hidden' ? true : false ,               
-                                               'className'     => 
$uicols['classname'][$i],
-                                       );
-                               }
-                       }
-
-//_debug_array($columndef);
-                       return $columndef;
-               }
-
-
-               public function get_locations()
-               {
-                       $location_code = phpgw::get_var('location_code');
-                       $child_level = phpgw::get_var('child_level', 'int', 
'REQUEST', 1);
-                       $part_of_town_id = phpgw::get_var('part_of_town_id', 
'int');
-
-                       $criteria = array
-                       (
-                               'location_code'         => $location_code,
-                               'child_level'           => $child_level,
-                               'field_name'            => 
"loc{$child_level}_name",
-                               'part_of_town_id'       => $part_of_town_id
-                       );
-       
-                       $locations = 
execMethod('property.solocation.get_children',$criteria);
-                       return $locations;
-               }
-
-       }

Modified: trunk/controller/inc/class.uicontrol_register_to_component.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_register_to_component.inc.php  
2012-10-17 10:50:39 UTC (rev 10251)
+++ trunk/controller/inc/class.uicontrol_register_to_component.inc.php  
2012-10-17 13:29:52 UTC (rev 10252)
@@ -59,11 +59,8 @@
                        'query'                                                 
        => true,
                        'edit_component'                                        
=> true,
                        'get_location_category'                         => true,
-                       'get_district_part_of_town'                     => true,
                        'get_category_by_entity'                        => true,
                        'get_entity_table_def'                          => true,
-                       'get_locations'                                         
=> true,
-                       'get_location_type_category'            => true
                );
 
                function __construct()
@@ -185,14 +182,14 @@
                                                                                
                                'part_of_town_list'             => 
array('options' => $part_of_town_list),
                                                                                
                                'location_type_list'    => array('options' => 
$location_type_list),
                                                                                
                        ),
-                               'update_action'                                 
=> self::link(array('menuaction' => 
'controller.uicontrol_location.edit_component'))
+                               'update_action'                                 
=> self::link(array('menuaction' => 
'controller.uicontrol_register_to_component.edit_component'))
                        );
 
                        phpgwapi_jquery::load_widget('core');
                        phpgwapi_jquery::load_widget('autocomplete');
 
                        self::add_javascript('controller', 'controller', 
'ajax_control_to_component.js');
-                       self::add_javascript('controller', 'yahoo', 
'register_control_to_component2.js');
+                       self::add_javascript('controller', 'yahoo', 
'register_control.js');
                        self::add_javascript('controller', 'yahoo', 
'datatable_light.js');
 
                        
self::render_template_xsl(array('control_location/register_control_to_component'
 ), $data);
@@ -217,20 +214,7 @@
                        return json_encode( $category_types );
                }
                
-               /*
-                * Return parts of town based on chosen district
-                */
-               public function get_district_part_of_town()
-               {
-                       $district_id = phpgw::get_var('district_id');
-                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',null,$district_id);
-                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
-                       array_unshift($part_of_town_list,$default_value);
 
-                       return json_encode( $part_of_town_list );
-               }
-
-
                /*
 
                 * Return parts of town based on chosen district
@@ -246,24 +230,6 @@
                }
 
 
-               public function get_location_type_category()
-               {
-                       $location_type                  = 
phpgw::get_var('location_type', 'int');
-
-                       $values  = $this->bocommon->select_category_list(array
-                                       (
-                                               'format'=>'filter',
-                                       //      'selected' => $this->cat_id,
-                                               'type' =>'location',
-                                               'type_id' =>$location_type,
-                                               'order'=>'descr'
-                                       )
-                               );
-
-                       return $values;
-               }
-
-
                public function get_entity_table_def()
                {
                        $entity_id                      = 
phpgw::get_var('entity_id', 'int');
@@ -318,26 +284,7 @@
                }
 
 
-               public function get_locations()
-               {
-                       $location_code = phpgw::get_var('location_code');
-                       $child_level = phpgw::get_var('child_level', 'int', 
'REQUEST', 1);
-                       $part_of_town_id = phpgw::get_var('part_of_town_id', 
'int');
 
-                       $criteria = array
-                       (
-                               'location_code'         => $location_code,
-                               'child_level'           => $child_level,
-                               'field_name'            => 
"loc{$child_level}_name",
-                               'part_of_town_id'       => $part_of_town_id
-                       );
-       
-                       $locations = 
execMethod('property.solocation.get_children',$criteria);
-                       return $locations;
-               }
-
-
-
                public function query()
                {
                        $entity_id                      = 
phpgw::get_var('entity_id', 'int');
@@ -360,17 +307,19 @@
                                $values = 
$boentity->read(array('control_registered' => $control_registered, 'control_id' 
=> $control_id));
                        }               
 
-                       foreach($values as &$entry)
+                       if($control_id)
                        {
-                               $checked = '';
-                               
if($this->so_control->check_control_component($control_id,$location_id,$entry['id']))
+                               foreach($values as &$entry)
                                {
-                                       $checked =  'checked = "checked" 
disabled = "disabled"';
-                                       $entry['delete'] = "<input class 
=\"mychecks_delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
+                                       $checked = '';
+                                       
if($this->so_control->check_control_component($control_id,$location_id,$entry['id']))
+                                       {
+                                               $checked =  'checked = 
"checked" disabled = "disabled"';
+                                               $entry['delete'] = "<input 
class =\"mychecks_delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
+                                       }
+                                       $entry['select'] = "<input class 
=\"mychecks_add\" type =\"checkbox\" $checked 
name=\"values[register_component][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
                                }
-                               $entry['select'] = "<input class 
=\"mychecks_add\" type =\"checkbox\" $checked 
name=\"values[register_component][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
                        }
-
                        
                        $results = $results ? $results : 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
                        $return_data['recordsReturned'] = count($values);
@@ -429,7 +378,7 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 
'controller.uicontrol_location.register_control_to_component'));
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_register_to_component.index'));
                        }
                }
        }

Added: trunk/controller/inc/class.uicontrol_register_to_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_register_to_location.inc.php           
                (rev 0)
+++ trunk/controller/inc/class.uicontrol_register_to_location.inc.php   
2012-10-17 13:29:52 UTC (rev 10252)
@@ -0,0 +1,441 @@
+<?php
+       /**
+       * phpGroupWare - controller: a part of a Facilities Management System.
+       *
+       * @author Erink Holm-Larsen <address@hidden>
+       * @author Torstein Vadla <address@hidden>
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare is free software; you can redistribute it and/or modify
+       * it under the terms of the GNU General Public License as published by
+       * the Free Software Foundation; either version 2 of the License, or
+       * (at your option) any later version.
+       *
+       * phpGroupWare is distributed in the hope that it will be useful,
+       * but WITHOUT ANY WARRANTY; without even the implied warranty of
+       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       * GNU General Public License for more details.
+       *
+       * You should have received a copy of the GNU General Public License
+       * along with phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+       * @package property
+       * @subpackage controller
+       * @version $Id: class.uicheck_list.inc.php 8628 2012-01-21 10:42:05Z 
vator $
+       */
+       
+       phpgw::import_class('phpgwapi.yui');
+
+       /**
+       * Import the jQuery class
+       */
+       phpgw::import_class('phpgwapi.jquery');
+
+       phpgw::import_class('phpgwapi.uicommon');
+               
+       class controller_uicontrol_register_to_location extends 
phpgwapi_uicommon
+       {
+               var $cat_id;
+               var $start;
+               var $query;
+               var $sort;
+               var $order;
+               var $filter;
+               var $type_id;
+               var $location_code;
+               
+               private $bo;
+               private $bocommon;
+               private $so_control;
+       
+               var $public_functions = array
+               (
+                       'index'                                                 
        => true,
+                       'query'                                                 
        => true,
+                       'edit_location'                                         
=> true,
+                       'get_location_category'                         => true,
+                       'get_district_part_of_town'                     => true,
+                       'get_category_by_entity'                        => true,
+                       'get_entity_table_def'                          => true,
+                       'get_locations'                                         
=> true,
+                       'get_location_type_category'            => true
+               );
+
+               function __construct()
+               {
+                       parent::__construct();
+                       
+                       $this->bo                                       = 
CreateObject('property.bolocation',true);
+                       $this->bocommon                         = & 
$this->bo->bocommon;
+                       $this->so_control                       = 
CreateObject('controller.socontrol');
+                       
+                       $this->type_id                          = 
$this->bo->type_id;
+                       
+                       $this->start                            = 
$this->bo->start;
+                       $this->query                            = 
$this->bo->query;
+                       $this->sort                                     = 
$this->bo->sort;
+                       $this->order                            = 
$this->bo->order;
+                       $this->filter                           = 
$this->bo->filter;
+                       $this->cat_id                           = 
$this->bo->cat_id;
+                       $this->part_of_town_id          = 
$this->bo->part_of_town_id;
+                       $this->district_id                      = 
$this->bo->district_id;
+                       $this->status                           = 
$this->bo->status;
+                       $this->allrows                          = 
$this->bo->allrows;
+                       $this->lookup                           = 
$this->bo->lookup;
+                       $this->location_code            = 
$this->bo->location_code;
+                       
+                       
self::set_active_menu('controller::control::location_for_check_list');
+               }       
+       
+
+
+               function index()
+               {
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+                       $receipt = array();
+
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
+
+                       $msgbox_data = array();
+                       if( phpgw::get_var('phpgw_return_as') != 'json' && 
$receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                       {
+                               phpgwapi_cache::session_clear('phpgwapi', 
'phpgw_messages');
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                       }
+
+                       $myColumnDefs = array();
+                       $datavalues = array();
+                       $myButtons      = array();
+
+                       $datavalues[] = array
+                       (
+                               'name'                          => "0",
+                               'values'                        => 
json_encode(array()),
+                               'total_records'         => 0,
+                               'permission'            => "''",
+                               'is_paginator'          => 1,
+                               'edit_action'           => "''",
+                               'footer'                        => 0
+                       );
+
+                       $myColumnDefs[0] = array
+                       (
+                               'name'          => "0",
+                               'values'        =>      json_encode(array())
+                       );      
+
+                       $GLOBALS['phpgw']->translation->add_app('property');
+
+                       $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
+
+                       $part_of_town_list = 
execMethod('property.bogeneric.get_list', array('type'=>'part_of_town', 
'selected' => $part_of_town_id ));
+                       $location_type_list = 
execMethod('property.soadmin_location.select_location_type');
+
+                       array_unshift($district_list ,array 
('id'=>'','name'=>lang('select')));
+                       array_unshift($part_of_town_list ,array 
('id'=>'','name'=>lang('select')));
+                       array_unshift($location_type_list ,array 
('id'=>'','name'=>lang('select')));
+
+                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
+                       $cats->supress_info     = true;
+
+                       $control_area = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
+
+                                                               
+                       $control_area_list = array();
+                       foreach($control_area['cat_list'] as $cat_list)
+                       {
+                               $control_area_list[] = array
+                               (
+                                       'id'    => $cat_list['cat_id'],
+                                       'name'  => $cat_list['name'],
+                               );              
+                       }
+
+                       array_unshift ($control_area_list ,array 
('id'=>'','name'=>lang('select')));
+
+                       
+                                       
+                       $data = array
+                       (
+                               'td_count'                                      
        => '""',
+                               'datatable'                                     
        => $datavalues,
+                               'myColumnDefs'                                  
=> $myColumnDefs,
+                               'myButtons'                                     
        => $myButtons,
+
+                               'msgbox_data'                                   
=> $msgbox_data,
+                               'control_area_list'             => 
array('options' => $control_area_list),
+                               'filter_form'                                   
=> array
+                                                                               
                        (
+                                                                               
                                'control_area_list'             => 
array('options' => $control_area_list),
+                                                                               
                                'district_list'                 => 
array('options' => $district_list),
+                                                                               
                                'part_of_town_list'             => 
array('options' => $part_of_town_list),
+                                                                               
                                'location_type_list'    => array('options' => 
$location_type_list),
+                                                                               
                        ),
+                               'update_action'                                 
=> self::link(array('menuaction' => 
'controller.uicontrol_register_to_location.edit_location'))
+                       );
+
+                       phpgwapi_jquery::load_widget('core');
+                       phpgwapi_jquery::load_widget('autocomplete');
+
+                       self::add_javascript('controller', 'controller', 
'ajax_control_to_location.js');
+                       self::add_javascript('controller', 'yahoo', 
'register_control.js');
+                       self::add_javascript('controller', 'yahoo', 
'datatable_light.js');
+
+                       
self::render_template_xsl(array('control_location/register_control_to_location' 
), $data);
+               }
+
+               
+               /*
+                * Return categories based on chosen location
+                */
+               public function get_location_category()
+               {
+                       $type_id = phpgw::get_var('type_id');
+                       $category_types = 
$this->bocommon->select_category_list(array(
+                                                                               
                                                                
'format'=>'filter',
+                                                                               
                                                                'selected' => 0,
+                                                                               
                                                                'type' 
=>'location',
+                                                                               
                                                                'type_id' 
=>$type_id,
+                                                                               
                                                                'order'=>'descr'
+                                                                               
                                                        ));
+                       $default_value = array ('id'=>'','name'=>lang('no 
category selected'));
+                       array_unshift($category_types,$default_value);
+                       return json_encode( $category_types );
+               }
+               
+               /*
+                * Return parts of town based on chosen district
+                */
+               public function get_district_part_of_town()
+               {
+                       $district_id = phpgw::get_var('district_id');
+                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',null,$district_id);
+                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
+                       array_unshift($part_of_town_list,$default_value);
+
+                       return json_encode( $part_of_town_list );
+               }
+
+
+               /*
+
+                * Return parts of town based on chosen district
+                */
+               public function get_category_by_entity()
+               {
+                       $entity_id              = phpgw::get_var('entity_id');
+                       $entity                 = 
CreateObject('property.soadmin_entity');
+
+                       $category_list = 
$entity->read_category(array('allrows'=>true,'entity_id'=>$entity_id));
+
+                       return $category_list;
+               }
+
+
+               public function get_location_type_category()
+               {
+                       $location_type                  = 
phpgw::get_var('location_type', 'int');
+
+                       $values  = $this->bocommon->select_category_list(array
+                                       (
+                                               'format'=>'filter',
+                                       //      'selected' => $this->cat_id,
+                                               'type' =>'location',
+                                               'type_id' =>$location_type,
+                                               'order'=>'descr'
+                                       )
+                               );
+
+                       return $values;
+               }
+
+
+               public function get_entity_table_def()
+               {
+
+                       $location_level         = 
phpgw::get_var('location_level', 'int', 'REQUEST', 1);
+                       $solocation     = CreateObject('property.solocation');
+                       $solocation->read(array('dry_run' => true, 'type_id' 
=>$location_level));
+                       $uicols = $solocation->uicols;
+
+                       $columndef = array();
+
+                       /*This one has to defined - chokes otherwise*/
+                       $columndef[] = array
+                       (
+                               'key'           => 'id',
+                               'label'         => '',
+                               'sortable'      => false,
+                               'formatter'     => false,
+                               'hidden'        => true,
+                               'className' => false
+                       );
+
+                       $columndef[] = array
+                       (
+                               'key'           => 'select',
+                               'label'         => lang('select'),
+                               'sortable'      => false,
+                               'formatter'     => false,
+                               'hidden'        => false,
+                               'className' => ''
+                       );
+
+                       $columndef[] = array
+                       (
+                               'key'           => 'delete',
+                               'label'         => lang('delete'),
+                               'sortable'      => false,
+                               'formatter'     => false,
+                               'hidden'        => false,
+                               'className' => ''
+                       );
+
+
+                       $count_fields = count($uicols['name']);
+
+                       for ($i=0;$i<$count_fields;$i++)
+                       {
+                               if( $uicols['name'][$i])
+                               {
+                                       $columndef[] = array
+                                       (
+                                               'key'           => 
$uicols['name'][$i],
+                                               'label'         => 
$uicols['descr'][$i],
+                                               'sortable'      => 
$uicols['sortable'][$i],
+                                               'formatter'     => 
$uicols['formatter'][$i],
+                                               'hidden'        => 
$uicols['input_type'][$i] == 'hidden' ? true : false ,               
+                                               'className'     => 
$uicols['classname'][$i],
+                                       );
+                               }
+                       }
+
+
+//_debug_array($columndef);
+                       return $columndef;
+               }
+
+
+               public function get_locations()
+               {
+                       $location_code = phpgw::get_var('location_code');
+                       $child_level = phpgw::get_var('child_level', 'int', 
'REQUEST', 1);
+                       $part_of_town_id = phpgw::get_var('part_of_town_id', 
'int');
+
+                       $criteria = array
+                       (
+                               'location_code'         => $location_code,
+                               'child_level'           => $child_level,
+                               'field_name'            => 
"loc{$child_level}_name",
+                               'part_of_town_id'       => $part_of_town_id
+                       );
+       
+                       $locations = 
execMethod('property.solocation.get_children',$criteria);
+                       return $locations;
+               }
+
+
+               public function query()
+               {
+                       $type_id = phpgw::get_var('location_level', 'int', 
'REQUEST', 1);
+                       $district_id            = phpgw::get_var('district_id', 
'int');
+                       $part_of_town_id        = 
phpgw::get_var('part_of_town_id', 'int');
+                       $control_id                     = 
phpgw::get_var('control_id', 'int');
+                       $results                        = 
phpgw::get_var('results', 'int');
+                       $control_registered     = 
phpgw::get_var('control_registered', 'bool');
+
+                       $this->bo->results = $results;                  
+
+                       $values = $this->bo->read(array('control_registered' => 
$control_registered,
+                                        'control_id' => $control_id,
+                                        'type_id'=>$type_id,
+                                        'allrows'=>$this->allrows,
+                                        'results' => $results
+                                       )
+                               );
+
+
+                       if($control_id)
+                       {
+                               foreach($values as &$entry)
+                               {
+                                       $checked = '';
+                                       if( 
$this->so_control->get_control_location($control_id, $entry['location_code']) )
+                                       {
+                                               $checked =  'checked = 
"checked" disabled = "disabled"';
+                                               $entry['delete'] = "<input 
class =\"mychecks_delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$control_id}_{$entry['location_code']}\">";
+                                       }
+                                       $entry['select'] = "<input class 
=\"mychecks_add\" type =\"checkbox\" $checked 
name=\"values[register_location][]\" 
value=\"{$control_id}_{$entry['location_code']}\">";
+                               }
+                       }
+                       
+                       $results = $results ? $results : 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $return_data['recordsReturned'] = count($values);
+                       $return_data['totalRecords'] = $this->bo->total_records;
+                       $return_data['startIndex'] = $this->bo->start;
+                       $return_data['sort'] = 'location_code';
+                       $return_data['dir'] = "ASC";
+                       $return_data['pageSize'] = $results;
+                       $return_data['activePage'] = floor($this->bo->start / 
$results) + 1;
+                       $return_data['records'] = $values;
+
+                       return $return_data;
+               }
+
+               public function edit_location()
+               {
+                       if($values = phpgw::get_var('values'))
+                       {
+                               if(!$GLOBALS['phpgw']->acl->check('.admin', 
PHPGW_ACL_EDIT, 'property'))
+                               {
+                                       $receipt['error'][]=true;
+                                       phpgwapi_cache::message_set(lang('you 
are not approved for this task'), 'error');
+                               }
+                               if(!$receipt['error'])
+                               {
+
+                                       
if($this->so_control->register_control_to_location($values))
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'updated'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'error'
+                                               );
+                                       }
+                               }
+                       }
+
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               if( $receipt = 
phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                               {
+                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                       $result['receipt'] = $receipt;
+                               }
+                               else
+                               {
+                                       $result['receipt'] = array();
+                               }
+                               return $result;
+                       }
+                       else
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_register_to_location.index'));
+                       }
+               }
+       }

Modified: trunk/controller/js/controller/ajax.js
===================================================================
--- trunk/controller/js/controller/ajax.js      2012-10-17 10:50:39 UTC (rev 
10251)
+++ trunk/controller/js/controller/ajax.js      2012-10-17 13:29:52 UTC (rev 
10252)
@@ -54,7 +54,7 @@
        // Update location category based on location type
        $("#type_id").change(function () {
                 var location_type_id = $(this).val();
-                var oArgs = 
{menuaction:'controller.uicontrol_location.get_location_category'};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_location_category'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
          
          var htmlString = "";
@@ -165,7 +165,7 @@
        //update part of town category based on district
        $("#district_id").change(function () {
                var district_id = $(this).val();
-                var oArgs = 
{menuaction:'controller.uicontrol_location.get_district_part_of_town'};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_district_part_of_town'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
          //var requestUrl = 
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
          

Modified: trunk/controller/js/controller/ajax_control_to_component.js
===================================================================
--- trunk/controller/js/controller/ajax_control_to_component.js 2012-10-17 
10:50:39 UTC (rev 10251)
+++ trunk/controller/js/controller/ajax_control_to_component.js 2012-10-17 
13:29:52 UTC (rev 10252)
@@ -88,10 +88,10 @@
 
 
        $("#location_type").change(function () {
-                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_location_type_category',
 location_type: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_location_type_category',
 location_type: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
-         var htmlString = "";
+         var htmlString  = "<option value=''>Velg</option>";
 
          $.ajax({
                        type: 'POST',
@@ -167,7 +167,7 @@
        //update part of town category based on district
        $("#district_id").change(function () {
                var district_id = $(this).val();
-                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_district_part_of_town'};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_district_part_of_town'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString = "";
@@ -207,7 +207,7 @@
 
        $("#part_of_town_id").change(function ()
        {
-                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_locations', 
child_level:1, part_of_town_id: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_locations', 
child_level:1, part_of_town_id: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString  = "<option value=''>Velg</option>";
@@ -244,7 +244,7 @@
 
        $("#loc1").change(function ()
        {
-                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_locations', 
child_level:2, location_code: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_locations', 
child_level:2, location_code: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString  = "<option value=''>Velg</option>";

Added: trunk/controller/js/controller/ajax_control_to_location.js
===================================================================
--- trunk/controller/js/controller/ajax_control_to_location.js                  
        (rev 0)
+++ trunk/controller/js/controller/ajax_control_to_location.js  2012-10-17 
13:29:52 UTC (rev 10252)
@@ -0,0 +1,519 @@
+$(document).ready(function()
+{
+
+       $("#control_area_id").change(function () {
+               var control_area_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol.get_controls_by_control_area'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+       //      $("#hidden_control_area_id").val( control_area_id );
+    //     var control_id_init = $("#hidden_control_id").val();
+         var htmlString = "";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl + "&control_area_id=" + control_area_id,
+                       success: function(data) {
+                               if( data != null){
+                                       htmlString  = "<option>Velg 
kontroll</option>"
+                                       var obj = jQuery.parseJSON(data);
+
+                                       $.each(obj, function(i) {
+
+                                               var selected = '';
+/*
+                                               if(obj[i].id == control_id_init)
+                                               {
+                                                       selected = ' selected';
+                                               }
+*/
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].title + "</option>";
+                                       });
+                                        
+                                       $("#control_id").html( htmlString );
+                                       }
+                                       else
+                                       {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#control_id").html( htmlString );
+//                                             
$("#hidden_control_id").val(-1); //reset
+                               }
+                       }
+                       });
+
+    });
+
+
+       $("#location_type").change(function () {
+
+               get_table_def();
+
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_location_type_category',
 location_type: $(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+                                       });
+                                        
+                                       $("#location_type_category").html( 
htmlString );
+                               $("#loc1").html( "<option 
value=''>Velg</option>" );
+                               $("#loc2").html( "<option 
value=''>Velg</option>" );
+                               }
+                               else
+                               {
+                               htmlString  += "<option value=''>Velg</option>";
+                               $("#part_of_town_id").html( htmlString );
+                               $("#loc1").html( htmlString );
+                               $("#loc2").html( htmlString );
+                       }
+                       }
+         });
+    });
+
+       $("#location_type_category").change(function () {
+               var level = $("#location_type").val();
+               update_loc(level);
+    });
+
+       var oArgs = {menuaction:'property.bolocation.get_locations_by_name'};
+       var baseUrl = phpGWLink('index.php', oArgs, true);
+
+       $("#search-location-name").autocomplete({
+               source: function( request, response ) {
+                       location_type = $("#location_type").val();
+                       $.ajax({
+                               url: baseUrl,
+                               dataType: "json",
+                               data: {
+                                       location_name: request.term,
+                                       level: location_type
+                               },
+                               success: function( data ) {
+                                       response( $.map( data, function( item ) 
{
+                                               return {
+                                                       label: item.name,
+                                                       value: 
item.location_code
+                                               }
+                                       }));
+                               }
+                       });
+               },
+               focus: function (event, ui) {
+                       $(event.target).val(ui.item.label);
+                       return false;
+               },
+               minLength: 1,
+               select: function( event, ui ) {
+//                     console.log(ui.item);
+//                     $("#search-location-name").val( ui.item.label );
+                       $("#search-location_code").val( ui.item.value );
+                       update_location_table();
+               }
+       });
+
+
+       //update part of town category based on district
+       $("#district_id").change(function () {
+               var district_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_district_part_of_town'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString = "";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl + "&district_id=" + district_id,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = jQuery.parseJSON(data);
+
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+                                       });
+                                        
+                                       $("#part_of_town_id").html( htmlString 
);
+                               $("#loc1").html( "<option 
value=''>Velg</option>" );
+                               $("#loc2").html( "<option 
value=''>Velg</option>" );
+                               }
+                               else
+                               {
+                               htmlString  += "<option value=''>Velg</option>";
+                               $("#part_of_town_id").html( htmlString );
+                               $("#loc1").html( htmlString );
+                               $("#loc2").html( htmlString );
+                       }
+                       }
+         });
+
+               $("#search-location_code").val('');
+               update_location_table();
+    });
+
+
+       $("#part_of_town_id").change(function ()
+       {
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_locations', 
child_level:1, part_of_town_id: $(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" +  obj[i].id + " " + obj[i].name + "</option>";
+                                       });
+                                        
+                                       $("#loc1").html( htmlString );
+                               $("#loc2").html( "<option 
value=''>Velg</option>" );
+                                       }
+                                       else
+                                       {
+                                       htmlString  = "<option>Ingen</option>";
+                                       $("#loc1").html( htmlString );
+                                       $("#loc2").html(htmlString);
+                               }
+                       }
+         });
+
+               $("#search-location_code").val('');
+               update_location_table();
+    });
+
+       $("#loc1").change(function ()
+       {
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_locations', 
child_level:2, location_code: $(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" +  obj[i].id + " " + obj[i].name + "</option>";
+                                       });
+                                        
+                                       $("#loc2").html( htmlString );
+                                       }
+                                       else
+                                       {
+                                       htmlString  = "<option>Ingen</option>";
+                                       $("#loc2").html( htmlString );
+                               }
+                       }
+         });
+
+               $("#search-location_code").val('');
+               update_location_table();
+
+    });
+
+
+       $("#control_registered").change(function ()
+       {
+               init_component_table();
+    });
+
+       $("#control_id").change(function ()
+       {
+               $("#control_id_hidden").val( $(this).val() );
+
+               init_component_table();
+    });
+
+       $("#loc2").change(function ()
+       {
+               $("#search-location_code").val('');
+               update_location_table();
+    });
+
+
+
+       $("#search").click(function(e)
+       {
+               update_location_table();
+    });
+
+
+       $("#acl_form").live("submit", function(e){
+               e.preventDefault();
+               var control_id = $("#control_id_hidden").val();
+
+               if(!control_id || control_id == null)
+               {
+                       alert('du må velge kontroll');
+                       return;
+               }
+
+               var thisForm = $(this);
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               var requestUrl = $(thisForm).attr("action");
+               $.ajax({
+                       type: 'POST',
+                       url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
+                       success: function(data) {
+                               if(data)
+                               {
+                                       if(data.sessionExpired)
+                                       {
+                                               alert('Sesjonen er utløpt - du 
må logge inn på nytt');
+                                               return;
+                                       }
+
+                               var obj = data;
+                 
+                               var submitBnt = 
$(thisForm).find("input[type='submit']");
+                               if(obj.status == "updated")
+                               {
+                                       $(submitBnt).val("Lagret");
+
+                                               
YAHOO.portico.update_datatable();
+                               }
+                               else
+                               {
+                                       $(submitBnt).val("Feil ved lagring");
+                               }
+                 
+                               // Changes text on save button back to original
+                               window.setTimeout(function() {
+                                               $(submitBnt).val('Lagre');
+                                               
$(submitBnt).addClass("not_active");
+                               }, 1000);
+
+                                       var htmlString = "";
+                                       if(typeof(data['receipt']['error']) != 
'undefined')
+                                       {
+                                               for ( var i = 0; i < 
data['receipt']['error'].length; ++i )
+                                               {
+                                                       htmlString += "<div 
class=\"error\">";
+                                                       htmlString += 
data['receipt']['error'][i]['msg'];
+                                                       htmlString += '</div>';
+                                               }
+        
+                                       }
+                                       if(typeof(data['receipt']['message']) 
!= 'undefined')
+                                       {
+                                               for ( var i = 0; i < 
data['receipt']['message'].length; ++i )
+                                               {
+                                                       htmlString += "<div 
class=\"msg_good\">";
+                                                       htmlString += 
data['receipt']['message'][i]['msg'];
+                                                       htmlString += '</div>';
+                                               }
+        
+                                       }
+                                       $("#receipt").html(htmlString);
+                               }
+                       }
+               });
+       });
+});
+
+
+function update_loc(level)
+{
+       var oArgs = {
+               menuaction:'property.bolocation.read',
+               cat_id:$("#location_type_category").val(),
+               district_id:$("#district_id").val(),
+               part_of_town_id:$("#part_of_town_id").val(),
+               location_code:$("#loc1").val(),
+               type_id:level
+       };
+
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].location_code + "'>" +  obj[i].location_code + " " + 
obj[i]["loc"+level+"_name"] + "</option>";
+                                       });
+                                        
+                                       $("#loc" + level).html( htmlString );
+                                       if(level == 1)
+                                       {
+                                       $("#loc2").html( "<option value=''>Velg 
Eiendom først</option>" );
+                               }
+                                       if(level == 2)
+                                       {
+                                       $("#loc1").html( "" );
+                               }
+                               }
+                               else
+                               {
+                               htmlString  = "<option>Ingen</option>";
+                               $("#loc1").html( htmlString );
+                               $("#loc2").html(htmlString);
+                       }
+                       }
+         });
+
+
+
+}
+
+function get_table_def()
+{
+       var oArgs = {
+               
menuaction:'controller.uicontrol_register_to_location.get_entity_table_def',
+               location_level:$("#location_type").val()
+       };
+
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+       $.ajax({
+               type: 'POST',
+               dataType: 'json',
+               url: requestUrl,
+               success: function(data) {
+                       if( data != null)
+                       {
+                               myColumnDefs = data;
+                               init_component_table();
+                       }
+                       else
+                       {
+                               alert('error');
+                       }
+               }
+       });
+
+}
+
+
+function init_component_table()
+{
+       var location_type = $("#location_type").val() != null ? 
$("#location_type").val():'';
+
+       if(!location_type)
+       {
+               return false;
+       }
+
+
+       var control_registered = 0;
+       if (typeof($($("#control_registered")).attr("checked")) != 'undefined' 
&& $($("#control_registered")).attr("checked") == 'checked')
+       {
+               control_registered = 1;
+       }
+
+
+       var location_code = '';
+
+       if( $("#search-location_code").val() != null && 
$("#search-location_code").val())
+       {
+               location_code = $("#search-location_code").val();
+       }
+       else if( $("#loc2").val() != null && $("#loc2").val())
+       {
+               location_code = $("#loc2").val();
+       }
+       else if ( $("#loc1").val() != null && $("#loc1").val())
+       {
+               location_code = $("#loc1").val();
+       }
+
+       var oArgs = {
+               menuaction:'controller.uicontrol_register_to_location.query',
+               location_level:location_type,
+               district_id:$("#district_id").val(),
+               part_of_town_id:$("#part_of_town_id").val(),
+               location_code:location_code,
+               control_id:$("#control_id_hidden").val() != null ? 
$("#control_id_hidden").val():'',
+               control_registered:control_registered
+       };
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+
+       YAHOO.portico.init_datatable(myColumnDefs,requestUrl);
+}
+
+
+function update_location_table()
+{
+
+       var control_registered = 0;
+       if (typeof($($("#control_registered")).attr("checked")) != 'undefined' 
&& $($("#control_registered")).attr("checked") == 'checked')
+       {
+               control_registered = 1;
+       }
+
+       var location_type = $("#location_type").val() != null ? 
$("#location_type").val():'';
+
+       if(!location_type)
+       {
+               return false;
+       }
+
+       if($("#control_id_hidden").val() != null)
+       {
+               var location_code = '';
+
+               if( $("#search-location_code").val() != null && 
$("#search-location_code").val())
+               {
+                       location_code = $("#search-location_code").val();
+               }
+               else if( $("#loc2").val() != null && $("#loc2").val())
+               {
+                       location_code = $("#loc2").val();
+               }
+               else if ( $("#loc1").val() != null && $("#loc1").val())
+               {
+                       location_code = $("#loc1").val();
+               }
+
+               var oArgs = {
+                       
menuaction:'controller.uicontrol_register_to_location.query',
+                       location_level:location_type,
+                       district_id:$("#district_id").val(),
+                       part_of_town_id:$("#part_of_town_id").val(),
+                       location_code:location_code,
+                       control_id:$("#control_id_hidden").val() != null ? 
$("#control_id_hidden").val():'',
+                       control_registered:control_registered
+               };
+
+               var requestUrl = phpGWLink('index.php', oArgs, true);
+
+               YAHOO.portico.update_datatable(requestUrl);
+       }
+//     $("#receipt").html('');
+}
+

Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang        2012-10-17 10:50:39 UTC (rev 
10251)
+++ trunk/controller/setup/phpgw_no.lang        2012-10-17 13:29:52 UTC (rev 
10252)
@@ -347,6 +347,7 @@
 repeat_type_year       controller      no      År
 components for control controller      no      Komponenter tilknyttet kontroll
 add components for control     controller      no      Legg til knytning 
mellom kontroll og komponent(er)
+locations for control  controller      no      Lokasjoner tilknyttet kontroll
 location category      controller      no      Lokaliseringskategori
 select add     controller      no      Velg for å legge til
 select delete  controller      no      Velg for sletting

Modified: 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
===================================================================
--- 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
   2012-10-17 10:50:39 UTC (rev 10251)
+++ 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
   2012-10-17 13:29:52 UTC (rev 10252)
@@ -1,4 +1,5 @@
 <!-- $Id$ -->
+
 <func:function name="phpgw:conditional">
        <xsl:param name="test"/>
        <xsl:param name="true"/>
@@ -16,201 +17,177 @@
        </func:result>
 </func:function>
 
-<xsl:template name="register_control_to_location" 
xmlns:php="http://php.net/xsl";>
-       <!-- IMPORTANT!!! Loads YUI javascript -->
-       <xsl:call-template name="common"/>
+<!-- separate tabs and  inline tables-->
 
-       <div class="content-wrp">
-               <div>
-                       <xsl:call-template name="yui_phpgw_i18n"/>
-                       <xsl:call-template name="control_filters" />
-                       <xsl:apply-templates select="filter_form" />
-                       <xsl:apply-templates select="paging"/>
-                       <xsl:apply-templates select="datatable"/>
-                       <xsl:apply-templates select="form/list_actions"/>
-               </div>
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+       <xsl:call-template name="yui_phpgw_i18n"/>
+       
+<div class="yui-navset yui-navset-top" id="control_location_tabview">
+       <div class="identifier-header">
+               <h1><xsl:value-of select="php:function('lang', 'locations for 
control')"/></h1>
        </div>
+       <xsl:value-of disable-output-escaping="yes" select="tabs" />
+       <xsl:call-template name="register_control_to_component" />
+</div>
 </xsl:template>
 
-<xsl:template name="control_filters" xmlns:php="http://php.net/xsl";>
-       
-       <div id="choose_control">
-               <!-- 
-                       When control area is chosen, an ajax request is 
executed. 
-                       The operation fetches controls from db and populates 
the control list.
-                       The ajax opearation is handled in ajax.js 
-               -->
-                <div class="error_msg">Du må velge kontroll før du kan legge 
til bygg</div>
-                <h4>Velg kontroll</h4> 
-                <select id="control_area_list" name="control_area_list">
-                  <option value="">Velg kontrollområde</option>
-                        <xsl:for-each select="control_areas_array">
-                                 <option value="{id}">
-                                   <xsl:if test="id = 
//current_control_area_id">
-                                     <xsl:attribute 
name="selected">selected</xsl:attribute>
-                                   </xsl:if>
-                                   <xsl:value-of select="name"/>
-                                 </option>
-                         </xsl:for-each>
-                 </select>
-                 
-                <form id="loc_form" action="" method="GET">
-                       <select id="control_id" name="control_id">
-                               <xsl:choose>
-                                       <xsl:when 
test="controls_array/child::node()">
-                                               <xsl:for-each 
select="controls_array">
-                                                       <xsl:variable 
name="control_id"><xsl:value-of select="id"/></xsl:variable>
-                                                       <option 
value="{$control_id}">
-                                                         <xsl:if 
test="control_id = //current_control_id">
-                                         <xsl:attribute 
name="selected">selected</xsl:attribute>
-                                       </xsl:if>
-                                                               <xsl:value-of 
select="title"/>
-                                                       </option>               
                
-                                               </xsl:for-each>
-                                       </xsl:when>
-                                       <xsl:otherwise>
-                                               <option>
-                                                       Ingen kontroller
-                                               </option>
-                                       </xsl:otherwise>
-                               </xsl:choose>
-                       </select>
-               </form>
+<xsl:template name="register_control_to_component" 
xmlns:php="http://php.net/xsl";>
+       <div class="content-wrp">
+               <div id="invoice-layout">
+                               <div class="header">
+                                       <h2><xsl:value-of 
select="php:function('lang', 'invoice')"/></h2>
+                               </div>
+                       <xsl:choose>
+                               <xsl:when test="msgbox_data != ''">
+                                       <xsl:call-template name="msgbox"/>
+                               </xsl:when>
+                       </xsl:choose>
+                               <div class="body">
+                                                       
+                               <style type="text/css">
+                                       
+                                       </style>
+                                       <div id="choose_control">
+                                               <h4>Velg kontroll</h4>
+                                               <select id="control_area_id" 
name="control_area_id">
+                                                       <xsl:apply-templates 
select="control_area_list/options"/>
+                                               </select>                
+                                               <select id="control_id" 
name="control_id">
+                                                       <xsl:apply-templates 
select="control/options"/>
+                                               </select>
+                                       </div>
+                               
+                                       <div id="choose-location">
+                                                       <xsl:apply-templates 
select="filter_form" />
+                                       
+                                               <form action="{update_action}" 
name="acl_form" id="acl_form" method="post">
+                                                                       
<xsl:apply-templates select="datatable"/>
+                                               </form>
+                                       </div>
+                               </div>
+               </div>
        </div>
 </xsl:template>
 
 <xsl:template match="filter_form" xmlns:php="http://php.net/xsl";>
-
-       <form id="queryForm">
-               <xsl:attribute name="method">
-                       <xsl:value-of select="phpgw:conditional(not(method), 
'GET', method)"/>
-               </xsl:attribute>
-
-               <xsl:attribute name="action">
-                       <xsl:value-of select="phpgw:conditional(not(action), 
'', action)"/>
-               </xsl:attribute>
                <xsl:call-template name="filter_list"/>
-       </form>
-       
-       <form id="update_table_dummy" method='POST' action='' ></form>
-
 </xsl:template>
 
 <xsl:template name="filter_list" xmlns:php="http://php.net/xsl";>
-       <div id="choose-location">
-               <h4>Velg bygg/eiendom</h4>
-         <ul id="filters">
-               <li>
-                       <input type="hidden" id="hidden_control_id" 
name="control_id">
-                               <xsl:attribute name="value">
-                                       <xsl:value-of 
select="//current_control_id"/>
-                               </xsl:attribute>
-                       </input>
-
-                       <input type="hidden" id="hidden_control_area_id" 
name="control_area_id">
-                       </input>
-               
-                 <select id="type_id" name="type_id">
-                       <xsl:for-each select="building_types">
-                               <xsl:variable 
name="building_type_id"><xsl:value-of select="id"/></xsl:variable>
-                               <option value="{$building_type_id}">
-                                       <xsl:value-of select="name"/>
-                               </option>
-                       </xsl:for-each>
-                 </select>
-               </li>
-               <li>
-                 <select id="cat_id" name="cat_id">
-                       <xsl:for-each select="category_types">
-                               <xsl:variable 
name="category_type_id"><xsl:value-of select="id"/></xsl:variable>
-                               <option value="{$category_type_id}">
-                                       <xsl:value-of select="name"/>
-                               </option>
-                       </xsl:for-each>
-                 </select>
-               </li>
-               <li>
-                 <select id="district_id" name="district_id">
-                       <xsl:for-each select="district_list">
-                               <xsl:variable name="district_id"><xsl:value-of 
select="id"/></xsl:variable>
-                               <option value="{$district_id}">
-                                       <xsl:value-of select="name"/>
-                               </option>
-                       </xsl:for-each>
-                 </select>
-               </li>
-               <li>
-                 <select id="part_of_town_id" name="part_of_town_id">
-                       <xsl:for-each select="part_of_town_list">
-                               <xsl:variable 
name="part_of_town_id"><xsl:value-of select="id"/></xsl:variable>
-                               <option value="{$part_of_town_id}">
-                                       <xsl:value-of select="name"/>
-                               </option>
-                       </xsl:for-each>
-                 </select>
-               </li>           
-         </ul>
-         <ul id="search_list">
-                 <li>
-                       <input type="text" name="query" />
-                 </li>
-                 <li>
-                       <xsl:variable name="lang_search"><xsl:value-of 
select="php:function('lang', 'Search')" /></xsl:variable>
-                       <input type="submit" name="search" 
value="{$lang_search}" title = "{$lang_search}" />
-                 </li>                 
-         </ul>
-       </div>
+       <h4>Velg lokasjoner som du vil knytte til kontrollen</h4>
+       <fieldset id="comp-filters">
+               <input id= "control_id_hidden" type="hidden" name="control_id"/>
+               
+               <div class="select-box">
+                       <label><xsl:value-of select="php:function('lang', 
'registered')" /></label>
+               <input id= "control_registered" type="checkbox" 
name="control_registered" value="1"/>
+         </div>
+         
+               <div class="select-box">
+                       <div class="filter">
+                       <label><xsl:value-of select="php:function('lang', 
'district')" /></label>
+                               <select id="district_id" name="district_id">
+                                       <xsl:apply-templates 
select="district_list/options"/>
+                         </select>
+               </div>
+                 <div class="filter">
+                               <label><xsl:value-of 
select="php:function('lang', 'part of town')" /></label>
+                               <select id="part_of_town_id" 
name="part_of_town_id">
+                                       <xsl:apply-templates 
select="part_of_town_list/options"/>
+                         </select>
+                       </div>
+         </div>
+               
+               <div class="select-box">
+                       <div class="filter">
+                               <label><xsl:value-of 
select="php:function('lang', 'property')" /></label>
+                               <select id="loc1" name="loc1">
+                                       <xsl:apply-templates 
select="loc1_list/options"/>
+                         </select>
+               </div>
+                 <div class="filter">
+                       <label><xsl:value-of select="php:function('lang', 
'building')" /></label>
+                         <select id="loc2" name="loc2">
+                                       <xsl:apply-templates 
select="loc2_list/options"/>
+                         </select>
+                       </div>
+         </div>
+         
+         <div class="select-box">
+                       <div class="filter">
+                               <label><xsl:value-of 
select="php:function('lang', 'location type')" /></label>
+                         <select id="location_type" name="location_type">
+                                       <xsl:apply-templates 
select="location_type_list/options"/>
+                         </select>
+                       </div>
+                 <div class="filter">
+                               <label><xsl:value-of 
select="php:function('lang', 'location category')" /></label>
+                         <select id="location_type_category" 
name="location_type_category"></select>
+                       </div>
+         </div>
+         
+         <div class="select-box">
+                       <label>Søk etter eiendom/bygg/rom</label>
+                       <input type="text" value="" id="search-location-name" />
+                       <input id= "search-location_code" type="hidden" 
name="search-location_code"/>
+               </div>
+               
+       </fieldset>
 </xsl:template>
 
+
 <xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
-       <div id="data_paginator"/>
-       <div class="error_msg">Du må velge bygg før du kan legge til en 
kontroll</div>
-       <div id="datatable-container"/>
+       <div id="paging"></div>
+       <div id="datatable-container"></div>
+
+  <xsl:call-template name="datasource-definition" />
+       <div id="receipt"></div>
+  <xsl:variable name="label_submit"><xsl:value-of select="php:function('lang', 
'save')" /></xsl:variable>
+       <input type="submit" name="update_acl" id="frm_update_acl" class="btn" 
value="{$label_submit}"/>
+
+  <xsl:variable name="label_select_add"><xsl:value-of 
select="php:function('lang', 'select add')" /></xsl:variable>
+  <input type="button" name="select_add" id="frm_update_add" class="btn" 
value="{$label_select_add}" onclick="checkAll('mychecks_add')"/>
        
-       <xsl:call-template name="datasource-definition" />
-       <xsl:variable name="label_submit"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
-       <xsl:variable name="label_checkAll"><xsl:value-of 
select="php:function('lang', 'invert_checkboxes')" /></xsl:variable>
-       <div><input type="button" id="select_all" value="{$label_checkAll}" 
onclick="checkAll('mychecks')"/></div>
-       <form action="#" name="location_form" id="location_form" method="post">
-               <div class="location_submit"><input type="submit" 
name="save_location" id="save_location" value="{$label_submit}" onclick="return 
saveLocationToControl()"/></div>
-       </form>
+  <xsl:variable name="label_select_delete"><xsl:value-of 
select="php:function('lang', 'select delete')" /></xsl:variable>
+       <input type="button" name="select_add" id="frm_update_delete" 
class="btn" value="{$label_select_delete}" 
onclick="checkAll('mychecks_delete')"/>
 </xsl:template>
 
-
 <xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
-       <script>
-               YAHOO.namespace('controller');
-        
-               YAHOO.controller.columnDefs = [
-                               <xsl:for-each select="//datatable/field">
+
+               <!--  DATATABLE DEFINITIONS-->
+               <script type="text/javascript">
+                       var datatable = new Array();
+                       var myColumnDefs = new Array();
+                       var myButtons = new Array();
+                       var td_count = <xsl:value-of select="//td_count"/>;
+
+                       <xsl:for-each select="//datatable">
+                               datatable[<xsl:value-of select="name"/>] = [
                                        {
-                                               key: "<xsl:value-of 
select="key"/>",
-                                               <xsl:if test="label">
-                                               label: "<xsl:value-of 
select="label"/>",
-                                               </xsl:if>
-                                               sortable: <xsl:value-of 
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
-                                               <xsl:if test="hidden">
-                                               hidden: true,
-                                               </xsl:if>
-                                               <xsl:if test="formatter">
-                                               formatter: <xsl:value-of 
select="formatter"/>,
-                                               </xsl:if>
-                                               className: "<xsl:value-of 
select="className"/>"
-                                       }<xsl:value-of 
select="phpgw:conditional(not(position() = last()), ',', '')"/>
-                               </xsl:for-each>
-                       ];
+                                               values:<xsl:value-of 
select="values"/>,
+                                               total_records: <xsl:value-of 
select="total_records"/>,
+                                               is_paginator:  <xsl:value-of 
select="is_paginator"/>,
+                                               edit_action:  <xsl:value-of 
select="edit_action"/>,
+                                               footer:<xsl:value-of 
select="footer"/>
+                                       }
+                               ]
+                       </xsl:for-each>
+                       <xsl:for-each select="//myColumnDefs">
+                               myColumnDefs[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
+                       </xsl:for-each>
+                       <xsl:for-each select="//myButtons">
+                               myButtons[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
+                       </xsl:for-each>
+               </script>
+</xsl:template>
 
-               var main_source = '<xsl:value-of select="source"/>';
-               var main_columnDefs = YAHOO.controller.columnDefs;
-               var main_form = 'queryForm';
-               var main_filters = ['type_id', 'cat_id', 'district_id', 
'part_of_town_id', 'responsibility_roles_list', 'control_area_list', 
'control_id'];
-               var main_container = 'datatable-container';
-               var main_table_id = 'datatable';
-               var main_pag = 'data_paginator';
-               var related_table = new Array('locations_table');
-       
-               setDataSource(main_source, main_columnDefs, main_form, 
main_filters, main_container, main_pag, main_table_id, related_table ); 
-               
-       </script>
-        
+<!-- options for use with select-->
+<xsl:template match="options">
+       <option value="{id}">
+               <xsl:if test="selected != 0">
+                       <xsl:attribute name="selected" value="selected"/>
+               </xsl:if>
+               <xsl:value-of disable-output-escaping="yes" select="name"/>
+       </option>
 </xsl:template>
+




reply via email to

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