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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-85 / +68 lines)
Lines 2-7 Link Here
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% USE ColumnsSettings %]
5
6
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; ILL requests  &rsaquo;</title>
8
<title>Koha &rsaquo; ILL requests  &rsaquo;</title>
Lines 9-69 Link Here
9
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
10
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %]
10
[% Asset.css("css/datatables.css") %]
11
[% Asset.css("css/datatables.css") %]
11
[% INCLUDE 'datatables.inc' %]
12
[% INCLUDE 'datatables.inc' %]
13
[% INCLUDE 'columns_settings.inc' %]
12
<script type="text/javascript">
14
<script type="text/javascript">
13
    //<![CDATA[
15
    //<![CDATA[
14
    $(document).ready(function() {
16
    $(document).ready(function() {
15
17
16
        // Illview Datatable setup
18
        // Illview Datatable setup
17
19
18
        // Fields we don't want to display
20
        var columns_settings = [% ColumnsSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %];
19
        var ignore = [
20
            'accessurl',
21
            'backend',
22
            'branchcode',
23
            'completed',
24
            'capabilities',
25
            'cost',
26
            'medium',
27
            'notesopac',
28
            'notesstaff',
29
            'placed',
30
            'replied'
31
        ];
32
21
33
        // Fields we need to expand (flatten)
22
        // Fields we need to expand (flatten)
34
        var expand = [
23
        var expand = [
35
            'metadata',
24
            'metadata',
36
            'patron'
25
            'patron',
26
            'library'
37
        ];
27
        ];
38
28
39
        // Expanded fields
29
        // Expanded fields
40
        // This is auto populated
30
        // This is auto populated
41
        var expanded = {};
31
        var expanded = {};
42
32
43
        // The core fields that should be displayed first
44
        var core = [
45
            'metadata_Author',
46
            'metadata_Title',
47
            'borrowername',
48
            'biblio_id',
49
            'library',
50
            'status',
51
            'updated',
52
            'illrequest_id',
53
            'action'
54
        ];
55
56
        // Remove any fields we're ignoring
57
        var removeIgnore = function(dataObj) {
58
            dataObj.forEach(function(thisRow) {
59
                ignore.forEach(function(thisIgnore) {
60
                    if (thisRow.hasOwnProperty(thisIgnore)) {
61
                        delete thisRow[thisIgnore];
62
                    }
63
                });
64
            });
65
        };
66
67
        // Expand any fields we're expanding
33
        // Expand any fields we're expanding
68
        var expandExpand = function(row) {
34
        var expandExpand = function(row) {
69
            expand.forEach(function(thisExpand) {
35
            expand.forEach(function(thisExpand) {
Lines 74-80 Link Here
74
                    var expandObj = row[thisExpand];
40
                    var expandObj = row[thisExpand];
75
                    Object.keys(expandObj).forEach(
41
                    Object.keys(expandObj).forEach(
76
                        function(thisExpandCol) {
42
                        function(thisExpandCol) {
77
                            var expColName = thisExpand + '_' + thisExpandCol;
43
                            var expColName = thisExpand + '_' + thisExpandCol.replace(/\s/g,'_');
78
                            // Keep a list of fields that have been expanded
44
                            // Keep a list of fields that have been expanded
79
                            // so we can create toggle links for them
45
                            // so we can create toggle links for them
80
                            if (expanded[thisExpand].indexOf(expColName) == -1) {
46
                            if (expanded[thisExpand].indexOf(expColName) == -1) {
Lines 91-102 Link Here
91
            });
57
            });
92
        };
58
        };
93
59
94
        // Build a de-duped list of all column names
95
        var allCols = {};
96
        core.map(function(thisCore) {
97
            allCols[thisCore] = 1;
98
        });
99
100
        // Strip the expand prefix if it exists, we do this for display
60
        // Strip the expand prefix if it exists, we do this for display
101
        var stripPrefix = function(value) {
61
        var stripPrefix = function(value) {
102
            expand.forEach(function(thisExpand) {
62
            expand.forEach(function(thisExpand) {
Lines 112-130 Link Here
112
                'href="/cgi-bin/koha/members/moremember.pl?' +
72
                'href="/cgi-bin/koha/members/moremember.pl?' +
113
                'borrowernumber='+row.borrowernumber+'">' +
73
                'borrowernumber='+row.borrowernumber+'">' +
114
                row.patron_firstname + ' ' + row.patron_surname +
74
                row.patron_firstname + ' ' + row.patron_surname +
75
                ' [' + row.patron_cardnumber + ' ]'
115
                '</a>';
76
                '</a>';
116
        };
77
        };
117
78
118
        // Our 'render' function for the library name
119
        var createLibrary = function(data, type, row) {
120
            return row.library.branchname;
121
        };
122
123
        // Render function for request ID
79
        // Render function for request ID
124
        var createRequestId = function(data, type, row) {
80
        var createRequestId = function(data, type, row) {
125
            return row.id_prefix + row.illrequest_id;
81
            return row.id_prefix + row.illrequest_id;
126
        };
82
        };
127
83
84
        // Render function for type
85
        var createType = function(data, type, row) {
86
            if (!row.hasOwnProperty('metadata_Type') || !row.metadata_Type) {
87
                if (row.hasOwnProperty('medium') && row.medium) {
88
                    row.metadata_Type = row.medium;
89
                } else {
90
                    row.metadata_Type = null;
91
                }
92
            }
93
            return row.metadata_Type;
94
        };
95
128
        // Render function for request status
96
        // Render function for request status
129
        var createStatus = function(data, type, row, meta) {
97
        var createStatus = function(data, type, row, meta) {
130
            var origData = meta.settings.oInit.originalData;
98
            var origData = meta.settings.oInit.originalData;
Lines 169-195 Link Here
169
        // Columns that require special treatment
137
        // Columns that require special treatment
170
        var specialCols = {
138
        var specialCols = {
171
            action: {
139
            action: {
172
                name: '',
173
                func: createActionLink
140
                func: createActionLink
174
            },
141
            },
175
            borrowername: {
142
            borrowernumber: {
176
                name: _("Patron"),
177
                func: createPatronLink
143
                func: createPatronLink
178
            },
144
            },
179
            illrequest_id: {
145
            illrequest_id: {
180
                name: _("Request number"),
181
                func: createRequestId
146
                func: createRequestId
182
            },
147
            },
183
            status: {
148
            status: {
184
                name: _("Status"),
185
                func: createStatus
149
                func: createStatus
186
            },
150
            },
187
            biblio_id: {
151
            metadata_Medium: {
188
                name: _("Biblio ID")
152
                func: createType
189
            },
153
            },
190
            library: {
154
            metadata_Type: {
191
                name: _("Library"),
155
                func: createType
192
                func: createLibrary
193
            }
156
            }
194
        };
157
        };
195
158
Lines 225-232 Link Here
225
                // Make a copy, we'll be removing columns next and need
188
                // Make a copy, we'll be removing columns next and need
226
                // to be able to refer to data that has been removed
189
                // to be able to refer to data that has been removed
227
                var dataCopy = $.extend(true, [], data);
190
                var dataCopy = $.extend(true, [], data);
228
                // Remove all columns we're not interested in
229
                removeIgnore(dataCopy);
230
                // Expand columns that need it and create an array
191
                // Expand columns that need it and create an array
231
                // of all column names
192
                // of all column names
232
                $.each(dataCopy, function(k, row) {
193
                $.each(dataCopy, function(k, row) {
Lines 236-262 Link Here
236
                // Assemble an array of column definitions for passing
197
                // Assemble an array of column definitions for passing
237
                // to datatables
198
                // to datatables
238
                var colData = [];
199
                var colData = [];
239
                Object.keys(allCols).forEach(function(thisCol) {
200
                columns_settings.forEach(function(thisCol) {
201
                    var colName = thisCol.columnname;
240
                    // Create the base column object
202
                    // Create the base column object
241
                    var colObj = {
203
                    var colObj = $.extend({}, thisCol);
242
                        name: thisCol,
204
                    colObj.name = colName;
243
                        className: thisCol
205
                    colObj.className = colName;
244
                    };
245
                    // We may need to process the data going in this
206
                    // We may need to process the data going in this
246
                    // column, so do it if necessary
207
                    // column, so do it if necessary
247
                    if (
208
                    if (
248
                        specialCols.hasOwnProperty(thisCol) &&
209
                        specialCols.hasOwnProperty(colName) &&
249
                        specialCols[thisCol].hasOwnProperty('func')
210
                        specialCols[colName].hasOwnProperty('func')
250
                    ) {
211
                    ) {
251
                        colObj.render = specialCols[thisCol].func;
212
                        colObj.render = specialCols[colName].func;
252
                    } else {
213
                    } else {
253
                        colObj.data = thisCol;
214
                        colObj.data = colName;
254
                    }
215
                    }
216
                    // Make sure properties that aren't present in the API
217
                    // response are populated with null to avoid Datatables
218
                    // choking on their absence
219
                    dataCopy.forEach(function(thisData) {
220
                        if (!thisData.hasOwnProperty(colName)) {
221
                            thisData[colName] = null;
222
                        }
223
                    });
255
                    colData.push(colObj);
224
                    colData.push(colObj);
256
                });
225
                });
257
226
258
                // Initialise the datatable
227
                // Initialise the datatable
259
                $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
228
                var illTable = KohaTable("ill-requests", {
260
                    'aoColumnDefs': [  // Last column shouldn't be sortable or searchable
229
                    'aoColumnDefs': [  // Last column shouldn't be sortable or searchable
261
                        {
230
                        {
262
                            'aTargets': [ 'actions' ],
231
                            'aTargets': [ 'actions' ],
Lines 264-270 Link Here
264
                            'bSearchable': false
233
                            'bSearchable': false
265
                        },
234
                        },
266
                    ],
235
                    ],
267
                    'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending
236
                    'aaSorting': [[ 7, 'desc' ]], // Default sort, updated descending
268
                    'processing': true, // Display a message when manipulating
237
                    'processing': true, // Display a message when manipulating
269
                    'iDisplayLength': 10, // 10 results per page
238
                    'iDisplayLength': 10, // 10 results per page
270
                    'sPaginationType': "full_numbers", // Pagination display
239
                    'sPaginationType': "full_numbers", // Pagination display
Lines 273-279 Link Here
273
                    'columns': colData,
242
                    'columns': colData,
274
                    'originalData': data // Enable render functions to access
243
                    'originalData': data // Enable render functions to access
275
                                       // our original data
244
                                       // our original data
276
                }));
245
                }, columns_settings);
277
            }
246
            }
278
        );
247
        );
279
248
Lines 602-616 Link Here
602
                        <table id="ill-requests">
571
                        <table id="ill-requests">
603
                            <thead>
572
                            <thead>
604
                                <tr id="illview-header">
573
                                <tr id="illview-header">
605
                                    <th>Author</th>
574
                                    <th scope="col">Request ID</th>
606
                                    <th>Title</th>
575
                                    <th scope="col">Patron</th>
607
                                    <th>Patron</th>
576
                                    <th scope="col">Biblio ID</th>
608
                                    <th>Biblio ID</th>
577
                                    <th scope="col">Branch</th>
609
                                    <th>Library</th>
578
                                    <th scope="col">Status</th>
610
                                    <th>Status</th>
579
                                    <th scope="col">Placed on</th>
611
                                    <th>Updated on</th>
580
                                    <th scope="col">Replied</th>
612
                                    <th>Request number</th>
581
                                    <th scope="col" class="updated">Updated on</th>
613
                                    <th class="actions"></th>
582
                                    <th scope="col">Completed on</th>
583
                                    <th scope="col">Access URL</th>
584
                                    <th scope="col">Cost</th>
585
                                    <th scope="col">OPAC notes</th>
586
                                    <th scope="col">Staff notes</th>
587
                                    <th scope="col">Order ID</th>
588
                                    <th scope="col">Backend</th>
589
                                    <th scope="col">Author</th>
590
                                    <th scope="col">Title</th>
591
                                    <th scope="col">Issue</th>
592
                                    <th scope="col">Volume</th>
593
                                    <th scope="col">Year</th>
594
                                    <th scope="col">Pages</th>
595
                                    <th scope="col">Article title</th>
596
                                    <th scope="col">Type</th>
597
                                    <th scope="col" class="actions"></th>
614
                                </tr>
598
                                </tr>
615
                            </thead>
599
                            </thead>
616
                            <tbody id="illview-body">
600
                            <tbody id="illview-body">
617
- 

Return to bug 21063