fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9520] controller: register control to component


From: Sigurd Nes
Subject: [Fmsystem-commits] [9520] controller: register control to component
Date: Wed, 06 Jun 2012 10:59:13 +0000

Revision: 9520
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9520
Author:   sigurdne
Date:     2012-06-06 10:59:10 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
controller: register control to component

Modified Paths:
--------------
    trunk/controller/inc/class.socontrol.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_component.js
    trunk/controller/setup/setup.inc.php
    trunk/controller/setup/tables_current.inc.php
    trunk/controller/setup/tables_update.inc.php
    
trunk/controller/templates/base/control_location/register_control_to_component.xsl

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-06-06 10:27:21 UTC 
(rev 9519)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-06-06 10:59:10 UTC 
(rev 9520)
@@ -253,7 +253,7 @@
                        }
                }
                
-               function register_control_to_location($control_id, $data)
+               public function register_control_to_location($control_id, $data)
                {
 
                        $control_id = (int) $control_id;
@@ -297,6 +297,76 @@
                        return $this->db->transaction_commit();
                }
 
+               public function check_control_component($control_id, 
$location_id, $component_id)
+               {
+                       $control_id             = (int) $control_id;
+                       $location_id    = (int) $location_id;
+                       $component_id   = (int) $component_id;
+                       $sql =  "SELECT * FROM 
controller_control_component_list WHERE control_id = {$control_id} AND 
location_id = {$location_id} AND component_id = {$component_id}";
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       return $this->db->next_record();
+               }
+
+               function register_control_to_component($data)
+               {
+
+                       $delete_component = array();
+                       $add_component = array();
+                       $this->db->transaction_begin();
+
+                       if(isset($data['register_component']) && 
is_array($data['register_component']))
+                       {
+                               foreach($data['register_component'] as 
$component_info)
+                               {
+                                       $component_arr = explode('_', 
$component_info);
+                                       if(count($component_arr)!=3)
+                                       {
+                                               continue;
+                                       }
+                                       
+                                       $control_id             = (int) 
$component_arr[0];
+                                       $location_id    = (int) 
$component_arr[1];
+                                       $component_id   = (int) 
$component_arr[2];
+
+                                       if(!$control_id)
+                                       {
+                                               return false;
+                                       }
+
+                                       $sql =  "SELECT * FROM 
controller_control_component_list WHERE control_id = {$control_id} AND 
location_id = {$location_id} AND component_id = {$component_id}";
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
+                       
+                                       if(!$this->db->next_record())
+                                       {
+                                               $sql =  "INSERT INTO 
controller_control_component_list (control_id, location_id, component_id) 
VALUES ( {$control_id}, {$location_id}, {$component_id})";
+                                               $this->db->query($sql);
+                                       }
+                               }
+                       }
+
+                       if(isset($data['delete']) && is_array($data['delete']))
+                       {
+                               foreach($data['delete'] as $component_info)
+                               {
+                                       $component_arr = explode('_', 
$component_info);
+                                       if(count($component_arr)!=3)
+                                       {
+                                               continue;
+                                       }
+                                       
+                                       $control_id             = (int) 
$component_arr[0];
+                                       $location_id    = (int) 
$component_arr[1];
+                                       $component_id   = (int) 
$component_arr[2];
+                               
+                                       $sql =  "DELETE FROM 
controller_control_component_list WHERE control_id = {$control_id} AND 
location_id = {$location_id} AND component_id = {$component_id}";
+                                       $this->db->query($sql);
+                               }
+                       }
+
+                       return $this->db->transaction_commit();
+               }
+
+
                function add_component_to_control($control_id, $component_id)
                {
                        $sql =  "INSERT INTO controller_control_component_list 
(control_id, component_id) values($control_id, $component_id)";

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-06 
10:27:21 UTC (rev 9519)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-06 
10:59:10 UTC (rev 9520)
@@ -69,11 +69,10 @@
                        '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,
-                       'entity'                                                
        => true,
-                       'index2'                                                
        => true,
                        'query2'                                                
        => true,
                        'get_category_by_entity'                        => true,
                        'get_entity_table_def'                          => true,
@@ -134,12 +133,23 @@
                        }
                        // END as categories
 
