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

(-)a/Koha/REST/V1/Illrequests.pm (-6 / +21 lines)
Lines 21-26 use Mojo::Base 'Mojolicious::Controller'; Link Here
21
21
22
use Koha::Illrequests;
22
use Koha::Illrequests;
23
use Koha::Libraries;
23
use Koha::Libraries;
24
use Koha::DateUtils qw( format_sqldatetime );
24
25
25
=head1 NAME
26
=head1 NAME
26
27
Lines 40-45 sub list { Link Here
40
    my $args = $c->req->params->to_hash // {};
41
    my $args = $c->req->params->to_hash // {};
41
    my $filter;
42
    my $filter;
42
    my $output = [];
43
    my $output = [];
44
    my @format_dates = ( 'placed', 'updated' );
43
45
44
    # Create a hash where all keys are embedded values
46
    # Create a hash where all keys are embedded values
45
    # Enables easy checking
47
    # Enables easy checking
Lines 54-71 sub list { Link Here
54
        $filter->{$filter_param} = \@values;
56
        $filter->{$filter_param} = \@values;
55
    }
57
    }
56
58
57
    my $requests = Koha::Illrequests->search($filter);
59
    my @req_list = Koha::Illrequests->search($filter)->as_list;
58
60
59
    if ( scalar (keys %embed) )
61
    if ( scalar (keys %embed) )
60
    {
62
    {
61
        # Need to embed stuff
63
        # Need to embed stuff
62
        my @results = map { $_->TO_JSON(\%embed) } $requests->as_list;
64
        @req_list = map { $_->TO_JSON(\%embed) } @req_list;
63
        return $c->render( status => 200, openapi => \@results );
64
    }
65
    }
65
    else
66
66
    {
67
    # Create new "formatted" columns for each date column
67
        return $c->render( status => 200, openapi => $requests );
68
    # that needs formatting
69
    foreach(@req_list) {
70
        foreach my $field(@format_dates) {
71
            if (defined $_->{$field}) {
72
                $_->{$field . "_formatted"} = format_sqldatetime(
73
                    $_->{$field},
74
                    undef,
75
                    undef,
76
                    1
77
                );
78
            }
79
        }
80
68
    }
81
    }
82
83
    return $c->render( status => 200, openapi => \@req_list );
69
}
84
}
70
85
71
1;
86
1;
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+4 lines)
Lines 4014-4020 span { Link Here
4014
            margin-bottom: 1em;
4014
            margin-bottom: 1em;
4015
        }
4015
        }
4016
    }
4016
    }
4017
}
4017
4018
4019
#illfilter_dateplaced,
4020
#illfilter_datemodified {
4021
    width: 80%;
4018
}
4022
}
4019
4023
4020
#requestattributes {
4024
#requestattributes {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-31 / +299 lines)
Lines 10-21 Link Here
10
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
10
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
11
[% Asset.css("css/datatables.css") | $raw %]
11
[% Asset.css("css/datatables.css") | $raw %]
12
[% INCLUDE 'datatables.inc' %]
12
[% INCLUDE 'datatables.inc' %]
13
[% INCLUDE 'calendar.inc' %]
13
<script type="text/javascript">
14
<script type="text/javascript">
14
    //<![CDATA[
15
    //<![CDATA[
