[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16031] form validation
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16031] form validation |
Date: |
Tue, 29 Nov 2016 12:12:32 +0000 (UTC) |
Revision: 16031
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16031
Author: sigurdne
Date: 2016-11-29 12:12:31 +0000 (Tue, 29 Nov 2016)
Log Message:
-----------
form validation
Modified Paths:
--------------
trunk/property/inc/class.uiproject.inc.php
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/project.xsl
trunk/property/templates/base/workorder.xsl
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2016-11-28 12:41:18 UTC (rev
16030)
+++ trunk/property/inc/class.uiproject.inc.php 2016-11-29 12:12:31 UTC (rev
16031)
@@ -881,8 +881,14 @@
$error_id = true;
}
- if (isset($values['budget']) && $values['budget'] &&
!ctype_digit(ltrim($values['budget'], '-')))
+ if(!$id && empty($values['budget']))
{
+ $this->receipt['error'][] = array('msg' =>
lang('enter the budget'));
+ $error_id = true;
+ }
+
+ if (!empty($values['budget']) &&
!ctype_digit(ltrim($values['budget'], '-')))
+ {
$this->receipt['error'][] = array('msg' =>
lang('budget') . ': ' . lang('Please enter an integer !'));
$error_id = true;
}
@@ -2044,8 +2050,13 @@
'b_account_data' =>
$b_account_data,
'ecodimb_data' => $ecodimb_data,
'contact_data' => $contact_data,
- 'tabs' => self::_generate_tabs($tabs,
$active_tab, array('documents' => $id ? false : true,
- 'history' => $id ? false : true)),
+ 'tabs' => self::_generate_tabs($tabs,
$active_tab, $_disable = array(
+ 'location' => !$id &&
empty($this->receipt['error']) ? true : false,
+ 'budget' => !$id &&
empty($this->receipt['error']) ? true : false,
+ 'coordination' => $id ? false : true,
+ 'documents' => $id ? false : true,
+ 'history' => $id ? false : true
+ )),
'value_active_tab' => $active_tab,
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'value_origin' => isset($values['origin_data'])
? $values['origin_data'] : '',
@@ -2700,7 +2711,7 @@
return $this->bocommon->get_external_project_name($id);
}
- protected function _generate_tabs( $tabs_ = array(),
$active_tab = 'general', $suppress = array() )
+ protected function _generate_tabs( $tabs_ = array(),
$active_tab = 'general', $_disable = array() )
{
$tabs = array
(
@@ -2714,11 +2725,11 @@
);
$tabs = array_merge($tabs, $tabs_);
- foreach ($suppress as $tab => $remove)
+ foreach ($_disable as $tab => $disable)
{
- if ($remove)
+ if ($disable)
{
- unset($tabs[$tab]);
+ $tabs[$tab]['disable'] = true;
}
}
Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php 2016-11-28 12:41:18 UTC
(rev 16030)
+++ trunk/property/inc/class.uiworkorder.inc.php 2016-11-29 12:12:31 UTC
(rev 16031)
@@ -1195,11 +1195,11 @@
if ($id)
{
self::message_set($this->receipt);
- $active_tab = phpgw::get_var('tab');
+ $active_tab =
phpgw::get_var('active_tab');
self::redirect(array(
'menuaction' =>
'property.uiworkorder.edit',
'id' => $id,
- 'tab' => $active_tab));
+ 'active_tab' => $active_tab));
}
$this->edit($values);
@@ -2211,7 +2211,7 @@
$msgbox_data =
$this->bocommon->msgbox_data($this->receipt);
- $active_tab = phpgw::get_var('tab', 'string',
'REQUEST', 'general');
+ $active_tab = phpgw::get_var('active_tab', 'string',
'REQUEST', 'general');
$collect_building_part = false;
$building_part_list = array();
@@ -2255,9 +2255,12 @@
'suppresscoordination' => $suppresscoordination,
'enable_unspsc' => $enable_unspsc,
'enable_order_service_id' =>
$enable_order_service_id,
- 'tabs' => self::_generate_tabs(array(),
$active_tab, array(
+ 'tabs' => self::_generate_tabs(array(),
$active_tab, $_disable = array(
+ 'budget' => !$id &&
empty($this->receipt['error']) ? true : false,
+ 'coordination' => $id ? false : true,
'documents' => $id ? false : true,
'history' => $id ? false : true)),
+ 'value_active_tab' => $active_tab,
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'value_origin' => isset($values['origin_data'])
? $values['origin_data'] : '',
'value_origin_type' => isset($origin) ? $origin
: '',
@@ -2818,7 +2821,7 @@
'redirect' => isset($redirect) && $redirect ?
$GLOBALS['phpgw']->link('/index.php', array(
'menuaction' =>
'property.uiworkorder.edit',
'id' => $order_id,
- 'tab' => 'budget')) : null,
+ 'active_tab' => 'budget')) :
null,
);
$GLOBALS['phpgw']->xslttpl->add_file(array(
@@ -2946,7 +2949,7 @@
return $this->bocommon->get_unspsc_code_name($id);
}
- protected function _generate_tabs( $tabs_ = array(),
$active_tab = 'general', $suppress = array() )
+ protected function _generate_tabs( $tabs_ = array(),
$active_tab = 'general', $_disable = array() )
{
$tabs = array
(
@@ -2973,11 +2976,11 @@
);
$tabs = array_merge($tabs, $tabs_);
- foreach ($suppress as $tab => $remove)
+ foreach ($_disable as $tab => $disable)
{
- if ($remove)
+ if ($disable)
{
- unset($tabs[$tab]);
+ $tabs[$tab]['disable'] = true;
}
}
Modified: trunk/property/js/portico/project.edit.js
===================================================================
--- trunk/property/js/portico/project.edit.js 2016-11-28 12:41:18 UTC (rev
16030)
+++ trunk/property/js/portico/project.edit.js 2016-11-29 12:12:31 UTC (rev
16031)
@@ -125,6 +125,7 @@
$(document).ready(function ()
{
+ check_button_names();
$("#global_category_id").change(function ()
{
@@ -271,7 +272,15 @@
this.validate_form = function ()
{
- return $('form').isValid();
+ conf = {
+ // modules: 'date, security, file',
+ validateOnBlur: false,
+ scrollToTopOnError: true,
+ errorMessagePosition: 'top'
+ // language: validateLanguage
+ };
+
+ return $('form').isValid(false, conf);
}
JqueryPortico.FormatterClosed = function (key, oData)
@@ -311,41 +320,46 @@
}
};
-$(document).ready(function ()
+validate_submit = function ()
{
- check_button_names();
+ var active_tab = $("#active_tab").val();
- $('form[name=form]').submit(function (e)
+ if (!validate_form())
{
- e.preventDefault();
+ return;
+ }
- var active_tab = $("#active_tab").val();
+ if (active_tab === 'general' && Number(project_id) === 0)
+ {
+ $('#tab-content').responsiveTabs('enable', 1);
+ $('#tab-content').responsiveTabs('activate', 1);
+ $("#submitform").val(lang['next']);
+ $("#active_tab").val('location');
+ }
+ else if (active_tab === 'location' && Number(project_id) === 0)
+ {
+ $('#tab-content').responsiveTabs('enable', 2);
+ $('#tab-content').responsiveTabs('activate', 2);
+ $("#submitform").val(lang['save']);
+ $("#active_tab").val('budget');
+ }
+ else
+ {
+ check_and_submit_valid_session();
+ }
- if (!validate_form())
- {
- return;
- }
+};
- if (active_tab === 'general' && Number(project_id) === 0)
- {
- $('#tab-content').responsiveTabs('activate', 1);
- $("#submitform").val(lang['next']);
- $("#active_tab").val('location');
- }
- else if (active_tab === 'location' && Number(project_id) === 0)
- {
- $('#tab-content').responsiveTabs('activate', 2);
- $("#submitform").val(lang['save']);
- $("#active_tab").val('budget');
- }
- else
- {
- check_and_submit_valid_session();
- }
+//$(document).ready(function ()
+//{
+//
+// $('form[name=form]').submit(function (e)
+// {
+// e.preventDefault();
+//
+// });
+//});
- });
-});
-
var oArgs = {menuaction: 'property.uiproject.get_external_project'};
var strURL = phpGWLink('index.php', oArgs, true);
JqueryPortico.autocompleteHelper(strURL, 'external_project_name',
'external_project_id', 'external_project_container');
Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2016-11-28 12:41:18 UTC (rev
16030)
+++ trunk/property/js/portico/workorder.edit.js 2016-11-29 12:12:31 UTC (rev
16031)
@@ -15,11 +15,25 @@
function submit_workorder()
{
+ var active_tab = $("#active_tab").val();
+
if (!validate_form())
{
return;
}
- check_and_submit_valid_session();
+
+ if (active_tab === 'general' && Number(order_id) === 0)
+ {
+ $('#tab-content').responsiveTabs('enable', 1);
+ $('#tab-content').responsiveTabs('activate', 1);
+ $("#save_button").val(lang['save']);
+ $("#save_button_bottom").val(lang['save']);
+ $("#active_tab").val('budget');
+ }
+ else
+ {
+ check_and_submit_valid_session();
+ }
}
@@ -33,38 +47,24 @@
check_and_submit_valid_session();
}
-$(document).ready(function ()
+check_button_names = function ()
{
- $('form[name=form]').submit(function (e)
+ var active_tab = $("#active_tab").val();
+ if (Number(order_id) === 0)
{
- e.preventDefault();
-
- if (!validate_form())
+ if (active_tab === 'general')
{
- return;
+ $("#save_button").val(lang['next']);
+ $("#save_button_bottom").val(lang['next']);
}
- check_and_submit_valid_session();
- });
-
- $.formUtils.addValidator({
- name: 'budget',
- validatorFunction: function (value, $el, config, languaje,
$form)
+ else
{
- //check_for_budget is defined in xsl-template
- var v = false;
- var budget = $('#field_budget').val();
- var contract_sum = $('#field_contract_sum').val();
- if ((budget != "" || contract_sum != "") ||
(check_for_budget > 0))
- {
- v = true;
- }
- return v;
- },
- errorMessage: lang['please enter either a budget or contrakt
sum'],
- errorMessageKey: ''
- });
+ $("#save_button").val(lang['save']);
+ $("#save_button_bottom").val(lang['save']);
+ }
+ }
+};
-});
function receive_order(workorder_id)
{
@@ -149,9 +149,10 @@
return $('form').isValid(validateLanguage, conf);
}
-function set_tab(tab)
+function set_tab(active_tab)
{
- $("#order_tab").val(tab);
+ $("#active_tab").val(active_tab);
+ check_button_names();
}
this.showlightbox_manual_invoice = function (workorder_id)
@@ -279,6 +280,37 @@
$(document).ready(function ()
{
+ check_button_names();
+
+// $('form[name=form]').submit(function (e)
+// {
+// e.preventDefault();
+//
+// if (!validate_form())
+// {
+// return;
+// }
+// check_and_submit_valid_session();
+// });
+
+ $.formUtils.addValidator({
+ name: 'budget',
+ validatorFunction: function (value, $el, config, languaje,
$form)
+ {
+ //check_for_budget is defined in xsl-template
+ var v = false;
+ var budget = $('#field_budget').val();
+ var contract_sum = $('#field_contract_sum').val();
+ if ((budget != "" || contract_sum != "") ||
(check_for_budget > 0))
+ {
+ v = true;
+ }
+ return v;
+ },
+ errorMessage: lang['please enter either a budget or contrakt
sum'],
+ errorMessageKey: ''
+ });
+
$("#global_category_id").change(function ()
{
var oArgs = {menuaction: 'property.boworkorder.get_category',
cat_id: $(this).val()};
@@ -552,7 +584,7 @@
}
else
{
- //
required = 'checked="checked"';
+ //
required = 'checked="checked"';
}
}
else
@@ -598,7 +630,7 @@
$("#approval_container").html(htmlString);
}
},
- error: function()
+ error: function ()
{
alert('feil med oppslag til fullmakter');
}
Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl 2016-11-28 12:41:18 UTC (rev
16030)
+++ trunk/property/templates/base/project.xsl 2016-11-29 12:12:31 UTC (rev
16031)
@@ -76,7 +76,7 @@
</xsl:variable>
<td>
<input type="hidden" name='save' value=""/>
-
<input type="submit" id="submitform" class="pure-button
pure-button-primary" name="values[save]" value="{$lang_save}">
+
<input type="button" id="submitform" class="pure-button
pure-button-primary" name="values[save]" value="{$lang_save}"
onClick="validate_submit();">
<xsl:attribute name="title">
<xsl:value-of select="lang_save_statustext"/>
</xsl:attribute>
Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2016-11-28 12:41:18 UTC (rev
16030)
+++ trunk/property/templates/base/workorder.xsl 2016-11-29 12:12:31 UTC (rev
16031)
@@ -168,7 +168,7 @@
<xsl:value-of select="decimal_separator"/>
</xsl:variable>
- <input id="order_tab" type="hidden" name="tab" value=""/>
+ <input type="hidden" id="active_tab" name="active_tab"
value="{value_active_tab}"/>
<div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="tabs"/>
<div id="floating-box">
@@ -1234,7 +1234,7 @@
</xsl:when>
</xsl:choose>
<script type="text/javascript">
- var lang = <xsl:value-of
select="php:function('js_lang', 'please enter either a budget or contrakt
sum')"/>;
+ var lang = <xsl:value-of
select="php:function('js_lang', 'please enter either a budget or contrakt sum',
'next', 'save')"/>;
var check_for_budget = <xsl:value-of
select="check_for_budget"/>;
var amount = <xsl:value-of
select="check_value_budget"/>;
var project_ecodimb = '<xsl:value-of
select="project_ecodimb"/>';
@@ -1247,7 +1247,7 @@
<xsl:choose>
<xsl:when test="mode='edit'">
<input type="hidden"
name="values[save]" value="1"/>
- <input type="submit" class="pure-button
pure-button-primary" name="save" value="{$lang_save}">
+ <input type="button" class="pure-button
pure-button-primary" id="save_button_bottom" name="save" value="{$lang_save}"
onClick="submit_workorder();">
<xsl:attribute name="title">
<xsl:value-of
select="lang_save_statustext"/>
</xsl:attribute>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16031] form validation,
sigurdne <=