-                       $tabs = array( array(
-                                               'label' => 
lang('View_locations_for_control')
-                                       ), array(
-                                               'label' => 
lang('Add_locations_for_control'),
-                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
-                                       ));
+                       $tabs = array
+                       (
+                               array
+                               (
+                                       'label' => 
lang('View_locations_for_control')
+                               ),
+                                array
+                               (
+                                       'label' => 
lang('Add_locations_for_control'),
+                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
+                               ),
+                               array
+                               (
+                                       'label' => lang('add components for 
control'),
+                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_component'))
+                               )
+                       );
                        
                        $data = array(
                                'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
@@ -387,578 +397,6 @@
                
 
 
-               function register_control_to_component()
-               {
-                       $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);
-
-/*                             if($ok)
-                               {
-                                       return json_encode( array( "status" => 
"saved" ) );
-                               }
-                               else
-                               {
-                                       return json_encode( array( "status" => 
"not_saved" ) );
-                               }
-*/
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 
'controller.uicontrol_location.register_control_to_location', '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_info = 
execMethod('controller.socontrol.get_single', $control_id);
-                               if($control_info)
-                               {
-                                       $control_array = array
-                                       (
-                                               'id' => $control_id,
-                                               'title' => 
$control_info->get_title()
-                                       );
-                               }
-
-                               $tabs = array
-                               ( 
-                                       array
-                                       (
-                                               'label' => 
lang('View_locations_for_control'),
-                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
-                                       ),
-                                       array
-                                       (
-                                               'label' => 
lang('Add_locations_for_control'),
-                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
-                                       ),
-                                       array
-                                       (
-                                               'label' => lang('add components 
for control'),
-                                       )
-
-                               );
-                                               
-                               $data = array(
-                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
-                                       'view'                                  
        => "register_control_to_location",
-                                       'control_id'                            
=> $control_id,
-                                       'control_filters'                       
=> array(
-                                               'control_areas_array'   => 
$control_areas_array,
-                                               'control_array'                 
        => $control_array
-                                       ),
-                                       'filter_form'                           
=> array(
-                                               'building_types'                
        => $building_types,
-                                               'category_types'                
        => $category_types,
-                                               'district_list'                 
        => $district_list,
-                                               'part_of_town_list'             
=> $part_of_town_list
-                                       ),
-                                       'datatable' => array(
-                                               'source' => 
self::link(array('menuaction' => 'controller.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');
-                               
-                               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);
-                       }               
-               }
-
-
-
-               function entity()
-               {
-                       $bocommon                                       = 
CreateObject('property.bocommon');
-                       $boentity                                       = 
CreateObject('property.boentity');
-                       $boadmin_entity                         = 
CreateObject('property.boadmin_entity');
-                       $this->start                            = 
$boentity->start;
-                       $this->query                            = 
$boentity->query;
-                       $this->sort                                     = 
$boentity->sort;
-                       $this->order                            = 
$boentity->order;
-                       $this->filter                           = 
$boentity->filter;
-                       $this->cat_id                           = 
$boentity->cat_id;
-                       $this->part_of_town_id          = 
$boentity->part_of_town_id;
-                       $this->district_id                      = 
$boentity->district_id;
-                       $this->entity_id                        = 
$boentity->entity_id;
-                       $this->location_code            = 
$boentity->location_code;
-                       $this->criteria_id                      = 
$boentity->criteria_id;
-
-                       $second_display = phpgw::get_var('second_display', 
'bool');
-                       $default_district       = 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'])?$GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']:'');
-
-                       if ($default_district && !$second_display && 
!$this->district_id)
-                       {
-                               $this->bo->district_id  = $default_district;
-                               $this->district_id              = 
$default_district;
-                       }
-
-                       if( phpgw::get_var('phpgw_return_as') != 'json' )
-                       {
-
-                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
-                                       (
-                                               'menuaction'            => 
'property.uilookup.entity',
-                                               'entity_id'                     
=> $this->entity_id,
-                                               'cat_id'                        
=> $this->cat_id,
-                                               'district_id'           => 
$this->district_id,
-                                               'query'                         
=> $this->query,
-                                               'filter'                        
=> $this->filter,
-                                               'location_code'         => 
$this->location_code,
-                                               'criteria_id'           => 
$this->criteria_id
-                                       ));
-
-                               $datatable['config']['allow_allrows'] = true;
-
-                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uilookup.entity',"
-                                       ."second_display:1,"
-                                       ."entity_id:'{$this->entity_id}',"
-                                       ."cat_id:'{$this->cat_id}',"
-                                       ."district_id:'{$this->district_id}',"
-                                       ."query:'{$this->query}',"
-                                       ."filter:'{$this->filter}',"
-                                       ."criteria_id:'{$this->criteria_id}',"
-                                       
."location_code:'{$this->location_code}'";
-
-                               $values_combo_box[0] = 
$boentity->select_category_list('filter',$this->cat_id);
-                               $default_value = array 
('id'=>'','name'=>lang('no category'));
-                               array_unshift 
($values_combo_box[0],$default_value);
-
-                               $values_combo_box[1]  = 
$bocommon->select_district_list('filter',$this->district_id);
-                               $default_value = array 
('id'=>'','name'=>lang('no district'));
-                               array_unshift 
($values_combo_box[1],$default_value);
-
-                               $values_combo_box[2]  = 
$boentity->get_criteria_list($this->criteria_id);
-                               $default_value = array 
('id'=>'','name'=>lang('no criteria'));
-                               array_unshift 
($values_combo_box[2],$default_value);
-
-                               $datatable['actions']['form'] = array
-                                       (
-                                               array
-                                               (
-                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
-                                                       array
-                                                       (
-                                                               'menuaction'    
        => 'property.uilookup.entity',
-                                                               
'second_display'        => $second_display,
-                                                               'entity_id'     
                => $this->entity_id,
-                                                               'cat_id'        
                => $this->cat_id,
-                                                               'district_id'   
        => $this->district_id,
-                                                               'query'         
                => $this->query,
-                                                               'filter'        
                => $this->filter
-                                                       )
-                                               ),
-                                               'fields'        => array
-                                               (
-                                                       'field' => array
-                                                       (
-                                                               array
-                                                               ( //boton       
CATEGORY
-                                                                       'id' => 
'btn_cat_id',
-                                                                       'name' 
=> 'cat_id',
-                                                                       'value' 
=> lang('Category'),
-                                                                       'type' 
=> 'button',
-                                                                       'style' 
=> 'filter',
-                                                                       
'tab_index' => 1
-                                                               ),
-                                                               array
-                                                               ( //boton       
CATEGORY
-                                                                       'id' => 
'btn_district_id',
-                                                                       'name' 
=> 'district_id',
-                                                                       'value' 
=> lang('District'),
-                                                                       'type' 
=> 'button',
-                                                                       'style' 
=> 'filter',
-                                                                       
'tab_index' => 2
-                                                               ),
-                                                               array
-                                                               ( //boton       
search criteria
-                                                                       'id' => 
'btn_criteria_id',
-                                                                       'name' 
=> 'criteria_id',
-                                                                       'value' 
=> lang('search criteria'),
-                                                                       'type' 
=> 'button',
-                                                                       'style' 
=> 'filter',
-                                                                       
'tab_index' => 3
-                                                               ),
-                                                               array
-                                                               ( //boton  
SEARCH
-                                                                       'id' => 
'btn_search',
-                                                                       'name' 
=> 'search',
-                                                                       'value' 
   => lang('search'),
-                                                                       'type' 
=> 'button',
-                                                                       
'tab_index' => 5
-                                                               ),
-                                                               array
-                                                               ( // TEXT IMPUT
-                                                                       'name'  
   => 'query',
-                                                                       'id'    
 => 'txt_query',
-                                                                       'value' 
   => '',//'',//$query,
-                                                                       'type' 
=> 'text',
-                                                                       'size'  
  => 28,
-                                                                       
'onkeypress' => 'return pulsar(event)',
-                                                                       
'tab_index' => 4
-                                                               )
-                                                       ),
-                                                       'hidden_value' => array
-                                                       (
-                                                               array
-                                                               ( //div values  
combo_box_0
-                                                                       'id' => 
'values_combo_box_0',
-                                                                       'value' 
=> $bocommon->select2String($values_combo_box[0]) //i.e.  id,value/id,vale/
-                                                               ),
-                                                               array
-                                                               ( //div values  
combo_box_1
-                                                                       'id' => 
'values_combo_box_1',
-                                                                       'value' 
=> $bocommon->select2String($values_combo_box[1]) //i.e.  id,value/id,vale/
-                                                               ),
-                                                               array
-                                                               ( //div values  
combo_box_2
-                                                                       'id' => 
'values_combo_box_2',
-                                                                       'value' 
=> $bocommon->select2String($values_combo_box[2]) //i.e.  id,value/id,vale/
-                                                               )
-                                                       )
-                                               )
-                                       )
-                               );
-                       }
-
-                       $entity_list = $boentity->read(array('lookup'=>true));
-                       $input_name = 
$GLOBALS['phpgw']->session->appsession('lookup_fields','property');
-                       $uicols = $boentity->uicols;
-
-                       if (count($uicols['name']) > 0)
-                       {
-                               for ($m = 0; $m<count($input_name); $m++)
-                               {
-                                       if 
(!array_search($input_name[$m],$uicols['name']))
-                                       {
-                                               $uicols['name'][]       = 
$input_name[$m];
-                                               $uicols['descr'][]      = '';
-                                               $uicols['input_type'][]         
= 'hidden';
-                                       }
-                               }
-                       }
-                       else
-                       {
-
-                               $uicols['name'][]       = 'num';
-                               $uicols['descr'][]      = 'ID';
-                               $uicols['input_type'][]         = 'text';
-                       }
-
-                       $content = array();
-                       $j=0;
-                       if (isset($entity_list) && is_array($entity_list))
-                       {
-                               foreach($entity_list as $entity_entry)
-                               {
-                                       for 
($i=0;$i<count($uicols['name']);$i++)
-                                       {
-                                               
$datatable['rows']['row'][$j]['column'][$i]['value']    = 
($entity_entry[$uicols['name'][$i]] == null ? '' : 
$entity_entry[$uicols['name'][$i]]);
-                                               
$datatable['rows']['row'][$j]['column'][$i]['name']     = $uicols['name'][$i];
-
-                                               if(isset($uicols['datatype']) 
&& isset($uicols['datatype'][$i]) && $uicols['datatype'][$i]=='link' && 
$entity_entry[$uicols['name'][$i]])
-                                               {
-                                                       
$datatable['rows']['row'][$j]['column'][$i]['format']   = 'link';
-                                                       
$datatable['rows']['row'][$j]['column'][$i]['value']    = lang('link');
-                                                       
$datatable['rows']['row'][$j]['column'][$i]['link']             = 
$entity_entry[$uicols['name'][$i]];
-                                                       
$datatable['rows']['row'][$j]['column'][$i]['target']   = '_blank';
-                                               }
-                                       }
-
-                                       /*for ($i=0;$i<count($input_name);$i++)
-                                       {
-                                               
$datatable['rows']['row'][$j]['hidden'][$i]['value']    = 
$entity_entry[$input_name[$i]];
-                                               
$datatable['rows']['row'][$j]['hidden'][$i]['name']     = $input_name[$i];
-                                       }*/
-                                       $j++;
-                               }
-                       }
-
-                       $uicols_count   = count($uicols['descr']);
-                       $datatable['rowactions']['action'] = array();
-                       for ($i=0;$i<$uicols_count;$i++)
-                       {
-                               //all colums should be have formatter
-                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
-
-                               if($uicols['input_type'][$i]!='hidden')
-                               {
-                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
-                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
-                                       
$datatable['headers']['header'][$i]['visible']                  = true;
-                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
-
-                                       if($uicols['name'][$i]=='loc1' || 
$uicols['name'][$i]=='num')
-                                       {
-                                               
$datatable['headers']['header'][$i]['sortable']         = true;
-                                               
$datatable['headers']['header'][$i]['sort_field']       = $uicols['name'][$i];
-                                       }
-                               }
-                               else
-                               {
-                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
-                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
-                                       
$datatable['headers']['header'][$i]['visible']                  = false;
-                                       
$datatable['headers']['header'][$i]['sortable']         = false;
-                                       
$datatable['headers']['header'][$i]['format']                   = 'hidden';
-                               }
-                       }
-
-                       $function_exchange_values = '';
-
-                       for ($i=0;$i<count($input_name);$i++)
-                       {
-                               $function_exchange_values .= 
"opener.document.getElementsByName('{$input_name[$i]}')[0].value = '';\r\n";
-                       }
-
-                       for ($i=0;$i<count($input_name);$i++)
-                       {
-                               $function_exchange_values .= 
"opener.document.getElementsByName('{$input_name[$i]}')[0].value = 
data.getData('{$input_name[$i]}');\r\n";
-                       }
-
-                       $function_exchange_values .= 'window.close()';
-
-                       $datatable['exchange_values'] = 
$function_exchange_values;
-                       $datatable['valida'] = '';
-
-                       // path for property.js
-                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
-
-                       // Pagination and sort values
-                       $datatable['pagination']['records_start']       = 
(int)$this->start;
-                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       $datatable['pagination']['records_returned']= 
count($entity_list);
-                       $datatable['pagination']['records_total']       = 
$boentity->total_records;
-
-                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
-                       {
-                               $datatable['sorting']['order']                  
= 'num'; // name key Column in myColumnDef
-                               $datatable['sorting']['sort']                   
= 'desc'; // ASC / DESC
-                       }
-                       else
-                       {
-                               $datatable['sorting']['order']                  
= phpgw::get_var('order', 'string'); // name of column of Database
-                               $datatable['sorting']['sort']                   
= phpgw::get_var('sort', 'string'); // ASC / DESC
-                       }
-
-
-                       //-- BEGIN----------------------------- JSON CODE 
------------------------------
-
-                       //values for Pagination
-                       $json = array
-                               (
-                                       'recordsReturned'       => 
$datatable['pagination']['records_returned'],
-                                       'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
-                                       'startIndex'            => 
$datatable['pagination']['records_start'],
-                                       'sort'                          => 
$datatable['sorting']['order'],
-                                       'dir'                           => 
$datatable['sorting']['sort'],
-                                       'records'                       => 
array(),
-                                       'headers'                       => 
$uicols
-
-                               );
-
-                       // values for datatable
-                       if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
-                               foreach( $datatable['rows']['row'] as $row )
-                               {
-                                       $json_row = array();
-                                       foreach( $row['column'] as $column)
-                                       {
-                                               if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
-                                               {
-                                                       
$json_row[$column['name']] = "<a href='#' id='{$column['link']}' 
onclick='javascript:filter_data(this.id);'>{$column['value']}</a>";
-                                               }
-                                               else 
if(isset($column['format']) && $column['format']== "link")
-                                               {
-                                                       
$json_row[$column['name']] = "<a href='{$column['link']}' 
target='_blank'>{$column['value']}</a>";
-                                               }
-                                               else
-                                               {
-                                                       
$json_row[$column['name']] = $column['value'];
-                                               }
-                                       }
-                                       $json['records'][] = $json_row;
-                               }
-                       }
-
-                       // right in datatable
-                       if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
-                       {
-                               $json ['rights'] = 
$datatable['rowactions']['action'];
-                       }
-
-                       if( phpgw::get_var('phpgw_return_as') == 'json' )
-                       {
-                               return $json;
-                       }
-
-                       $datatable['json_data'] = json_encode($json);
-                       //-------------------- JSON CODE ----------------------
-
-                       // Prepare template variables and process XSLT
-                       $template_vars = array();
-                       $template_vars['datatable'] = $datatable;
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'),PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/base');
-                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
-
-                       if($this->entity_id)
-                       {
-                               $entity         = 
$boadmin_entity->read_single($this->entity_id,false);
-                               $appname        = $entity['name'];
-                       }
-                       if($this->cat_id)
-                       {
-                               $category = 
$boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
-                               $function_msg                                   
= lang('lookup') . ' ' . $category['name'];
-                       }
-
-                       //Title of Page
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
-
-                       // Prepare YUI Library
-                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'lookup.entity.index', 'property' );
-
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
-
-                       phpgwapi_yui::load_widget('tabview');
-                       phpgwapi_yui::load_widget('dragdrop');
-                       phpgwapi_yui::load_widget('datatable');
-                       phpgwapi_yui::load_widget('menu');
-                       phpgwapi_yui::load_widget('connection');
-                       phpgwapi_yui::load_widget('loader');
-                       phpgwapi_yui::load_widget('tabview');
-                       phpgwapi_yui::load_widget('paginator');
-                       phpgwapi_yui::load_widget('animation');
-
-                       if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
-                       {
-                               $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
-                       }
-                       // Prepare CSS Style
-                       $GLOBALS['phpgw']->css->validate_file('datatable');
-                       $GLOBALS['phpgw']->css->validate_file('property');
-                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
-
-
-//                     $this->save_sessiondata();
-               }
-
-
                // Returns locations for a control
                public function get_locations_for_control()
                {
@@ -1122,7 +560,7 @@
                        return $category_list;
                }
 
