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 118-129 Link Here
118
              //Remove item type column settings
158
              //Remove item type column settings
119
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
159
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
120
            [% END %]
160
            [% END %]
121
            build_holds_table("#table_holdshistory");
161
            let current_holds_table = build_holds_table("#table_holdshistory");
122
            build_holds_table("#table_oldholdshistory", 1);
162
            let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
123
            function build_holds_table(table_id, old){
163
            function build_holds_table(table_id, old){
164
                let additional_filters = {
165
                    "-or": function(){
166
                        let statuses = [];
167
                        let include_cancelled = false;
168
                        if ( table_id == '#table_holdshistory' ) {
169
                            if ( $("#current_pending_filter").is(":checked") ) {
170
                                statuses.push(null);
171
                            }
172
                            if ( $("#current_waiting_filter").is(":checked") ) {
173
                                statuses.push("W");
174
                            }
175
                            if ( $("#current_processing_filter").is(":checked") ) {
176
                                statuses.push("P");
177
                            }
178
                            if ( $("#current_transit_filter").is(":checked") ) {
179
                                statuses.push("T");
180
                            }
181
                        } else {
182
                            if ( $("#old_fulfilled_filter").is(":checked") ) {
183
                                statuses.push("F");
184
                            }
185
                            if ( $("#old_cancelled_filter").is(":checked") ) {
186
                                include_cancelled = true;
187
                            }
188
                        }
189
                        if ( include_cancelled ) {
190
                            return [{status: statuses}, { cancellation_date: {"<": new Date().toISOString() } } ]; // cancellation_date cannot be in the future. Would be better a 'not null' here however.
191
                        } else {
192
                            return [{status: statuses}];
193
                        }
194
                    },
195
196
                };
197
124
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
198
                let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds';
125
                if (old){table_url += '?old=1'}
199
                if (old){table_url += '?old=1'}
126
                $(table_id).kohaTable({
200
                return $(table_id).kohaTable({
127
                    ajax: {
201
                    ajax: {
128
                        url: table_url,
202
                        url: table_url,
129
                    },
203
                    },
Lines 221-228 Link Here
221
                        },
295
                        },
222
                        [% END %]
296
                        [% END %]
223
                        {
297
                        {
224
                            data: "found", // FIXME filter with dropdown list
298
                            data: "status",
225
                            searchable: true,
299
                            searchable: false,
226
                            orderable: true,
300
                            orderable: true,
227
                            render: function (data, type, row, meta) {
301
                            render: function (data, type, row, meta) {
228
                                if ( row.status == 'F' ) {
302
                                if ( row.status == 'F' ) {
Lines 245-252 Link Here
245
                            }
319
                            }
246
                        },
320
                        },
247
                    ],
321
                    ],
248
                }, table_settings);
322
                }, table_settings, true, additional_filters);
249
            }
323
            }
324
            $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
325
                e.preventDefault();
326
                let container = $(this).closest("div");
327
                if ( $(this).hasClass("show_all") ) {
328
                    if ( $(this).is(":checked") ) {
329
                        container.find(":checkbox").prop("checked", true);
330
                    }
331
                } else if ( $(this).not(":checked") ) {
332
                    container.find(".show_all").prop("checked", false);
333
                }
334
                let table_dt = $("#"+container.data("table-id")).DataTable();
335
                table_dt.draw();
336
            });
250
        });
337
        });
251
    </script>
338
    </script>
252
[% END %]
339
[% END %]
253
- 

Return to bug 35560