fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10055] controller: split functions


From: Sigurd Nes
Subject: [Fmsystem-commits] [10055] controller: split functions
Date: Fri, 28 Sep 2012 14:14:00 +0000

Revision: 10055
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10055
Author:   sigurdne
Date:     2012-09-28 14:14:00 +0000 (Fri, 28 Sep 2012)
Log Message:
-----------
controller: split functions

Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.uicontrol_location.inc.php
    trunk/controller/js/controller/ajax_control_to_component.js
    trunk/controller/js/yahoo/register_control_to_location.js

Added Paths:
-----------
    trunk/controller/inc/class.uicontrol_register_to_component.inc.php

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2012-09-28 11:06:59 UTC (rev 
10054)
+++ trunk/controller/inc/class.menu.inc.php     2012-09-28 14:14:00 UTC (rev 
10055)
@@ -67,7 +67,7 @@
                                                                                
        'component_for_check_list' => array
                                                                                
        (
                                                                                
                'text'  => lang('component'),
-                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 
'controller.uicontrol_location.register_control_to_component') ),
+                                                                               
                'url'   => $GLOBALS['phpgw']->link('/index.php', 
array('menuaction'=> 'controller.uicontrol_register_to_component.index') ),
                                                                                
                'image' => array('property', 'entity_1')
                                                                                
        )
                                                                                
)

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-09-28 
11:06:59 UTC (rev 10054)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-09-28 
14:14:00 UTC (rev 10055)
@@ -66,12 +66,9 @@
                        'view_locations_for_control'            => true,
                        'register_control_to_location'          => true,
                        'register_control_to_location_2'        => true,
-                       'register_control_to_component'         => true,
-                       'edit_component'                                        
=> true,
                        'get_locations_for_control'             => true,
                        'get_location_category'                         => true,
                        'get_district_part_of_town'                     => true,
-                       'query2'                                                
        => true,
                        'get_category_by_entity'                        => true,
                        'get_entity_table_def'                          => true,
                        'get_locations'                                         
=> true,
@@ -417,125 +414,7 @@
                        return $category_list;
                }
 
-               function register_control_to_component()
-               {
-                   
self::set_active_menu('controller::control::component_for_check_list');
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
-                       $receipt = array();
 
-                       if(phpgw::get_var('phpgw_return_as') == 'json')
-                       {
-                               return $this->query2();
-                       }
-
-                       $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');
-                       $entity                 = 
CreateObject('property.soadmin_entity');
-                       $entity_list    = $entity->read(array('allrows' => 
true));
-
-                       $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($entity_list ,array 
('id'=>'','name'=>lang('select')));
-                       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'                                      
        => '""',
-               //              'property_js'                                   
=> 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
-                               '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),
-                                                                               
                                'entity_list'                   => 
array('options' => $entity_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_location.edit_component'))
-                       );
-
-
-
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
-                       $theme = 'ui-lightness';
-                       
$GLOBALS['phpgw']->css->add_external_file("phpgwapi/js/jquery/development-bundle/themes/{$theme}/jquery.ui.autocomplete.css");
-
-
-                       phpgwapi_yui::load_widget('connection');
-                       phpgwapi_yui::load_widget('loader');
-                       phpgwapi_yui::load_widget('tabview');
-
-                       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_component.js');
-                       self::add_javascript('controller', 'yahoo', 
'register_control_to_component2.js');
-
-                       
self::render_template_xsl(array('control_location/register_control_to_component'
 ), $data);
-               }
-       
-
                public function get_location_type_category()
                {
                        $location_type                  = 
phpgw::get_var('location_type', 'int');
@@ -626,100 +505,4 @@
                        return $locations;
                }
 
-
-
-               public function query2()
-               {
-                       $entity_id                      = 
phpgw::get_var('entity_id', 'int');
-                       $cat_id                         = 
phpgw::get_var('cat_id', 'int');
-                       $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');
-
-                       if(!$entity_id && !$cat_id)
-                       {
-                               $values = array();
-                       }
-                       else
-                       {
-                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', 
".entity.{$entity_id}.{$cat_id}");
-                               $boentity       = 
CreateObject('property.boentity',false, 'entity');
-                               $boentity->results = $results;
-                               $values = 
$boentity->read(array('control_registered' => $control_registered, 'control_id' 
=> $control_id));
-                       }               
-
-                       foreach($values as &$entry)
-                       {
-                               $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']}\">";
-                       }
-
-                       
-                       $results = $results ? $results : 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       $return_data['recordsReturned'] = count($values);
-                       $return_data['totalRecords'] = $boentity->total_records;
-                       $return_data['startIndex'] = $this->start;
-                       $return_data['sort'] = 'location_code';
-                       $return_data['dir'] = "ASC";
-                       $return_data['pageSize'] = $results;
-                       $return_data['activePage'] = floor($this->start / 
$results) + 1;
-                       $return_data['records'] = $values;
-
-                       return $return_data;
-               }
-
-               public function edit_component()
-               {
-                       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_component($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_location.register_control_to_component'));
-                       }
-               }
        }

Added: trunk/controller/inc/class.uicontrol_register_to_component.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_register_to_component.inc.php          
                (rev 0)
