4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › ILL requests ›</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css">
9 [% INCLUDE 'datatables.inc' %]
10 <script type="text/javascript">
12 $(document).ready(function() {
14 // Illview Datatable setup
16 // Fields we don't want to display
31 // Fields we need to expand (flatten)
38 // This is auto populated
41 // The core fields that should be displayed first
54 // Extra fields that we need to tack on to the end
55 var extra = [ 'action' ];
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];
68 // Expand any fields we're expanding
69 var expandExpand = function(row) {
70 expand.forEach(function(thisExpand) {
71 if (row.hasOwnProperty(thisExpand)) {
72 if (!expanded.hasOwnProperty(thisExpand)) {
73 expanded[thisExpand] = [];
75 var expandObj = row[thisExpand];
76 Object.keys(expandObj).forEach(
77 function(thisExpandCol) {
78 var expColName = thisExpand + '_' + thisExpandCol;
79 // Keep a list of fields that have been expanded
80 // so we can create toggle links for them
81 if (expanded[thisExpand].indexOf(expColName) == -1) {
82 expanded[thisExpand].push(expColName);
84 expandObj[expColName] =
85 expandObj[thisExpandCol];
86 delete expandObj[thisExpandCol];
89 $.extend(true, row, expandObj);
90 delete row[thisExpand];
95 // Build a de-duped list of all column names
97 core.map(function(thisCore) {
98 allCols[thisCore] = 1;
100 var unionColumns = function(row) {
101 Object.keys(row).forEach(function(col) {
102 if (ignore.indexOf(col) == -1) {
108 // Some rows may not have fields that other rows have,
109 // so make sure all rows have the same fields
110 var fillMissing = function(row) {
111 Object.keys(allCols).forEach(function(thisCol) {
112 row[thisCol] = (!row.hasOwnProperty(thisCol)) ?
118 // Strip the expand prefix if it exists, we do this for display
119 var stripPrefix = function(value) {
120 expand.forEach(function(thisExpand) {
121 var regex = new RegExp(thisExpand + '_', 'g');
122 value = value.replace(regex, '');
127 // Our 'render' function for borrowerlink
128 var createBorrowerLink = function(data, type, row) {
129 return '<a title="View borrower details" ' +
130 'href="/cgi-bin/koha/members/moremember.pl?' +
131 'borrowernumber='+row.borrowernumber+'">' +
132 row.patron_firstname + ' ' + row.patron_surname +
136 // Render function for request ID
137 var createRequestId = function(data, type, row) {
138 return row.id_prefix + row.illrequest_id;
141 // Render function for request status
142 var createStatus = function(data, type, row, meta) {
143 var origData = meta.settings.oInit.originalData;
144 if (origData.length > 0) {
145 return meta.settings.oInit.originalData[0].capabilities[
153 // Render function for creating a row's action link
154 var createActionLink = function(data, type, row) {
155 return '<a class="btn btn-default btn-sm" ' +
156 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
157 'method=illview&illrequest_id=' +
159 '">Manage request</a>' +
163 // Columns that require special treatment
167 func: createActionLink
171 func: createBorrowerLink
174 name: 'Request number',
175 func: createRequestId
182 name: 'Biblio number'
189 // Helper for handling prefilter column names
190 function toColumnName(myVal) {
192 .replace(/^filter/, '')
193 .replace(/([A-Z])/g, "_$1")
194 .replace(/^_/,'').toLowerCase();
197 // Toggle request attributes in Illview
198 $('#toggle_requestattributes').click(function() {
199 $('#requestattributes').toggleClass('content_hidden');
202 // Filter partner list
203 $('#partner_filter').keyup(function() {
204 var needle = $('#partner_filter').val();
205 $('#partners > option').each(function() {
206 var regex = new RegExp(needle, 'i');
208 needle.length == 0 ||
209 $(this).is(':selected') ||
210 $(this).text().match(regex)
219 // Get our data from the API and process it prior to passing
222 '/api/v1/illrequests?embed=metadata,patron,capabilities,branch'
224 var data = JSON.parse(ajax.responseText);
225 // Make a copy, we'll be removing columns next and need
226 // to be able to refer to data that has been removed
227 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
231 // of all column names
232 $.each(dataCopy, function(k, row) {
236 // Append any extra columns we need to tag on
237 if (extra.length > 0) {
238 extra.forEach(function(thisExtra) {
239 allCols[thisExtra] = 1;
242 // Different requests will have different columns,
243 // make sure they all have the same
244 $.each(dataCopy, function(k, row) {
248 // Assemble an array of column definitions for passing
251 Object.keys(allCols).forEach(function(thisCol) {
252 // We may have defined a pretty name for this column
254 specialCols.hasOwnProperty(thisCol) &&
255 specialCols[thisCol].hasOwnProperty('name')
257 specialCols[thisCol].name :
259 // Create the table header for this column
260 var str = '<th>' + stripPrefix(colName) + '</th>';
261 $(str).appendTo('#illview-header');
262 // Create the base column object
267 // We may need to process the data going in this
268 // column, so do it if necessary
270 specialCols.hasOwnProperty(thisCol) &&
271 specialCols[thisCol].hasOwnProperty('func')
273 colObj.render = specialCols[thisCol].func;
275 colObj.data = thisCol
277 colData.push(colObj);
280 // Create the toggle links for all metadata fields
282 expanded.metadata.forEach(function(thisExpanded) {
283 if (core.indexOf(thisExpanded) == -1) {
285 '<a href="#" class="toggle-vis" data-column="' +
286 thisExpanded + '">' + stripPrefix(thisExpanded) +
291 $('#column-toggle').append(links.join(' | '));
293 // Initialise the datatable
294 var myTable = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
295 aoColumnDefs: [ // Last column shouldn't be sortable or searchable
297 aTargets: [ 'action' ],
302 aaSorting: [[ 6, 'desc' ]], // Default sort, updated descending
303 processing: true, // Display a message when manipulating
305 loadingRecords: "Please wait - loading requests...",
306 zeroRecords: "No requests were found"
308 iDisplayLength: 10, // 10 results per page
309 sPaginationType: "full_numbers", // Pagination display
310 deferRender: true, // Improve performance on big datasets
313 originalData: data // Enable render functions to access
317 // Reset columns to default
318 var resetColumns = function() {
319 Object.keys(allCols).forEach(function(thisCol) {
320 myTable.column(thisCol + ':name').visible(core.indexOf(thisCol) != -1);
322 myTable.columns.adjust().draw(false);
325 // Handle the click event on a toggle link
326 $('a.toggle-vis').on('click', function(e) {
328 var column = myTable.column(
329 $(this).data('column') + ':name'
331 column.visible(!column.visible());
334 // Reset column toggling
335 $('#reset-toggle').click(function() {
339 // Handle a prefilter request and do the prefiltering
340 var filters = $('#ill-requests').data();
341 if (typeof filters !== 'undefined') {
342 var filterNames = Object.keys(filters).filter(
344 return thisData.match(/^filter/);
347 filterNames.forEach(function(thisFilter) {
348 var filterName = toColumnName(thisFilter) + ':name';
349 var regex = '^'+filters[thisFilter]+'$';
350 myTable.columns(filterName).search(regex, true, false);
355 // Initialise column hiding
366 <body id="illrequests" class="ill">
367 [% INCLUDE 'header.inc' %]
368 [% INCLUDE 'cat-search.inc' %]
370 <div id="breadcrumbs">
371 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
372 <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
373 [% IF query_type == 'create' %]
375 [% ELSIF query_type == 'status' %]
380 <div id="doc3" class="yui-t2">
383 <div id="interlibraryloans" class="yui-b">
384 [% IF !backends_available %]
385 <div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div>
387 [% INCLUDE 'ill-toolbar.inc' %]
390 <h1>Error performing operation</h1>
391 <!-- Dispatch on Status -->
392 <p>We encountered an error:</p>
394 <pre>[% whole.message %] ([% whole.status %])</pre>
398 [% IF query_type == 'create' %]
399 <h1>New ILL request</h1>
400 [% IF whole.stage == 'copyrightclearance' %]
403 [% Koha.Preference('ILLModuleCopyrightClearance') %]
405 <a href="?method=create&stage=copyrightclearance&backend=[% whole.value.backend %]"
406 class="btn btn-sm btn-default btn-group"><i class="fa fa-check">Yes</i></a>
407 <a href="/cgi-bin/koha/ill/ill-requests.pl"
408 class="btn btn-sm btn-default btn-group"><i class="fa fa-times">No</i></a>
411 [% PROCESS $whole.template %]
414 [% ELSIF query_type == 'confirm' %]
415 <h1>Confirm ILL request</h1>
416 [% PROCESS $whole.template %]
418 [% ELSIF query_type == 'cancel' and !whole.error %]
419 <h1>Cancel a confirmed request</h1>
420 [% PROCESS $whole.template %]
422 [% ELSIF query_type == 'generic_confirm' %]
423 <h1>Place request with partner libraries</h1>
424 <!-- Start of GENERIC_EMAIL case -->
425 [% IF whole.value.partners %]
426 [% ill_url = here_link _ "?method=illview&illrequest_id=" _ request.illrequest_id %]
427 <form method="POST" action=[% here_link %]>
428 <fieldset class="rows">
429 <legend>Interlibrary loan request details</legend>
432 <label for="partner_filter">Filter partner libraries:</label>
433 <input type="text" id="partner_filter">
436 <label for="partners">Select partner libraries:</label>
437 <select size="5" multiple="true" id="partners"
439 [% FOREACH partner IN whole.value.partners %]
440 <option value=[% partner.email %]>
441 [% partner.branchcode _ " - " _ partner.surname %]
448 <label for="subject">Subject Line</label>
449 <input type="text" name="subject"
450 id="subject" type="text"
451 value="[% whole.value.draft.subject %]"/>
454 <label for="body">Email text:</label>
455 <textarea name="body" id="body" rows="20" cols="80">[% whole.value.draft.body %]</textarea>
458 <input type="hidden" value="generic_confirm" name="method">
459 <input type="hidden" value="draft" name="stage">
460 <input type="hidden" value="[% request.illrequest_id %]" name="illrequest_id">
462 <fieldset class="action">
463 <input type="submit" class="btn btn-default" value="Send email"/>
464 <span><a href="[% ill_url %]" title="Return to request details">Cancel</a></span>
468 <fieldset class="rows">
469 <legend>Interlibrary loan request details</legend>
470 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
471 <p>Be sure to provide email addresses for these patrons.</p>
472 <p><span><a href="[% ill_url %]" title="Return to request details">Cancel</a></span></p>
475 <!-- generic_confirm ends here -->
477 [% ELSIF query_type == 'edit_action' %]
478 <form method="POST" action=[% here_link %]>
479 <fieldset class="rows">
480 <legend>Request details</legend>
482 <li class="borrowernumber">
483 <label for="borrowernumber">Borrower number:</label>
484 <input name="borrowernumber" id="borrowernumber" type="text" value="[% request.borrowernumber %]">
486 <li class="biblio_id">
487 <label for="biblio_id" class="biblio_id">Biblio number:</label>
488 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id %]">
490 <li class="branchcode">
491 <label for="branchcode" class="branchcode">Branch:</label>
492 <select name="branchcode" id="branch">
493 [% FOREACH branch IN branches %]
494 [% IF ( branch.branchcode == request.branchcode ) %]
495 <option value="[% branch.branchcode %]" selected="selected">
496 [% branch.branchname %]
499 <option value="[% branch.branchcode %]">
500 [% branch.branchname %]
507 <label class="status">Status:</label>
508 [% stat = request.status %]
509 [% request.capabilities.$stat.name %]
512 <label class="updated">Last updated:</label>
513 [% request.updated %]
516 <label class="medium">Request type:</label>
520 <label class="cost">Cost:</label>
524 <label class="req_id">Request number:</label>
525 [% request.id_prefix _ request.illrequest_id %]
527 <li class="notesstaff">
528 <label for="notesstaff" class="notesstaff">Staff notes:</label>
529 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff %]</textarea>
531 <li class="notesopac">
532 <label for="notesopac" class="notesopac">Opac notes:</label>
533 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac %]</textarea>
537 <fieldset class="action">
538 <input type="hidden" value="edit_action" name="method">
539 <input type="hidden" value="form" name="stage">
540 <input type="hidden" value="[% request.illrequest_id %]" name="illrequest_id">
541 <input type="submit" value="Submit">
542 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id %]">Cancel</a>
546 [% ELSIF query_type == 'delete_confirm' %]
548 <div class="dialog alert">
549 <h3>Are you sure you wish to delete this request?</h3>
551 <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>
552 <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>
557 [% ELSIF query_type == 'illview' %]
558 [% actions = request.available_actions %]
559 [% capabilities = request.capabilities %]
560 [% req_status = request.status %]
561 <h1>Manage ILL request</h1>
562 <div id="toolbar" class="btn-toolbar">
563 <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 %]">
564 <span class="fa fa-pencil"></span>
567 [% FOREACH action IN actions %]
568 [% IF action.method != 0 %]
569 <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 %]">
570 <span class="fa [% action.ui_method_icon %]"></span>
571 [% action.ui_method_name %]
576 <div id="ill-view-panel" class="panel panel-default">
577 <div class="panel-heading">
578 <h3>Request details</h3>
580 <div class="panel-body">
581 <h4>Details from library</h4>
583 <div class="orderid">
584 <span class="label orderid">Order ID:</span>
585 [% request.orderid || "N/A" %]
587 <div class="borrowernumber">
588 <span class="label borrowernumber">Borrower:</span>
589 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
590 <a href="[% borrowerlink %]" title="View borrower details">
591 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" %]
595 <div class="biblio_id">
596 <span class="label biblio_id">Biblio number:</span>
597 [% request.biblio_id || "N/A" %]
599 <div class="branchcode">
600 <span class="label branchcode">Branch:</span>
601 [% Branches.GetName(request.branchcode) %]
604 <span class="label status">Status:</span>
605 [% capabilities.$req_status.name %]
607 <div class="updated">
608 <span class="label updated">Last updated:</span>
609 [% request.updated %]
612 <span class="label medium">Request type:</span>
616 <span class="label cost">Cost:</span>
617 [% request.cost || "N/A" %]
620 <span class="label req_id">Request number:</span>
621 [% request.id_prefix _ request.illrequest_id %]
623 <div class="notesstaff">
624 <span class="label notes_staff">Staff notes:</span>
625 <pre>[% request.notesstaff %]</pre>
627 <div class="notesopac">
628 <span class="label notes_opac">Notes:</span>
629 <pre>[% request.notesopac %]</pre>
633 <h4>Details from supplier ([% request.backend %])</h4>
634 [% FOREACH meta IN request.metadata %]
635 <div class="requestmeta-[% meta.key %]">
636 <span class="label">[% meta.key %]:</span>
642 <h3><a id="toggle_requestattributes" href="#">Toggle full supplier metadata</a></h3>
643 <div id="requestattributes" class="content_hidden">
644 [% FOREACH attr IN request.illrequestattributes %]
645 <div class="requestattr-[% attr.type %]">
646 <span class="label">[% attr.type %]:</span>
656 [% ELSIF query_type == 'illlist' %]
658 <h1>View ILL requests</h1>
660 <h3>Details for all requests</h3>
662 <div id="column-toggle">
663 Toggle additional columns:
665 <div id="reset-toggle"><a href="#">Reset toggled columns</a></div>
668 [% FOREACH filter IN prefilters %]
669 data-filter-[% filter.name %]="[% filter.value %]"
673 <tr id="illview-header"></tr>
675 <tbody id="illview-body">
680 <!-- Custom Backend Action -->
681 [% INCLUDE $whole.template %]
691 [% PROCESS backend_jsinclude %]
695 [% INCLUDE 'intranet-bottom.inc' %]