fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7457] property: disallow_multiple_condition_types at


From: Sigurd Nes
Subject: [Fmsystem-commits] [7457] property: disallow_multiple_condition_types at request
Date: Fri, 01 Jul 2011 13:47:55 +0000

Revision: 7457
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7457
Author:   sigurdne
Date:     2011-07-01 13:47:55 +0000 (Fri, 01 Jul 2011)
Log Message:
-----------
property: disallow_multiple_condition_types at request

Modified Paths:
--------------
    trunk/property/inc/class.borequest.inc.php
    trunk/property/inc/class.sorequest.inc.php
    trunk/property/templates/base/config.tpl
    trunk/property/templates/base/request.xsl

Modified: trunk/property/inc/class.borequest.inc.php
===================================================================
--- trunk/property/inc/class.borequest.inc.php  2011-06-30 13:50:58 UTC (rev 
7456)
+++ trunk/property/inc/class.borequest.inc.php  2011-07-01 13:47:55 UTC (rev 
7457)
@@ -239,17 +239,52 @@
                                $conditions = 
$this->so->select_conditions($request_id,$condition_type_list);
                        }
 
-                       for ($i=0;$i<count($condition_type_list);$i++)
+                       $config = CreateObject('phpgwapi.config','property');
+                       $config->read();
+                       $disallow_multiple_condition_types = isset( 
$config->config_data['disallow_multiple_condition_types']) &&  
$config->config_data['disallow_multiple_condition_types'] ? 
(int)$config->config_data['disallow_multiple_condition_types'] : 0;
+
+                       if( !$disallow_multiple_condition_types )
                        {
-                               $values[$i]['degree']                           
= array('options' => $this->select_degree_list($conditions[$i]['degree']));
-                               $values[$i]['probability']                      
= array('options' => 
$this->select_probability_list($conditions[$i]['probability']));
-                               $values[$i]['consequence']                      
= array('options' => 
$this->select_consequence_list($conditions[$i]['consequence']));
-                               $values[$i]['condition_type']           = 
$condition_type_list[$i]['id'];
-                               $values[$i]['condition_type_name']      = 
$condition_type_list[$i]['name'];
-                               $values[$i]['weight']                           
= $condition_type_list[$i]['weight'];
-                               $values[$i]['risk']                             
        = (int)$condition_type_list[$i]['weight'] * 
(int)$conditions[$i]['probability'] * (int)$conditions[$i]['consequence'];
-                               $values[$i]['score']                            
= $values[$i]['risk'] * (int)$conditions[$i]['degree'];
+                               foreach($condition_type_list as $condition_type)
+                               {
+                                       $i = $condition_type['id'];
+                                       $values[] = array
+                                       (
+                                               'degree'                        
        => array('options' => 
$this->select_degree_list($conditions[$i]['degree'])),
+                                               'probability'                   
=> array('options' => 
$this->select_probability_list($conditions[$i]['probability'])),
+                                               'consequence'                   
=> array('options' => 
$this->select_consequence_list($conditions[$i]['consequence'])),
+                                               'condition_type'                
=> $condition_type_list[$i]['id'],
+                                               'condition_type_name'   => 
$condition_type_list[$i]['name'],
+                                               'weight'                        
        => $condition_type_list[$i]['weight'],
+                                               'risk'                          
        => (int)$condition_type_list[$i]['weight'] * 
(int)$conditions[$i]['probability'] * (int)$conditions[$i]['consequence'],
+                                               'score'                         
        => $values[$i]['risk'] * (int)$conditions[$i]['degree']
+                                       );
+                               }
                        }
+                       else
+                       {
+                               $i = 0;
+                               foreach($conditions as $condition_type => 
$condition)
+                               {
+                                       if($condition['condition_type'])
+                                       {
+                                               $i = 
$condition['condition_type'];
+                                               break;
+                                       }
+                               }
+                               $values[] = array
+                               (
+                                       'condition_type_list'   => 
array('options' => $this->bocommon->select_list($i, $condition_type_list)),
+                                       'degree'                                
=> array('options' => $this->select_degree_list($conditions[$i]['degree'])),
+                                       'probability'                   => 
array('options' => 
$this->select_probability_list($conditions[$i]['probability'])),
+                                       'consequence'                   => 
array('options' => 
$this->select_consequence_list($conditions[$i]['consequence'])),
+                                       'condition_type'                => 
$condition_type_list[$i]['id'],
+                                       'condition_type_name'   => 
$condition_type_list[$i]['name'],
+                                       'weight'                                
=> $condition_type_list[$i]['weight'],
+                                       'risk'                                  
=> (int)$condition_type_list[$i]['weight'] * 
(int)$conditions[$i]['probability'] * (int)$conditions[$i]['consequence'],
+                                       'score'                                 
=> $values[$i]['risk'] * (int)$conditions[$i]['degree']
+                               );
+                       }
 
                        return $values;
                }

