fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11171] controller: add component to control group


From: Sigurd Nes
Subject: [Fmsystem-commits] [11171] controller: add component to control group
Date: Thu, 13 Jun 2013 13:43:17 +0000

Revision: 11171
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11171
Author:   sigurdne
Date:     2013-06-13 13:43:16 +0000 (Thu, 13 Jun 2013)
Log Message:
-----------
controller: add component to control group

Modified Paths:
--------------
    trunk/controller/inc/class.uicase.inc.php
    trunk/controller/inc/class.uicontrol_group.inc.php
    trunk/controller/inc/model/class.check_item_case.inc.php
    trunk/controller/js/controller/control_group_to_component.js
    trunk/controller/templates/base/case/add_case.xsl
    trunk/controller/templates/base/case/case_row.xsl
    trunk/controller/templates/base/case/view_closed_cases.xsl
    trunk/controller/templates/base/control_group/control_group.xsl
    trunk/property/inc/class.boadmin_entity.inc.php

Modified: trunk/controller/inc/class.uicase.inc.php
===================================================================
--- trunk/controller/inc/class.uicase.inc.php   2013-06-13 08:14:00 UTC (rev 
11170)
+++ trunk/controller/inc/class.uicase.inc.php   2013-06-13 13:43:16 UTC (rev 
11171)
@@ -106,7 +106,7 @@
         function add_case()
                {
                        $check_list_id = phpgw::get_var('check_list_id');
-                       $selected_location_code = 
phpgw::get_var('location_code');
+                       $case_location_code = phpgw::get_var('location_code');
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                        $control = 
$this->so_control->get_single($check_list->get_control_id());
                
@@ -135,7 +135,7 @@
                        else
                        {
                                $location_code = 
$check_list->get_location_code();
-                               $location_code_search_components = 
$selected_location_code ? $selected_location_code : $location_code;
+                               $location_code_search_components = 
$case_location_code ? $case_location_code : $location_code;
                                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                                $type = 'location';
                        }
@@ -207,14 +207,14 @@
                        $buildings_on_property = 
$this->location_finder->get_buildings_on_property($user_role, $location_code, 
$level);
                        foreach ( $buildings_on_property as &$building)
                        {
-                               $building['selected'] = $building['id'] == 
$selected_location_code ? 1 : 0;
+                               $building['selected'] = $building['id'] == 
$case_location_code ? 1 : 0;
                        }
 //_debug_array($control_groups_with_items_array);
                        $data = array
                        (
                                'control'                                       
                => $control,
                                'check_list'                                    
        => $check_list,
-                               'buildings_on_property'                  => 
$buildings_on_property,
+                               'buildings_on_property'                         
=> $buildings_on_property,
                            'location_array'                                    
=> $location_array,
                                'component_array'                               
        => $component_array,
                                'control_groups_with_items_array'       => 
$control_groups_with_items_array,
@@ -232,7 +232,8 @@
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                        self::add_javascript('controller', 'controller', 
'case.js');
                        self::add_javascript('controller', 'controller', 
'check_list.js');
-                       
+                       self::add_javascript('controller', 'controller', 
'check_list_update_status.js');                        
+
                        
self::render_template_xsl(array('check_list/fragments/check_list_menu', 
'check_list/fragments/nav_control_plan', 
                                                                          
'check_list/fragments/check_list_top_section', 'case/add_case', 
                                                                          
'check_list/fragments/select_buildings_on_property'), $data);
@@ -764,7 +765,7 @@
       
                        if( count($buildings_on_property) > 0 )
                        {
-                               $case_location_code = $case_location_code ? 
$case_location_code : $buildings_on_property[0]['id'];
+               //              $case_location_code = $case_location_code ? 
$case_location_code : $buildings_on_property[0]['id'];
 
                                $open_check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, $type = null, 
'open_or_waiting', null, $case_location_code);
 
@@ -780,9 +781,18 @@
                                $control_item_with_options = 
$this->so_control_item->get_single_with_options( 
$check_item->get_control_item_id() );
                                
                                $component_location_id = 
$check_item->get_control_item()->get_component_location_id();
-                               //FIXME
-                               //GET 'Short description' for component_id
+                               
+                               foreach($check_item->get_cases_array() as 
&$case)
+                               {
 
+                                       $component_id = 
$case->get_component_id();
+                                       if($component_id)
+                                       {
+                                               $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component_location_id, 'id' => $component_id));
+                                               
$case->set_component_descr($short_desc);
+                                       }
+                               }
+
                            $check_item->get_control_item()->set_options_array( 
$control_item_with_options->get_options_array() );
                                $open_check_items_and_cases[$key] = $check_item;
                        }
