fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11178] more on controller


From: Sigurd Nes
Subject: [Fmsystem-commits] [11178] more on controller
Date: Sun, 16 Jun 2013 17:02:16 +0000

Revision: 11178
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11178
Author:   sigurdne
Date:     2013-06-16 17:02:16 +0000 (Sun, 16 Jun 2013)
Log Message:
-----------
more on controller

Modified Paths:
--------------
    trunk/controller/inc/class.socontrol_group.inc.php
    trunk/controller/inc/class.socontrol_group_list.inc.php
    trunk/controller/inc/class.uicase.inc.php
    trunk/controller/inc/class.uicontrol_group.inc.php
    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_group/control_group.xsl

Modified: trunk/controller/inc/class.socontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_group.inc.php  2013-06-16 17:01:33 UTC 
(rev 11177)
+++ trunk/controller/inc/class.socontrol_group.inc.php  2013-06-16 17:02:16 UTC 
(rev 11178)
@@ -63,7 +63,8 @@
                                        'procedure_id',
                                        'control_area_id',
                                        'building_part_id',
-                                       'component_location_id'
+                                       'component_location_id',
+                                       'component_criteria'
                        );
 
                        $values = array(
@@ -72,6 +73,7 @@
                                
$this->marshal($control_group->get_control_area_id(), 'int'),
                                
$this->marshal($control_group->get_building_part_id(), 'string'),
                                
$this->marshal($control_group->get_component_location_id(), 'int'),
+                               
$this->marshal(serialize($control_group->get_component_criteria()), 'string')
                        );
 
                        $result = $this->db->query('INSERT INTO 
controller_control_group (' . join(',', $cols) . ') VALUES (' . join(',', 
$values) . ')', __LINE__,__FILE__);
@@ -104,6 +106,7 @@
                                'control_area_id = ' . 
$this->marshal($control_group->get_control_area_id(), 'int'),
                                'building_part_id = ' . 
$this->marshal($control_group->get_building_part_id(), 'string'),
                                'component_location_id = '. 
$this->marshal($control_group->get_component_location_id(), 'int'),
+                               'component_criteria = ' . 
$this->marshal(serialize($control_group->get_component_criteria()), 'string')
                        );
 
                        $result = $this->db->query('UPDATE 
controller_control_group SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__,__FILE__);
@@ -140,8 +143,9 @@
                        
$control_group->set_control_area_name($category[0]['name']);
 
                        
$control_group->set_component_location_id($this->unmarshal($this->db->f('component_location_id'),
 'int'));
+                       $component_criteria = 
$this->db->f('component_criteria') ? 
unserialize($this->db->f('component_criteria',true)) : array();
+                       
$control_group->set_component_criteria($component_criteria);
 
-
                        return $control_group;
                }
 

Modified: trunk/controller/inc/class.socontrol_group_list.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_group_list.inc.php     2013-06-16 
17:01:33 UTC (rev 11177)
+++ trunk/controller/inc/class.socontrol_group_list.inc.php     2013-06-16 
17:02:16 UTC (rev 11178)
@@ -225,6 +225,9 @@
                                
$control_group->set_building_part_id($this->unmarshal($this->db->f('building_part_id'),
 'int'));
                                
$control_group->set_component_location_id($this->unmarshal($this->db->f('component_location_id'),
 'int'));
 
+                               $component_criteria = 
$this->db->f('component_criteria') ? 
unserialize($this->db->f('component_criteria',true)) : array();
+                               
$control_group->set_component_criteria($component_criteria);
+
                                if($returnType == "array")
                                {
                                        $control_group_list[] = 
$control_group->toArray();

Modified: trunk/controller/inc/class.uicase.inc.php
===================================================================
--- trunk/controller/inc/class.uicase.inc.php   2013-06-16 17:01:33 UTC (rev 
11177)
+++ trunk/controller/inc/class.uicase.inc.php   2013-06-16 17:02:16 UTC (rev 
11178)
@@ -139,8 +139,7 @@
                                $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                                $type = 'location';
                        }
-                       
-//_debug_array($saved_control_groups);
+
                        //Populating array with saved control items for each 
group
                        //Cache result
                        $components_at_location = array();
