View | Details | Raw Unified | Return to bug 12310
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug12310_add_DecimalSeparators.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('DecimalSeparators',  ',.', NULL ,  'The allowed separators between entire and decimal parts of numbers',  'Free');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 139-144 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
139
('DefaultToLoggedInLibraryNoticesSlips',  '0', NULL ,  'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
139
('DefaultToLoggedInLibraryNoticesSlips',  '0', NULL ,  'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
140
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
140
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
141
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
141
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
142
('DecimalSeparators',  '.,', NULL ,  'The allowed separators between entire and decimal parts of numbers',  'Free'),
142
('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','Choice'),
143
('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','Choice'),
143
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
144
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
144
('displayFacetCount','0',NULL,NULL,'YesNo'),
145
('displayFacetCount','0',NULL,NULL,'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc (+47 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE JSON.Escape %]
3
4
<script type="text/javascript">
5
var decimal = (function() {
6
7
    var is_decimal = function(input) {
8
        // JSON escaping to handle the strange case of " in the syspref
9
        var separators = [% Koha.Preference('DecimalSeparators').json %];
10
        var regex = "[0-9]{1,}(["+separators+"][0-9]{1,}|)";
11
        var decimal = new RegExp(regex);
12
        if (decimal.test(input)) {
13
            return true;
14
        }
15
        return false;
16
    }
17
18
    var decimal_from_string = function(formatted_decimal) {
19
        // remove everything except digits, minuses, and the chars in DecimalSeparators syspref
20
        var formatted_decimal = formatted_decimal
21
                              .replace(/[^0-9-[% Koha.Preference('DecimalSeparators') %]]/g, '');
22
        var decimal = formatted_decimal
23
                    .replace(/[[% Koha.Preference('DecimalSeparators') %]]/g, '.');
24
        return decimal;
25
    }
26
27
    return {
28
        /**
29
         * Handler made to process an <input> field containing a decimal number
30
         * to unformat it. So it can be processed by the server without having
31
         * to care about decimal separators (see DecimalSeparators syspref) and
32
         * currency symbols for example.
33
         */
34
        handler_unformat_input: function(field) {
35
            if (is_decimal(field.value)) {
36
                field.value = decimal_from_string(field.value);
37
            }
38
        }
39
    };
40
41
})();
42
43
// equivalent of $(document).ready, jQuery hasn't load yet so vanilla JS version
44
document.addEventListener("DOMContentLoaded", function() {
45
    $(".decimal-unformating").on("change", function() {decimal.handler_unformat_input(this)});
46
});
47
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (-1 / +1 lines)
Lines 28-34 Acquisitions: Link Here
28
                  branch: from staff member's library.
28
                  branch: from staff member's library.
29
                  all: in system, regardless of owner.
29
                  all: in system, regardless of owner.
30
        -
30
        -
31
            - Display currencies using the following format
31
            - Display currencies using the following format. It you want to choose the possible decimal separators for price input, please use the system preference 'DecimalSeparators'.
32
            - pref: CurrencyFormat
32
            - pref: CurrencyFormat
33
              choices:
33
              choices:
34
                  US: 360,000.00 (US)
34
                  US: 360,000.00 (US)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref (+4 lines)
Lines 68-70 I18N/L10N: Link Here
68
              no: "Don't allow"
68
              no: "Don't allow"
69
        - notices to be translated.
69
        - notices to be translated.
70
        - If set, notices will be translatable from the "Notices and Slips" interface. The language used to send a notice to a patron will be the one defined for the patron.
70
        - If set, notices will be translatable from the "Notices and Slips" interface. The language used to send a notice to a patron will be the one defined for the patron.
71
    -
72
        - "Any of these characters can be used as a separator between integer and decimal parts in the price fields. To work well with thousands separators you must (usually) choose between dot and comma to avoid ambiguity. So thousands separators come at the expense of handling both dots and commas. It you want to format price output, please use the system preference 'CurrencyFormat'"
73
        - pref: DecimalSeparators
74
          class: long
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-1 / +3 lines)
Lines 4-9 Link Here
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Patrons &rsaquo; Create manual credit</title>
5
<title>Koha &rsaquo; Patrons &rsaquo; Create manual credit</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'decimal-input-js.inc' %]
7
</head>
8
</head>
8
9
9
<body id="pat_mancredit" class="pat">
10
<body id="pat_mancredit" class="pat">
Lines 41-47 Link Here
41
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
42
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
42
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
43
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
43
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
44
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
44
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
45
    <li><label for="amount">Amount: </label><input name="amount" id="amount" class="decimal-unformating" required="required" value="" step="any" min="0" /></li>
46
45
</ol></fieldset>
47
</ol></fieldset>
46
48
47
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></fieldset>
49
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (-1 / +2 lines)
Lines 54-60 Link Here
54
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
54
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
55
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
55
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
56
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
56
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
57
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
57
    <li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" class="decimal-unformating" required="required"/></li>
58
	</ol></fieldset>
58
	</ol></fieldset>
59
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></fieldset>
59
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a></fieldset>
60
</form>
60
</form>
Lines 70-75 Link Here
70
</div>
70
</div>
71
</div>
71
</div>
72
72
73
[% INCLUDE 'decimal-input-js.inc' %]
73
[% MACRO jsinclude BLOCK %]
74
[% MACRO jsinclude BLOCK %]
74
    [% Asset.js("js/members-menu.js") %]
75
    [% Asset.js("js/members-menu.js") %]
75
    <script type="text/javascript">
76
    <script type="text/javascript">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-54 / +4 lines)