Modified: trunk/property/inc/class.sorequest.inc.php
===================================================================
--- trunk/property/inc/class.sorequest.inc.php  2011-06-30 13:50:58 UTC (rev 
7456)
+++ trunk/property/inc/class.sorequest.inc.php  2011-07-01 13:47:55 UTC (rev 
7457)
@@ -143,35 +143,44 @@
 
                function select_condition_type_list()
                {
-                       $this->db->query("SELECT id, descr, priority_key FROM 
fm_request_condition_type ORDER BY id ");
+                       $this->db->query("SELECT id, descr, priority_key FROM 
fm_request_condition_type ORDER BY id",__LINE__,__FILE__);
 
                        $values = array();
                        while ($this->db->next_record())
                        {
-                               $values[] = array
+                               $id = $this->db->f('id');
+                               $values[$id] = array
                                (
-                                       'id'            => $this->db->f('id'),
+                                       'id'            => $id,
                                        'name'          => 
$this->db->f('descr',true),
-                                       'weight'        => 
$this->db->f('priority_key'),                                        
+                                       'weight'        => 
$this->db->f('priority_key')                                 
                                );
                        }
                        return $values;
                }
 
-               function 
select_conditions($request_id='',$condition_type_list='')
+               function select_conditions($request_id, $condition_type_list = 
array())
                {
-                       $conditions = array();
-                       for ($i=0;$i<count($condition_type_list);$i++)
+                       $request_id = (int)$request_id;
+                       $values = array();
+                       foreach($condition_type_list as $condition_type)
                        {
-                               $this->db->query("SELECT 
degree,probability,consequence FROM fm_request_condition WHERE 
request_id=$request_id AND condition_type =" . 
(int)$condition_type_list[$i]['id']);
+                               $i = (int)$condition_type['id'];
+                               $this->db->query("SELECT * FROM 
fm_request_condition WHERE request_id={$request_id} AND condition_type = 
{$i}",__LINE__,__FILE__);
+
                                $this->db->next_record();
-                               $conditions[$i]['request_id']           = 
$request_id;
-                               $conditions[$i]['degree']                       
= $this->db->f('degree');
-                               $conditions[$i]['probability']          = 
$this->db->f('probability');
-                               $conditions[$i]['consequence']          = 
$this->db->f('consequence');
+
+                               $values[$i] = array
+                               (
+                                       'request_id'            => $request_id,
+                                       'condition_type'        => 
$this->db->f('condition_type'),
+                                       'degree'                        => 
$this->db->f('degree'),
+                                       'probability'           => 
$this->db->f('probability'),
+                                       'consequence'           => 
$this->db->f('consequence')
+                               );
                        }
 
-                       return $conditions;
+                       return $values;
                }
 
 
@@ -616,22 +625,25 @@
 
                        $this->db->query("INSERT INTO fm_request ({$cols}) 
VALUES ({$values})",__LINE__,__FILE__);
 
-                       while (is_array($request['condition']) && 
list($condition_type,$value_type) = each($request['condition']))
+                       if(isset($request['condition']) && 
is_array($request['condition']))
                        {
-                               $this->db->query("INSERT INTO 
fm_request_condition 
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
-                                       . "VALUES ('"
-                                       . $id. "','"
-                                       . $condition_type . "',"
-                                       . $value_type['degree']. ","
-                                       . $value_type['probability']. ","
-                                       . $value_type['consequence']. ","
-                                       . $this->account . ","
-                                       . time() . ")",__LINE__,__FILE__);
+                               foreach( $request['condition'] as 
$condition_type => $value_type )
+                               {
+                                       $_condition_type = 
isset($value_type['condition_type']) && $value_type['condition_type'] ? 
$value_type['condition_type'] : $condition_type;
+                                       $this->db->query("INSERT INTO 
fm_request_condition 
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
+                                               . "VALUES ('"
+                                               . $request['id']. "','"
+                                               . $_condition_type . "',"
+                                               . $value_type['degree']. ","
+                                               . $value_type['probability']. 
","
+                                               . $value_type['consequence']. 
","
+                                               . $this->account . ","
+                                               . time() . 
")",__LINE__,__FILE__);
+                               }
                        }
 
                        $this->update_score($id);
 
-
                        if($request['extra']['contact_phone'] && 
$request['extra']['tenant_id'])
                        {
                                $this->db->query("update fm_tenant set 
contact_phone='". $request['extra']['contact_phone']. "' where id='". 
$request['extra']['tenant_id']. "'",__LINE__,__FILE__);
@@ -791,17 +803,21 @@
                        $this->db->query("UPDATE fm_request SET $value_set 
WHERE id= '{$request['id']}'",__LINE__,__FILE__);
 
                        $this->db->query("DELETE FROM fm_request_condition 
WHERE request_id='{$request['id']}'",__LINE__,__FILE__);
-                       while (is_array($request['condition']) && 
list($condition_type,$value_type) = each($request['condition']))
+                       if(isset($request['condition']) && 
is_array($request['condition']))
                        {
-                               $this->db->query("INSERT INTO 
fm_request_condition 
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
-                                       . "VALUES ('"
-                                       . $request['id']. "','"
-                                       . $condition_type . "',"
-                                       . $value_type['degree']. ","
-                                       . $value_type['probability']. ","
-                                       . $value_type['consequence']. ","
-                                       . $this->account . ","
-                                       . time() . ")",__LINE__,__FILE__);
+                               foreach( $request['condition'] as 
$condition_type => $value_type )
+                               {
+                                       $_condition_type = 
isset($value_type['condition_type']) && $value_type['condition_type'] ? 
$value_type['condition_type'] : $condition_type;
+                                       $this->db->query("INSERT INTO 
fm_request_condition 
(request_id,condition_type,degree,probability,consequence,user_id,entry_date) "
+                                               . "VALUES ('"
+                                               . $request['id']. "','"
+                                               . $_condition_type . "',"
+                                               . $value_type['degree']. ","
+                                                       . 
$value_type['probability']. ","
+                                               . $value_type['consequence']. 
","
+                                               . $this->account . ","
+                                               . time() . 
")",__LINE__,__FILE__);
+                               }
                        }
 
                        $this->update_score($request['id']);

Modified: trunk/property/templates/base/config.tpl
===================================================================
--- trunk/property/templates/base/config.tpl    2011-06-30 13:50:58 UTC (rev 
7456)
+++ trunk/property/templates/base/config.tpl    2011-07-01 13:47:55 UTC (rev 
7457)
@@ -455,6 +455,17 @@
                                </select>
                        </td>
                </tr>
+
+               <tr class="row_off">
+                       
<td>{lang_disallow_multiple_condition_types_at_demands}.</td>
+                       <td>
+                               <select 
name="newsettings[disallow_multiple_condition_types]">
+                                       <option value="" 
{selected_disallow_multiple_condition_types_}>NO</option>
+                                       <option value="1" 
{selected_disallow_multiple_condition_types_1}>YES</option>
+                               </select>
+                       </td>
+               </tr>
+
                <tr class="row_on">
                        <td valign = 'top'>{lang_list_location_level}:</td>
                        <td>

Modified: trunk/property/templates/base/request.xsl
===================================================================
--- trunk/property/templates/base/request.xsl   2011-06-30 13:50:58 UTC (rev 
7456)
+++ trunk/property/templates/base/request.xsl   2011-07-01 13:47:55 UTC (rev 
7457)
@@ -710,22 +710,20 @@
 
        <xsl:template match="condition_list">
                <tr>
-                       <xsl:attribute name="class">
+                       <td class="small_text" align="left">
                                <xsl:choose>
-                                       <xsl:when test="@class">
-                                               <xsl:value-of select="@class"/>
+                                       <xsl:when test="condition_type_list != 
''">
+                                               <xsl:variable 
name="lang_degree_statustext"><xsl:value-of 
select="//lang_degree_statustext"/></xsl:variable>
+                                               <select 
name="values[condition][{condition_type}][condition_type]" class="forms" 
title="{$lang_degree_statustext}">
+                                                       <xsl:apply-templates 
select="condition_type_list/options"/>
+                                               </select>
                                        </xsl:when>
-                                       <xsl:when test="position() mod 2 = 0">
-                                               <xsl:text>row_off</xsl:text>
-                                       </xsl:when>
                                        <xsl:otherwise>
-                                               <xsl:text>row_on</xsl:text>
+                                               <xsl:value-of 
select="condition_type_name"/>
                                        </xsl:otherwise>
                                </xsl:choose>
-                       </xsl:attribute>
-                       <td class="small_text" align="left">
-                               <xsl:value-of select="condition_type_name"/>
                        </td>
+
                        <td class="small_text" align="center">
                                <xsl:variable 
name="lang_degree_statustext"><xsl:value-of 
select="//lang_degree_statustext"/></xsl:variable>
                                <select 
name="values[condition][{condition_type}][degree]" class="forms" 
title="{$lang_degree_statustext}">




reply via email to

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