fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9515] controller: register control til component


From: Sigurd Nes
Subject: [Fmsystem-commits] [9515] controller: register control til component
Date: Tue, 05 Jun 2012 17:48:44 +0000

Revision: 9515
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9515
Author:   sigurdne
Date:     2012-06-05 17:48:44 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
controller: register control til component

Modified Paths:
--------------
    trunk/controller/inc/class.uicontrol_location.inc.php
    trunk/controller/js/controller/ajax_control_to_component.js
    
trunk/controller/templates/base/control_location/register_control_to_component.xsl

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-05 
17:47:22 UTC (rev 9514)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-06-05 
17:48:44 UTC (rev 9515)
@@ -62,20 +62,23 @@
                private $so_check_item;
                private $so_procedure;
        
-               var $public_functions = array(
-                                                                               
'index'                                                         => true,
-                                                                               
'view_locations_for_control'            => true,
-                                                                               
'register_control_to_location'          => true,
-                                                                               
'register_control_to_location_2'        => true,
-                                                                               
'register_control_to_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
-                                                                       );
+               var $public_functions = array
+               (
+                       'index'                                                 
        => true,
+                       'view_locations_for_control'            => true,
+                       'register_control_to_location'          => true,
+                       'register_control_to_location_2'        => true,
+                       'register_control_to_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,
+                       'get_locations'                                         
=> true
+               );
 
                function __construct()
                {
@@ -1144,93 +1147,20 @@
                        $datavalues[] = array
                        (
                                'name'                          => "0",
-                               'values'                        => 
$this->query2(),//json_encode(array()),
+                               'values'                        => 
json_encode(array()),
                                'total_records'         => 0,
                                'permission'            => "''",
-                               'is_paginator'          => 0,
+                               'is_paginator'          => 1,
                                'edit_action'           => "''",
                                'footer'                        => 0
                        );
 
-                       $datatable = array
-                       (
-                               array
-                               (
-                               'key' => 'id',
-                               'hidden' => true
-                               ),
-                               array
-                               (
-                                       'key' => 'user',
-                                       'label' => lang('user'),
-                                       'sortable' => false
-                               ),
-                               array
-                               (
-                                       'key' => 'ecodimb',
-                                       'label' => lang('dim b'),
-                                       'sortable' => false,
-                                       'formatter' => 'FormatterRight',
-                               ),
-                               array
-                               (
-                                       'key'   =>      'role',
-                                       'label' =>      lang('role'),
-                                       'formatter' => 'FormatterRight',
-                                       'sortable'      =>      true
-                               ),
-                               array
-                               (
-                                       'key' => 'default_user',
-                                       'label' => lang('default'),
-                                       'sortable'      => false,
-                                       'formatter' => 'FormatterCenter',
-                               ),
-                               array
-                               (
-                                       'key' => 'active_from',
-                                       'label' => lang('date from'),
-                                       'sortable'      => true,
-                                       'formatter' => 'FormatterRight',
-                               ),
-                               array
-                               (
-                                       'key' => 'active_to',
-                                       'label' => lang('date to'),
-                                       'sortable' => false,
-                                       'formatter' => 'FormatterCenter',
-                               ),
-                               array
-                               (
-                                       'key' => 'add',
-                                       'label' => lang('add'),
-                                       'sortable' => false,
-                                       'formatter' => 'FormatterCenter',
-                               ),
-                               array
-                               (
-                                       'key' => 'delete',
-                                       'label' => lang('delete'),
-                                       'sortable' => false,
-                                       'formatter' => 'FormatterCenter',
-                               ),
-                               array
-                               (
-                                       'key' => 'alter_date',
-                                       'label' => lang('alter_date'),
-                                       'sortable' => false,
-                                       'formatter' => 'FormatterCenter',
-                               ),
-                       );
-
                        $myColumnDefs[0] = array
                        (
                                'name'          => "0",
-                               'values'        =>      json_encode($datatable)
+                               'values'        =>      json_encode(array())
                        );      
 
-
-
                        $GLOBALS['phpgw']->translation->add_app('property');
                        $entity                 = 
CreateObject('property.soadmin_entity');
                        $entity_list    = $entity->read(array('allrows' => 
true));
@@ -1241,14 +1171,8 @@
 
                        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 ($role_list ,array 
('id'=>'','name'=>lang('select')));
-                       array_unshift ($dimb_list ,array 
('id'=>'','name'=>lang('select')));
-
-
-
                        $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
                        $cats->supress_info     = true;
 
@@ -1313,6 +1237,53 @@
                }
        
 
