fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16128] property: validate parameter


From: sigurdne
Subject: [Fmsystem-commits] [16128] property: validate parameter
Date: Sun, 1 Jan 2017 18:05:51 +0000 (UTC)

Revision: 16128
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16128
Author:   sigurdne
Date:     2017-01-01 18:05:50 +0000 (Sun, 01 Jan 2017)
Log Message:
-----------
property: validate parameter

Modified Paths:
--------------
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/property/js/portico/project.edit.js
    trunk/property/js/portico/workorder.edit.js
    trunk/property/templates/base/cat_sub_select.xsl
    trunk/property/templates/base/project.xsl
    trunk/property/templates/base/workorder.xsl

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2017-01-01 18:04:24 UTC 
(rev 16127)
+++ trunk/property/inc/class.uiworkorder.inc.php        2017-01-01 18:05:50 UTC 
(rev 16128)
@@ -2192,6 +2192,8 @@
                        $_cat_sub = $this->cats->return_sorted_array($start = 
0, $limit = false, $query = '', $sort = '', $order = '', $globals = False, 
false);
 
                        $selected_cat = $values['cat_id'] ? $values['cat_id'] : 
$project['cat_id'];
+                       $validatet_category = '';
+
                        $cat_sub = array();
                        foreach ($_cat_sub as $entry)
                        {
@@ -2199,6 +2201,18 @@
                                {
                                        continue;
                                }
+
+                               if(!$validatet_category)
+                               {
+                                       if ($entry['active'] && $entry['id'] == 
$selected_cat)
+                                       {
+                                               $_category = 
$this->cats->return_single($entry['id']);
+                                               if($_category[0]['is_node'])
+                                               {
+                                                       $validatet_category = 1;
+                                               }
+                                       }
+                               }
                                $entry['name'] = str_repeat(' . ', 
(int)$entry['level']) . $entry['name'];
                                $entry['title'] = $entry['description'];
                                $cat_sub[] = $entry;
@@ -2378,6 +2392,7 @@
                                'cat_sub_list' => 
$this->bocommon->select_list($selected_cat, $cat_sub),
                                'cat_sub_name' => 'values[cat_id]',
                                'lang_cat_sub_statustext' => lang('select sub 
category'),
+                               'validatet_category'    => $validatet_category,
                                'sum_workorder_budget' => 
(isset($values['sum_workorder_budget']) ? $values['sum_workorder_budget'] : ''),
                                'workorder_budget' => 
(isset($values['workorder_budget']) ? $values['workorder_budget'] : ''),
                                'lang_coordinator' => lang('Coordinator'),

Modified: trunk/property/js/portico/project.edit.js
===================================================================
--- trunk/property/js/portico/project.edit.js   2017-01-01 18:04:24 UTC (rev 
16127)
+++ trunk/property/js/portico/project.edit.js   2017-01-01 18:05:50 UTC (rev 
16128)
@@ -127,6 +127,24 @@
 {
        check_button_names();
 
+       $.formUtils.addValidator({
+               name: 'category',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var validatet_category = $('#validatet_category').val();
+                       if(validatet_category ==1)
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               },
+               errorMessage: 'Ugyldig kategori',
+               errorMessageKey: ''
+       });
+
        $("#global_category_id").change(function ()
        {
                var oArgs = {menuaction: 'property.boworkorder.get_category', 
cat_id: $(this).val()};

Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2017-01-01 18:04:24 UTC (rev 
16127)
+++ trunk/property/js/portico/workorder.edit.js 2017-01-01 18:05:50 UTC (rev 
16128)
@@ -313,6 +313,24 @@
                errorMessageKey: ''
        });
 
+       $.formUtils.addValidator({
+               name: 'category',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var validatet_category = $('#validatet_category').val();
+                       if(validatet_category ==1)
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               },
+               errorMessage: 'Ugyldig kategori',
+               errorMessageKey: ''
+       });
+
        $("#global_category_id").change(function ()
        {
                var oArgs = {menuaction: 'property.boworkorder.get_category', 
cat_id: $(this).val()};
@@ -328,10 +346,15 @@
                        {
                                if (data != null)
                                {
-                                       if (data.active != 1)
+                                       if (data.active != 1 || data.is_node 
=== false)
                                        {
                                                alert('Denne kan ikke velges');
+                                               
$('#validatet_category').val('');
                                        }
+                                       else
+                                       {
+                                               $('#validatet_category').val(1);
+                                       }
                                }
                        }
                });
@@ -541,10 +564,10 @@
 
 
        var total_amount = Math.max((contract_sum - Number(local_value_budget) 
+ Number(accumulated_budget_amount)),
-       (budget_sum - Number(local_value_budget) + 
Number(accumulated_budget_amount)),
-       (Number(local_value_budget),Number(accumulated_budget_amount)));
+               (budget_sum - Number(local_value_budget) + 
Number(accumulated_budget_amount)),
+               (Number(local_value_budget), 
Number(accumulated_budget_amount)));
 
