Bugzilla – Attachment 60530 Details for
Bug 12310
Decimal separators issues in patrons payments/fines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
BUG 12310 : Modified scripts in order to convert any string to the good format
BUG-12310--Modified-scripts-in-order-to-convert-an.patch (text/plain), 5.21 KB, created by
Baptiste
on 2017-02-21 16:08:42 UTC
(
hide
)
Description:
BUG 12310 : Modified scripts in order to convert any string to the good format
Filename:
MIME Type:
Creator:
Baptiste
Created:
2017-02-21 16:08:42 UTC
Size:
5.21 KB
patch
obsolete
>From 01309cdc4c06ecbd0beafa100eb73da95fcbf009 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Tue, 21 Feb 2017 15:47:36 +0000 >Subject: [PATCH] BUG 12310 : Modified scripts in order to convert any string > to the good format > >paxed's solution is obsolete since the form asks for a number. > >The script includes 2 function which check if it is possible to transform >properly into the format "XX.XX" and which do it. >The money symbols are ignored. >All spaces (before or after) are ignored. > >Test plan : >1) Check you can't enter any string except like "XX.XX" when > - you create a Budget (Administration->Budget) > - you write a fine (Circulation->[select a Borrower]->new fine ) >2) Apply patch >3) Check you can enter any string with > - $, "Euro" (before or after), or nothing > - , or . as separator > - no more than 2 digits after separator > - as much digits as you wish before the separator > - as much spaces as you wish before or after the number >--- > .../intranet-tmpl/prog/en/includes/prices.inc | 23 ++++++++++++++++++ > .../prog/en/modules/admin/aqbudgetperiods.tt | 5 +++- > .../prog/en/modules/members/maninvoice.tt | 28 +++++++++++++++++++++- > 3 files changed, 54 insertions(+), 2 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc >new file mode 100644 >index 0000000..1188448 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc >@@ -0,0 +1,23 @@ >+[% USE Koha %] >+<script type="text/javascript"> >+//<![CDATA[ >+ >+function isPrice(string){ >+ var prix = new RegExp("^[$|â¬]{0,1}[ ]{0,}[0-9]{1,10}(([,|.][0-9]{0,2})|)([ ]{0,})([$|â¬]|)([ ]{0,})$"); >+ if (!prix.test(string)) { >+ return false; >+ } >+ return true; >+} >+ >+function Price_from_string(string){ >+ if (!isPrice(string)) { >+ return false; >+ } >+ string = string.replace(/[\s+|â¬|$]/g, ''); >+ string = string.replace(/,/g, '.'); >+ return string; >+} >+ >+//]]> >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >index a74329c..aa2c35b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >@@ -27,6 +27,7 @@ > [% END -%] > > [% INCLUDE 'doc-head-open.inc' %] >+[% INCLUDE 'prices.inc' %] > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> > [% INCLUDE 'doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] >@@ -87,8 +88,10 @@ > _alertString += "\n- " + _("Description missing"); > } > >- if (!(isNum(f.budget_period_total))) { >+ if (!(isPrice(f.budget_period_total.value))) { > _alertString += "\n- " + _("Amount must be a valid number, or empty"); >+ }else{ >+ f.budget_period_total.value=Price_from_string(f.budget_period_total.value); > } > > /* >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >index 7d35c73..d67e946 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >@@ -70,7 +70,7 @@ type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.li > <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li> > <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li> > <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li> >- <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li> >+ <li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" required="required"/> </li> > </ol></fieldset> > <fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset> > </form> >@@ -85,4 +85,30 @@ type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.li > [% INCLUDE 'circ-menu.inc' %] > </div> > </div> >+ >+[% INCLUDE 'prices.inc' %] >+ >+<script type="text/javascript"> >+$('#maninvoice').on('submit', function(){Check(this)}); >+function Check(f){ >+ var ok=1; >+ var _alertString=""; >+ var alertString2; >+ if (!(isPrice(f.amount.value))) { >+ _alertString += "\n- " + _("Amount must be a valid number, or empty"); >+ }else{ >+ f.amount.value=Price_from_string(f.amount.value); >+ } >+ if (_alertString.length==0) { >+ return true; >+ } else { >+ alertString2 = _("Form not submitted because of the following problem(s)"); >+ alertString2 += "\n------------------------------------------------------------------------------------\n"; >+ alertString2 += _alertString; >+ alert(alertString2); >+ return false; >+ } >+} >+</script> >+ > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12310
:
28455
|
60530
|
60563
|
61357
|
61603
|
61604
|
62655
|
64671
|
64672
|
64673
|
64674
|
64675
|
64678
|
64679
|
64696
|
72104
|
72213
|
72983
|
73055
|
73215
|
73546
|
73657
|
73784
|
73785
|
73873
|
73874
|
73880
|
74524
|
74525
|
74526
|
74527
|
74528
|
74529
|
75123
|
75127
|
75128
|
75129
|
75130
|
75947
|
75948
|
75949
|
75950
|
75951
|
75952
|
75954
|
75955
|
75956
|
75957
|
75958
|
75959
|
76896
|
76933
|
77971
|
77972
|
77973
|
77995
|
78017
|
78631
|
78632
|
78633
|
78634
|
78635
|
78636
|
78637
|
78638