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