-               function index2()
+               function register_control_to_component()
                {
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
                        $receipt = array();
@@ -1207,13 +645,9 @@
                                                                                
                                'district_list'         => array('options' => 
$district_list),
                                                                                
                                'part_of_town_list'     => array('options' => 
$part_of_town_list),
                                                                                
                        ),
-                               'update_action'                                 
=> self::link(array('menuaction' => 'controller.uicontrol_location.edit'))
+                               'update_action'                                 
=> self::link(array('menuaction' => 
'controller.uicontrol_location.edit_component'))
                        );
 
-                       $GLOBALS['phpgw']->jqcal->add_listener('query_start');
-                       $GLOBALS['phpgw']->jqcal->add_listener('query_end');
-                       $GLOBALS['phpgw']->jqcal->add_listener('active_from');
-                       $GLOBALS['phpgw']->jqcal->add_listener('active_to');
 
                        
$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');
@@ -1246,16 +680,40 @@
                        $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++)
                        {
                                $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                        
+                                       '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],
                                );
                        }
 
@@ -1298,42 +756,28 @@
                                return json_encode(array());
                        }
 
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', 
".entity.{$entity_id}.{$cat_id}");
                        $boentity       = 
CreateObject('property.boentity',false, 'entity');
                        $boentity->allrows = true;
                        
                        $values = $boentity->read();
 