+               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();
+
+                       $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                        
+                               );
+                       }
+
+//_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 query2()
                {
                        $entity_id                      = 
phpgw::get_var('entity_id', 'int');
@@ -1328,10 +1299,11 @@
                        }
 
                        $boentity       = 
CreateObject('property.boentity',false, 'entity');
-//                     $boentity->allrows = true;
+                       $boentity->allrows = true;
                        
                        $values = $boentity->read();
 
+/*
                        foreach($values as &$entry)
                        {
                                if($entry['active_from'])
@@ -1351,7 +1323,7 @@
                                }
                                $results['results'][]= $entry;
                        }
-
+*/
                        return json_encode($values);
                }
 

Modified: trunk/controller/js/controller/ajax_control_to_component.js
===================================================================
--- trunk/controller/js/controller/ajax_control_to_component.js 2012-06-05 
17:47:22 UTC (rev 9514)
+++ trunk/controller/js/controller/ajax_control_to_component.js 2012-06-05 
17:48:44 UTC (rev 9515)
@@ -5,11 +5,11 @@
                var control_area_id = $(this).val();
                 var oArgs = 
{menuaction:'controller.uicontrol.get_controls_by_control_area'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
-        
+
        //      $("#hidden_control_area_id").val( control_area_id );
     //     var control_id_init = $("#hidden_control_id").val();
          var htmlString = "";
-         
+
          $.ajax({
                        type: 'POST',
                        dataType: 'json',
@@ -39,7 +39,7 @@
                                        $("#control_id").html( htmlString );
 //                                             
$("#hidden_control_id").val(-1); //reset
                                }
-                       }  
+                       }
                        });
                        
     });
@@ -49,16 +49,16 @@
        $("#entity_id").change(function () {
                 var oArgs = 
{menuaction:'controller.uicontrol_location.get_category_by_entity', entity_id: 
$(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
-        
+
          var htmlString = "";
-         
+
          $.ajax({
                        type: 'POST',
                        dataType: 'json',
                        url: requestUrl,
                        success: function(data) {
                                if( data != null){
-                                       htmlString  = "<option>Velg</option>"
+                                       htmlString  = "<option 
value=''>Velg</option>"
                                        var obj = data;
 
                                        $.each(obj, function(i)
@@ -75,14 +75,14 @@
                                        });
                                                                                
                        
                                        $("#cat_id").html( htmlString );
-                                       update_component_table();
+       //                              update_component_table();
                                        }
                                        else
                                        {
                                        htmlString  += "<option>Ingen 
kontroller</option>"
                                        $("#cat_id").html( htmlString );
                                }
-                       }  
+                       }
                        });
                        
     });
@@ -93,9 +93,9 @@
                var district_id = $(this).val();
                 var oArgs = 
{menuaction:'controller.uicontrol_location.get_district_part_of_town'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
-         
+
          var htmlString = "";
-         
+
          $.ajax({
                        type: 'POST',
                        dataType: 'json',
@@ -111,19 +111,91 @@
                                        });
                                                                                
                        
                                        $("#part_of_town_id").html( htmlString 
);
-                                       
-                                       update_component_table();
+                               $("#loc1").html( "<option 
value=''>Velg</option>" );
+                               $("#loc2").html( "<option 
value=''>Velg</option>" );
+                               }
+                               else
+                               {
+                               htmlString  += "<option value=''>Velg</option>";
+                               $("#part_of_town_id").html( htmlString );
+                               $("#loc1").html( htmlString );
+                               $("#loc2").html( htmlString );
+                       }
+                       }
+         });
+    });
+
+
+       $("#part_of_town_id").change(function ()
+       {
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_locations', child_level:1, 
part_of_town_id: $(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+                                               
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" +  obj[i].id + " " + obj[i].name + "</option>";
+                                       });
+                                                                               
                        
+                                       $("#loc1").html( htmlString );
+                               $("#loc2").html( "<option 
value=''>Velg</option>" );
                                        }
                                        else
                                        {
-                                       htmlString  += "<option>Ingen 
kontroller</option>"
-                                       $("#part_of_town_id").html( htmlString 
);
+                                       htmlString  = "<option>Ingen</option>";
+                                       $("#loc1").html( htmlString );
+                                       $("#loc2").html(htmlString);
+                               }
+                       }
+         });
+
+    });
+
+       $("#loc1").change(function ()
+       {
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_locations', child_level:2, 
location_code: $(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+
+         var htmlString  = "<option value=''>Velg</option>";
+
+         $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       var obj = data;
+                                               
+                                       $.each(obj, function(i)
+                                       {
+                                               htmlString  += "<option 
value='" + obj[i].id + "'>" +  obj[i].id + " " + obj[i].name + "</option>";
+                                       });
+                                                                               
                        
+                                       $("#loc2").html( htmlString );
+                                       }
+                                       else
+                                       {
+                                       htmlString  = "<option>Ingen</option>";
+                                       $("#loc2").html( htmlString );
                                }
-                       }  
+                       }
          });
