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

(-)a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css (+5 lines)
Lines 3148-3153 table#ill-requests { Link Here
3148
    width: 100% !important;
3148
    width: 100% !important;
3149
}
3149
}
3150
3150
3151
#illfilter_dateplaced,
3152
#illfilter_datemodified {
3153
    width: 80%;
3154
}
3155
3151
#helper span {
3156
#helper span {
3152
    display: none;
3157
    display: none;
3153
}
3158
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-28 / +277 lines)
Lines 9-20 Link Here
9
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
9
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
10
[% Asset.css("css/datatables.css") %]
10
[% Asset.css("css/datatables.css") %]
11
[% INCLUDE 'datatables.inc' %]
11
[% INCLUDE 'datatables.inc' %]
12
[% INCLUDE 'calendar.inc' %]
12
<script type="text/javascript">
13
<script type="text/javascript">
13
    //<![CDATA[
14
    //<![CDATA[
14
    $(document).ready(function() {
15
    $(document).ready(function() {
15
16
16
        // Illview Datatable setup
17
        // Illview Datatable setup
17
18
19
        var table;
20
21
        // Filters that are active
22
        var activeFilters = {};
23
24
        // Date format for datepickers
25
        var dateMap = {
26
            dmydot: 'dd.mm.yy',
27
            iso: 'yy-mm-dd',
28
            metric: 'dd/mm/yy',
29
            us: 'mm/dd/yy'
30
        };
31
        var dateFormat = dateMap['[% Koha.Preference('dateformat') %]'];
32
        $('#illfilter_dateplaced, #illfilter_datemodified').datepicker(
33
            'option', 'dateFormat', dateFormat
34
        );
35
18
        // Fields we don't want to display
36
        // Fields we don't want to display
19
        var ignore = [
37
        var ignore = [
20
            'accessurl',
38
            'accessurl',
Lines 26-32 Link Here
26
            'medium',
44
            'medium',
27
            'notesopac',
45
            'notesopac',
28
            'notesstaff',
46
            'notesstaff',
29
            'placed',
30
            'replied'
47
            'replied'
31
        ];
48
        ];
32
49
Lines 45-58 Link Here
45
            'metadata_Author',
62
            'metadata_Author',
46
            'metadata_Title',
63
            'metadata_Title',
47
            'borrowername',
64
            'borrowername',
65
            'patron_cardnumber',
48
            'biblio_id',
66
            'biblio_id',
49
            'library',
67
            'library',
50
            'status',
68
            'status',
69
            'placed',
51
            'updated',
70
            'updated',
52
            'illrequest_id',
71
            'illrequest_id',
53
            'action'
72
            'action'
54
        ];
73
        ];
55
74
75
        // Filterable columns
76
        var filterable = {
77
            status: {
78
                prep: function(tableData, oData) {
79
                    var uniques = {};
80
                    tableData.forEach(function(row) {
81
                        var resolvedName = getStatusName(
82
                            oData[0].capabilities[row.status].name
83
                        );
84
                        uniques[resolvedName] = 1
85
                    });
86
                    Object.keys(uniques).sort().forEach(function(unique) {
87
                        $('#illfilter_status').append(
88
                            '<option value="' + unique  +
89
                            '">' + unique +  '</option>'
90
                        );
91
                    });
92
                },
93
                listener: function() {
94
                    var me = 'status';
95
                    $('#illfilter_status').change(function() {
96
                        var sel = $('#illfilter_status option:selected').val();
97
                        if (sel && sel.length > 0) {
98
                            activeFilters[me] = function() {
99
                                table.column(6).search(sel);
100
                            }
101
                        } else {
102
                            if (activeFilters.hasOwnProperty(me)) {
103
                                delete activeFilters[me];
104
                            }
105
                        }
106
                    });
107
                },
108
                clear: function() {
109
                    $('#illfilter_status').val('');
110
                }
111
            },
112
            pickupBranch: {
113
                prep: function(tableData, oData) {
114
                    var uniques = {};
115
                    tableData.forEach(function(row) {
116
                        uniques[row.library.branchname] = 1
117
                    });
118
                    Object.keys(uniques).sort().forEach(function(unique) {
119
                        $('#illfilter_branchname').append(
120
                            '<option value="' + unique  +
121
                            '">' + unique +  '</option>'
122
                        );
123
                    });
124
                },
125
                listener: function() {
126
                    var me = 'pickupBranch';
127
                    $('#illfilter_branchname').change(function() {
128
                        var sel = $('#illfilter_branchname option:selected').val();
129
                        if (sel && sel.length > 0) {
130
                            activeFilters[me] = function() {
131
                                table.column(5).search(sel);
132
                            }
133
                        } else {
134
                            if (activeFilters.hasOwnProperty(me)) {
135
                                delete activeFilters[me];
136
                            }
137
                        }
138
                    });
139
                },
140
                clear: function() {
141
                    $('#illfilter_branchname').val('');
142
                }
143
            },
144
            barcode: {
145
                listener: function() {
146
                    var me = 'barcode';
147
                    $('#illfilter_barcode').change(function() {
148
                        var val = $('#illfilter_barcode').val();
149
                        if (val && val.length > 0) {
150
                            activeFilters[me] = function() {
151
                                table.column(3).search(val);
152
                            }
153
                        } else {
154
                            if (activeFilters.hasOwnProperty(me)) {
155
                                delete activeFilters[me];
156
                            }
157
                        }
158
                    });
159
                },
160
                clear: function() {
161
                    $('#illfilter_barcode').val('');
162
                }
163
            },
164
            dateModified: {
165
                listener: function() {
166
                    var me = 'dateModified';
167
                    $('#illfilter_datemodified').change(function() {
168
                        var val = $('#illfilter_datemodified').val();
169
                        if (val && val.length > 0) {
170
                            activeFilters[me] = function() {
171
                                table.column(8).search(val);
172
                            }
173
                        } else {
174
                            if (activeFilters.hasOwnProperty(me)) {
175
                                delete activeFilters[me];
176
                            }
177
                        }
178
                    });
179
                },
180
                clear: function() {
181
                    $('#illfilter_datemodified').val('');
182
                }
183
            },
184
            datePlaced: {
185
                listener: function() {
186
                    var me = 'datePlaced';
187
                    $('#illfilter_dateplaced').change(function() {
188
                        var val = $('#illfilter_dateplaced').val();
189
                        if (val && val.length > 0) {
190
                            activeFilters[me] = function() {
191
                                table.column(7).search(val);
192
                            }
193
                        } else {
194
                            if (activeFilters.hasOwnProperty(me)) {
195
                                delete activeFilters[me];
196
                            }
197
                        }
198
                    });
199
                },
200
                clear: function() {
201
                    $('#illfilter_dateplaced').val('');
202
                }
203
            }
204
        };
205
56
        // Remove any fields we're ignoring
206
        // Remove any fields we're ignoring
57
        var removeIgnore = function(dataObj) {
207
        var removeIgnore = function(dataObj) {
58
            dataObj.forEach(function(thisRow) {
208
            dataObj.forEach(function(thisRow) {
Lines 132-162 Link Here
132
                var status_name = meta.settings.oInit.originalData[0].capabilities[
282
                var status_name = meta.settings.oInit.originalData[0].capabilities[
133
                    row.status
283
                    row.status
134
                ].name;
284
                ].name;
135
                switch( status_name ) {
285
                return getStatusName(status_name);
136
                    case "New request":
137
                        return _("New request");
138
                    case "Requested":
139
                        return _("Requested");
140
                    case "Requested from partners":
141
                        return _("Requested from partners");
142
                    case "Request reverted":
143
                        return _("Request reverted");
144
                    case "Queued request":
145
                        return _("Queued request");
146
                    case "Cancellation requested":
147
                        return _("Cancellation requested");
148
                    case "Completed":
149
                        return _("Completed");
150
                    case "Delete request":
151
                        return _("Delete request");
152
                    default:
153
                        return status_name;
154
                }
155
            } else {
286
            } else {
156
                return '';
287
                return '';
157
            }
288
            }
158
        };
289
        };
159
290
291
        var getStatusName = function(origName) {
292
            switch( origName ) {
293
                case "New request":
294
                    return _("New request");
295
                case "Requested":
296
                    return _("Requested");
297
                case "Requested from partners":
298
                    return _("Requested from partners");
299
                case "Request reverted":
300
                    return _("Request reverted");
301
                case "Queued request":
302
                    return _("Queued request");
303
                case "Cancellation requested":
304
                    return _("Cancellation requested");
305
                case "Completed":
306
                    return _("Completed");
307
                case "Delete request":
308
                    return _("Delete request");
309
                default:
310
                    return status_name;
311
            }
312
        };
313
160
        // Render function for creating a row's action link
314
        // Render function for creating a row's action link
161
        var createActionLink = function(data, type, row) {
315
        var createActionLink = function(data, type, row) {
162
            return '<a class="btn btn-default btn-sm" ' +
316
            return '<a class="btn btn-default btn-sm" ' +
Lines 190-195 Link Here
190
            library: {
344
            library: {
191
                name: _("Library"),
345
                name: _("Library"),
192
                func: createLibrary
346
                func: createLibrary
347
            },
348
            updated: {
349
                name: _("Updated on"),
350
            },
351
            patron_cardnumber: {
352
                name: _("Patron barcode")
193
            }
353
            }
194
        };
354
        };
195
355
Lines 240-246 Link Here
240
                    // Create the base column object
400
                    // Create the base column object
241
                    var colObj = {
401
                    var colObj = {
242
                        name: thisCol,
402
                        name: thisCol,
243
                        className: thisCol
403
                        className: thisCol,
404
                        defaultContent: ''
244
                    };
405
                    };
245
                    // We may need to process the data going in this
406
                    // We may need to process the data going in this
246
                    // column, so do it if necessary
407
                    // column, so do it if necessary
Lines 256-262 Link Here
256
                });
417
                });