15
    $(document).ready(function() {
16
    $(document).ready(function() {
16
17
17
        // Illview Datatable setup
18
        // Illview Datatable setup
18
19
20
        var table;
21
22
        // Filters that are active
23
        var activeFilters = {};
24
25
        // Date format for datepickers
26
        var dateMap = {
27
            dmydot: 'dd.mm.yy',
28
            iso: 'yy-mm-dd',
29
            metric: 'dd/mm/yy',
30
            us: 'mm/dd/yy'
31
        };
32
        var dateFormat = dateMap['[% Koha.Preference('dateformat') %]'];
33
        $('#illfilter_dateplaced, #illfilter_datemodified').datepicker(
34
            'option', 'dateFormat', dateFormat
35
        );
36
19
        // Fields we don't want to display
37
        // Fields we don't want to display
20
        var ignore = [
38
        var ignore = [
21
            'accessurl',
39
            'accessurl',
Lines 27-33 Link Here
27
            'medium',
45
            'medium',
28
            'notesopac',
46
            'notesopac',
29
            'notesstaff',
47
            'notesstaff',
30
            'placed',
31
            'replied'
48
            'replied'
32
        ];
49
        ];
33
50
Lines 46-59 Link Here
46
            'metadata_Author',
63
            'metadata_Author',
47
            'metadata_Title',
64
            'metadata_Title',
48
            'borrowername',
65
            'borrowername',
66
            'patron_cardnumber',
49
            'biblio_id',
67
            'biblio_id',
50
            'library',
68
            'library',
51
            'status',
69
            'status',
70
            'placed',
71
            'placed_formatted',
52
            'updated',
72
            'updated',
73
            'updated_formatted',
53
            'illrequest_id',
74
            'illrequest_id',
54
            'action'
75
            'action'
55
        ];
76
        ];
56
77
78
        // Filterable columns
79
        var filterable = {
80
            status: {
81
                prep: function(tableData, oData) {
82
                    var uniques = {};
83
                    tableData.forEach(function(row) {
84
                        var resolvedName = getStatusName(
85
                            oData[0].capabilities[row.status].name
86
                        );
87
                        uniques[resolvedName] = 1
88
                    });
89
                    Object.keys(uniques).sort().forEach(function(unique) {
90
                        $('#illfilter_status').append(
91
                            '<option value="' + unique  +
92
                            '">' + unique +  '</option>'
93
                        );
94
                    });
95
                },
96
                listener: function() {
97
                    var me = 'status';
98
                    $('#illfilter_status').change(function() {
99
                        var sel = $('#illfilter_status option:selected').val();
100
                        if (sel && sel.length > 0) {
101
                            activeFilters[me] = function() {
102
                                table.column(6).search(sel);
103
                            }
104
                        } else {
105
                            if (activeFilters.hasOwnProperty(me)) {
106
                                delete activeFilters[me];
107
                            }
108
                        }
109
                    });
110
                },
111
                clear: function() {
112
                    $('#illfilter_status').val('');
113
                }
114
            },
115
            pickupBranch: {
116
                prep: function(tableData, oData) {
117
                    var uniques = {};
118
                    tableData.forEach(function(row) {
119
                        uniques[row.library.branchname] = 1
120
                    });
121
                    Object.keys(uniques).sort().forEach(function(unique) {
122
                        $('#illfilter_branchname').append(
123
                            '<option value="' + unique  +
124
                            '">' + unique +  '</option>'
125
                        );
126
                    });
127
                },
128
                listener: function() {
129
                    var me = 'pickupBranch';
130
                    $('#illfilter_branchname').change(function() {
131
                        var sel = $('#illfilter_branchname option:selected').val();
132
                        if (sel && sel.length > 0) {
133
                            activeFilters[me] = function() {
134
                                table.column(5).search(sel);
135
                            }
136
                        } else {
137
                            if (activeFilters.hasOwnProperty(me)) {
138
                                delete activeFilters[me];
139
                            }
140
                        }
141
                    });
142
                },
143
                clear: function() {
144
                    $('#illfilter_branchname').val('');
145
                }
146
            },
147
            barcode: {
148
                listener: function() {
149
                    var me = 'barcode';
150
                    $('#illfilter_barcode').change(function() {
151
                        var val = $('#illfilter_barcode').val();
152
                        if (val && val.length > 0) {
153
                            activeFilters[me] = function() {
154
                                table.column(3).search(val);
155
                            }
156
                        } else {
157
                            if (activeFilters.hasOwnProperty(me)) {
158
                                delete activeFilters[me];
159
                            }
160
                        }
161
                    });
162
                },
163
                clear: function() {
164
                    $('#illfilter_barcode').val('');
165
                }
166
            },
167
            dateModified: {
168
                listener: function() {
169
                    var me = 'dateModified';
170
                    $('#illfilter_datemodified').change(function() {
171
                        var val = $('#illfilter_datemodified').val();
172
                        if (val && val.length > 0) {
173
                            activeFilters[me] = function() {
174
                                table.column(10).search(val);
175
                            }
176
                        } else {
177
                            if (activeFilters.hasOwnProperty(me)) {
178
                                delete activeFilters[me];
179
                            }
180
                        }
181
                    });
182
                },
183
                clear: function() {
184
                    $('#illfilter_datemodified').val('');
185
                }
186
            },
187
            datePlaced: {
188
                listener: function() {
189
                    var me = 'datePlaced';
190
                    $('#illfilter_dateplaced').change(function() {
191
                        var val = $('#illfilter_dateplaced').val();
192
                        if (val && val.length > 0) {
193
                            activeFilters[me] = function() {
194
                                table.column(8).search(val);
195
                            }
196
                        } else {
197
                            if (activeFilters.hasOwnProperty(me)) {
198
                                delete activeFilters[me];
199
                            }
200
                        }
201
                    });
202
                },
203
                clear: function() {
204
                    $('#illfilter_dateplaced').val('');
205
                }
206
            }
207
        };
208
57
        // Remove any fields we're ignoring
209
        // Remove any fields we're ignoring
58
        var removeIgnore = function(dataObj) {
210
        var removeIgnore = function(dataObj) {
59
            dataObj.forEach(function(thisRow) {
211
            dataObj.forEach(function(thisRow) {
Lines 133-163 Link Here
133
                var status_name = meta.settings.oInit.originalData[0].capabilities[
285
                var status_name = meta.settings.oInit.originalData[0].capabilities[
134
                    row.status
286
                    row.status
135
                ].name;
287
                ].name;
136
                switch( status_name ) {
288
                return getStatusName(status_name);
137
                    case "New request":
138
                        return _("New request");
139
                    case "Requested":
140
                        return _("Requested");
141
                    case "Requested from partners":
142
                        return _("Requested from partners");
143
                    case "Request reverted":
144
                        return _("Request reverted");
145
                    case "Queued request":
146
                        return _("Queued request");
147
                    case "Cancellation requested":
148
                        return _("Cancellation requested");
149
                    case "Completed":
150
                        return _("Completed");
151
                    case "Delete request":
152
                        return _("Delete request");
153
                    default:
154
                        return status_name;
155
                }
156
            } else {
289
            } else {
157
                return '';
290
                return '';
158
            }
291
            }
159
        };
292
        };
160
293
294
        var getStatusName = function(origName) {
295
            switch( origName ) {
296
                case "New request":
297
                    return _("New request");
298
                case "Requested":
299
                    return _("Requested");
300
                case "Requested from partners":
301
                    return _("Requested from partners");
302
                case "Request reverted":
303
                    return _("Request reverted");
304
                case "Queued request":
305
                    return _("Queued request");
306
                case "Cancellation requested":
307
                    return _("Cancellation requested");
308
                case "Completed":
309
                    return _("Completed");
310
                case "Delete request":
311
                    return _("Delete request");
312
                default:
313
                    return origName;
314
            }
315
        };
316
161
        // Render function for creating a row's action link
317
        // Render function for creating a row's action link
162
        var createActionLink = function(data, type, row) {
318
        var createActionLink = function(data, type, row) {
163
            return '<a class="btn btn-default btn-sm" ' +
319
            return '<a class="btn btn-default btn-sm" ' +
Lines 191-196 Link Here
191
            library: {
347
            library: {
192
                name: _("Library"),
348
                name: _("Library"),
193
                func: createLibrary
349
                func: createLibrary
350
            },
351
            updated: {
352
                name: _("Updated on"),
353
            },
354
            patron_cardnumber: {
355
                name: _("Patron barcode")
194
            }
356
            }
195
        };
357
        };
196
358
Lines 241-247 Link Here
241
                    // Create the base column object
403
                    // Create the base column object
242
                    var colObj = {
404
                    var colObj = {
243
                        name: thisCol,
405
                        name: thisCol,
244
                        className: thisCol
406
                        className: thisCol,
407
                        defaultContent: ''
245
                    };
408
                    };
246
                    // We may need to process the data going in this
409
                    // We may need to process the data going in this
247
                    // column, so do it if necessary
410
                    // column, so do it if necessary
Lines 257-283 Link Here
257
                });
420
                });
