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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc (+24 lines)
Line 0 Link Here
1
[% USE Koha %]
2
3
<script type="text/javascript">
4
    var currency_format = "[% Koha.Preference('CurrencyFormat') %]";
5
    if (currency_format === "US" || currency_format === "CH") {
6
        var decimal_separator = ".";
7
    } else if (currency_format === "FR") {
8
        var decimal_separator = ",";
9
    } else {
10
        console.error("Unhandled value for currency_format: \"" + currency_format +"\" You should report this issue to avoid unexpected behavior with numbers. Note that you should also check the code displaying the example value in manual invoice and credit pages.")
11
        var decimal_separator = ".";
12
    }
13
14
    // allow only non-decimal numbers and decimal numbers containing a dot or a comma
15
    jQuery.validator.addMethod("is_decimal_number", function(value, element){
16
        return /^\d+(\.|,)?\d*$/.test(value);
17
    }, _("Please input a decimal number without thousands separators"));
18
19
    jQuery.validator.addMethod("uses_correct_decimal_separator", function(value, element){
20
        var non_decimal_number = /^\d+$/.test(value);
21
        var correct_decimal_number = value.indexOf(decimal_separator) !== -1;
22
        return non_decimal_number || correct_decimal_number;
23
    }, _("Please do not use thousands separators and only the decimal separator shown in the example: "));
24
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt (-1 / +13 lines)
Lines 44-50 Link Here
44
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
44
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
45
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
45
	<li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li>
46
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
46
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
47
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
47
    <li><label for="amount">Amount: </label><input name="amount" id="amount" value="" /> <span>Example:</span> 5[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li>
48
48
</ol></fieldset>
49
</ol></fieldset>
49
50
50
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
51
<fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
Lines 63-72 Link Here
63
[% MACRO jsinclude BLOCK %]
64
[% MACRO jsinclude BLOCK %]
64
    [% INCLUDE 'str/members-menu.inc' %]
65
    [% INCLUDE 'str/members-menu.inc' %]
65
    [% Asset.js("js/members-menu.js") | $raw %]
66
    [% Asset.js("js/members-menu.js") | $raw %]
67
    [% INCLUDE 'decimal-input-js.inc' %]
66
    <script type="text/javascript">
68
    <script type="text/javascript">
67
        $(document).ready(function(){
69
        $(document).ready(function(){
68
            $('#mancredit').preventDoubleFormSubmit();
70
            $('#mancredit').preventDoubleFormSubmit();
69
            $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
71
            $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
72
73
            // decimal input
74
            $("#mancredit").validate({
75
                rules: {
76
                    amount: {
77
                        is_decimal_number: true,
78
                        uses_correct_decimal_separator: true
79
                    },
80
                }
81
            });
70
        });
82
        });
71
    </script>
83
    </script>
72
[% END %]
84
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt (-1 / +12 lines)
Lines 57-63 Link Here
57
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
57
	<li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
58
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
58
	<li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
59
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
59
    <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
60
    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
60
    <li><label for="amount">Amount: </label><input name="amount" id="amount" value="" /> <span>Example:</span> 5[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li>
61
	</ol></fieldset>
61
	</ol></fieldset>
62
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
62
<fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
63
</form>
63
</form>
Lines 76-81 Link Here
76
[% MACRO jsinclude BLOCK %]
76
[% MACRO jsinclude BLOCK %]
77
    [% INCLUDE 'str/members-menu.inc' %]
77
    [% INCLUDE 'str/members-menu.inc' %]
78
    [% Asset.js("js/members-menu.js") | $raw %]
78
    [% Asset.js("js/members-menu.js") | $raw %]
79
    [% INCLUDE 'decimal-input-js.inc' %]
79
    <script type="text/javascript">
80
    <script type="text/javascript">
80
        var type_fees = {'L':'','F':'','A':'','N':'','M':''};
81
        var type_fees = {'L':'','F':'','A':'','N':'','M':''};
81
        [% FOREACH invoice_types_loo IN invoice_types_loop %]
82
        [% FOREACH invoice_types_loo IN invoice_types_loop %]
Lines 88-93 Link Here
88
                this.form.desc.value = this.options[this.selectedIndex].value;
89
                this.form.desc.value = this.options[this.selectedIndex].value;
89
                this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
90
                this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
90
            });
91
            });
92
93
            // decimal input
94
            $("#maninvoice").validate({
95
                rules: {
96
                    amount: {
97
                        is_decimal_number: true,
98
                        uses_correct_decimal_separator: true
99
                    },
100
                }
101
            });
91
        });
102
        });
92
    </script>
103
    </script>
93
[% END %]
104
[% END %]
(-)a/members/maninvoice.pl (-3 / +3 lines)
Lines 31-42 use C4::Members; Link Here
31
use C4::Accounts;
31
use C4::Accounts;
32
use C4::Items;
32
use C4::Items;
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use Koha::Token;
35
34
35
use Koha::Token;
36
use Koha::Items;
36
use Koha::Items;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
39
use Koha::Patron::Categories;
38
use Koha::Patron::Categories;
39
use Koha::Number::Price;
40
40
41
my $input=new CGI;
41
my $input=new CGI;
42
my $flagsrequired = { borrowers => 'edit_borrowers' };
42
my $flagsrequired = { borrowers => 'edit_borrowers' };
Lines 67-72 if ($add){ Link Here
67
        }
67
        }
68
        my $desc=$input->param('desc');
68
        my $desc=$input->param('desc');
69
        my $amount=$input->param('amount');
69
        my $amount=$input->param('amount');
70
        $amount=Koha::Number::Price->new( $amount )->unformat();
70
        my $type=$input->param('type');
71
        my $type=$input->param('type');
71
        my $note    = $input->param('note');
72
        my $note    = $input->param('note');
72
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
73
        my $error   = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note );
73
- 

Return to bug 21507