@@ -149,7 +148,6 @@
                        {       
                                $saved_control_items = 
$this->so_control_item_list->get_control_items_and_options_by_control_and_group($control->get_id(),
 $control_group->get_id(), "return_array");
 
-//_debug_array($control_group);
                                if(count($saved_control_items) > 0)
                                {                               
                                        $component_location_id = 
$control_group->get_component_location_id();
@@ -161,6 +159,22 @@
                                                $criterias_array['location_id'] 
= $component_location_id;
                                                
$criterias_array['location_code'] = $location_code_search_components;
                                                $criterias_array['allrows'] = 
true;
+
+                                               $component_criteria = 
$control_group->get_component_criteria();
+                                               $conditions = array();
+                                               foreach ($component_criteria as 
$attribute_id => $condition_value)
+                                               {
+                                                       if($condition_value)
+                                                       {
+                                                               $conditions[] = 
array
+                                                               (
+                                                                       
'attribute_id'  => $attribute_id,
+                                                                       
'operator'              => 'equal',
+                                                                       'value' 
                => $condition_value,
+                                                               );
+                                                       }
+                                               }
+                                               $criterias_array['conditions'] 
= $conditions;
                                                
                                                if( 
!isset($components_at_location[$component_location_id][$location_code_search_components])
  || !$_components_at_location = 
$components_at_location[$component_location_id][$location_code_search_components])
                                                {

Modified: trunk/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_group.inc.php  2013-06-16 17:01:33 UTC 
(rev 11177)
+++ trunk/controller/inc/class.uicontrol_group.inc.php  2013-06-16 17:02:16 UTC 
(rev 11178)
@@ -538,21 +538,25 @@
                                        }
 
                                        $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)
+
+                                       $component_criteria = 
$control_group->get_component_criteria();
+                                       foreach ($attributes as $key => &$a)
                                        {
-                                               if(in_array($a['id'], 
$selected_attributes))
+                                               
if(isset($component_criteria[$key]) && $component_criteria[$key])
                                                {
-                                                       $a['checked'] = 
'checked';
+                                                       $a['value'] = 
$component_criteria[$key];
+                                                       if(isset($a['choice']) 
&& $a['choice'])
+                                                       {
+                                                               
foreach($a['choice'] as &$choise)
+                                                               {
+                                                                       
$choise['selected'] = $choise['id'] == $component_criteria[$key] ? 1 : 0;
+                                                               }
+                                                       }
                                                }
                                        }
                                }
-                               //---
 
+                       //---
 
                                $data = array
                                (
@@ -803,7 +807,25 @@
                                $entity = 
$entity_so->read_single($entity_arr[2]);
                                $category = 
$entity_so->read_single_category($entity_arr[2],$entity_arr[3]);
 
+                               $custom = 
createObject('phpgwapi.custom_fields');
+                               $attributes = 
$custom->find('property',".entity.{$entity_arr[2]}.{$entity_arr[3]}", 0, 
'','','',true, true);
 
+                               $component_criteria = 
$control_group->get_component_criteria();
+                               foreach ($attributes as $key => &$a)
+                               {
+                                       if(isset($component_criteria[$key]) && 
$component_criteria[$key])
+                                       {
+                                               $a['value'] = 
$component_criteria[$key];
+                                               if(isset($a['choice']) && 
$a['choice'])
+                                               {
+                                                       foreach($a['choice'] as 
&$choise)
+                                                       {
+                                                               
$choise['selected'] = $choise['id'] == $component_criteria[$key] ? 1 : 0;
+                                                       }
+                                               }
+                                       }
+                               }
+
                                $control_items_array = 
$this->so_control_item_list->get_control_items($control_group_id);
 
                                $control_items = array();
@@ -822,6 +844,7 @@
                                        'control_group'                         
=> $control_group_array,
                                        'entity'                                
        => $entity,
                                        'category'                              
        => $category,
+                                       'attributes'                            
=> $attributes,
                                        'selected_control_items'        => 
$control_items,
                                );
 

Modified: trunk/controller/setup/setup.inc.php
===================================================================
--- trunk/controller/setup/setup.inc.php        2013-06-16 17:01:33 UTC (rev 
11177)
+++ trunk/controller/setup/setup.inc.php        2013-06-16 17:02:16 UTC (rev 
11178)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.46';
+       $setup_info['controller']['version'] = '0.1.47';
        $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       2013-06-16 17:01:33 UTC 
(rev 11177)
+++ trunk/controller/setup/tables_current.inc.php       2013-06-16 17:02:16 UTC 
(rev 11178)
@@ -111,6 +111,7 @@
                                'control_area_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
                                'building_part_id' => array('type' => 
'varchar', 'precision' => 30, 'nullable' => True),
                                'component_location_id' => array('type' => 
'int', 'precision' => 4, 'nullable' => True),
+                               'component_criteria'   => array('type' => 
'text', 'nullable' => true)
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: trunk/controller/setup/tables_update.inc.php
===================================================================
--- trunk/controller/setup/tables_update.inc.php        2013-06-16 17:01:33 UTC 
(rev 11177)
+++ trunk/controller/setup/tables_update.inc.php        2013-06-16 17:02:16 UTC 
(rev 11178)
@@ -171,8 +171,8 @@
                return $GLOBALS['setup_info']['controller']['currentver'];
        }
        
