Lines 2-7
Link Here
|
2 |
[% USE Koha %] |
2 |
[% USE Koha %] |
3 |
[% USE KohaDates %] |
3 |
[% USE KohaDates %] |
4 |
|
4 |
|
|
|
5 |
[% columns = [ 'metadata_Author', 'metadata_Title', 'borrowername', 'biblio_id', 'library', 'status', 'updated', 'illrequest_id', 'action' ] %] |
6 |
|
7 |
[% BLOCK translate_column %] |
8 |
[%- SWITCH column -%] |
9 |
[%- CASE 'metadata_Author' -%]Author |
10 |
[%- CASE 'metadata_Title' -%]Title |
11 |
[%- CASE 'borrowername' -%]Patron |
12 |
[%- CASE 'biblio_id' -%]Biblio ID |
13 |
[%- CASE 'library' -%]Library |
14 |
[%- CASE 'status' -%]Status |
15 |
[%- CASE 'updated' -%]Updated on |
16 |
[%- CASE 'illrequest_id' -%]Request number |
17 |
[%- END -%] |
18 |
[% END %] |
19 |
|
5 |
[% INCLUDE 'doc-head-open.inc' %] |
20 |
[% INCLUDE 'doc-head-open.inc' %] |
6 |
<title>Koha › ILL requests ›</title> |
21 |
<title>Koha › ILL requests ›</title> |
7 |
[% INCLUDE 'doc-head-close.inc' %] |
22 |
[% INCLUDE 'doc-head-close.inc' %] |
Lines 18-25
Link Here
|
18 |
var ignore = [ |
33 |
var ignore = [ |
19 |
'accessurl', |
34 |
'accessurl', |
20 |
'backend', |
35 |
'backend', |
|
|
36 |
'branchcode', |
21 |
'completed', |
37 |
'completed', |
22 |
'branch', |
|
|
23 |
'capabilities', |
38 |
'capabilities', |
24 |
'cost', |
39 |
'cost', |
25 |
'medium', |
40 |
'medium', |
Lines 45-51
Link Here
|
45 |
'metadata_Title', |
60 |
'metadata_Title', |
46 |
'borrowername', |
61 |
'borrowername', |
47 |
'biblio_id', |
62 |
'biblio_id', |
48 |
'branchcode', |
63 |
'library', |
49 |
'status', |
64 |
'status', |
50 |
'updated', |
65 |
'updated', |
51 |
'illrequest_id', |
66 |
'illrequest_id', |
Lines 98-120
Link Here
|
98 |
core.map(function(thisCore) { |
113 |
core.map(function(thisCore) { |
99 |
allCols[thisCore] = 1; |
114 |
allCols[thisCore] = 1; |
100 |
}); |
115 |
}); |
101 |
var unionColumns = function(row) { |
|
|
102 |
Object.keys(row).forEach(function(col) { |
103 |
if (ignore.indexOf(col) == -1) { |
104 |
allCols[col] = 1; |
105 |
} |
106 |
}); |
107 |
}; |
108 |
|
109 |
// Some rows may not have fields that other rows have, |
110 |
// so make sure all rows have the same fields |
111 |
var fillMissing = function(row) { |
112 |
Object.keys(allCols).forEach(function(thisCol) { |
113 |
row[thisCol] = (!row.hasOwnProperty(thisCol)) ? |
114 |
null : |
115 |
row[thisCol]; |
116 |
}); |
117 |
}; |
118 |
|
116 |
|
119 |
// Strip the expand prefix if it exists, we do this for display |
117 |
// Strip the expand prefix if it exists, we do this for display |
120 |
var stripPrefix = function(value) { |
118 |
var stripPrefix = function(value) { |
Lines 134-139
Link Here
|
134 |
'</a>'; |
132 |
'</a>'; |
135 |
}; |
133 |
}; |
136 |
|
134 |
|
|
|
135 |
// Our 'render' function for the library name |
136 |
var createLibrary = function(data, type, row) { |
137 |
return row.library.branchname; |
138 |
}; |
139 |
|
137 |
// Render function for request ID |
140 |
// Render function for request ID |
138 |
var createRequestId = function(data, type, row) { |
141 |
var createRequestId = function(data, type, row) { |
139 |
return row.id_prefix + row.illrequest_id; |
142 |
return row.id_prefix + row.illrequest_id; |
Lines 149-176
Link Here
|
149 |
switch( status_name ) { |
152 |
switch( status_name ) { |
150 |
case "New request": |
153 |
case "New request": |
151 |
return _("New request"); |
154 |
return _("New request"); |
152 |
break; |
|
|
153 |
case "Requested": |
155 |
case "Requested": |
154 |
return _("Requested"); |
156 |
return _("Requested"); |
155 |
break; |
|
|
156 |
case "Requested from partners": |
157 |
case "Requested from partners": |
157 |
return _("Requested from partners"); |
158 |
return _("Requested from partners"); |
158 |
break; |
|
|
159 |
case "Request reverted": |
159 |
case "Request reverted": |
160 |
return _("Request reverted"); |
160 |
return _("Request reverted"); |
161 |
break; |
|
|
162 |
case "Queued request": |
161 |
case "Queued request": |
163 |
return _("Queued request"); |
162 |
return _("Queued request"); |
164 |
break; |
|
|
165 |
case "Cancellation requested": |
163 |
case "Cancellation requested": |
166 |
return _("Cancellation requested"); |
164 |
return _("Cancellation requested"); |
167 |
break; |
|
|
168 |
case "Completed": |
165 |
case "Completed": |
169 |
return _("Completed"); |
166 |
return _("Completed"); |
170 |
break; |
|
|
171 |
case "Delete request": |
167 |
case "Delete request": |
172 |
return _("Delete request"); |
168 |
return _("Delete request"); |
173 |
break; |
|
|
174 |
default: |
169 |
default: |
175 |
return status_name; |
170 |
return status_name; |
176 |
} |
171 |
} |
Lines 209-227
Link Here
|
209 |
biblio_id: { |
204 |
biblio_id: { |
210 |
name: _("Biblio ID") |
205 |
name: _("Biblio ID") |
211 |
}, |
206 |
}, |
212 |
branchcode: { |
207 |
library: { |
213 |
name: _("Library") |
208 |
name: _("Library"), |
|
|
209 |
func: createLibrary |
214 |
} |
210 |
} |
215 |
}; |
211 |
}; |
216 |
|
212 |
|
217 |
// Helper for handling prefilter column names |
|
|
218 |
function toColumnName(myVal) { |
219 |
return myVal |
220 |
.replace(/^filter/, '') |
221 |
.replace(/([A-Z])/g, "_$1") |
222 |
.replace(/^_/,'').toLowerCase(); |
223 |
} |
224 |
|
225 |
// Toggle request attributes in Illview |
213 |
// Toggle request attributes in Illview |
226 |
$('#toggle_requestattributes').on('click', function(e) { |
214 |
$('#toggle_requestattributes').on('click', function(e) { |
227 |
e.preventDefault(); |
215 |
e.preventDefault(); |
Lines 248-254
Link Here
|
248 |
// Get our data from the API and process it prior to passing |
236 |
// Get our data from the API and process it prior to passing |
249 |
// it to datatables |
237 |
// it to datatables |
250 |
var ajax = $.ajax( |
238 |
var ajax = $.ajax( |
251 |
'/api/v1/illrequests?embed=metadata,patron,capabilities,branch' |
239 |
'/api/v1/illrequests?embed=metadata,patron,capabilities,library' |
252 |
).done(function() { |
240 |
).done(function() { |
253 |
var data = JSON.parse(ajax.responseText); |
241 |
var data = JSON.parse(ajax.responseText); |
254 |
// Make a copy, we'll be removing columns next and need |
242 |
// Make a copy, we'll be removing columns next and need |
Lines 260-293
Link Here
|
260 |
// of all column names |
248 |
// of all column names |
261 |
$.each(dataCopy, function(k, row) { |
249 |
$.each(dataCopy, function(k, row) { |
262 |
expandExpand(row); |
250 |
expandExpand(row); |
263 |
unionColumns(row); |
|
|
264 |
}); |
251 |
}); |
|
|
252 |
|
265 |
// Append any extra columns we need to tag on |
253 |
// Append any extra columns we need to tag on |
266 |
if (extra.length > 0) { |
254 |
if (extra.length > 0) { |
267 |
extra.forEach(function(thisExtra) { |
255 |
extra.forEach(function(thisExtra) { |
268 |
allCols[thisExtra] = 1; |
256 |
allCols[thisExtra] = 1; |
269 |
}); |
257 |
}); |
270 |
} |
258 |
} |
271 |
// Different requests will have different columns, |
|
|
272 |
// make sure they all have the same |
273 |
$.each(dataCopy, function(k, row) { |
274 |
fillMissing(row); |
275 |
}); |
276 |
|
259 |
|
277 |
// Assemble an array of column definitions for passing |
260 |
// Assemble an array of column definitions for passing |
278 |
// to datatables |
261 |
// to datatables |
279 |
var colData = []; |
262 |
var colData = []; |
280 |
Object.keys(allCols).forEach(function(thisCol) { |
263 |
Object.keys(allCols).forEach(function(thisCol) { |
281 |
// We may have defined a pretty name for this column |
|
|
282 |
var colName = ( |
283 |
specialCols.hasOwnProperty(thisCol) && |
284 |
specialCols[thisCol].hasOwnProperty('name') |
285 |
) ? |
286 |
specialCols[thisCol].name : |
287 |
thisCol; |
288 |
// Create the table header for this column |
289 |
var str = '<th>' + stripPrefix(colName) + '</th>'; |
290 |
$(str).appendTo('#illview-header'); |
291 |
// Create the base column object |
264 |
// Create the base column object |
292 |
var colObj = { |
265 |
var colObj = { |
293 |
name: thisCol, |
266 |
name: thisCol, |
Lines 306-389
Link Here
|
306 |
colData.push(colObj); |
279 |
colData.push(colObj); |
307 |
}); |
280 |
}); |
308 |
|
281 |
|
309 |
// Create the toggle links for all metadata fields |
|
|
310 |
var links = []; |
311 |
expanded.metadata.forEach(function(thisExpanded) { |
312 |
if (core.indexOf(thisExpanded) == -1) { |
313 |
links.push( |
314 |
'<a href="#" class="toggle-vis" data-column="' + |
315 |
thisExpanded + '">' + stripPrefix(thisExpanded) + |
316 |
'</a>' |
317 |
); |
318 |
} |
319 |
}); |
320 |
$('#column-toggle').append(links.join(' | ')); |
321 |
|
322 |
// Initialise the datatable |
282 |
// Initialise the datatable |
323 |
var myTable = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { |
283 |
$('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { |
324 |
aoColumnDefs: [ // Last column shouldn't be sortable or searchable |
284 |
'aoColumnDefs': [ // Last column shouldn't be sortable or searchable |
325 |
{ |
285 |
{ |
326 |
aTargets: [ 'action' ], |
286 |
'aTargets': [ 'action' ], |
327 |
bSortable: false, |
287 |
'bSortable': false, |
328 |
bSearchable: false |
288 |
'bSearchable': false |
329 |
}, |
289 |
}, |
330 |
], |
290 |
], |
331 |
aaSorting: [[ 6, 'desc' ]], // Default sort, updated descending |
291 |
'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending |
332 |
processing: true, // Display a message when manipulating |
292 |
'processing': true, // Display a message when manipulating |
333 |
language: { |
293 |
'iDisplayLength': 10, // 10 results per page |
334 |
loadingRecords: "Please wait - loading requests...", |
294 |
'sPaginationType': "full_numbers", // Pagination display |
335 |
zeroRecords: "No requests were found" |
295 |
'deferRender': true, // Improve performance on big datasets |
336 |
}, |
296 |
'data': dataCopy, |
337 |
iDisplayLength: 10, // 10 results per page |
297 |
'columns': colData, |
338 |
sPaginationType: "full_numbers", // Pagination display |
298 |
'originalData': data // Enable render functions to access |
339 |
deferRender: true, // Improve performance on big datasets |
|
|
340 |
data: dataCopy, |
341 |
columns: colData, |
342 |
originalData: data // Enable render functions to access |
343 |
// our original data |
299 |
// our original data |
344 |
})); |
300 |
})); |
345 |
|
|
|
346 |
// Reset columns to default |
347 |
var resetColumns = function() { |
348 |
Object.keys(allCols).forEach(function(thisCol) { |
349 |
myTable.column(thisCol + ':name').visible(core.indexOf(thisCol) != -1); |
350 |
}); |
351 |
myTable.columns.adjust().draw(false); |
352 |
}; |
353 |
|
354 |
// Handle the click event on a toggle link |
355 |
$('a.toggle-vis').on('click', function(e) { |
356 |
e.preventDefault(); |
357 |
var column = myTable.column( |
358 |
$(this).data('column') + ':name' |
359 |
); |
360 |
column.visible(!column.visible()); |
361 |
}); |
362 |
|
363 |
// Reset column toggling |
364 |
$('#reset-toggle').click(function() { |
365 |
resetColumns(); |
366 |
}); |
367 |
|
368 |
// Handle a prefilter request and do the prefiltering |
369 |
var filters = $('#ill-requests').data(); |
370 |
if (typeof filters !== 'undefined') { |
371 |
var filterNames = Object.keys(filters).filter( |
372 |
function(thisData) { |
373 |
return thisData.match(/^filter/); |
374 |
} |
375 |
); |
376 |
filterNames.forEach(function(thisFilter) { |
377 |
var filterName = toColumnName(thisFilter) + ':name'; |
378 |
var regex = '^'+filters[thisFilter]+'$'; |
379 |
myTable.columns(filterName).search(regex, true, false); |
380 |
}); |
381 |
myTable.draw(); |
382 |
} |
383 |
|
384 |
// Initialise column hiding |
385 |
resetColumns(); |
386 |
|
387 |
} |
301 |
} |
388 |
); |
302 |
); |
389 |
|
303 |
|
Lines 464-471
Link Here
|
464 |
[% END %] |
378 |
[% END %] |
465 |
<!-- Start of GENERIC_EMAIL case --> |
379 |
<!-- Start of GENERIC_EMAIL case --> |
466 |
[% IF whole.value.partners %] |
380 |
[% IF whole.value.partners %] |
467 |
[% ill_url = here_link _ "?method=illview&illrequest_id=" _ request.illrequest_id %] |
381 |
[% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %] |
468 |
<form method="POST" action=[% here_link %]> |
382 |
<form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl"> |
469 |
<fieldset class="rows"> |
383 |
<fieldset class="rows"> |
470 |
<legend>Interlibrary loan request details</legend> |
384 |
<legend>Interlibrary loan request details</legend> |
471 |
<ol> |
385 |
<ol> |
Lines 516-522
Link Here
|
516 |
<!-- generic_confirm ends here --> |
430 |
<!-- generic_confirm ends here --> |
517 |
|
431 |
|
518 |
[% ELSIF query_type == 'edit_action' %] |
432 |
[% ELSIF query_type == 'edit_action' %] |
519 |
<form method="POST" action=[% here_link %]> |
433 |
<form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl"> |
520 |
<fieldset class="rows"> |
434 |
<fieldset class="rows"> |
521 |
<legend>Request details</legend> |
435 |
<legend>Request details</legend> |
522 |
<ol> |
436 |
<ol> |
Lines 700-717
Link Here
|
700 |
<div id="results"> |
614 |
<div id="results"> |
701 |
<h3>Details for all requests</h3> |
615 |
<h3>Details for all requests</h3> |
702 |
|
616 |
|
703 |
<div id="column-toggle"> |
617 |
<table id="ill-requests"> |
704 |
Toggle additional columns: |
|
|
705 |
</div> |
706 |
<div id="reset-toggle"><a href="#">Reset toggled columns</a></div> |
707 |
|
708 |
<table |
709 |
[% FOREACH filter IN prefilters %] |
710 |
data-filter-[% filter.name %]="[% filter.value %]" |
711 |
[% END %] |
712 |
id="ill-requests"> |
713 |
<thead> |
618 |
<thead> |
714 |
<tr id="illview-header"></tr> |
619 |
<tr id="illview-header"> |
|
|
620 |
[% FOR column IN columns %] |
621 |
<th>[% PROCESS translate_column column=column %]</th> |
622 |
[% END %] |
623 |
</tr> |
715 |
</thead> |
624 |
</thead> |
716 |
<tbody id="illview-body"> |
625 |
<tbody id="illview-body"> |
717 |
</tbody> |
626 |
</tbody> |
718 |
- |
|
|