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="completed_filter" class="filtered"><i class="fa fa-bars"></i> Include completed</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 5-12 $(document).ready(function () { Link Here
5
5
6
    // Load bookings table on tab selection
6
    // Load bookings table on tab selection
7
    $("#bookings-tab").on("click", function () {
7
    $("#bookings-tab").on("click", function () {
8
        let filter_completed = true;
9
        let additional_filters = {
10
            patron_id: patron_borrowernumber,
11
            end_date: function () {
12
                if (filter_completed) {
13
                    let today = new Date();
14
                    return { ">=": today.toISOString() }
15
                } else {
16
                    return;
17
                }
18
            }
19
        };
20
8
        if (!bookings_table) {
21
        if (!bookings_table) {
9
            var today = new Date();
22
10
            var bookings_table_url = "/api/v1/bookings";
23
            var bookings_table_url = "/api/v1/bookings";
11
            bookings_table = $("#bookings_table").kohaTable(
24
            bookings_table = $("#bookings_table").kohaTable(
12
                {
25
                {
Lines 88-100 $(document).ready(function () { Link Here
88
                        },
101
                        },
89
                    ],
102
                    ],
90
                },
103
                },
91
                table_settings_bookings_table,
104
                table_settings_bookings_table, 0, additional_filters
92
                0,
93
                {
94
                    patron_id: patron_borrowernumber,
95
                    end_date: { ">=": today.toISOString() },
96
                }
97
            );
105
            );
98
        }
106
        }
107
108
        var txtActivefilter = _("Include completed");
109
        var txtInactivefilter = _("Filter completed");
110
        $('#completed_filter').on("click", function () {
111
            if ($(this).hasClass('filtered')) {
112
                filter_completed = false;
113
                $(this).html('<i class="fa fa-filter"></i> ' + txtActivefilter);
114
            } else {
115
                filter_completed = true;
116
                $(this).html('<i class="fa fa-bars"></i> ' + txtInactivefilter);
117
            }
118
            bookings_table.DataTable().draw();
119
            $(this).toggleClass('filtered');
120
        });
121
99
    });
122
    });
100
});
123
});
101
- 

Return to bug 37141