-       /* Update Controller from v 0.1.9 to 0.1.10 
-        * Add table for connecting equipment (BIM) and control 
+       /* Update Controller from v 0.1.9 to 0.1.10
+        * Add table for connecting equipment (BIM) and control
        */
        
        $test[] = '0.1.9';
@@ -197,7 +197,7 @@
        }
 
        /* Update Controller from v 0.1.10 to 0.1.11
-        * Alter from naming from equipment to more generic component 
+        * Alter from naming from equipment to more generic component
        */
        
        $test[] = '0.1.10';
@@ -347,13 +347,13 @@
        function controller_upgrade0_1_16()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_item_case','message_ticket_id',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => '8',
                        'nullable' => true
                ));
                
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_item_case','measurement',array(
-                       'type' => 'varchar', 
+                       'type' => 'varchar',
                        'precision' => '50',
                        'nullable' => true
                ));
@@ -362,7 +362,7 @@
                return $GLOBALS['setup_info']['controller']['currentver'];
        }
        
-       $test[] = '0.1.17'; 
+       $test[] = '0.1.17';
        function controller_upgrade0_1_17()
        {
                
$GLOBALS['phpgw_setup']->oProc->DropTable('controller_check_item_case');
@@ -402,13 +402,13 @@
        function controller_upgrade0_1_18()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_item_case','entry_date',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => 8,
                        'nullable' => false
                ));
                
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_item_case','modified_date',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => 8,
                        'nullable' => true
                ));
@@ -455,7 +455,7 @@
        function controller_upgrade0_1_21()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_item','comment',array(
-                       'type' => 'varchar', 
+                       'type' => 'varchar',
                        'precision' => '255',
                        'nullable' => true
                ));
@@ -464,7 +464,7 @@
                return $GLOBALS['setup_info']['controller']['currentver'];
        }
 
-       /* Update Controller from v 0.1.22 to 0.1.23 
+       /* Update Controller from v 0.1.22 to 0.1.23
         * Add table for configurable status
        */
 
@@ -501,7 +501,7 @@
        function controller_upgrade0_1_23()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_procedure','reference',array(
-                       'type' => 'text', 
+                       'type' => 'text',
                        'nullable' => true
                ));
                
@@ -531,7 +531,7 @@
        }
        
        /* Update Controller from v 0.1.25 to 0.1.26
-        * Added table for connecting gontrol groups to components  
+        * Added table for connecting gontrol groups to components
        */
        
        $test[] = '0.1.25';
@@ -611,7 +611,7 @@
        function controller_upgrade0_1_29()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_procedure','responsibility',array(
-                       'type' => 'text', 
+                       'type' => 'text',
                        'nullable' => true
                ));
                
@@ -627,7 +627,7 @@
        function controller_upgrade0_1_30()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_control','description',array(
-                       'type' => 'text', 
+                       'type' => 'text',
                        'nullable' => true
                ));
                
@@ -650,7 +650,7 @@
        function controller_upgrade0_1_32()
        {
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_list','comment',array(
-                       'type' => 'text', 
+                       'type' => 'text',
                        'nullable' => true
                ));
                
@@ -776,7 +776,7 @@
                ));
 
                
$GLOBALS['phpgw_setup']->oProc->AlterColumn('controller_check_list','location_code',array(
-                       'type' => 'varchar', 
+                       'type' => 'varchar',
                        'precision' => '30',
                        'nullable' => true
                ));
@@ -828,7 +828,7 @@
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_check_item_case','location_code',array(
-                       'type' => 'varchar', 
+                       'type' => 'varchar',
                        'precision' => '30',
                        'nullable' => true
                ));
@@ -846,7 +846,7 @@
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_group_list','temp_order_nr',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => '4',
                        'nullable' => true
                ));
@@ -871,13 +871,13 @@
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_check_list','assigned_to',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => '4',
                        'nullable' => true
                ));
 
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_check_list','billable_hours',array(
-                       'type' => 'decimal', 
+                       'type' => 'decimal',
                        'precision' => '20',
                        'scale' => '2',
                        'nullable' => true