-       var order_received_amount = Math.max(contract_sum,      budget_sum,     
Number(local_value_budget));
+       var order_received_amount = Math.max(contract_sum, budget_sum, 
Number(local_value_budget));
 
        $("#order_received_amount").val(order_received_amount);
 

Modified: trunk/property/templates/base/cat_sub_select.xsl
===================================================================
--- trunk/property/templates/base/cat_sub_select.xsl    2017-01-01 18:04:24 UTC 
(rev 16127)
+++ trunk/property/templates/base/cat_sub_select.xsl    2017-01-01 18:05:50 UTC 
(rev 16128)
@@ -1,32 +1,36 @@
 
 <!-- $Id$ -->
 <xsl:template name="cat_sub_select">
-               <xsl:variable name="lang_cat_sub_statustext">
-                       <xsl:value-of select="lang_cat_sub_statustext"/>
-               </xsl:variable>
-               <xsl:variable name="cat_sub_name">
-                       <xsl:value-of select="cat_sub_name"/>
-               </xsl:variable>
-               <select id = "global_category_id" name="{$cat_sub_name}" 
class="forms" title="{$lang_cat_sub_statustext}">
-                       <xsl:apply-templates select="cat_sub_list"/>
-               </select>
+       <xsl:variable name="lang_cat_sub_statustext">
+               <xsl:value-of select="lang_cat_sub_statustext"/>
+       </xsl:variable>
+       <xsl:variable name="cat_sub_name">
+               <xsl:value-of select="cat_sub_name"/>
+       </xsl:variable>
+       <select id = "global_category_id" name="{$cat_sub_name}" class="forms" 
title="{$lang_cat_sub_statustext}">
+               <xsl:attribute name="data-validation">
+                       <xsl:text>category</xsl:text>
+               </xsl:attribute>
+
+               <xsl:apply-templates select="cat_sub_list"/>
+       </select>
 </xsl:template>
 
 <!-- New template-->
 <xsl:template match="cat_sub_list">
-               <xsl:variable name="id">
-                       <xsl:value-of select="id"/>
-               </xsl:variable>
-               <xsl:choose>
-                       <xsl:when test="selected">
-                               <option value="{$id}" selected="selected" 
title="{title}">
-                                       <xsl:value-of 
disable-output-escaping="yes" select="name"/>
-                               </option>
-                       </xsl:when>
-                       <xsl:otherwise>
-                               <option value="{$id}"  title="{title}">
-                                       <xsl:value-of 
disable-output-escaping="yes" select="name"/>
-                               </option>
-                       </xsl:otherwise>
-               </xsl:choose>
+       <xsl:variable name="id">
+               <xsl:value-of select="id"/>
+       </xsl:variable>
+       <xsl:choose>
+               <xsl:when test="selected">
+                       <option value="{$id}" selected="selected" 
title="{title}">
+                               <xsl:value-of disable-output-escaping="yes" 
select="name"/>
+                       </option>
+               </xsl:when>
+               <xsl:otherwise>
+                       <option value="{$id}"  title="{title}">
+                               <xsl:value-of disable-output-escaping="yes" 
select="name"/>
+                       </option>
+               </xsl:otherwise>
+       </xsl:choose>
 </xsl:template>

Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl   2017-01-01 18:04:24 UTC (rev 
16127)
+++ trunk/property/templates/base/project.xsl   2017-01-01 18:05:50 UTC (rev 
16128)
@@ -47,6 +47,7 @@
                        <xsl:value-of select="decimal_separator"/>
                </xsl:variable>
                <input type="hidden" id="active_tab" name="active_tab" 
value="{value_active_tab}"/>
+               <input type="hidden" name='validatet_category' 
id="validatet_category" value="1"/>
                <div id="tab-content">
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
 

Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2017-01-01 18:04:24 UTC (rev 
16127)
+++ trunk/property/templates/base/workorder.xsl 2017-01-01 18:05:50 UTC (rev 
16128)
@@ -164,6 +164,8 @@
        <form ENCTYPE="multipart/form-data" method="post" id='form' name="form" 
action="{$form_action}" class= "pure-form pure-form-aligned">
                <input type="hidden" name="send_workorder" value=""/>
                <input type="hidden" name='calculate_workorder'  value=""/>
+               <input type="hidden" name='validatet_category' 
id="validatet_category" value="{validatet_category}"/>
+
                <xsl:variable name="decimal_separator">
                        <xsl:value-of select="decimal_separator"/>
                </xsl:variable>




reply via email to

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