-/*
                        foreach($values as &$entry)
                        {
-                               if($entry['active_from'])
+                               $checked = '';
+                               
if($this->so_control->check_control_component($control_id,$location_id,$entry['id']))
                                {
-                                       $default_user_checked = 
$entry['default_user'] == 1 ? 'checked = "checked"' : '';
-                                       $entry['default_user'] = "<input 
id=\"default_user\" type =\"checkbox\" $default_user_checked 
name=\"values[default_user][]\" value=\"{$entry['id']}\">";
-                                       $entry['delete'] = "<input 
id=\"delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$entry['id']}\">";
-                                       $entry['alter_date'] = "<input 
id=\"alter_date\" type =\"checkbox\" name=\"values[alter_date][]\" 
value=\"{$entry['id']}\">";
-                                       $entry['add'] = '';
+                                       $checked =  'checked = "checked" 
disabled = "disabled"';
+                                       $entry['delete'] = "<input class 
=\"mychecks_delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
                                }
-                               else
-                               {
-                                       $entry['default_user'] = '';
-                                       $entry['delete'] = '';
-                                       $entry['alter_date'] = '';
-                                       $entry['add'] = "<input id=\"add\" type 
=\"checkbox\" name=\"values[add][]\" 
value=\"{$entry['ecodimb']}_{$entry['role_id']}_{$entry['user_id']}\">";        
                   
-                               }
-                               $results['results'][]= $entry;
+                               $entry['select'] = "<input class 
=\"mychecks_add\" type =\"checkbox\" $checked 
name=\"values[register_component][]\" 
value=\"{$control_id}_{$location_id}_{$entry['id']}\">";
                        }
-*/
+
                        return json_encode($values);
                }
 
