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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc (+3 lines)
Lines 228-233 Link Here
228
228
229
            [% WRAPPER tab_panel tabname="bookings" %]
229
            [% WRAPPER tab_panel tabname="bookings" %]
230
                [% IF ( bookings_count ) %]
230
                [% IF ( bookings_count ) %]
231
                    <fieldset class="action filters" style="cursor:pointer;">
232
                        <a id="expired_filter" class="filtered"><i class="fa fa-bars"></i> Show expired</a>
233
                    </fieldset>
231
                    <table id="bookings_table" style="width: 100% !Important;"></table>
234
                    <table id="bookings_table" style="width: 100% !Important;"></table>
232
                [% ELSE %]
235
                [% ELSE %]
233
                    <p>Patron has nothing booked.</p>
236
                    <p>Patron has nothing booked.</p>
(-)a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js (-8 / +30 lines)
Lines 4-11 var bookings_table; Link Here
4
$(document).ready(function () {
4
$(document).ready(function () {
5
    // Load bookings table on tab selection
5
    // Load bookings table on tab selection
6
    $("#bookings-tab").on("click", function () {
6
    $("#bookings-tab").on("click", function () {
7
        let filter_expired = true;
8
        let additional_filters = {
9
            patron_id: patron_borrowernumber,
10
            end_date: function () {
11
                if (filter_expired) {
12
                    let today = new Date();
13
                    return { ">=": today.toISOString() }
14
                } else {
15
                    return;
16
                }
17
            }
18
        };
19
7
        if (!bookings_table) {
20
        if (!bookings_table) {
8
            var today = new Date();
21
9
            var bookings_table_url = "/api/v1/bookings";
22
            var bookings_table_url = "/api/v1/bookings";
10
            bookings_table = $("#bookings_table").kohaTable(
23
            bookings_table = $("#bookings_table").kohaTable(
11
                {
24
                {
Lines 87-99 $(document).ready(function () { Link Here
87
                        },
100
                        },
88
                    ],
101
                    ],
89
                },
102
                },
90
                table_settings_bookings_table,
103
                table_settings_bookings_table, 0, additional_filters
91
                0,
92
                {
93
                    patron_id: patron_borrowernumber,
94
                    end_date: { ">=": today.toISOString() },
95
                }
96
            );
104
            );
97
        }
105
        }
98
    });
106
    });
107
108
    var txtActivefilter = _("Show expired");
109
    var txtInactivefilter = _("Hide expired");
110
    $("#expired_filter").on("click", function () {
111
        if ($(this).hasClass('filtered')) {
112
            filter_expired = false;
113
            $(this).html('<i class="fa fa-filter"></i> ' + txtInactivefilter);
114
        } else {
115
            filter_expired = true;
116
            $(this).html('<i class="fa fa-bars"></i> ' + txtActivefilter);
117
        }
118
        bookings_table.DataTable().draw();
119
        $(this).toggleClass('filtered');
120
    });
121
99
});
122
});
100
- 

Return to bug 37141