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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt (-7 / +93 lines)
Lines 56-61 Link Here
56
    <div id="holdshistory" class="page-section">
56
    <div id="holdshistory" class="page-section">
57
        <h2>Current holds</h2>
57
        <h2>Current holds</h2>
58
        [% IF patron.holds.count %]
58
        [% IF patron.holds.count %]
59
            <div id="current_holds_filters" data-table-id="table_holdshistory">
60
                <p>
61
                    <span class="selected">
62
                        <input id="current_show_all" type="checkbox" checked="checked" class="show_all"/>
63
                        <label for="current_show_all">Show all</label>
64
                    </span>
65
                    <span class="selected">
66
                        <input id="current_pending_filter" type="checkbox" checked="checked" />
67
                        <label for="current_pending_filter">Pending</label>
68
                    </span>
69
                    <span class="selected">
70
                        <input id="current_waiting_filter" type="checkbox" checked="checked" />
71
                        <label for="current_waiting_filter">Waiting</label>
72
                    </span>
73
                    <span class="selected">
74
                        <input id="current_processing_filter" type="checkbox" checked="checked" />
75
                        <label for="current_processing_filter">Processing</label>
76
                    </span>
77
                    <span class="selected">
78
                        <input id="current_transit_filter" type="checkbox" checked="checked" />
79
                        <label for="current_transit_filter">In transit</label>
80
                    </span>
81
                </p>
82
            </div>
59
            <table id="table_holdshistory">
83
            <table id="table_holdshistory">
60
                <thead>
84
                <thead>
61
                    <tr>
85
                    <tr>
Lines 81-86 Link Here
81
105
82
        <h2>Historical holds</h2>
106
        <h2>Historical holds</h2>
83
        [% IF patron.old_holds.count %]
107
        [% IF patron.old_holds.count %]
108
            <div id="old_holds_filters" data-table-id="table_oldholdshistory">
109
                <p>
110
                    <span class="selected">
111
                        <input id="old_show_all" type="checkbox" checked="checked" class="show_all"/>
112
                        <label for="old_show_all">Show all</label>
113
                    </span>
114
                    <span class="selected">
115
                        <input id="old_fulfilled_filter" type="checkbox" checked="checked" />
116
                        <label for="old_fulfilled_filter">Fulfilled</label>
117
                    </span>
118
                    <span class="selected">
119
                        <input id="old_cancelled_filter" type="checkbox" checked="checked" />
120
                        <label for="old_cancelled_filter">Cancelled</label>
121
                    </span>
122
                </p>
123
            </div>
84
            <table id="table_oldholdshistory">
124
            <table id="table_oldholdshistory">
85
                <thead>
125
                <thead>
86
                    <tr>
126
                    <tr>
Lines 129-140 Link Here
129
              //Remove item type column settings
169
              //Remove item type column settings
130
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
170
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
131
            [% END %]
171
            [% END %]
132
            build_holds_table("#table_holdshistory");
172
            let current_holds_table = build_holds_table("#table_holdshistory");
133
            build_holds_table("#table_oldholdshistory", 1);
173
            let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
134
            function build_holds_table(table_id, old){
174
            function build_holds_table(table_id, old){
175
                let additional_filters = {
176
                    "-or": function(){
177
                        let statuses = [];
178
                        let include_cancelled = false;
179
                        if ( table_id == '#table_holdshistory' ) {
180
                            if ( $("#current_pending_filter").is(":checked") ) {
181
                                statuses.push(null);
182
                            }
183
                            if ( $("#current_waiting_filter").is(":checked") ) {
184
                                statuses.push("W");
185
                            }
186
                            if ( $("#current_processing_filter").is(":checked") ) {
187
                                statuses.push("P");
188
                            }
189
                            if ( $("#current_transit_filter").is(":checked") ) {
190
                                statuses.push("T");
191
                            }
192
                        } else {
193
                            if ( $("#old_fulfilled_filter").is(":checked") ) {
194
                                statuses.push("F");
195
                            }
196
                            if ( $("#old_cancelled_filter").is(":checked") ) {
197
                                include_cancelled = true;
198
                            }
199
                        }
200
                        if ( include_cancelled ) {
201
                            return [{status: statuses}, { cancellation_date: {"<": new Date().toISOString() } } ]; // cancellation_date cannot be in the future. Would be better a 'not null' here however.
202
                        } else {
203
                            return [{status: statuses}];
204
                        }
205
                    },
206
207
                };
208
135
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
209
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
136
                if (old){table_url += '?old=1'}
210
                if (old){table_url += '?old=1'}
137
                $(table_id).kohaTable({
211
                return $(table_id).kohaTable({
138
                    ajax: {
212
                    ajax: {
139
                        url: table_url,
213
                        url: table_url,
140
                    },
214
                    },
Lines 232-239 Link Here
232
                        },
306
                        },
233
                        [% END %]
307
                        [% END %]
234
                        {
308
                        {
235
                            data: "found", // FIXME filter with dropdown list
309
                            data: "status",
236
                            searchable: true,
310
                            searchable: false,
237
                            orderable: true,
311
                            orderable: true,
238
                            render: function (data, type, row, meta) {
312
                            render: function (data, type, row, meta) {
239
                                if ( row.status == 'F' ) {
313
                                if ( row.status == 'F' ) {
Lines 256-263 Link Here
256
                            }
330
                            }
257
                        },
331
                        },
258
                    ],
332
                    ],
259
                }, table_settings);
333
                }, table_settings, true, additional_filters);
260
            }
334
            }
335
            $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
336
                e.preventDefault();
337
                let container = $(this).closest("div");
338
                if ( $(this).hasClass("show_all") ) {
339
                    if ( $(this).is(":checked") ) {
340
                        container.find(":checkbox").prop("checked", true);
341
                    }
342
                } else if ( $(this).not(":checked") ) {
343
                    container.find(".show_all").prop("checked", false);
344
                }
345
                let table_dt = $("#"+container.data("table-id")).DataTable();
346
                table_dt.draw();
347
            });
261
        });
348
        });
262
    </script>
349
    </script>
263
[% END %]
350
[% END %]
264
- 

Return to bug 35560