Lines 85-91 Link Here
85
    <li>
85
    <li>
86
        <label for="paid">Collect from patron: </label>
86
        <label for="paid">Collect from patron: </label>
87
            <!-- default to paying all -->
87
            <!-- default to paying all -->
88
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
88
        <input name="paid" id="paid" class="decimal-unformating" value="[% amountoutstanding %]" />
89
    </li>
89
    </li>
90
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
90
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
91
    [% IF payment_types %]
91
    [% IF payment_types %]
Lines 164-170 Link Here
164
    <li>
164
    <li>
165
        <label for="paid">Collect from patron: </label>
165
        <label for="paid">Collect from patron: </label>
166
        <!-- default to paying all -->
166
        <!-- default to paying all -->
167
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
167
        <input name="paid" id="paid" class="decimal-unformating" value="[% total | format('%.2f') %]" />
168
    </li>
168
    </li>
169
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
169
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
170
    [% IF payment_types %]
170
    [% IF payment_types %]
Lines 202-261 Link Here
202
    <script type= "text/javascript">
202
    <script type= "text/javascript">
203
        $(document).ready(function() {
203
        $(document).ready(function() {
204
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
204
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
205
            $("#paid").on("change",function(){
206
                moneyFormat( this );
207
            });
208
        });
205
        });
206
    </script>
209
207
210
        function moneyFormat(textObj) {
208
    [% INCLUDE 'decimal-input-js.inc' %]
211
            var newValue = textObj.value;
212
            var decAmount = "";
213
            var dolAmount = "";
214
            var decFlag   = false;
215
            var aChar     = "";
216
217
            for(i=0; i < newValue.length; i++) {
218
                aChar = newValue.substring(i, i+1);
219
                if (aChar >= "0" && aChar <= "9") {
220
                    if(decFlag) {
221
                        decAmount = "" + decAmount + aChar;
222
                    }
223
                    else {
224
                        dolAmount = "" + dolAmount + aChar;
225
                    }
226
                }
227
                if (aChar == ".") {
228
                    if (decFlag) {
229
                        dolAmount = "";
230
                        break;
231
                    }
232
                    decFlag = true;
233
                }
234
            }
235
236
            if (dolAmount == "") {
237
                dolAmount = "0";
238
            }
239
        // Strip leading 0s
240
            if (dolAmount.length > 1) {
241
                while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
242
                    dolAmount = dolAmount.substring(1,dolAmount.length);
243
                }
244
            }
245
            if (decAmount.length > 2) {
246
                decAmount = decAmount.substring(0,2);
247
            }
248
        // Pad right side
249
            if (decAmount.length == 1) {
250
               decAmount = decAmount + "0";
251
            }
252
            if (decAmount.length == 0) {
253
               decAmount = decAmount + "00";
254
            }
255
209
256
            textObj.value = dolAmount + "." + decAmount;
257
        }
258
    </script>
259
[% END %]
210
[% END %]
260
211
261
[% INCLUDE 'intranet-bottom.inc' %]
212
[% INCLUDE 'intranet-bottom.inc' %]
262
- 

Return to bug 12310