+++ trunk/controller/inc/class.uicontrol_register_to_component.inc.php  
2012-09-28 14:14:00 UTC (rev 10055)
@@ -0,0 +1,434 @@
+<?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_component 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_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()
+               {
+                       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()
+               {
+                   
self::set_active_menu('controller::control::component_for_check_list');
+                       $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');
+                       $entity                 = 
CreateObject('property.soadmin_entity');
+                       $entity_list    = $entity->read(array('allrows' => 
true));
+
+                       $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($entity_list ,array 
('id'=>'','name'=>lang('select')));
+                       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),
+                                                                               
                                'entity_list'                   => 
array('options' => $entity_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_location.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::render_template_xsl(array('control_location/register_control_to_component'
 ), $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()
+               {
+                       $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;
+               }
+
+
+
+               public function query()
+               {
+                       $entity_id                      = 
phpgw::get_var('entity_id', 'int');
+                       $cat_id                         = 
phpgw::get_var('cat_id', 'int');
+                       $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');
+
+                       if(!$entity_id && !$cat_id)
+                       {
+                               $values = array();
+                       }
+                       else
+                       {
+                               $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', 
".entity.{$entity_id}.{$cat_id}");
+                               $boentity       = 
CreateObject('property.boentity',false, 'entity');
+                               $boentity->results = $results;
+                               $values = 
$boentity->read(array('control_registered' => $control_registered, 'control_id' 
=> $control_id));
+                       }               
+
+                       foreach($values as &$entry)
+                       {
+                               $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']}\">";
+                       }
+
+                       
+                       $results = $results ? $results : 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $return_data['recordsReturned'] = count($values);
+                       $return_data['totalRecords'] = $boentity->total_records;
+                       $return_data['startIndex'] = $this->start;
+                       $return_data['sort'] = 'location_code';
+                       $return_data['dir'] = "ASC";
+                       $return_data['pageSize'] = $results;
+                       $return_data['activePage'] = floor($this->start / 
$results) + 1;
+                       $return_data['records'] = $values;
+
+                       return $return_data;
+               }
+
+               public function edit_component()
+               {
+                       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_component($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_location.register_control_to_component'));
+                       }
+               }
+       }

Modified: trunk/controller/js/controller/ajax_control_to_component.js
===================================================================
--- trunk/controller/js/controller/ajax_control_to_component.js 2012-09-28 
11:06:59 UTC (rev 10054)
+++ trunk/controller/js/controller/ajax_control_to_component.js 2012-09-28 
14:14:00 UTC (rev 10055)
@@ -47,7 +47,7 @@
 
 
        $("#entity_id").change(function () {
-                var oArgs = 
{menuaction:'controller.uicontrol_location.get_category_by_entity', entity_id: 
$(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_category_by_entity',
 entity_id: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString = "";
@@ -88,7 +88,7 @@
 
 
        $("#location_type").change(function () {
-                var oArgs = 
{menuaction:'controller.uicontrol_location.get_location_type_category', 
location_type: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_location_type_category',
 location_type: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString = "";
@@ -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_location.get_district_part_of_town'};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.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_location.get_locations', child_level:1, 
part_of_town_id: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.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_location.get_locations', child_level:2, 
location_code: $(this).val()};
+                var oArgs = 
{menuaction:'controller.uicontrol_register_to_component.get_locations', 
child_level:2, location_code: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString  = "<option value=''>Velg</option>";
@@ -440,7 +440,7 @@
 function get_table_def()
 {
        var oArgs = {
-               menuaction:'controller.uicontrol_location.get_entity_table_def',
+               
menuaction:'controller.uicontrol_register_to_component.get_entity_table_def',
                entity_id:$("#entity_id").val(),
                cat_id:$("#cat_id").val()
        };
@@ -498,7 +498,7 @@
        }
 
        var oArgs = {
-               menuaction:'controller.uicontrol_location.query2',
+               menuaction:'controller.uicontrol_register_to_component.query',
                entity_id:$("#entity_id").val(),
                cat_id:cat_id,
                district_id:$("#district_id").val(),
@@ -540,7 +540,7 @@
                }
 
                var oArgs = {
-                       menuaction:'controller.uicontrol_location.query2',
+                       
menuaction:'controller.uicontrol_register_to_component.query',
                        entity_id:$("#entity_id").val(),
                        cat_id:$("#cat_id").val(),
                        district_id:$("#district_id").val(),

Modified: trunk/controller/js/yahoo/register_control_to_location.js
===================================================================
--- trunk/controller/js/yahoo/register_control_to_location.js   2012-09-28 
11:06:59 UTC (rev 10054)
+++ trunk/controller/js/yahoo/register_control_to_location.js   2012-09-28 
14:14:00 UTC (rev 10055)
@@ -1,15 +1,3 @@
-
-//----------
-       var oArgs_edit = {menuaction:'registration.uipending.edit'};
-       var edit_Url = phpGWLink('index.php', oArgs_edit);
-
-       formatLinkPending = function(elCell, oRecord, oColumn, oData)
-       {
-               var id = oRecord.getData(oColumn.key);
-               elCell.innerHTML = '<a href="' + edit_Url + '&id=' + id + '">' 
+ lang['edit'] + '</a>'; 
-       };
-
-
        var formatterCheckLocation = function(elCell, oRecord, oColumn, oData)
        {
                var checked = '';




reply via email to

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