@@ -861,11 +871,38 @@
                        if( count($buildings_on_property) > 0 )
                        {
                //              $building_location_code = 
$buildings_on_property[0]['id'];
-                               $closed_check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, null, 
'closed', null, $building_location_code);
+                               $closed_check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, null, 
'closed', null, $case_location_code);
                                foreach ( $buildings_on_property as &$building)
                                {
                                        $building['selected'] = $building['id'] 
== $case_location_code ? 1 : 0;
                                }
+
+//---------
+                               foreach($closed_check_items_and_cases as $key 
=> $check_item)
+                               {
+       //                              $control_item_with_options = 
$this->so_control_item->get_single_with_options( 
$check_item->get_control_item_id() );
+                               
+                                       $component_location_id = 
$check_item->get_control_item()->get_component_location_id();
+                               
+                                       foreach($check_item->get_cases_array() 
as &$case)
+                                       {
+
+                                               $component_id = 
$case->get_component_id();
+                                               if($component_id)
+                                               {
+                                                       $short_desc = 
execMethod('property.soentity.get_short_description', array('location_id' => 
$component_location_id, 'id' => $component_id));
+                                                       
$case->set_component_descr($short_desc);
+                                               }
+                                       }
+
+       //                              
$check_item->get_control_item()->set_options_array( 
$control_item_with_options->get_options_array() );
+       //                              $closed_check_items_and_cases[$key] = 
$check_item;
+                               }
+
+
+//-------
+
+
                        }
 
                        $data = array

Modified: trunk/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_group.inc.php  2013-06-13 08:14:00 UTC 
(rev 11170)
+++ trunk/controller/inc/class.uicontrol_group.inc.php  2013-06-13 13:43:16 UTC 
(rev 11171)
@@ -511,6 +511,7 @@
 
                                //--- sigurd 10.juni 13
                                $entity_so      = 
CreateObject('property.soadmin_entity');
+                               $custom = 
createObject('phpgwapi.custom_fields');
                                $entity_list = $entity_so->read(array('allrows' 
=> true));
 
                                array_unshift($entity_list,array 
('id'=>'','name'=> lang('select value')));
@@ -538,6 +539,20 @@
                                                        $c['selected'] = 1;
                                                }
                                        }
+
+                                       $attributes = 
$custom->find('property',".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0, 
'','','',true, true);
+                                       $selected_attributes = array();//
+                                       
+                                       /*FIXME
+                                       *$selected_attributes = 
$this->so->get_selected_attributes($location_id, $project_type_id);
+                                       */
+                                       foreach ($attributes as &$a)
+                                       {
+                                               if(in_array($a['id'], 
$selected_attributes))
+                                               {
+                                                       $a['checked'] = 
'checked';
+                                               }
+                                       }
                                }
                                //---
 