258
421
259
                // Initialise the datatable
422
                // Initialise the datatable
260
                $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
423
                table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
261
                    'aoColumnDefs': [  // Last column shouldn't be sortable or searchable
424
                    'aoColumnDefs': [
262
                        {
425
                        { // Last column shouldn't be sortable or searchable
263
                            'aTargets': [ 'actions' ],
426
                            'aTargets': [ 'actions' ],
264
                            'bSortable': false,
427
                            'bSortable': false,
265
                            'bSearchable': false
428
                            'bSearchable': false
266
                        },
429
                        },
430
                        { // Hide the two date columns we use just for sorting
431
                            'aTargets': [ 'placed', 'updated' ],
432
                            'bVisible': false,
433
                            'bSearchable': false
434
                        },
435
                        { // When sorting 'placed', we want to use the
436
                          // unformatted column
437
                          'aTargets': [ 'placed_formatted'],
438
                          'iDataSort': 7
439
                        },
440
                        { // When sorting 'updated', we want to use the
441
                          // unformatted column
442
                          'aTargets': [ 'updated_formatted'],
443
                          'iDataSort': 9
444
                        }
267
                    ],
445
                    ],
268
                    'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending
446
                    'aaSorting': [[ 9, 'desc' ]], // Default sort, updated descending
269
                    'processing': true, // Display a message when manipulating
447
                    'processing': true, // Display a message when manipulating
270
                    'iDisplayLength': 10, // 10 results per page
448
                    'iDisplayLength': 10, // 10 results per page
271
                    'sPaginationType': "full_numbers", // Pagination display
449
                    'sPaginationType': "full_numbers", // Pagination display
272
                    'deferRender': true, // Improve performance on big datasets
450
                    'deferRender': true, // Improve performance on big datasets
273
                    'data': dataCopy,
451
                    'data': dataCopy,
274
                    'columns': colData,
452
                    'columns': colData,
275
                    'originalData': data // Enable render functions to access
453
                    'originalData': data, // Enable render functions to access