@@ -896,7 +896,7 @@
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_group','component_location_id',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => '4',
                        'nullable' => true
                ));
@@ -914,7 +914,7 @@
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                
                
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_check_item_case','component_id',array(
-                       'type' => 'int', 
+                       'type' => 'int',
                        'precision' => '4',
                        'nullable' => true
                ));
@@ -925,4 +925,20 @@
                        return 
$GLOBALS['setup_info']['controller']['currentver'];
                }
        }
-       
+
+       $test[] = '0.1.46';
+       function controller_upgrade0_1_46()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+               
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_control_group','component_criteria',array(
+                       'type' => 'text',
+                       'nullable' => true
+               ));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['controller']['currentver'] = 
'0.1.47';
+                       return 
$GLOBALS['setup_info']['controller']['currentver'];
+               }
+       }

Modified: trunk/controller/templates/base/control_group/control_group.xsl
===================================================================
--- trunk/controller/templates/base/control_group/control_group.xsl     
2013-06-16 17:01:33 UTC (rev 11177)
+++ trunk/controller/templates/base/control_group/control_group.xsl     
2013-06-16 17:02:16 UTC (rev 11178)
@@ -90,20 +90,35 @@
                                                        </dt>
                                                        <dd>
                                                                <div 
id="attributes">
-                                                                       <xsl:if 
test="req_type/cust_attribute_id">
+                                                                       <table>
                                                                                
<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>
+                                                                               
        <tr>
+                                                                               
                <td>
+                                                                               
                        <xsl:value-of select="input_text" /> &nbsp;( 
<xsl:value-of select="trans_datatype" /> )
+                                                                               
                </td>
+                                                                               
                <td>
+                                                                               
                        <xsl:choose>
+                                                                               
                                <xsl:when test="choice!=''">
+                                                                               
                                        <select name='attributes[{id}]' 
id='attribute_{id}'>;
+                                                                               
                                                <option value = 
''>Velg</option>";
+                                                                               
                                                <xsl:for-each select="choice">
+                                                                               
                                                        <option value="{id}">
+                                                                               
                                                                <xsl:if 
test="selected != 0">
+                                                                               
                                                                        
<xsl:attribute name="selected" value="selected" />
+                                                                               
                                                                </xsl:if>
+                                                                               
                                                                <xsl:value-of 
disable-output-escaping="yes" select="value"/>
+                                                                               
                                                        </option>
+                                                                               
                                                </xsl:for-each>
+                                                                               
                                        </select>
+                                                                               
                                </xsl:when>
+                                                                               
                                <xsl:otherwise>
+                                                                               
                                        <input type= 'text' 
name='attributes[{id}]' id='attribute_{id}' value = '{value}'/>                 
    
+                                                                               
                                </xsl:otherwise>
+                                                                               
                        </xsl:choose>
+                                                                               
                </td>
+                                                                               
        </tr>
                                                                                
</xsl:for-each>
-                                                                       
</xsl:if>
+                                                                       </table>
                                                                </div>
                                                        </dd>
 
@@ -125,9 +140,36 @@
                                                                
<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>
+                                                               <table>
+                                                                       
<xsl:for-each select="attributes">
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="value!=''">
+                                                                               
                <tr>
+                                                                               
                        <td>
+                                                                               
                                <xsl:value-of select="input_text" /> &nbsp;( 
<xsl:value-of select="trans_datatype" /> )
+                                                                               
                        </td>
+                                                                               
                         <td>
+                                                                               
                                 <xsl:text>     => </xsl:text>
+                                                                               
                         </td> 
+                                                                               
                        <td>
+                                                                               
                                <xsl:choose>
+                                                                               
                                        <xsl:when test="choice!=''">
+                                                                               
                                                <xsl:for-each select="choice">
+                                                                               
                                                        <xsl:if test="selected 
!= 0">
+                                                                               
                                                                <xsl:value-of 
disable-output-escaping="yes" select="value"/>
+                                                                               
                                                        </xsl:if>
+                                                                               
                                                </xsl:for-each>
+                                                                               
                                        </xsl:when>
+                                                                               
                                        <xsl:otherwise>
+                                                                               
                                                <xsl:value-of 
disable-output-escaping="yes" select="value"/>
+                                                                               
                                        </xsl:otherwise>
+                                                                               
                                </xsl:choose>
+                                                                               
                        </td>
+                                                                               
                </tr>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                       
</xsl:for-each>
+                                                               </table>
                                                        </dd>
                                                </xsl:otherwise>
                                        </xsl:choose>




reply via email to

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