fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8847]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [8847]
Date: Mon, 13 Feb 2012 12:24:57 +0000

Revision: 8847
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8847
Author:   erikhl
Date:     2012-02-13 12:24:56 +0000 (Mon, 13 Feb 2012)
Log Message:
-----------


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

Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php       2012-02-13 
12:21:59 UTC (rev 8846)
+++ trunk/controller/inc/class.uicontrol_location.inc.php       2012-02-13 
12:24:56 UTC (rev 8847)
@@ -61,7 +61,9 @@
                                                                                
'view_locations_for_control'    => true,
                                                                                
'register_control_to_location'  => true,
                                                                                
'register_control_to_location_2'        => true,
-                                                                               
'get_locations_for_control'     => true
+                                                                               
'get_locations_for_control'     => true,
+                                                                               
'get_location_category'                 => true,
+                                                                               
'get_district_part_of_town'             => true
                                                                        );
 
                function __construct()
@@ -224,7 +226,8 @@
                                        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(
@@ -234,7 +237,9 @@
                                                                                
                                                                        
'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);
@@ -381,6 +386,7 @@
                
                public function query(){
                        $type_id = phpgw::get_var('type_id');
+                       //var_dump($type_id);
                        $view_type = phpgw::get_var('view_type');
                        $return_results = phpgw::get_var('results', 'int', 
'REQUEST', 0);
                        
@@ -393,7 +399,7 @@
                        
                        $location_list = $this->bo->read(array('user_id' => 
$user_id, 'role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
                                                                                
                   'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run' 
=>$dry_run));
-
+//_debug_array($location_list);
                        $rows_total = $this->bo->read(array('type_id' => 
$type_id, 'allrows' => true));
                        
                        foreach($location_list as $location)
@@ -447,4 +453,35 @@
                        $value['parameters'][] = "control_id";
                        */
                }
-       }
+               
+               /*
+                * Return categories based on chosen location
+                */
+               public function get_location_category()
+               {
+                       $type_id = phpgw::get_var('type_id');
+                       $category_types = 
$this->bocommon->select_category_list(array(
+                                                                               
                                                                
'format'=>'filter',
+                                                                               
                                                                'selected' => 0,
+                                                                               
                                                                'type' 
=>'location',
+                                                                               
                                                                'type_id' 
=>$type_id,
+                                                                               
                                                                'order'=>'descr'
+                                                                               
                                                        ));
+                       $default_value = array ('id'=>'','name'=>lang('no 
category selected'));
+                       array_unshift($category_types,$default_value);
+                       return json_encode( $category_types );
+               }
+               
+               /*
+                * Return parts of town based on chosen district
+                */
+               public function get_district_part_of_town()
+               {
+                       $district_id = phpgw::get_var('district_id');
+                       $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',null,$district_id);
+                       $default_value = array ('id'=>'','name'=>lang('no part 
of town'));
+                       array_unshift($part_of_town_list,$default_value);
+
+                       return json_encode( $part_of_town_list );
+               }
+       }
\ No newline at end of file

Modified: trunk/controller/js/controller/ajax.js
===================================================================
--- trunk/controller/js/controller/ajax.js      2012-02-13 12:21:59 UTC (rev 
8846)
+++ trunk/controller/js/controller/ajax.js      2012-02-13 12:24:56 UTC (rev 
8847)
@@ -27,6 +27,70 @@
                 window.location.href = requestUrl;
     });
        
+       //update location category based on location type
+       //file: 
+       $("#type_id").change(function () {
+               var location_type_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_location_category'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+         //var requestUrl = 
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
+         
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl + "&type_id=" + location_type_id,
+                         success: function(data) {
+                                 if( data != null){
+                                         var obj = jQuery.parseJSON(data);
+                                               
+                                         $.each(obj, function(i) {
+                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#cat_id").html( htmlString );
+                                       }else {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#cat_id").html( htmlString );
+                               }
+                         }  
+                       });
+                       
+    });
+       
+       //update part of town category based on district
+       //file: 
+       $("#district_id").change(function () {
+               var district_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_district_part_of_town'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+         //var requestUrl = 
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
+         
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl + "&district_id=" + district_id,
+                         success: function(data) {
+                                 if( data != null){
+                                         var obj = jQuery.parseJSON(data);
+                                               
+                                         $.each(obj, function(i) {
+                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#part_of_town_id").html( 
htmlString );
+                                       }else {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#part_of_town_id").html( htmlString 
);
+                               }
+                         }  
+                       });
+                       
+    });
+       
        // file: uicheck_list.xsl
        // When control area is selected, controls are fetched from db and 
control select list is populated
        $("#control_area_list").change(function () {

Modified: trunk/controller/setup/phpgw_no.lang
===================================================================
--- trunk/controller/setup/phpgw_no.lang        2012-02-13 12:21:59 UTC (rev 
8846)
+++ trunk/controller/setup/phpgw_no.lang        2012-02-13 12:24:56 UTC (rev 
8847)
@@ -317,4 +317,5 @@
 show_controls_for_location     controller      no      Vis lokasjoner
 Property name  controller      no      Lokasjonsnavn
 Address        controller      no      Adresse
-Zip code       controller      no      Postnummer
\ No newline at end of file
+Zip code       controller      no      Postnummer
+no category selected   controller      no      Kategori ikke valgt
\ No newline at end of file

Modified: 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
===================================================================
--- 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
   2012-02-13 12:21:59 UTC (rev 8846)
+++ 
trunk/controller/templates/base/control_location/register_control_to_location.xsl
   2012-02-13 12:24:56 UTC (rev 8847)
@@ -90,9 +90,6 @@
          <ul id="filters">
                <li>
                  <select id="type_id" name="type_id">
-                       <option value="">
-                               <xsl:value-of select="php:function('lang', 
'Choose_building_type')"/>
-                       </option>
                        <xsl:for-each select="building_types">
                                <xsl:variable 
name="building_type_id"><xsl:value-of select="id"/></xsl:variable>
                                <option value="{$building_type_id}">
@@ -103,9 +100,6 @@
                </li>
                <li>
                  <select id="cat_id" name="cat_id">
-                       <option value="">
-                               <xsl:value-of select="php:function('lang', 
'Choose_building_category')"/>
-                       </option>
                        <xsl:for-each select="category_types">
                                <xsl:variable 
name="category_type_id"><xsl:value-of select="id"/></xsl:variable>
                                <option value="{$category_type_id}">
@@ -116,9 +110,6 @@
                </li>
                <li>
                  <select id="district_id" name="district_id">
-                       <option value="">
-                                       <xsl:value-of 
select="php:function('lang', 'Choose_district')"/>
-                       </option>
                        <xsl:for-each select="district_list">
                                <xsl:variable name="district_id"><xsl:value-of 
select="id"/></xsl:variable>
                                <option value="{$district_id}">
@@ -129,9 +120,6 @@
                </li>
                <li>
                  <select id="part_of_town_id" name="part_of_town_id">
-                       <option value="">
-                                       <xsl:value-of 
select="php:function('lang', 'Choose_part_of_town')"/>
-                       </option>
                        <xsl:for-each select="part_of_town_list">
                                <xsl:variable 
name="part_of_town_id"><xsl:value-of select="id"/></xsl:variable>
                                <option value="{$part_of_town_id}">




reply via email to

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