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 54-59 Link Here
54
        <div id="holdshistory" class="page-section">
54
        <div id="holdshistory" class="page-section">
55
            <h2>Current holds</h2>
55
            <h2>Current holds</h2>
56
            [% IF patron.holds.count %]
56
            [% IF patron.holds.count %]
57
                <div id="current_holds_filters" data-table-id="table_holdshistory">
58
                    <p>
59
                        <span class="selected">
60
                            <input id="current_show_all" type="checkbox" checked="checked" class="show_all" />
61
                            <label for="current_show_all">Show all</label>
62
                        </span>
63
                        <span class="selected">
64
                            <input id="current_pending_filter" type="checkbox" checked="checked" />
65
                            <label for="current_pending_filter">Pending</label>
66
                        </span>
67
                        <span class="selected">
68
                            <input id="current_waiting_filter" type="checkbox" checked="checked" />
69
                            <label for="current_waiting_filter">Waiting</label>
70
                        </span>
71
                        <span class="selected">
72
                            <input id="current_processing_filter" type="checkbox" checked="checked" />
73
                            <label for="current_processing_filter">Processing</label>
74
                        </span>
75
                        <span class="selected">
76
                            <input id="current_transit_filter" type="checkbox" checked="checked" />
77
                            <label for="current_transit_filter">In transit</label>
78
                        </span>
79
                    </p>
80
                </div>
57
                <table id="table_holdshistory">
81
                <table id="table_holdshistory">
58
                    <thead>
82
                    <thead>
59
                        <tr>
83
                        <tr>
Lines 79-84 Link Here
79
103
80
            <h2>Historical holds</h2>
104
            <h2>Historical holds</h2>
81
            [% IF patron.old_holds.count %]
105
            [% IF patron.old_holds.count %]
106
                <div id="old_holds_filters" data-table-id="table_oldholdshistory">
107
                    <p>
108
                        <span class="selected">
109
                            <input id="old_show_all" type="checkbox" checked="checked" class="show_all" />
110
                            <label for="old_show_all">Show all</label>
111
                        </span>
112
                        <span class="selected">
113
                            <input id="old_fulfilled_filter" type="checkbox" checked="checked" />
114
                            <label for="old_fulfilled_filter">Fulfilled</label>
115
                        </span>
116
                        <span class="selected">
117
                            <input id="old_cancelled_filter" type="checkbox" checked="checked" />
118
                            <label for="old_cancelled_filter">Cancelled</label>
119
                        </span>
120
                    </p>
121
                </div>
82
                <table id="table_oldholdshistory">
122
                <table id="table_oldholdshistory">
83
                    <thead>
123
                    <thead>
84
                        <tr>
124
                        <tr>
Lines 117-128 Link Here
117
              //Remove item type column settings
157
              //Remove item type column settings
118
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
158
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
119
            [% END %]
159
            [% END %]
120
            build_holds_table("#table_holdshistory");
160
            let current_holds_table = build_holds_table("#table_holdshistory");
121
            build_holds_table("#table_oldholdshistory", 1);
161
            let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
122
            function build_holds_table(table_id, old){
162
            function build_holds_table(table_id, old){
163
                let additional_filters = {
164
                    "-or": function(){
165
                        let statuses = [];
166
                        let include_cancelled = false;
167
                        if ( table_id == '#table_holdshistory' ) {
168
                            if ( $("#current_pending_filter").is(":checked") ) {
169
                                statuses.push(null);
170
                            }
171
                            if ( $("#current_waiting_filter").is(":checked") ) {
172
                                statuses.push("W");
173
                            }
174
                            if ( $("#current_processing_filter").is(":checked") ) {
175
                                statuses.push("P");
176
                            }
177
                            if ( $("#current_transit_filter").is(":checked") ) {
178
                                statuses.push("T");
179
                            }
180
                        } else {
181
                            if ( $("#old_fulfilled_filter").is(":checked") ) {
182
                                statuses.push("F");
183
                            }
184
                            if ( $("#old_cancelled_filter").is(":checked") ) {
185
                                include_cancelled = true;
186
                            }
187
                        }
188
                        if ( include_cancelled ) {
189
                            return [{status: statuses}, { cancellation_date: {"<": new Date().toISOString() } } ]; // cancellation_date cannot be in the future. Would be better a 'not null' here however.
190
                        } else {
191
                            return [{status: statuses}];
192
                        }
193
                    },
194
195
                };
196
123
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
197
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
124
                if (old){table_url += '?old=1'}
198
                if (old){table_url += '?old=1'}
125
                $(table_id).kohaTable({
199
                return $(table_id).kohaTable({
126
                    ajax: {
200
                    ajax: {
127
                        url: table_url,
201
                        url: table_url,
128
                    },
202
                    },
Lines 220-227 Link Here
220
                        },
294
                        },
221
                        [% END %]
295
                        [% END %]
222
                        {
296
                        {
223
                            data: "found", // FIXME filter with dropdown list
297
                            data: "status",
224
                            searchable: true,
298
                            searchable: false,
225
                            orderable: true,
299
                            orderable: true,
226
                            render: function (data, type, row, meta) {
300
                            render: function (data, type, row, meta) {
227
                                if ( row.status == 'F' ) {
301
                                if ( row.status == 'F' ) {
Lines 244-251 Link Here
244
                            }
318
                            }
245
                        },
319
                        },
246
                    ],
320
                    ],
247
                }, table_settings);
321
                }, table_settings, true, additional_filters);
248
            }
322
            }
323
            $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
324
                e.preventDefault();
325
                let container = $(this).closest("div");
326
                if ( $(this).hasClass("show_all") ) {
327
                    if ( $(this).is(":checked") ) {
328
                        container.find(":checkbox").prop("checked", true);
329
                    }
330
                } else if ( $(this).not(":checked") ) {
331
                    container.find(".show_all").prop("checked", false);
332
                }
333
                let table_dt = $("#"+container.data("table-id")).DataTable();
334
                table_dt.draw();
335
            });
249
        });
336
        });
250
    </script>
337
    </script>
251
[% END %]
338
[% END %]
252
- 

Return to bug 35560