-               public function edit()
+               public function edit_component()
                {
-                       $user_id =      phpgw::get_var('user_id', 'int');
-                       $dimb_id =      phpgw::get_var('dimb_id', 'int');
-                       $role_id =      phpgw::get_var('role_id', 'int');
-                       $query =        phpgw::get_var('query');
-
                        if($values = phpgw::get_var('values'))
                        {
                                if(!$GLOBALS['phpgw']->acl->check('.admin', 
PHPGW_ACL_EDIT, 'property'))
@@ -1343,7 +787,8 @@
                                }
                                if(!$receipt['error'])
                                {
-                                       if($this->bo->edit($values))
+
+                                       
if($this->so_control->register_control_to_component($values))
                                        {
                                                $result =  array
                                                (
@@ -1375,7 +820,7 @@
                        }
                        else
                        {
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_location.index2', 'user_id' => 
$user_id, 'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query' => $query));
+                               $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-06-06 
10:27:21 UTC (rev 9519)
+++ trunk/controller/js/controller/ajax_control_to_component.js 2012-06-06 
10:59:10 UTC (rev 9520)
@@ -238,13 +238,23 @@
                                if(obj.status == "updated")
                                {
                                        $(submitBnt).val("Lagret");
-                                               var oArgs = 
{menuaction:'property.uidimb_role_user.query', dimb_id:$("#dimb_id").val(), 
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query_start:$("#query_start").val(),query_end:$("#query_end").val()};
+
+                                       var oArgs = {
+                                               
menuaction:'controller.uicontrol_location.query2',
+                                               entity_id:$("#entity_id").val(),
+                                               cat_id:$("#cat_id").val(),
+                                               
district_id:$("#district_id").val(),
+                                               
part_of_town_id:$("#part_of_town_id").val(),
+                                               location_code:$("#loc1").val(),
+                                               
control_id:$("#control_id").val()
+                                               };
+       
                                                
execute_async(myDataTable_0,oArgs);
-                                       }
-                                       else
-                                       {
+                               }
+                               else
+                               {
                                        $(submitBnt).val("Feil ved lagring");   
                                
-                                       }
+                               }
                                                
                                // Changes text on save button back to original
                                window.setTimeout(function() {

Modified: trunk/controller/js/yahoo/register_control_to_component.js
===================================================================
--- trunk/controller/js/yahoo/register_control_to_component.js  2012-06-06 
10:27:21 UTC (rev 9519)
+++ trunk/controller/js/yahoo/register_control_to_component.js  2012-06-06 
10:59:10 UTC (rev 9520)
@@ -18,6 +18,34 @@
        }
 
 
+       function checkAll(myclass)
+       {
+               controls = YAHOO.util.Dom.getElementsByClassName(myclass);
+
+               for(i=0;i<controls.length;i++)
+               {
+                       if(!controls[i].disabled)
+                       {
+//                             if(myclass=="mychecks")
+                               {
+                                       if(controls[i].checked)
+                                       {
+                                               controls[i].checked = false;
+                                       }
+                                       else
+                                       {
+                                               controls[i].checked = true;
+                                       }
+                               }
+                               //for the rest, always id checked
+//                             else
+//                             {
+//                                     controls[i].checked = true;
+//                             }
+                       }
+               }
+       }
+ 
  
/********************************************************************************/
 
 

Modified: trunk/controller/setup/setup.inc.php
===================================================================
--- trunk/controller/setup/setup.inc.php        2012-06-06 10:27:21 UTC (rev 
9519)
+++ trunk/controller/setup/setup.inc.php        2012-06-06 10:59:10 UTC (rev 
9520)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.35';
+       $setup_info['controller']['version'] = '0.1.36';
        $setup_info['controller']['app_order'] = 100;
        $setup_info['controller']['enable'] = 1;
        $setup_info['controller']['app_group']  = 'office';

Modified: trunk/controller/setup/tables_current.inc.php
===================================================================
--- trunk/controller/setup/tables_current.inc.php       2012-06-06 10:27:21 UTC 
(rev 9519)
+++ trunk/controller/setup/tables_current.inc.php       2012-06-06 10:59:10 UTC 
(rev 9520)
@@ -152,6 +152,7 @@
                                'fd' => array(
                                        'id' => array('type' => 'auto', 
'nullable' => false),
                                        'control_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
+                                       'location_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => false),
                                        'component_id' => array('type' => 
'int', 'precision' => '4', 'nullable' => false)
                                ),
                        'pk' => array('id'),

Modified: trunk/controller/setup/tables_update.inc.php
===================================================================
--- trunk/controller/setup/tables_update.inc.php        2012-06-06 10:27:21 UTC 
(rev 9519)
+++ trunk/controller/setup/tables_update.inc.php        2012-06-06 10:59:10 UTC 
(rev 9520)
@@ -686,4 +686,23 @@
                                
                $GLOBALS['setup_info']['controller']['currentver'] = '0.1.35';
                return $GLOBALS['setup_info']['controller']['currentver'];
-       }
\ No newline at end of file
+       }
+
+       $test[] = '0.1.35';
+       function controller_upgrade0_1_35()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+               
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_component_list','location_id',array(
+                       'type' => 'int',
+                       'precision' => 4,
+                       'nullable' => false
+               ));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['controller']['currentver'] = 
'0.1.36';
+                       return 
$GLOBALS['setup_info']['controller']['currentver'];
+               }
+       }
+

