4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › ILL requests ›</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
8 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
9 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css">
10 [% INCLUDE 'datatables.inc' %]
11 <script type="text/javascript">
13 $(document).ready(function() {
15 // Illview Datatable setup
17 // Fields we don't want to display
32 // Fields we need to expand (flatten)
39 // This is auto populated
42 // The core fields that should be displayed first
55 // Extra fields that we need to tack on to the end
56 var extra = [ 'action' ];
58 // Remove any fields we're ignoring
59 var removeIgnore = function(dataObj) {
60 dataObj.forEach(function(thisRow) {
61 ignore.forEach(function(thisIgnore) {
62 if (thisRow.hasOwnProperty(thisIgnore)) {
63 delete thisRow[thisIgnore];
69 // Expand any fields we're expanding
70 var expandExpand = function(row) {
71 expand.forEach(function(thisExpand) {
72 if (row.hasOwnProperty(thisExpand)) {
73 if (!expanded.hasOwnProperty(thisExpand)) {
74 expanded[thisExpand] = [];
76 var expandObj = row[thisExpand];
77 Object.keys(expandObj).forEach(
78 function(thisExpandCol) {
79 var expColName = thisExpand + '_' + thisExpandCol;
80 // Keep a list of fields that have been expanded
81 // so we can create toggle links for them
82 if (expanded[thisExpand].indexOf(expColName) == -1) {
83 expanded[thisExpand].push(expColName);
85 expandObj[expColName] =
86 expandObj[thisExpandCol];
87 delete expandObj[thisExpandCol];
90 $.extend(true, row, expandObj);
91 delete row[thisExpand];
96 // Build a de-duped list of all column names
98 core.map(function(thisCore) {
99 allCols[thisCore] = 1;
101 var unionColumns = function(row) {
102 Object.keys(row).forEach(function(col) {
103 if (ignore.indexOf(col) == -1) {
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)) ?
119 // Strip the expand prefix if it exists, we do this for display
120 var stripPrefix = function(value) {
121 expand.forEach(function(thisExpand) {
122 var regex = new RegExp(thisExpand + '_', 'g');
123 value = value.replace(regex, '');
128 // Our 'render' function for borrowerlink
129 var createBorrowerLink = function(data, type, row) {
130 return '<a title="View borrower details" ' +
131 'href="/cgi-bin/koha/members/moremember.pl?' +
132 'borrowernumber='+row.borrowernumber+'">' +
133 row.patron_firstname + ' ' + row.patron_surname +
137 // Render function for request ID
138 var createRequestId = function(data, type, row) {
139 return row.id_prefix + row.illrequest_id;
142 // Render function for request status
143 var createStatus = function(data, type, row, meta) {
144 var origData = meta.settings.oInit.originalData;
145 if (origData.length > 0) {
146 return meta.settings.oInit.originalData[0].capabilities[
154 // Render function for creating a row's action link
155 var createActionLink = function(data, type, row) {
156 return '<a class="btn btn-default btn-sm" ' +
157 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
158 'method=illview&illrequest_id=' +
160 '">Manage request</a>' +
164 // Columns that require special treatment
168 func: createActionLink
172 func: createBorrowerLink
175 name: 'Request number',
176 func: createRequestId
183 name: 'Biblio number'
190 // Helper for handling prefilter column names
191 function toColumnName(myVal) {
193 .replace(/^filter/, '')
194 .replace(/([A-Z])/g, "_$1")
195 .replace(/^_/,'').toLowerCase();
198 // Toggle request attributes in Illview
199 $('#toggle_requestattributes').click(function() {
200 $('#requestattributes').toggleClass('content_hidden');
203 // Filter partner list
204 $('#partner_filter').keyup(function() {
205 var needle = $('#partner_filter').val();
206 $('#partners > option').each(function() {
207 var regex = new RegExp(needle, 'i');
209 needle.length == 0 ||
210 $(this).is(':selected') ||
211 $(this).text().match(regex)
220 // Get our data from the API and process it prior to passing
223 '/api/v1/illrequests?embed=metadata,patron,capabilities,branch'
225 var data = JSON.parse(ajax.responseText);
226 // Make a copy, we'll be removing columns next and need
227 // to be able to refer to data that has been removed
228 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
232 // of all column names
233 $.each(dataCopy, function(k, row) {
237 // Append any extra columns we need to tag on
238 if (extra.length > 0) {
239 extra.forEach(function(thisExtra) {
240 allCols[thisExtra] = 1;
243 // Different requests will have different columns,
244 // make sure they all have the same
245 $.each(dataCopy, function(k, row) {
249 // Assemble an array of column definitions for passing
252 Object.keys(allCols).forEach(function(thisCol) {
253 // We may have defined a pretty name for this column
255 specialCols.hasOwnProperty(thisCol) &&
256 specialCols[thisCol].hasOwnProperty('name')
258 specialCols[thisCol].name :
260 // Create the table header for this column
261 var str = '<th>' + stripPrefix(colName) + '</th>';
262 $(str).appendTo('#illview-header');
263 // Create the base column object
268 // We may need to process the data going in this
269 // column, so do it if necessary
271 specialCols.hasOwnProperty(thisCol) &&
272 specialCols[thisCol].hasOwnProperty('func')
274 colObj.render = specialCols[thisCol].func;
276 colObj.data = thisCol
278 colData.push(colObj);
281 // Create the toggle links for all metadata fields
283 expanded.metadata.forEach(function(thisExpanded) {
284 if (core.indexOf(thisExpanded) == -1) {
286 '<a href="#" class="toggle-vis" data-column="' +
287 thisExpanded + '">' + stripPrefix(thisExpanded) +
292 $('#column-toggle').append(links.join(' | '));
294 // Initialise the datatable
295 var myTable = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
296 aoColumnDefs: [ // Last column shouldn't be sortable or searchable
298 aTargets: [ 'action' ],
303 aaSorting: [[ 6, 'desc' ]], // Default sort, updated descending
304 processing: true, // Display a message when manipulating
306 loadingRecords: "Please wait - loading requests...",
307 zeroRecords: "No requests were found"
309 iDisplayLength: 10, // 10 results per page
310 sPaginationType: "full_numbers", // Pagination display
311 deferRender: true, // Improve performance on big datasets
314 originalData: data // Enable render functions to access
318 // Reset columns to default
319 var resetColumns = function() {
320 Object.keys(allCols).forEach(function(thisCol) {
321 myTable.column(thisCol + ':name').visible(core.indexOf(thisCol) != -1);
323 myTable.columns.adjust().draw(false);
326 // Handle the click event on a toggle link
327 $('a.toggle-vis').on('click', function(e) {
329 var column = myTable.column(
330 $(this).data('column') + ':name'
332 column.visible(!column.visible());
335 // Reset column toggling
336 $('#reset-toggle').click(function() {
340 // Handle a prefilter request and do the prefiltering
341 var filters = $('#ill-requests').data();
342 if (typeof filters !== 'undefined') {
343 var filterNames = Object.keys(filters).filter(
345 return thisData.match(/^filter/);
348 filterNames.forEach(function(thisFilter) {
349 var filterName = toColumnName(thisFilter) + ':name';
350 var regex = '^'+filters[thisFilter]+'$';
351 myTable.columns(filterName).search(regex, true, false);
356 // Initialise column hiding
367 <body id="illrequests" class="ill">
368 [% INCLUDE 'header.inc' %]
369 [% INCLUDE 'cat-search.inc' %]
371 <div id="breadcrumbs">
372 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
373 [% IF query_type == 'create' %]
374 <a href=[% parent %]>ILL requests</a> › New request
375 [% ELSIF query_type == 'status' %]
376 <a href=[% parent %]>ILL requests</a> › Status
382 <div id="doc3" class="yui-t2">
385 <div id="interlibraryloans" class="yui-b">
386 [% INCLUDE 'ill-toolbar.inc' %]
389 <h1>Error performing operation</h1>
390 <!-- Dispatch on Status -->
391 <p>We encountered an error:</p>
393 <pre>[% whole.message %] ([% whole.status %])</pre>
397 [% IF query_type == 'create' %]
398 <h1>New ILL request</h1>
399 [% IF whole.stage == 'copyrightclearance' %]
402 [% Koha.Preference('ILLModuleCopyrightClearance') %]
404 <a href="?method=create&stage=copyrightclearance&backend=[% whole.value.backend %]"
405 class="btn btn-sm btn-default btn-group"><i class="fa fa-check">Yes</i></a>
406 <a href="/cgi-bin/koha/ill/ill-requests.pl"
407 class="btn btn-sm btn-default btn-group"><i class="fa fa-times">No</i></a>
410 [% PROCESS $whole.template %]
413 [% ELSIF query_type == 'confirm' %]
414 <h1>Confirm ILL request</h1>
415 [% PROCESS $whole.template %]
417 [% ELSIF query_type == 'cancel' and !whole.error %]
418 <h1>Cancel a confirmed request</h1>
419 [% PROCESS $whole.template %]
421 [% ELSIF query_type == 'generic_confirm' %]
422 <h1>Place request with partner libraries</h1>
423 <!-- Start of GENERIC_EMAIL case -->
424 [% IF whole.value.partners %]
425 [% ill_url = here_link _ "?method=illview&illrequest_id=" _ request.illrequest_id %]
426 <form method="POST" action=[% here_link %]>
427 <fieldset class="rows">
428 <legend>Interlibrary loan request details</legend>
431 <label for="partner_filter">Filter partner libraries:</label>
432 <input type="text" id="partner_filter">
435 <label for="partners">Select partner libraries:</label>
436 <select size="5" multiple="true" id="partners"
438 [% FOREACH partner IN whole.value.partners %]
439 <option value=[% partner.email %]>
440 [% partner.branchcode _ " - " _ partner.surname %]
447 <label for="subject">Subject Line</label>
448 <input type="text" name="subject"
449 id="subject" type="text"
450 value="[% whole.value.draft.subject %]"/>
453 <label for="body">Email text:</label>
454 <textarea name="body" id="body" rows="20" cols="80">[% whole.value.draft.body %]</textarea>
457 <input type="hidden" value="generic_confirm" name="method">
458 <input type="hidden" value="draft" name="stage">
459 <input type="hidden" value="[% request.illrequest_id %]" name="illrequest_id">
461 <fieldset class="action">
462 <input type="submit" class="btn btn-default" value="Send email"/>
463 <span><a href="[% ill_url %]" title="Return to request details">Cancel</a></span>
467 <fieldset class="rows">
468 <legend>Interlibrary loan request details</legend>
469 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
470 <p>Be sure to provide email addresses for these patrons.</p>
471 <p><span><a href="[% ill_url %]" title="Return to request details">Cancel</a></span></p>
474 <!-- generic_confirm ends here -->
476 [% ELSIF query_type == 'edit_action' %]
477 <form method="POST" action=[% here_link %]>
478 <fieldset class="rows">
479 <legend>Request details</legend>
481 <li class="borrowernumber">
482 <label for="borrowernumber">Borrower number:</label>
483 <input name="borrowernumber" id="borrowernumber" type="text" value="[% request.borrowernumber %]">
485 <li class="biblio_id">
486 <label for="biblio_id" class="biblio_id">Biblio number:</label>
487 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id %]">
489 <li class="branchcode">
490 <label for="branchcode" class="branchcode">Branch:</label>
491 <select name="branchcode" id="branch">
492 [% FOREACH branch IN branches %]
493 [% IF ( branch.branchcode == request.branchcode ) %]
494 <option value="[% branch.branchcode %]" selected="selected">
495 [% branch.branchname %]
498 <option value="[% branch.branchcode %]">
499 [% branch.branchname %]
506 <label class="status">Status:</label>
507 [% stat = request.status %]
508 [% request.capabilities.$stat.name %]
511 <label class="updated">Last updated:</label>
512 [% request.updated %]
515 <label class="medium">Request type:</label>
519 <label class="cost">Cost:</label>
523 <label class="req_id">Request number:</label>
524 [% request.id_prefix _ request.illrequest_id %]
526 <li class="notesstaff">
527 <label for="notesstaff" class="notesstaff">Staff notes:</label>
528 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff %]</textarea>
530 <li class="notesopac">
531 <label for="notesopac" class="notesopac">Opac notes:</label>
532 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac %]</textarea>
536 <fieldset class="action">
537 <input type="hidden" value="edit_action" name="method">
538 <input type="hidden" value="form" name="stage">
539 <input type="hidden" value="[% request.illrequest_id %]" name="illrequest_id">
540 <input type="submit" value="Submit">
541 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id %]">Cancel</a>
545 [% ELSIF query_type == 'delete_confirm' %]
547 <div class="dialog alert">
548 <h3>Are you sure you wish to delete this request?</h3>
550 <a class="btn btn-default btn-sm approve" href="?method=delete&illrequest_id=[% request.id %]&confirmed=1"><i class="fa fa-fw fa-check"></i>Yes</a>
551 <a class="btn btn-default btn-sm deny" href="?method=illview&illrequest_id=[% request.id %]"><i class="fa fa-fw fa-remove"></i>No</a>
556 [% ELSIF query_type == 'illview' %]
557 [% actions = request.available_actions %]
558 [% capabilities = request.capabilities %]
559 [% req_status = request.status %]
560 <h1>Manage ILL request</h1>
561 <div id="toolbar" class="btn-toolbar">
562 <a title="Edit request" id="ill-toolbar-btn-edit-action" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=edit_action&illrequest_id=[% request.illrequest_id %]">
563 <span class="fa fa-pencil"></span>
566 [% FOREACH action IN actions %]
567 [% IF action.method != 0 %]
568 <a title="[% action.ui_method_name %]" id="ill-toolbar-btn-[% action.id | lower %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method %]&illrequest_id=[% request.illrequest_id %]">
569 <span class="fa [% action.ui_method_icon %]"></span>
570 [% action.ui_method_name %]
575 <div id="ill-view-panel" class="panel panel-default">
576 <div class="panel-heading">
577 <h3>Request details</h3>
579 <div class="panel-body">
580 <h4>Details from library</h4>
582 <div class="orderid">
583 <span class="label orderid">Order ID:</span>
584 [% request.orderid || "N/A" %]
586 <div class="borrowernumber">
587 <span class="label borrowernumber">Borrower:</span>
588 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
589 <a href="[% borrowerlink %]" title="View borrower details">
590 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" %]
594 <div class="biblio_id">
595 <span class="label biblio_id">Biblio number:</span>
596 [% request.biblio_id || "N/A" %]
598 <div class="branchcode">
599 <span class="label branchcode">Branch:</span>
600 [% Branches.GetName(request.branchcode) %]
603 <span class="label status">Status:</span>
604 [% capabilities.$req_status.name %]
606 <div class="updated">
607 <span class="label updated">Last updated:</span>
608 [% request.updated %]
611 <span class="label medium">Request type:</span>
615 <span class="label cost">Cost:</span>
616 [% request.cost || "N/A" %]
619 <span class="label req_id">Request number:</span>
620 [% request.id_prefix _ request.illrequest_id %]
622 <div class="notesstaff">
623 <span class="label notes_staff">Staff notes:</span>
624 <pre>[% request.notesstaff %]</pre>
626 <div class="notesopac">
627 <span class="label notes_opac">Notes:</span>
628 <pre>[% request.notesopac %]</pre>
632 <h4>Details from supplier ([% request.backend %])</h4>
633 [% FOREACH meta IN request.metadata %]
634 <div class="requestmeta-[% meta.key %]">
635 <span class="label">[% meta.key %]:</span>
641 <h3><a id="toggle_requestattributes" href="#">Toggle full supplier metadata</a></h3>
642 <div id="requestattributes" class="content_hidden">
643 [% FOREACH attr IN request.illrequestattributes %]
644 <div class="requestattr-[% attr.type %]">
645 <span class="label">[% attr.type %]:</span>
655 [% ELSIF query_type == 'illlist' %]
657 <h1>View ILL requests</h1>
659 <h3>Details for all requests</h3>
661 <div id="column-toggle">
662 Toggle additional columns:
664 <div id="reset-toggle"><a href="#">Reset toggled columns</a></div>
667 [% FOREACH filter IN prefilters %]
668 data-filter-[% filter.name %]="[% filter.value %]"
672 <tr id="illview-header"></tr>
674 <tbody id="illview-body">
679 <!-- Custom Backend Action -->
680 [% INCLUDE $whole.template %]
689 [% PROCESS backend_jsinclude %]
693 [% INCLUDE 'intranet-bottom.inc' %]