257
418
258
                // Initialise the datatable
419
                // Initialise the datatable
259
                $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
420
                table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
260
                    'aoColumnDefs': [  // Last column shouldn't be sortable or searchable
421
                    'aoColumnDefs': [  // Last column shouldn't be sortable or searchable
261
                        {
422
                        {
262
                            'aTargets': [ 'actions' ],
423
                            'aTargets': [ 'actions' ],
Lines 264-282 Link Here
264
                            'bSearchable': false
425
                            'bSearchable': false
265
                        },
426
                        },
266
                    ],
427
                    ],
267
                    'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending
428
                    'aaSorting': [[ 7, 'desc' ]], // Default sort, updated descending
268
                    'processing': true, // Display a message when manipulating
429
                    'processing': true, // Display a message when manipulating
269
                    'iDisplayLength': 10, // 10 results per page
430
                    'iDisplayLength': 10, // 10 results per page
270
                    'sPaginationType': "full_numbers", // Pagination display
431
                    'sPaginationType': "full_numbers", // Pagination display
271
                    'deferRender': true, // Improve performance on big datasets
432
                    'deferRender': true, // Improve performance on big datasets
272
                    'data': dataCopy,
433
                    'data': dataCopy,
273
                    'columns': colData,
434
                    'columns': colData,