+
     });
 
 
+
        $("#control_id").change(function ()
        {
                update_component_table();
@@ -132,6 +204,13 @@
 
        $("#cat_id").change(function ()
        {
+               get_table_def();
+    });
+
+
+
+       $("#search").click(function(e)
+       {
                update_component_table();
     });
 
@@ -166,7 +245,7 @@
                                        {
                                        $(submitBnt).val("Feil ved lagring");   
                                
                                        }
-                                                
+                                               
                                // Changes text on save button back to original
                                window.setTimeout(function() {
                                                $(submitBnt).val('Lagre');
@@ -201,7 +280,43 @@
        });
 });
 
+function get_table_def()
+{
+       var oArgs = {
+               menuaction:'controller.uicontrol_location.get_entity_table_def',
+               entity_id:$("#entity_id").val(),
+               cat_id:$("#cat_id").val()
+       };
 
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+       $.ajax({
+               type: 'POST',
+               dataType: 'json',
+               url: requestUrl,
+               success: function(data) {
+                       if( data != null)
+                       {               
+                               myColumnDefs = [];
+                       myColumnDefs.push(data);
+                               update_component_table_def();
+//                             update_component_table();
+                       }
+                       else
+                       {
+                               alert('error');
+                       }
+               }
+       });
+
+}
+
+function update_component_table_def()
+{
+       pager = YAHOO.util.Dom.get("paging_0");
+       div   = YAHOO.util.Dom.get("datatable-container_0");
+       this.init_datatable(datatable[0],div,pager,myColumnDefs[0],0);
+}
+
 function update_component_table()
 {
        var oArgs = {
@@ -210,9 +325,11 @@
                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);
-       $("#receipt").html('');
+
+       execute_async(myDataTable_0,  oArgs);
+//     $("#receipt").html('');
 }
 

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-05 17:47:22 UTC (rev 9514)
+++ 
trunk/controller/templates/base/control_location/register_control_to_component.xsl
  2012-06-05 17:48:44 UTC (rev 9515)
@@ -122,6 +122,12 @@
                <td>
                        <xsl:value-of select="php:function('lang', 'part of 
town')" />
                </td>
+               <td>
+                       <xsl:value-of select="php:function('lang', 'property')" 
/>
+               </td>
+               <td>
+                       <xsl:value-of select="php:function('lang', 'building')" 
/>
+               </td>
                <td >
                        <xsl:value-of select="php:function('lang', 'search')" />
                </td>
@@ -148,6 +154,16 @@
                  </select>
                </td>           
                <td>
+                 <select id="loc1" name="loc1">
+                       <xsl:apply-templates select="loc1_list/options"/>
+                 </select>
+               </td>           
+               <td>
+                 <select id="loc2" name="loc2">
+                       <xsl:apply-templates select="loc2_list/options"/>
+                 </select>
+               </td>
+               <td>
                        <xsl:variable name="lang_search"><xsl:value-of 
select="php:function('lang', 'Search')" /></xsl:variable>
                        <input type="button" id = "search" name="search" 
value="{$lang_search}" title = "{$lang_search}" />
                </td>                   




reply via email to

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