@@ -546,7 +561,7 @@
                                (
                                        'entities'                              
        => array('options' => $entity_list),
                                        'categories'                            
=> array('options' => $category_list),
-
+                                       'attributes'                            
=> $attributes,
                                        'tabs'                                  
        => phpgwapi_yui::tabview_generate($tabs, $tab_to_display),
                                        'value_id'                              
        => !empty($control_group) ? $control_group->get_id() : 0,
                                        'editable'                              
        => true,

Modified: trunk/controller/inc/model/class.check_item_case.inc.php
===================================================================
--- trunk/controller/inc/model/class.check_item_case.inc.php    2013-06-13 
08:14:00 UTC (rev 11170)
+++ trunk/controller/inc/model/class.check_item_case.inc.php    2013-06-13 
13:43:16 UTC (rev 11171)
@@ -51,6 +51,7 @@
                protected $measurement;
                protected $location_code;
                protected $component_id;
+               protected $component_descr;
     
                
                /**
@@ -157,7 +158,18 @@
                {
                        $this->component_id = $component_id;
                }
-    
+
+
+       public function get_component_descr()
+       {
+               return $this->component_descr;
+       }
+
+               public function set_component_descr($component_descr)
+               {
+                       $this->component_descr = $component_descr;
+               }
+
            public function validate()
                {
                        $status = true;

Modified: trunk/controller/js/controller/control_group_to_component.js
===================================================================
--- trunk/controller/js/controller/control_group_to_component.js        
2013-06-13 08:14:00 UTC (rev 11170)
+++ trunk/controller/js/controller/control_group_to_component.js        
2013-06-13 13:43:16 UTC (rev 11171)
@@ -31,4 +31,34 @@
                        }
                });
         });
+
+        $("#category_id").change(function () {
+                var oArgs = 
{menuaction:'property.boadmin_entity.get_attrib_list', entity_id: 
$("#entity_id").val(), cat_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)
+                               {
+                                       $.each(data, function(i) {
+                                               htmlString  += "<input 
type='checkbox' name='attributes[]' id='attributes[]' value='" + data[i].id + 
"'/>" + data[i].input_text + "&nbsp;(" + data[i].trans_datatype + ")<br/>";
+                               });
+
+                                       $("#attributes").html( htmlString );
+                               }
+                               else
+                               {
+                                       htmlString  += "";
+                                       $("#attributes").html( htmlString );
+                               }
+                       }
+               });
+        });
+
 });

Modified: trunk/controller/templates/base/case/add_case.xsl
===================================================================
--- trunk/controller/templates/base/case/add_case.xsl   2013-06-13 08:14:00 UTC 
(rev 11170)
+++ trunk/controller/templates/base/case/add_case.xsl   2013-06-13 13:43:16 UTC 
(rev 11171)
@@ -24,9 +24,13 @@
                                        <li>
                                                <h3 class="expand-trigger"><img 
src="controller/images/arrow_right.png" /><xsl:value-of 
select="control_group/group_name"/></h3>                                
                                                <ul class="expand_list" 
style="display:none;">
-                                                               <select 
name="component_at_control_group_{control_group/id}" 
id="component_at_control_group_{control_group/id}">
-                                                                       
<xsl:apply-templates select="components_at_location/component_options"/>
-                                                               </select>
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="components_at_location/child::node()">
+                                                                               
<select name="component_at_control_group_{control_group/id}" 
id="component_at_control_group_{control_group/id}">
+                                                                               
        <xsl:apply-templates select="components_at_location/component_options"/>
+                                                                               
</select>
+                                                               </xsl:when>
+                                                       </xsl:choose>
                                                        <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
                                                        <xsl:for-each 
select="control_items">
                                                                <li>
@@ -37,13 +41,7 @@
                                                                <input 
type="hidden" name="component_id"  value="" />
 
                                                                                
<xsl:choose>
-                                                                               
        <xsl:when test="type = 'control_item_type_1'">
-                                                                               
                        <xsl:variable name="control_item_id"><xsl:value-of 
select="id"/></xsl:variable>
-                                                                               
                        <input type="hidden" name="control_item_id" 
value="{$control_item_id}" /> 
-                                                                               
                        <input type="hidden" 
name="check_list_id"><xsl:attribute name="value"><xsl:value-of 
select="//check_list/id"/></xsl:attribute></input>
-                                                                               
                        <input type="hidden" name="status" value="0" />
-                                                                               
        <input type="hidden" name="type" value="control_item_type_1" />
-                                                                               
                          
+                                                                               
        <xsl:when test="what_to_do !=''">
                                                                                
                  <!--  WHAT TO DO -->
                                                                                
                  <div class="row what-to-do">
                                                                                
                    <label>Hva skal sjekkes:</label> 
@@ -51,14 +49,28 @@
                                                                                
                      <xsl:value-of disable-output-escaping="yes" 
select="what_to_do"/>
                                                                                
                    </div>
                                                                                
                  </div>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
 
-                                                                               
                  <!--  HOW TO DO -->
-                                                                               
                  <div class="row how-to-do">
-                                                                               
                    <label>Utførelsesbeskrivelse:</label> 
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="how_to_do !=''">
+                                                                               
                <!--  HOW TO DO -->
+                                                                               
                <div class="row how-to-do">
+                                                                               
                        <label>Utførelsesbeskrivelse:</label> 
                                                                                
                    <div>
                                                                                
                      <xsl:value-of disable-output-escaping="yes" 
select="how_to_do"/>
                                                                                
                    </div>
-                                                                               
                        </div>
+                                                                               
                </div>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="type = 'control_item_type_1'">
+                                                                               
                        <xsl:variable name="control_item_id"><xsl:value-of 
select="id"/></xsl:variable>
+                                                                               
                        <input type="hidden" name="control_item_id" 
value="{$control_item_id}" /> 
+                                                                               
                        <input type="hidden" 
name="check_list_id"><xsl:attribute name="value"><xsl:value-of 
select="//check_list/id"/></xsl:attribute></input>
+                                                                               
                        <input type="hidden" name="status" value="0" />
+                                                                               
        <input type="hidden" name="type" value="control_item_type_1" />
                                                                                
                    
                                                                                
                        <div>
                                                                                
                    <label class="comment">Beskrivelse av sak</label>

Modified: trunk/controller/templates/base/case/case_row.xsl
===================================================================
--- trunk/controller/templates/base/case/case_row.xsl   2013-06-13 08:14:00 UTC 
(rev 11170)
+++ trunk/controller/templates/base/case/case_row.xsl   2013-06-13 13:43:16 UTC 
(rev 11171)
@@ -33,6 +33,20 @@
               <!--  ==================== COL2: CASE CONTENT 
===================== -->
               <div class="col_2">
                 <div class="case_info">
+
+                        <xsl:choose>
+                             <xsl:when test="component_descr != ''">
+                                         <div class="row">
+                                           <label>
+                                                                       
<xsl:value-of select="php:function('lang','component')" />
+                                           </label> 
+                                         </div>
+                                          <div class="component_descr">
+                                           <xsl:value-of 
select="component_descr"/>
+                                         </div>
+                            </xsl:when>
+                    </xsl:choose>
+
                   <!-- STATUS -->
                   <xsl:if test="$control_item_type = 'control_item_type_2' or 
$control_item_type = 'control_item_type_3' or $control_item_type = 
'control_item_type_4'">
                

Modified: trunk/controller/templates/base/case/view_closed_cases.xsl
===================================================================
--- trunk/controller/templates/base/case/view_closed_cases.xsl  2013-06-13 
08:14:00 UTC (rev 11170)
+++ trunk/controller/templates/base/case/view_closed_cases.xsl  2013-06-13 
13:43:16 UTC (rev 11171)
@@ -37,7 +37,25 @@
                                                                                
                                                                                
        <!--  =============== SHOW CASE INFO ============= -->
                                                                                
        <div class="case_info">
-                                                                               
                                                                                
                                                                                
                                                
+                                                                               
                                                                                
                                
+                                                                               
                 <xsl:choose>
+                                                                               
                          <xsl:when test="component_descr != ''">
+                                                                               
                                  <div class="row">
+                                                                               
                                        <label>
+                                                                               
                                                <xsl:value-of 
select="php:function('lang','component')" />
+                                                                               
                                        </label> 
+                                                                               
                                  </div>
+                                                                               
                                   <div class="component_descr">
+                                                                               
                                        <xsl:value-of select="component_descr"/>
+                                                                               
                                  </div>
+                                                                               
                         </xsl:when>
+                                                                               
                </xsl:choose>
+
+                                                                               
          <!--  DESCRIPTION -->
+                                                                               
          <div class="row">
+                                                                               
                <label>Beskrivelse:</label> 
+                                                                               
          </div>
+
                                                                                
                <!--  DESCRIPTION -->
                                                                                
                <div class="case_descr"><xsl:value-of select="descr"/></div>
                                                                                
                <!-- === QUICK EDIT MENU === -->

Modified: trunk/controller/templates/base/control_group/control_group.xsl
===================================================================
--- trunk/controller/templates/base/control_group/control_group.xsl     
2013-06-13 08:14:00 UTC (rev 11170)
+++ trunk/controller/templates/base/control_group/control_group.xsl     
2013-06-13 13:43:16 UTC (rev 11171)
@@ -85,6 +85,28 @@
                                                                        
<xsl:apply-templates select="categories/options"/>
                                                                </select>
                                                        </dd>
+                                                       <dt>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Attributes')" /></label>
+                                                       </dt>
+                                                       <dd>
+                                                               <div 
id="attributes">
+                                                                       <xsl:if 
test="req_type/cust_attribute_id">
+                                                                               
<xsl:for-each select="attributes">
+                                                                               
        <xsl:if test="input_text">
+                                                                               
                <xsl:choose>
+                                                                               
                        <xsl:when test="checked">
+                                                                               
                                <input type='checkbox' name='attributes[]' 
id='attributes[]' value='{id}' checked='checked'/><xsl:value-of 
select="input_text" /> <xsl:value-of select="trans_datatype" /><br/>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:otherwise>
+                                                                               
                                <input type='checkbox' name='attributes[]' 
id='attributes[]' value='{id}'/><xsl:value-of select="input_text" /> 
<xsl:value-of select="trans_datatype" /><br/>
+                                                                               
                        </xsl:otherwise>
+                                                                               
                </xsl:choose>
+                                                                               
        </xsl:if>
+                                                                               
</xsl:for-each>
+                                                                       
</xsl:if>
+                                                               </div>
+                                                       </dd>
+
                                                </xsl:when>
                                                <xsl:otherwise>
                                                        <dt>
@@ -99,6 +121,14 @@
                                                        <dd>
                                                                <xsl:value-of 
select="category/name" />
                                                        </dd>
+                                                       <dt>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Chosen attributes')" 
/></label>
+                                                       </dt>
+                                                       <dd>
+                                                               <xsl:for-each 
select="attributes">
+                                                                       
<xsl:value-of select="input_text" /> (<xsl:value-of select="trans_datatype" 
/>)<br/>
+                                                               </xsl:for-each>
+                                                       </dd>
                                                </xsl:otherwise>
                                        </xsl:choose>
                                </dl>

Modified: trunk/property/inc/class.boadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.boadmin_entity.inc.php     2013-06-13 08:14:00 UTC 
(rev 11170)
+++ trunk/property/inc/class.boadmin_entity.inc.php     2013-06-13 13:43:16 UTC 
(rev 11171)
@@ -86,7 +86,8 @@
                        'save'                          => true,
                        'delete'                        => true,
                        'check_perms'           => true,
-                       'get_category_list'     => true
+                       'get_category_list'     => true,
+                       'get_attrib_list'       => true
                );
                var $type_app            = array
                        (
@@ -223,6 +224,18 @@
                }
 
 
+               /**
+               * Fetch custom attributes for an given komponent type
+               */
+               public function get_attrib_list()
+               {
+                       $entity_id              = phpgw::get_var('entity_id');
+                       $cat_id                 = phpgw::get_var('cat_id');
+
+                       return $attrib_data = 
$this->custom->find('property',".entity.{$entity_id}.{$cat_id}", 0, 
'','','',true, true);
+               }
+
+
                function read_single( $id )
                {
                        return $this->so->read_single( $id );




reply via email to

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