274
                    'originalData': data // Enable render functions to access
435
                    'originalData': data, // Enable render functions to access
275
                                       // our original data
436
                                          // our original data
437
                    'initComplete': function() {
438
439
                        // Prepare any filter elements that need it
440
                        for (var el in filterable) {
441
                            if (filterable.hasOwnProperty(el)) {
442
                                if (filterable[el].hasOwnProperty('prep')) {
443
                                    filterable[el].prep(dataCopy, data);
444
                                }
445
                                if (filterable[el].hasOwnProperty('listener')) {
446
                                    filterable[el].listener();
447
                                }
448
                            }
449
                        }
450
                        
451
                    }
276
                }));
452
                }));
453
277
            }
454
            }
278
        );
455
        );
279
456
457
        var clearSearch = function() {
458
            table.search('').columns().search('');
459
            activeFilters = {};
460
            for (var filter in filterable) {
461
                if (
462
                    filterable.hasOwnProperty(filter) &&
463
                    filterable[filter].hasOwnProperty('clear')
464
                ) {
465
                    filterable[filter].clear();
466
                }
467
            }
468
            table.draw();
469
        };
470
471
        // Apply any search filters, or clear any previous
472
        // ones
473
        $('#illfilter_form').submit(function(event) {
474
            event.preventDefault();
475
            table.search('').columns().search('');
476
            for (var active in activeFilters) {
477
                if (activeFilters.hasOwnProperty(active)) {
478
                    activeFilters[active]();
479
                }
480
            }
481
            table.draw();
482
        });
