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

(-)a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js (+25 lines)
Line 0 Link Here
1
/*!
2
   Copyright 2017-2018 SpryMedia Ltd.
3
4
 This source file is free software, available under the following license:
5
   MIT license - http://datatables.net/license/mit
6
7
 This source file is distributed in the hope that it will be useful, but
8
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9
 or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
10
11
 For details please refer to: http://www.datatables.net
12
 RowGroup 1.1.0
13
 ©2017-2018 SpryMedia Ltd - datatables.net/license
14
*/
15
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,d,c){a instanceof String&&(a=String(a));for(var e=a.length,f=0;f<e;f++){var h=a[f];if(d.call(c,h,f,a))return{i:f,v:h}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,c){a!=Array.prototype&&a!=Object.prototype&&(a[d]=c.value)};
16
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,d,c,e){if(d){c=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var f=a[e];f in c||(c[f]={});c=c[f]}a=a[a.length-1];e=c[a];d=d(e);d!=e&&null!=d&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:d})}};
17
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6","es3");
18
(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(d){return a(d,window,document)}):"object"===typeof exports?module.exports=function(d,c){d||(d=window);c&&c.fn.dataTable||(c=require("datatables.net")(d,c).$);return a(c,d,d.document)}:a(jQuery,window,document)})(function(a,d,c,e){var f=a.fn.dataTable,h=function(b,g){if(!f.versionCheck||!f.versionCheck("1.10.8"))throw"RowGroup requires DataTables 1.10.8 or newer";this.c=a.extend(!0,{},f.defaults.rowGroup,
19
h.defaults,g);this.s={dt:new f.Api(b)};this.dom={};b=this.s.dt.settings()[0];if(g=b.rowGroup)return g;b.rowGroup=this;this._constructor()};a.extend(h.prototype,{dataSrc:function(b){if(b===e)return this.c.dataSrc;var g=this.s.dt;this.c.dataSrc=b;a(g.table().node()).triggerHandler("rowgroup-datasrc.dt",[g,b]);return this},disable:function(){this.c.enable=!1;return this},enable:function(b){if(!1===b)return this.disable();this.c.enable=!0;return this},_constructor:function(){var b=this,a=this.s.dt;a.on("draw.dtrg",
20
function(){b.c.enable&&b._draw()});a.on("column-visibility.dt.dtrg responsive-resize.dt.dtrg",function(){b._adjustColspan()});a.on("destroy",function(){a.off(".dtrg")});a.on("responsive-resize.dt",function(){b._adjustColspan()})},_adjustColspan:function(){a("tr."+this.c.className,this.s.dt.table().body()).find("td").attr("colspan",this._colspan())},_colspan:function(){return this.s.dt.columns().visible().reduce(function(b,a){return b+a},0)},_draw:function(){var b=this._group(0,this.s.dt.rows({page:"current"}).indexes());
21
this._groupDisplay(0,b)},_group:function(b,g){for(var c=a.isArray(this.c.dataSrc)?this.c.dataSrc:[this.c.dataSrc],d=f.ext.oApi._fnGetObjectDataFn(c[b]),h=this.s.dt,l,n,m=[],k=0,p=g.length;k<p;k++){var q=g[k];l=h.row(q).data();l=d(l);if(null===l||l===e)l=that.c.emptyDataGroup;if(n===e||l!==n)m.push({dataPoint:l,rows:[]}),n=l;m[m.length-1].rows.push(q)}if(c[b+1]!==e)for(k=0,p=m.length;k<p;k++)m[k].children=this._group(b+1,m[k].rows);return m},_groupDisplay:function(b,a){for(var c=this.s.dt,g,d=0,f=
22
a.length;d<f;d++){var e=a[d],h=e.dataPoint,k=e.rows;this.c.startRender&&(g=this.c.startRender.call(this,c.rows(k),h,b),(g=this._rowWrap(g,this.c.startClassName,b))&&g.insertBefore(c.row(k[0]).node()));this.c.endRender&&(g=this.c.endRender.call(this,c.rows(k),h,b),(g=this._rowWrap(g,this.c.endClassName,b))&&g.insertAfter(c.row(k[k.length-1]).node()));e.children&&this._groupDisplay(b+1,e.children)}},_rowWrap:function(b,g,c){if(null===b||""===b)b=this.c.emptyDataGroup;return b===e?null:("object"===typeof b&&
23
b.nodeName&&"tr"===b.nodeName.toLowerCase()?a(b):b instanceof a&&b.length&&"tr"===b[0].nodeName.toLowerCase()?b:a("<tr/>").append(a("<td/>").attr("colspan",this._colspan()).append(b))).addClass(this.c.className).addClass(g).addClass("dtrg-level-"+c)}});h.defaults={className:"dtrg-group",dataSrc:0,emptyDataGroup:"No group",enable:!0,endClassName:"dtrg-end",endRender:null,startClassName:"dtrg-start",startRender:function(a,c){return c}};h.version="1.1.0";a.fn.dataTable.RowGroup=h;a.fn.DataTable.RowGroup=
24
h;f.Api.register("rowGroup()",function(){return this});f.Api.register("rowGroup().disable()",function(){return this.iterator("table",function(a){a.rowGroup&&a.rowGroup.enable(!1)})});f.Api.register("rowGroup().enable()",function(a){return this.iterator("table",function(b){b.rowGroup&&b.rowGroup.enable(a===e?!0:a)})});f.Api.register("rowGroup().dataSrc()",function(a){return a===e?this.context[0].rowGroup.dataSrc():this.iterator("table",function(b){b.rowGroup&&b.rowGroup.dataSrc(a)})});a(c).on("preInit.dt.dtrg",
25
function(b,c,d){"dt"===b.namespace&&(b=c.oInit.rowGroup,d=f.defaults.rowGroup,b||d)&&(d=a.extend({},d,b),!1!==b&&new h(c,d))});return h});
(-)a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css (+1 lines)
Line 0 Link Here
1
table.dataTable tr.dtrg-group td{background-color:#e0e0e0}table.dataTable tr.dtrg-group.dtrg-level-0 td{font-weight:bold}table.dataTable tr.dtrg-group.dtrg-level-1 td,table.dataTable tr.dtrg-group.dtrg-level-2 td{background-color:#f0f0f0;padding-top:0.25em;padding-bottom:0.25em;padding-left:2em;font-size:0.9em}table.dataTable tr.dtrg-group.dtrg-level-2 td{background-color:#f3f3f3}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt (-1 lines)
Lines 178-184 Link Here
178
[% END %]
178
[% END %]
179
179
180
[% MACRO jsinclude BLOCK %]
180
[% MACRO jsinclude BLOCK %]
181
    [% Asset.js("js/admin-menu.js") | $raw %]
182
    [% INCLUDE 'format_price.inc' %]
181
    [% INCLUDE 'format_price.inc' %]
183
    [% INCLUDE 'datatables.inc' %]
182
    [% INCLUDE 'datatables.inc' %]
184
    [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
183
    [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-15 / +27 lines)
Lines 9-14 Link Here
9
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Koha &rsaquo; Cashup</title>
10
<title>Koha &rsaquo; Cashup</title>
11
[% INCLUDE 'doc-head-close.inc' %]
11
[% INCLUDE 'doc-head-close.inc' %]
12
[% Asset.css("lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css") | $raw %]
12
</head>
13
</head>
13
14
14
<body id="register" class="pos">
15
<body id="register" class="pos">
Lines 53-58 Link Here
53
                    <th>
54
                    <th>
54
                        Receipt ID
55
                        Receipt ID
55
                    </th>
56
                    </th>
57
                    <th>
58
                        Transaction
59
                    </th>
56
                    <th>
60
                    <th>
57
                        Description of charges
61
                        Description of charges
58
                    </th>
62
                    </th>
Lines 69-90 Link Here
69
                <tbody>
73
                <tbody>
70
                    [% FOREACH accountline IN accountlines %]
74
                    [% FOREACH accountline IN accountlines %]
71
                        [% IF accountline.is_credit %]
75
                        [% IF accountline.is_credit %]
72
                            <tr class="credit">
73
                                <td>[% accountline.accountlines_id %]</td>
74
                                <td>
75
                                    [%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])
76
                                </td>
77
                                <td></td>
78
                                <td>
79
                                    [% accountline.amount * -1 | $Price %]
80
                                </td>
81
                                <td>
82
                                    <button class="printReceipt" data-accountline="[%- accountline.accountlines_id | html -%]"><i class="fa fa-print"></i> Print receipt</button>
83
                                </td>
84
                            </tr>
85
                            [% FOREACH credit IN accountline.credit_offsets %]
76
                            [% FOREACH credit IN accountline.credit_offsets %]
86
                            <tr>
77
                            <tr>
87
                                <td>[% accountline.accountlines_id %]</td>
78
                                <td>[% accountline.accountlines_id %]</td>
79
                                <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
88
                                <td>[%- PROCESS account_type_description account=credit.debit -%]</td>
80
                                <td>[%- PROCESS account_type_description account=credit.debit -%]</td>
89
                                <td>[% credit.debit.amount | $Price %]</td>
81
                                <td>[% credit.debit.amount | $Price %]</td>
90
                                <td></td>
82
                                <td></td>
Lines 96-102 Link Here
96
                </tbody>
88
                </tbody>
97
                <tfoot>
89
                <tfoot>
98
                    <tr>
90
                    <tr>
99
                        <td colspan="3">Total income: </td>
91
                        <td colspan="4">Total income: </td>
100
                        <td>[% accountlines.total * -1 | $Price %]</td>
92
                        <td>[% accountlines.total * -1 | $Price %]</td>
101
                        <td></td>
93
                        <td></td>
102
                    </tr>
94
                    </tr>
Lines 113-119 Link Here
113
    </div><!-- /.row -->
105
    </div><!-- /.row -->
114
106
115
[% MACRO jsinclude BLOCK %]
107
[% MACRO jsinclude BLOCK %]
108
    [% INCLUDE 'datatables.inc' %]
109
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
116
    <script>
110
    <script>
111
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
112
            orderFixed: [ 0, 'asc'],
113
            columnDefs: [ {
114
                targets: [ 0, 1 ],
115
                visible: false
116
            }],
117
            rowGroup: {
118
                dataSrc: 0,
119
                startRender: function ( rows, group ) {
120
                    var details = JSON.parse(rows.data().pluck(1).pop());
121
                    return $('<tr class="'+details.type+'"/>')
122
                        .append( '<td colspan="2">'+group+' '+details.description+'</td>' )
123
                        .append( '<td>'+details.amount+'</td>' )
124
                        .append( '<td><button class="printReceipt" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
125
                },
126
                endRender: null,
127
            }
128
        }));
129
117
        $(".printReceipt").click(function() {
130
        $(".printReceipt").click(function() {
118
            var accountlines_id = $(this).data('accountline');
131
            var accountlines_id = $(this).data('accountline');
119
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
132
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
120
- 

Return to bug 23355