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 (+32 lines)
Lines 607-609 function parse_callnumber ( html ) { Link Here
607
        return "";
607
        return "";
608
    }
608
    }
609
}
609
}
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
}
641
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-13 / +40 lines)
Lines 13-23 dt_overwrite_html_sorting_localeCompare(); Link Here
13
13
14
$(document).ready(function() {
14
$(document).ready(function() {
15
15
16
    var inactive = $(".b_inactive,.bu_active");
17
    var active = $(".bu_inactive");
18
    inactive.hide();
19
    active.show();
20
21
    var oTable = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
16
    var oTable = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
22
        "fnDrawCallback": function ( oSettings ) {
17
        "fnDrawCallback": function ( oSettings ) {
23
            if ( oSettings.aiDisplay.length == 0 )
18
            if ( oSettings.aiDisplay.length == 0 )
Lines 45-50 $(document).ready(function() { Link Here
45
                }
40
                }
46
            }
41
            }
47
        },
42
        },
43
        "footerCallback": function ( row, data, start, end, display ) {
44
            var api = this.api(), data;
45
            footer_column_sum( api, [ 6, 7, 8, 9 ] );
46
        },
48
        "aoColumnDefs": [
47
        "aoColumnDefs": [
49
            { "bVisible": false, "aTargets": [ 0, 1 ] },
48
            { "bVisible": false, "aTargets": [ 0, 1 ] },
50
            { "bSortable": false, "aTargets": ["_all"] }
49
            { "bSortable": false, "aTargets": ["_all"] }
Lines 168-177 $(document).ready(function() { Link Here
168
            <th></th>
167
            <th></th>
169
            <th></th>
168
            <th></th>
170
            <th colspan="4">Total</th>
169
            <th colspan="4">Total</th>
171
            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
170
            <th class="data"></th>
172
            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
171
            <th class="data"></th>
173
            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
172
            <th class="data"></th>
174
            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
173
            <th class="data"></th>
175
        </tr>
174
        </tr>
176
        </tfoot>
175
        </tfoot>
177
        <tbody>
176
        <tbody>
Lines 199-208 $(document).ready(function() { Link Here
199
                    [% END %]
198
                    [% END %]
200
                </td>
199
                </td>
201
                <td>[% loop_budge.budget_branchname %]</td>
200
                <td>[% loop_budge.budget_branchname %]</td>
202
                <td class="data"><span title="[% loop_budge.budget_amount %]">[% loop_budge.formatted_budget_amount %]</span></td>
201
                <td class="data">
203
                <td class="data"><span title="[% loop_budge.budget_ordered %]"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.formatted_budget_ordered %]</a></span></td>
202
                    [% IF loop_budge.budget_parent_id %]
204
                <td class="data"><span title="[% loop_budge.budget_spent %]"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.formatted_budget_spent %]</span></a></td>
203
                        [% loop_budge.formatted_budget_amount %]
205
                <td class="data"><span title="[% loop_budge.budget_avail %]">[% loop_budge.formatted_budget_avail %]</td>
204
                    [% ELSE %]
205
                        <span class="total_amount">[% loop_budge.formatted_budget_amount %]</span>
206
                    [% END %]
207
                </td>
208
                <td class="data">
209
                    <a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">
210
                    [% IF loop_budge.budget_parent_id %]
211
                        [% loop_budge.formatted_budget_ordered %]
212
                    [% ELSE %]
213
                        <span class="total_amount">[% loop_budge.formatted_budget_ordered %]</span>
214
                    [% END %]
215
                    </a>
216
                </td>
217
                <td class="data">
218
                    <a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">
219
                    [% IF loop_budge.budget_parent_id %]
220
                        [% loop_budge.formatted_budget_spent %]
221
                    [% ELSE %]
222
                        <span class="total_amount">[% loop_budge.formatted_budget_spent %]</span>
223
                    [% END %]
224
                    </a>
225
                </td>
226
                <td class="data">
227
                    [% IF loop_budge.budget_parent_id %]
228
                        [% loop_budge.formatted_budget_avail %]
229
                    [% ELSE %]
230
                        <span class="total_amount">[% loop_budge.formatted_budget_avail %]</span>
231
                    [% END %]
232
                </td>
206
            </tr>
233
            </tr>
207
        [% END %]
234
        [% END %]
208
        </tbody>
235
        </tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-13 / +19 lines)
Lines 152-157 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
152
//<![CDATA[
152
//<![CDATA[
153
    //
153
    //
154
    $(document).ready(function() {
154
    $(document).ready(function() {
155
156
155
        var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
157
        var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
156
            "fnDrawCallback": function ( oSettings ) {
158
            "fnDrawCallback": function ( oSettings ) {
157
                if ( oSettings.aiDisplay.length == 0 )
159
                if ( oSettings.aiDisplay.length == 0 )
Lines 179-184 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
179
                    }
181
                    }
180
                }
182
                }
181
            },
183
            },
184
            "footerCallback": function ( row, data, start, end, display ) {
185
                var api = this.api(), data;
186
                footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
187
            },
182
            "aoColumnDefs": [
188
            "aoColumnDefs": [
183
                { "bVisible": false, "aTargets": [ 0, 1 ] },
189
                { "bVisible": false, "aTargets": [ 0, 1 ] },
184
                { "bSortable": false, "aTargets": ["_all"] }
190
                { "bSortable": false, "aTargets": ["_all"] }
Lines 213-218 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
213
          });
219
          });
214
          $("#hide_inactive").click();
220
          $("#hide_inactive").click();
215
        [% END %]
221
        [% END %]
222
        oTable.fnAddFilters("filter", 750);
216
223
217
        $("#filterbutton").click(function() {
224
        $("#filterbutton").click(function() {
218
            $("#fundfilters").slideToggle(0);
225
            $("#fundfilters").slideToggle(0);
Lines 295-307 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
295
    <th></th>
302
    <th></th>
296
    <th></th>
303
    <th></th>
297
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
304
    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
298
    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
305
    <th class="data"></th>
299
    <th></th>
306
    <th></th>
300
    <th class="data">[% ordered_total %]</th>
307
    <th class="data"></td>
301
    <th></th>
308
    <th></th>
302
    <th class="data">[% spent_total %]</th>
309
    <th class="data"></th>
303
    <th></th>
310
    <th></th>
304
    <th class="data">[% available_total %]</th>
311
    <th class="data"></th>
305
    <th></th>
312
    <th></th>
306
    </tr>
313
    </tr>
307
    </tfoot>
314
    </tfoot>
Lines 320-354 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
320
      [% IF budget.budget_parent_id %]
327
      [% IF budget.budget_parent_id %]
321
        <span class="child_fund_amount">[% budget.budget_amount %]</span>
328
        <span class="child_fund_amount">[% budget.budget_amount %]</span>
322
      [% ELSE %]
329
      [% ELSE %]
323
        [% budget.budget_amount %]
330
        <span class="total_amount">[% budget.budget_amount %]</span>
324
      [% END %]
331
      [% END %]
325
    </td>
332
    </td>
326
    <td class="data">
333
    <td class="data">
327
      [% IF budget.budget_parent_id %]
334
      [% IF budget.budget_parent_id %]
328
        <span class="child_fund_amount">[% budget.budget_ordered %]</span>
335
        <span class="child_fund_amount">[% budget.budget_ordered %]</span>
329
      [% ELSE %]
336
      [% ELSE %]
330
        [% budget.budget_ordered %]
337
        <span class="total_amount">[% budget.budget_ordered %]</span>
331
      [% END %]
338
      [% END %]
332
    </td>
339
    </td>
333
    <td class="data">
340
    <td class="data">
334
      [% IF budget.budget_parent_id %]
341
      [% IF budget.budget_parent_id %]
335
        <span class="child_fund_amount">[% budget.total_ordered %]</span>
342
        <span class="child_fund_amount">[% budget.total_ordered %]</span>
336
      [% ELSE %]
343
      [% ELSE %]
337
        [% budget.total_ordered %]
344
        <span class="total_amount">[% budget.total_ordered %]</span>
338
      [% END %]
345
      [% END %]
339
    </td>
346
    </td>
340
    <td class="data">
347
    <td class="data">
341
      [% IF budget.budget_parent_id %]
348
      [% IF budget.budget_parent_id %]
342
        <span class="child_fund_amount">[% budget.budget_spent %]</span>
349
        <span class="child_fund_amount">[% budget.budget_spent %]</span>
343
      [% ELSE %]
350
      [% ELSE %]
344
        [% budget.budget_spent %]
351
        <span class="total_amount">[% budget.budget_spent %]</span>
345
      [% END %]
352
      [% END %]
346
    </td>
353
    </td>
347
    <td class="data">
354
    <td class="data">
348
      [% IF budget.budget_parent_id %]
355
      [% IF budget.budget_parent_id %]
349
        <span class="child_fund_amount">[% budget.total_spent %]</span>
356
        <span class="child_fund_amount">[% budget.total_spent %]</span>
350
      [% ELSE %]
357
      [% ELSE %]
351
        [% budget.total_spent %]
358
        <span class="total_amount">[% budget.total_spent %]</span>
352
      [% END %]
359
      [% END %]
353
    </td>
360
    </td>
354
361
Lines 364-374 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
364
            [% END %]
371
            [% END %]
365
         [% ELSE %]
372
         [% ELSE %]
366
            [% IF (value > 0) %]
373
            [% IF (value > 0) %]
367
                <span style="color: green;">
374
                <span class="total_amount" style="color: green;">
368
            [% ELSIF (value < 0) %]
375
            [% ELSIF (value < 0) %]
369
                <span style="color: red;">
376
                <span class="total_amount" style="color: red;">
370
            [% ELSE %]
377
            [% ELSE %]
371
                <span>
378
                <span class="totalamount">
372
            [% END %]
379
            [% END %]
373
        [% END %]
380
        [% END %]
374
            [% text %]
381
            [% text %]
375
- 

Return to bug 12987