483
484
        // Clear all filters
485
        $('#clear_search').click(function() {
486
            clearSearch();
487
        });
488
280
    });
489
    });
281
    //]]>
490
    //]]>
282
</script>
491
</script>
Lines 298-303 Link Here
298
507
299
<div id="doc3" class="yui-t2">
508
<div id="doc3" class="yui-t2">
300
    <div id="bd">
509
    <div id="bd">
510
        [% IF query_type == 'illlist' %]
511
        <div id="illfilter_yui_column" class="yui-b">
512
            <form method="get" id="illfilter_form">
513
                <fieldset class="brief">
514
                    <h3>Filters</h3>
515
                    <ol>
516
                        <li>
517
                            <label for="illfilter_status">Status:</label>
518
                            <select name="illfilter_status" id="illfilter_status">
519
                                <option value=""></option>
520
                            </select>
521
                        </li>
522
                        <li>
523
                            <label for="illfilter_dateplaced">Date placed:</label>
524
                            <input type="text" name="illfilter_dateplaced" id="illfilter_dateplaced" class="datepicker">
525
                        </li>
526
                        <li>
527
                            <label for="illfilter_datemodified">Date modified:</label>
528
                            <input type="text" name="illfilter_datemodified" id="illfilter_datemodified" class="datepicker">
529
                        </li>
530
                        <li>
531
                            <label for="illfilter_branchname">Pickup branch:</label>
532
                            <select name="illfilter_branchname" id="illfilter_branchname">
533
                                <option value=""></option>
534
                            </select>
535
                        </li>
536
                        <li>
537
                            <label for="illfilter_barcode">Borrower card number:</label>
538
                            <input type="text" name="illfilter_barcode" id="illfilter_barcode">
539
                        </li>
540
                    </ol>
541
                    <fieldset class="action">
542
                        <input type="submit" value="Search" />
543
                        <input type="button" value="Clear" id="clear_search" />
544
                    </fieldset>
545
                </fieldset>
546
            </form>
547
        </div>
548
        [% END %]
301
        <div id="yui-main">
549
        <div id="yui-main">
302
            <div id="interlibraryloans" class="yui-b">
550
            <div id="interlibraryloans" class="yui-b">
303
        [% IF !backends_available %]
551
        [% IF !backends_available %]
Lines 588-597 Link Here
588
                                <tr id="illview-header">
836
                                <tr id="illview-header">
589
                                    <th>Author</th>
837
                                    <th>Author</th>
590
                                    <th>Title</th>
838
                                    <th>Title</th>
591
                                    <th>Patron</th>
839
                                    <th>Patron name</th>
840
                                    <th>Patron barcode</th>
592
                                    <th>Biblio ID</th>
841
                                    <th>Biblio ID</th>
593
                                    <th>Library</th>
842
                                    <th>Library</th>
594
                                    <th>Status</th>
843
                                    <th>Status</th>
844
                                    <th>Date placed</th>
595
                                    <th>Updated on</th>
845
                                    <th>Updated on</th>
596
                                    <th>Request number</th>
846
                                    <th>Request number</th>
597
                                    <th class="actions"></th>
847
                                    <th class="actions"></th>
598
- 

Return to bug 20600