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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc (+27 lines)
Line 0 Link Here
1
[% USE Koha %]
2
<script type="text/javascript">
3
    [%# This should use the Format template plugin, but not pushed yet %]
4
    [% IF Koha.Preference("CurrencyFormat") == 'FR' %]
5
        var default_value = {
6
            thousands_sep: ' ',
7
            decimal_point: ',',
8
            decimal_digits: 2
9
        };
10
    [% ELSE %]
11
        var default_value = {
12
            thousands_sep: ',',
13
            decimal_point: '.',
14
            decimal_digits: 2
15
        };
16
    [% END %]
17
    Number.prototype.format_price = function( value, params ) {
18
        params = params == undefined ? {} : params;
19
        var thousands_sep = params.thousands_sep == undefined ? default_value.thousands_sep : params.thousands_sep,
20
            decimal_point = params.decimal_point == undefined ? default_value.decimal_point : params.decimal_point,
21
            //symbol = params.symbol == undefined ? '$' : params.symbol, // Not implemented yet
22
            decimal_digits = params.decimal_digits == undefined ? default_value.decimal_digits : params.decimal_digits;
23
24
            var re = '\\d(?=(\\d{' + 3 + '})+' + '\\D' + ')', value = this.toFixed(decimal_digits);
25
            return value.replace('.', decimal_point).replace(new RegExp(re, 'g'), '$&' + thousands_sep);
26
    }
27
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js (-1 / +31 lines)
Lines 607-609 function parse_callnumber ( html ) { Link Here
607
        return "";
607
        return "";
608
    }
608
    }
609
}
609
}
610
- 
610
611
// see http://www.datatables.net/examples/advanced_init/footer_callback.html
612
function footer_column_sum( api, column_numbers ) {
613
    // Remove the formatting to get integer data for summation
614
    var intVal = function ( i ) {
615
        if ( typeof i === 'number' ) {
616
            if ( isNaN(i) ) return 0;
617
            return i;
618
        } else if ( typeof i === 'string' ) {
619
            var value = i.replace(/[a-zA-Z ,.]/g, '')*1;
620
            if ( isNaN(value) ) return 0;
621
            return value;
622
        }
623
        return 0;
624
    };
625
626
627
    for ( var indice = 0 ; indice < column_numbers.length ; indice++ ) {
628
        var column_number = column_numbers[indice];
629
630
        var total = 0;
631
        var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount");
632
        $(cells).each(function(){
633
            total += intVal( $(this).html() );
634
        });
635
        total /= 100; // Hard-coded decimal precision
636
637
        // Update footer
638
        $( api.column( column_number ).footer() ).html(total.format_price());
639
    };
640
}

Return to bug 12987