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 137-142 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
137
('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'),
137
('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'),
138
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
138
('DefaultToLoggedInLibraryOverdueTriggers',  '0', NULL ,  'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.',  'YesNo'),
139
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
139
('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'),
140
('DecimalSeparators',  '.,', NULL ,  'The allowed separators between entire and decimal parts of numbers',  'Free'),
140
('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'),
141
('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'),
141
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
142
('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'),
142
('displayFacetCount','0',NULL,NULL,'YesNo'),
143
('displayFacetCount','0',NULL,NULL,'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc (+50 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
        if (!is_decimal(formatted_decimal)) {
20
            return false;
21
        }
22
        // remove everything except digits, minuses, and the chars in DecimalSeparators syspref
23
        var formatted_decimal = formatted_decimal
24
                              .replace(/[^0-9-[% Koha.Preference('DecimalSeparators') %]]/g, '');
25
        var decimal = formatted_decimal
26
                    .replace(/[[% Koha.Preference('DecimalSeparators') %]]/g, '.');
27
        return decimal;
28
    }
29
30
    return {
31
        /**
32
         * Handler made to process an <input> field containing a decimal number
33
         * to unformat it. So it can be processed by the server without having
34
         * to care about decimal separators (see DecimalSeparators syspref) and
35
         * currency symbols for example.
36
         */
37
        handler_unformat_input: function(field) {
38
            if (is_decimal(field.value)) {
39
                field.value = decimal_from_string(field.value);
40
            }
41
        }
42
    };
43
44
})();
45
46
// equivalent of $(document).ready, jQuery hasn't load yet so vanilla JS version
47
document.addEventListener("DOMContentLoaded", function() {
48
    $(".decimal-unformating").on("change", function() {decimal.handler_unformat_input(this)});
49
});
50
</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 66-68 I18N/L10N: Link Here
66
              no: "Don't allow"
66
              no: "Don't allow"
67
        - notices to be translated.
67
        - notices to be translated.
68
        - 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.
68
        - 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.
69
    -
70
        - "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'"
71
        - pref: DecimalSeparators
72
          class: long
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-1 / +3 lines)
Lines 3-8 Link Here
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons &rsaquo; Create manual credit</title>
4
<title>Koha &rsaquo; Patrons &rsaquo; Create manual credit</title>
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'decimal-input-js.inc' %]
6
</head>
7
</head>
7
8
8
<body id="pat_mancredit" class="pat">
9
<body id="pat_mancredit" class="pat">
Lines 40-46 Link Here
40
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
41
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
41
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
42
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
42
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
43
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
43
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
44
    <li><label for="amount">Amount: </label><input name="amount" id="amount" class="decimal-unformating" required="required" value="" step="any" min="0" /></li>
45
44
</ol></fieldset>
46
</ol></fieldset>
45
47
46
<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>
48
<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 53-59 Link Here
53
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
53
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
54
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
54
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
55
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
55
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
56
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
56
    <li><label for="amount">Amount: </label><input type="text" name="amount" id="amount" class="decimal-unformating" required="required"/></li>
57
	</ol></fieldset>
57
	</ol></fieldset>
58
<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>
58
<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
</form>
59
</form>
Lines 69-74 Link Here
69
</div>
69
</div>
70
</div>
70
</div>
71
71
72
[% INCLUDE 'decimal-input-js.inc' %]
72
[% MACRO jsinclude BLOCK %]
73
[% MACRO jsinclude BLOCK %]
73
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
74
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu_[% KOHA_VERSION %].js"></script>
74
    <script type="text/javascript">
75
    <script type="text/javascript">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-55 / +5 lines)
Lines 83-89 Link Here
83
    <li>
83
    <li>
84
        <label for="paid">Collect from patron: </label>
84
        <label for="paid">Collect from patron: </label>
85
            <!-- default to paying all -->
85
            <!-- default to paying all -->
86
        <input name="paid" id="paid" value="[% amountoutstanding %]" />
86
        <input name="paid" id="paid" class="decimal-unformating" value="[% amountoutstanding %]" />
87
    </li>
87
    </li>
88
</ol>
88
</ol>
89
</fieldset>
89
</fieldset>
Lines 150-156 Link Here
150
    <li>
150
    <li>
151
        <label for="paid">Collect from patron: </label>
151
        <label for="paid">Collect from patron: </label>
152
        <!-- default to paying all -->
152
        <!-- default to paying all -->
153
        <input name="paid" id="paid" value="[% total | format('%.2f') %]" />
153
        <input name="paid" id="paid" class="decimal-unformating" value="[% total | format('%.2f') %]" />
154
    </li>
154
    </li>
155
    <li>
155
    <li>
156
        <label for="selected_accts_notes">Note: </label>
156
        <label for="selected_accts_notes">Note: </label>
Lines 176-235 Link Here
176
    <script type= "text/javascript">
176
    <script type= "text/javascript">
177
        $(document).ready(function() {
177
        $(document).ready(function() {
178
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
178
            $('#payindivfine, #woindivfine, #payfine').preventDoubleFormSubmit();
179
            $("#paid").on("change",function(){
180
                moneyFormat( this );
181
            });
182
        });
179
        });
183
184
        function moneyFormat(textObj) {
185
            var newValue = textObj.value;
186
            var decAmount = "";
187
            var dolAmount = "";
188
            var decFlag   = false;
189
            var aChar     = "";
190
191
            for(i=0; i < newValue.length; i++) {
192
                aChar = newValue.substring(i, i+1);
193
                if (aChar >= "0" && aChar <= "9") {
194
                    if(decFlag) {
195
                        decAmount = "" + decAmount + aChar;
196
                    }
197
                    else {
198
                        dolAmount = "" + dolAmount + aChar;
199
                    }
200
                }
201
                if (aChar == ".") {
202
                    if (decFlag) {
203
                        dolAmount = "";
204
                        break;
205
                    }
206
                    decFlag = true;
207
                }
208
            }
209
210
            if (dolAmount == "") {
211
                dolAmount = "0";
212
            }
213
        // Strip leading 0s
214
            if (dolAmount.length > 1) {
215
                while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
216
                    dolAmount = dolAmount.substring(1,dolAmount.length);
217
                }
218
            }
219
            if (decAmount.length > 2) {
220
                decAmount = decAmount.substring(0,2);
221
            }
222
        // Pad right side
223
            if (decAmount.length == 1) {
224
               decAmount = decAmount + "0";
225
            }
226
            if (decAmount.length == 0) {
227
               decAmount = decAmount + "00";
228
            }
229
230
            textObj.value = dolAmount + "." + decAmount;
231
        }
232
    </script>
180
    </script>
181
182
    [% INCLUDE 'decimal-input-js.inc' %]
183
233
[% END %]
184
[% END %]
234
185
235
[% INCLUDE 'intranet-bottom.inc' %]
186
[% INCLUDE 'intranet-bottom.inc' %]
236
- 

Return to bug 12310