8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha › ILL requests ›</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
12 [% Asset.css("css/datatables.css") | $raw %]
13 [% INCLUDE 'datatables.inc' %]
16 $(document).ready(function() {
18 // Illview Datatable setup
20 // Fields we don't want to display
35 // Fields we need to expand (flatten)
42 // This is auto populated
45 // The core fields that should be displayed first
56 'action' // Action should always be last
59 // Remove any fields we're ignoring
60 var removeIgnore = function(dataObj) {
61 dataObj.forEach(function(thisRow) {
62 ignore.forEach(function(thisIgnore) {
63 if (thisRow.hasOwnProperty(thisIgnore)) {
64 delete thisRow[thisIgnore];
70 // Expand any fields we're expanding
71 var expandExpand = function(row) {
72 expand.forEach(function(thisExpand) {
73 if (row.hasOwnProperty(thisExpand)) {
74 if (!expanded.hasOwnProperty(thisExpand)) {
75 expanded[thisExpand] = [];
77 var expandObj = row[thisExpand];
78 Object.keys(expandObj).forEach(
79 function(thisExpandCol) {
80 var expColName = thisExpand + '_' + thisExpandCol;
81 // Keep a list of fields that have been expanded
82 // so we can create toggle links for them
83 if (expanded[thisExpand].indexOf(expColName) == -1) {
84 expanded[thisExpand].push(expColName);
86 expandObj[expColName] =
87 expandObj[thisExpandCol];
88 delete expandObj[thisExpandCol];
91 $.extend(true, row, expandObj);
92 delete row[thisExpand];
97 // Build a de-duped list of all column names
99 core.map(function(thisCore) {
100 allCols[thisCore] = 1;
103 // Strip the expand prefix if it exists, we do this for display
104 var stripPrefix = function(value) {
105 expand.forEach(function(thisExpand) {
106 var regex = new RegExp(thisExpand + '_', 'g');
107 value = value.replace(regex, '');
112 // Our 'render' function for borrowerlink
113 var createPatronLink = function(data, type, row) {
114 var patronLink = '<a title="' + _("View borrower details") + '" ' +
115 'href="/cgi-bin/koha/members/moremember.pl?' +
116 'borrowernumber='+row.borrowernumber+'">';
117 if ( row.patron_firstname ) {
118 patronLink = patronLink + row.patron_firstname + ' ';
120 patronLink = patronLink + row.patron_surname + '</a>';
124 // Our 'render' function for biblio_id
125 var createBiblioLink = function(data, type, row) {
126 return (row.biblio_id) ?
127 '<a title="' + _("View biblio details") + '" ' +
128 'href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' +
129 row.biblio_id + '">' +
134 // Our 'render' function for the library name
135 var createLibrary = function(data, type, row) {
136 return row.library.branchname;
139 // Render function for request ID
140 var createRequestId = function(data, type, row) {
141 return row.id_prefix + row.illrequest_id;
144 // Render function for request status
145 var createStatus = function(data, type, row, meta) {
146 var origData = meta.settings.oInit.originalData;
147 if (origData.length > 0) {
148 var status_name = meta.settings.oInit.originalData[0].capabilities[
151 switch( status_name ) {
153 return _("New request");
155 return _("Requested");
156 case "Requested from partners":
157 return _("Requested from partners");
158 case "Request reverted":
159 return _("Request reverted");
160 case "Queued request":
161 return _("Queued request");
162 case "Cancellation requested":
163 return _("Cancellation requested");
165 return _("Completed");
166 case "Delete request":
167 return _("Delete request");
176 // Render function for creating a row's action link
177 var createActionLink = function(data, type, row) {
178 return '<a class="btn btn-default btn-sm" ' +
179 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
180 'method=illview&illrequest_id=' +
182 '">' + _("Manage request") + '</a>';
185 // Columns that require special treatment
189 func: createActionLink
193 func: createPatronLink
196 name: _("Request number"),
197 func: createRequestId
204 name: _("Bibliographic record ID"),
205 func: createBiblioLink
213 // Toggle request attributes in Illview
214 $('#toggle_requestattributes').on('click', function(e) {
216 $('#requestattributes').toggleClass('content_hidden');
219 // Toggle new comment form in Illview
220 $('#toggle_addcomment').on('click', function(e) {
222 $('#addcomment').toggleClass('content_hidden');
225 // Filter partner list
226 $('#partner_filter').keyup(function() {
227 var needle = $('#partner_filter').val();
228 $('#partners > option').each(function() {
229 var regex = new RegExp(needle, 'i');
231 needle.length == 0 ||
232 $(this).is(':selected') ||
233 $(this).text().match(regex)
242 // Display the modal containing request supplier metadata
243 $('#ill-request-display-metadata').on('click', function(e) {
245 $('#dataPreview').modal({show:true});
248 // Get our data from the API and process it prior to passing
251 '/api/v1/illrequests?embed=metadata,patron,capabilities,library,comments'
253 var data = JSON.parse(ajax.responseText);
254 // Make a copy, we'll be removing columns next and need
255 // to be able to refer to data that has been removed
256 var dataCopy = $.extend(true, [], data);
257 // Remove all columns we're not interested in
258 removeIgnore(dataCopy);
259 // Expand columns that need it and create an array
260 // of all column names
261 $.each(dataCopy, function(k, row) {
265 // Assemble an array of column definitions for passing
268 Object.keys(allCols).forEach(function(thisCol) {
269 // Create the base column object
274 // We may need to process the data going in this
275 // column, so do it if necessary
277 specialCols.hasOwnProperty(thisCol) &&
278 specialCols[thisCol].hasOwnProperty('func')
280 colObj.render = specialCols[thisCol].func;
282 colObj.data = thisCol;
284 colData.push(colObj);
287 // Initialise the datatable
288 $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
289 'aoColumnDefs': [ // Last column shouldn't be sortable or searchable
291 'aTargets': [ 'actions' ],
296 'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending
297 'processing': true, // Display a message when manipulating
298 'iDisplayLength': 10, // 10 results per page
299 'sPaginationType': "full_numbers", // Pagination display
300 'deferRender': true, // Improve performance on big datasets
303 'originalData': data // Enable render functions to access
314 <body id="illrequests" class="ill">
315 [% INCLUDE 'header.inc' %]
316 [% INCLUDE 'cat-search.inc' %]
318 <div id="breadcrumbs">
319 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
320 <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
321 [% IF query_type == 'create' %]
323 [% ELSIF query_type == 'status' %]
328 <div id="doc3" class="yui-t2">
331 <div id="interlibraryloans" class="yui-b">
332 [% IF !backends_available || !has_branch %]
333 <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>
335 [% INCLUDE 'ill-toolbar.inc' %]
338 <h1>Error performing operation</h1>
339 <!-- Dispatch on Status -->
340 <p>We encountered an error:</p>
342 <pre>[% whole.message | html %] ([% whole.status | html %])</pre>
346 [% IF query_type == 'create' %]
347 <h1>New ILL request</h1>
348 [% PROCESS $whole.template %]
350 [% ELSIF query_type == 'confirm' %]
351 <h1>Confirm ILL request</h1>
352 [% PROCESS $whole.template %]
354 [% ELSIF query_type == 'cancel' and !whole.error %]
355 <h1>Cancel a confirmed request</h1>
356 [% PROCESS $whole.template %]
358 [% ELSIF query_type == 'generic_confirm' %]
359 <h1>Place request with partner libraries</h1>
361 [% IF error == 'no_target_email' %]
363 No target email addresses found. Either select at least
364 one partner or check your ILL partner library records.
366 [% ELSIF error == 'no_library_email' %]
368 Your library has no usable email address. Please set it.
370 [% ELSIF error == 'unkown_error' %]
372 Unknown error processing your request. Contact your administrator.
376 <!-- Start of GENERIC_EMAIL case -->
377 [% IF whole.value.partners %]
378 [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %]
379 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
380 <fieldset class="rows">
381 <legend>Interlibrary loan request details</legend>
384 <label for="partner_filter">Filter partner libraries:</label>
385 <input type="text" id="partner_filter">
388 <label for="partners" class="required">Select partner libraries:</label>
389 <select size="5" multiple="true" id="partners" name="partners" required="required">
390 [% FOREACH partner IN whole.value.partners %]
391 <option value=[% partner.email | html %]>
392 [% partner.branchcode _ " - " _ partner.surname %]
399 <label for="subject" class="required">Subject Line</label>
400 <input type="text" name="subject" id="subject" type="text" value="[% whole.value.draft.subject | html %]" required="required" />
403 <label for="body" class="required">Email text:</label>
404 <textarea name="body" id="body" rows="20" cols="80" required="required">[% whole.value.draft.body | html %]</textarea>
407 <input type="hidden" value="generic_confirm" name="method">
408 <input type="hidden" value="draft" name="stage">
409 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
411 <fieldset class="action">
412 <input type="submit" class="btn btn-default" value="Send email"/>
413 <span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span>
417 <fieldset class="rows">
418 <legend>Interlibrary loan request details</legend>
419 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
420 <p>Be sure to provide email addresses for these patrons.</p>
421 <p><span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span></p>
424 <!-- generic_confirm ends here -->
426 [% ELSIF query_type == 'edit_action' %]
427 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
428 <fieldset class="rows">
429 <legend>Request details</legend>
431 [% type = request.get_type %]
432 <li class="borrowernumber">
433 <label for="borrowernumber">Patron ID:</label>
434 [% request.borrowernumber | html %]
436 <li class="biblio_id">
437 <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label>
438 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]">
440 <li class="branchcode">
441 <label for="library" class="branchcode">Library:</label>
442 <select name="branchcode" id="library">
443 [% PROCESS options_for_libraries libraries => Branches.all( selected => request.branchcode ) %]
447 <label class="status">Status:</label>
448 [% stat = request.status %]
449 [% request.capabilities.$stat.name | html %]
452 <label class="updated">Last updated:</label>
453 [% request.updated | $KohaDates with_hours => 1 %]
456 <label class="medium">Request type:</label>
457 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
460 <label class="cost">Cost:</label>
461 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
463 <li class="price_paid">
464 <label class="price_paid">Price paid:</label>
465 <input name="price_paid" id="price_paid" type="text" value="[% request.price_paid | html %]">
468 <label class="req_id">Request number:</label>
469 [% request.id_prefix _ request.illrequest_id | html %]
471 <li class="notesstaff">
472 <label for="notesstaff" class="notesstaff">Staff notes:</label>
473 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff | html %]</textarea>
475 <li class="notesopac">
476 <label for="notesopac" class="notesopac">Opac notes:</label>
477 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac | html %]</textarea>
481 <fieldset class="action">
482 <input type="hidden" value="edit_action" name="method">
483 <input type="hidden" value="form" name="stage">
484 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
485 <input type="hidden" value="[% request.borrowernumber | html %]" name="borrowernumber">
486 <input type="submit" value="Submit">
487 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id | html %]">Cancel</a>
491 [% ELSIF query_type == 'delete_confirm' %]
493 <div class="dialog alert">
494 <h3>Are you sure you wish to delete this request?</h3>
495 <form action="/cgi-bin/koha/ill/ill-requests.pl" method="post">
496 <input type="hidden" name="method" value="delete" />
497 <input type="hidden" name="confirmed" value="1" />
498 <input type="hidden" name="illrequest_id" value="[% request.id | html %]" />
499 <button type="submit" class="btn btn-default btn-sm approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
501 <a class="btn btn-default btn-sm deny" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id | html %]"><i class="fa fa-fw fa-remove"></i>No, do not delete</a>
504 [% ELSIF query_type == 'illview' %]
505 [% req_status = request.status %]
508 [% IF error == 'migrate_target' %]
510 The backend you tried to migrate to does not yet support migrations, please try again with an alternative target.
515 <h1>Manage ILL request</h1>
516 <div id="request-toolbar" class="btn-toolbar">
517 <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 | html %]">
518 <span class="fa fa-pencil"></span>
521 [% FOREACH action IN request.available_actions %]
522 [% IF action.method == 'migrate' %]
523 [% IF backends.size > 2 %]
524 <div class="dropdown btn-group">
525 <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
526 <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
528 <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
529 [% FOREACH backend IN backends %]
530 [% IF backend != request.backend %]
531 <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&illrequest_id=[% request.illrequest_id | uri %]&backend=[% backend | uri %]">[% backend | html %]</a></li>
536 [% ELSIF backends.size == 2 %]
537 [% FOREACH backend IN backends %]
538 [% IF backend != request.backend %]
539 <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&illrequest_id=[% request.illrequest_id | uri %]&backend=[% backend | uri %]">
540 <span class="fa [% action.ui_method_icon | html %]"></span>
541 [% action.ui_method_name | html %]
546 [% ELSIF action.method != 0 %]
547 <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&illrequest_id=[% request.illrequest_id | uri %]">
548 <span class="fa [% action.ui_method_icon | html %]"></span>
549 [% action.ui_method_name | html %]
553 <a title="Display supplier metadata" id="ill-request-display-metadata" class="btn btn-sm btn-default pull-right" href="#">
554 <span class="fa fa-eye"></span>
555 Display supplier metadata
558 <div class="ill-view-panel panel panel-default">
559 <div class="panel-heading">
560 <h3>Request details</h3>
562 <div class="panel-body">
563 <h4>Details from library</h4>
567 <span class="label orderid">Order ID:</span>
568 [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
570 <li class="borrowernumber">
571 <span class="label borrowernumber">Patron:</span>
572 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
573 <a href="[% borrowerlink | url %]" title="View borrower details">
574 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
578 <li class="biblio_id">
579 <span class="label biblio_id">Bibliographic record ID:</span>
580 [% IF request.biblio_id %]
581 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
586 <li class="branchcode">
587 <span class="label branchcode">Library:</span>
588 [% Branches.GetName(request.branchcode) | html %]
591 <span class="label status">Status:</span>
592 [% request.capabilities.$req_status.name | html %]
595 <span class="label updated">Last updated:</span>
596 [% request.updated | $KohaDates with_hours => 1 %]
599 <span class="label medium">Request type:</span>
600 [% type = request.get_type %]
601 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
604 <span class="label cost">Cost:</span>
605 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
607 <li class="price_paid">
608 <span class="label price_paid">Price paid:</span>
609 [% IF request.price_paid %][% request.price_paid | $Price %][% ELSE %]<span>N/A</span>[% END %]
612 <span class="label req_id">Request number:</span>
613 [% request.id_prefix _ request.illrequest_id | html %]
615 <li class="notesstaff">
616 <span class="label notes_staff">Staff notes:</span>
617 <p>[% request.notesstaff | html %]</p>
619 <li class="notesopac">
620 <span class="label notes_opac">Notes:</span>
621 <p>[% request.notesopac | html %]</p>
626 <h4>Details from supplier ([% request.backend | html %])</h4>
628 [% FOREACH meta IN request.metadata %]
629 <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
630 <span class="label">[% meta.key | html %]:</span>
631 [% meta.value | html %]
639 <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
640 <div class="modal-dialog">
641 <div class="modal-content">
642 <div class="modal-header">
643 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
644 <h3 id="dataPreviewLabel"> Supplier metadata</h3>
646 <div class="modal-body">
647 <div id="requestattributes">
648 [% FOREACH attr IN request.illrequestattributes %]
649 <div class="requestattr-[% attr.type | html %]">
650 <span class="label">[% attr.type | html %]:</span>
651 [% attr.value | html %]
656 <div class="modal-footer">
657 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
663 <div class="ill-view-panel panel panel-default">
664 <div class="panel-heading">
665 <h3>[% request.illcomments.count | html %] comments</h3>
667 <div class="panel-body">
668 [% IF request.illcomments.count && request.illcomments.count > 0 %]
669 [% FOREACH comment IN request.illcomments %]
670 <div class="rows comment_[% comment.patron.categorycode | html %]">
672 <a href="[% borrowerlink | url %]" title="View borrower details">
673 [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
674 [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
675 <p>[% comment.comment | html %]</p>
680 <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
681 <div id="addcomment" class="content_hidden">
682 <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
683 <input type="hidden" value="save_comment" name="method">
684 <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
685 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
686 <fieldset class="rows">
689 <label class="required" for="comment">Comment: </label>
690 <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
691 <span class="required">Required</span>
695 <fieldset class="action">
696 <input type="submit" value="Submit">
704 [% ELSIF query_type == 'illlist' %]
706 <h1>View ILL requests</h1>
708 <h3>Details for all requests</h3>
710 <table id="ill-requests">
712 <tr id="illview-header">
716 <th>Bibliographic record ID</th>
720 <th>Request number</th>
722 <th class="actions"></th>
725 <tbody id="illview-body">
730 <!-- Custom Backend Action -->
731 [% PROCESS $whole.template %]
740 [% PROCESS backend_jsinclude %]
744 [% INCLUDE 'intranet-bottom.inc' %]