Modified: 
trunk/controller/templates/base/control_location/register_control_to_component.xsl
===================================================================
--- 
trunk/controller/templates/base/control_location/register_control_to_component.xsl
  2012-06-06 10:27:21 UTC (rev 9519)
+++ 
trunk/controller/templates/base/control_location/register_control_to_component.xsl
  2012-06-06 10:59:10 UTC (rev 9520)
@@ -179,14 +179,18 @@
 <xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
        <div id="paging_0"/>
        <div id="datatable-container_0"/>
-
-       <div id="data_paginator"/>
-       <div id="datatable-container"/>
        
        <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>
        <div class="row_on"><input type="submit" name="update_acl" 
id="frm_update_acl" value="{$label_submit}"/></div>
+
+       <xsl:variable name="label_select_add"><xsl:value-of 
select="php:function('lang', 'select')" /></xsl:variable>
+       <div class="row_on"><input type="button" name="select_add" 
id="frm_update_add" value="{$label_select_add}" 
onclick="checkAll('mychecks_add')"/></div>
+       
+       <xsl:variable name="label_select_delete"><xsl:value-of 
select="php:function('lang', 'select delete')" /></xsl:variable>
+       <div class="row_on"><input type="button" name="select_add" 
id="frm_update_delete" value="{$label_select_delete}" 
onclick="checkAll('mychecks_delete')"/></div>
+       
 </xsl:template>
 
 <xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>




reply via email to

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