276
                                       // our original data
454
                                          // our original data
455
                    'initComplete': function() {
456
457
                        // Prepare any filter elements that need it
458
                        for (var el in filterable) {
459
                            if (filterable.hasOwnProperty(el)) {
460
                                if (filterable[el].hasOwnProperty('prep')) {
461
                                    filterable[el].prep(dataCopy, data);
462
                                }
463
                                if (filterable[el].hasOwnProperty('listener')) {
464
                                    filterable[el].listener();
465
                                }
466
                            }
467
                        }
468
469
                    }
277
                }));
470
                }));
471
278
            }
472
            }
279
        );
473
        );
280
474
475
        var clearSearch = function() {
476
            table.search('').columns().search('');
477
            activeFilters = {};
478
            for (var filter in filterable) {
479
                if (
480
                    filterable.hasOwnProperty(filter) &&
481
                    filterable[filter].hasOwnProperty('clear')
482
                ) {
483
                    filterable[filter].clear();
484
                }
485
            }
486
            table.draw();
487
        };
488
489
        // Apply any search filters, or clear any previous
490
        // ones
491
        $('#illfilter_form').submit(function(event) {
492
            event.preventDefault();
493
            table.search('').columns().search('');
494
            for (var active in activeFilters) {
495
                if (activeFilters.hasOwnProperty(active)) {
496
                    activeFilters[active]();
497
                }
498
            }
499
            table.draw();
500
        });
501
502
        // Clear all filters
503
        $('#clear_search').click(function() {
504
            clearSearch();
505
        });
506
281
    });
507
    });
282
    //]]>
508
    //]]>
283
</script>
509
</script>
Lines 299-304 Link Here
299
525
300
<div id="doc3" class="yui-t2">
526
<div id="doc3" class="yui-t2">
301
    <div id="bd">
527
    <div id="bd">
528
        [% IF query_type == 'illlist' %]
529
        <div id="illfilter_yui_column" class="yui-b">
530
            <form method="get" id="illfilter_form">
531
                <fieldset class="brief">
532
                    <h3>Filters</h3>
533
                    <ol>
534
                        <li>
535
                            <label for="illfilter_status">Status:</label>
536
                            <select name="illfilter_status" id="illfilter_status">
537
                                <option value=""></option>
538
                            </select>
539
                        </li>
540
                        <li>
541
                            <label for="illfilter_dateplaced">Date placed:</label>
542
                            <input type="text" name="illfilter_dateplaced" id="illfilter_dateplaced" class="datepicker">
543
                        </li>
544
                        <li>
545
                            <label for="illfilter_datemodified">Updated on:</label>
546
                            <input type="text" name="illfilter_datemodified" id="illfilter_datemodified" class="datepicker">
547
                        </li>
548
                        <li>
549
                            <label for="illfilter_branchname">Library:</label>
550
                            <select name="illfilter_branchname" id="illfilter_branchname">
551
                                <option value=""></option>
552
                            </select>
553
                        </li>
554
                        <li>
555
                            <label for="illfilter_barcode">Patron barcode:</label>
556
                            <input type="text" name="illfilter_barcode" id="illfilter_barcode">
557
                        </li>
558
                    </ol>
559
                    <fieldset class="action">
560
                        <input type="submit" value="Search" />
561
                        <input type="button" value="Clear" id="clear_search" />
562
                    </fieldset>
563
                </fieldset>
564
            </form>
565
        </div>
566
        [% END %]
302
        <div id="yui-main">
567
        <div id="yui-main">
303
            <div id="interlibraryloans" class="yui-b">
568
            <div id="interlibraryloans" class="yui-b">
304
        [% IF !backends_available %]
569
        [% IF !backends_available %]
Lines 605-615 Link Here
605
                                <tr id="illview-header">
870
                                <tr id="illview-header">
606
                                    <th>Author</th>
871
                                    <th>Author</th>
607
                                    <th>Title</th>
872
                                    <th>Title</th>
608
                                    <th>Patron</th>
873
                                    <th>Patron name</th>
874
                                    <th>Patron barcode</th>
609
                                    <th>Biblio ID</th>
875
                                    <th>Biblio ID</th>
610
                                    <th>Library</th>
876
                                    <th>Library</th>
611
                                    <th>Status</th>
877
                                    <th>Status</th>
612
                                    <th>Updated on</th>
878
                                    <th class="placed">&nbsp;</th>
879
                                    <th class="placed_formatted">Date placed</th>
880
                                    <th class="updated">&nbsp;</th>
881
                                    <th class="updated_formatted">Updated on</th>
613
                                    <th>Request number</th>
882
                                    <th>Request number</th>
614
                                    <th class="actions"></th>
883
                                    <th class="actions"></th>
615
                                </tr>
884
                                </tr>
616
- 

Return to bug 20600