7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › ILL requests ›</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
11 [% Asset.css("css/datatables.css") | $raw %]
12 [% INCLUDE 'datatables.inc' %]
15 $(document).ready(function() {
17 // Illview Datatable setup
19 // Fields we don't want to display
34 // Fields we need to expand (flatten)
41 // This is auto populated
44 // The core fields that should be displayed first
55 'action' // Action should always be last
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;
102 // Strip the expand prefix if it exists, we do this for display
103 var stripPrefix = function(value) {
104 expand.forEach(function(thisExpand) {
105 var regex = new RegExp(thisExpand + '_', 'g');
106 value = value.replace(regex, '');
111 // Our 'render' function for borrowerlink
112 var createPatronLink = function(data, type, row) {
113 var patronLink = '<a title="' + _("View borrower details") + '" ' +
114 'href="/cgi-bin/koha/members/moremember.pl?' +
115 'borrowernumber='+row.borrowernumber+'">';
116 if ( row.patron_firstname ) {
117 patronLink = patronLink + row.patron_firstname + ' ';
119 patronLink = patronLink + row.patron_surname + '</a>';
123 // Our 'render' function for biblio_id
124 var createBiblioLink = function(data, type, row) {
125 return (row.biblio_id) ?
126 '<a title="' + _("View biblio details") + '" ' +
127 'href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' +
128 row.biblio_id + '">' +
133 // Our 'render' function for the library name
134 var createLibrary = function(data, type, row) {
135 return row.library.branchname;
138 // Render function for request ID
139 var createRequestId = function(data, type, row) {
140 return row.id_prefix + row.illrequest_id;
143 // Render function for request status
144 var createStatus = function(data, type, row, meta) {
145 var origData = meta.settings.oInit.originalData;
146 if (origData.length > 0) {
147 var status_name = meta.settings.oInit.originalData[0].capabilities[
150 switch( status_name ) {
152 return _("New request");
154 return _("Requested");
155 case "Requested from partners":
156 return _("Requested from partners");
157 case "Request reverted":
158 return _("Request reverted");
159 case "Queued request":
160 return _("Queued request");
161 case "Cancellation requested":
162 return _("Cancellation requested");
164 return _("Completed");
165 case "Delete request":
166 return _("Delete request");
175 // Render function for creating a row's action link
176 var createActionLink = function(data, type, row) {
177 return '<a class="btn btn-default btn-sm" ' +
178 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
179 'method=illview&illrequest_id=' +
181 '">' + _("Manage request") + '</a>';
184 // Columns that require special treatment
188 func: createActionLink
192 func: createPatronLink
195 name: _("Request number"),
196 func: createRequestId
203 name: _("Bibliograpic record ID"),
204 func: createBiblioLink
212 // Toggle request attributes in Illview
213 $('#toggle_requestattributes').on('click', function(e) {
215 $('#requestattributes').toggleClass('content_hidden');
218 // Toggle new comment form in Illview
219 $('#toggle_addcomment').on('click', function(e) {
221 $('#addcomment').toggleClass('content_hidden');
224 // Filter partner list
225 $('#partner_filter').keyup(function() {
226 var needle = $('#partner_filter').val();
227 $('#partners > option').each(function() {
228 var regex = new RegExp(needle, 'i');
230 needle.length == 0 ||
231 $(this).is(':selected') ||
232 $(this).text().match(regex)
241 // Display the modal containing request supplier metadata
242 $('#ill-request-display-metadata').on('click', function(e) {
244 $('#dataPreview').modal({show:true});
247 // Get our data from the API and process it prior to passing
250 '/api/v1/illrequests?embed=metadata,patron,capabilities,library,comments'
252 var data = JSON.parse(ajax.responseText);
253 // Make a copy, we'll be removing columns next and need
254 // to be able to refer to data that has been removed
255 var dataCopy = $.extend(true, [], data);
256 // Remove all columns we're not interested in
257 removeIgnore(dataCopy);
258 // Expand columns that need it and create an array
259 // of all column names
260 $.each(dataCopy, function(k, row) {
264 // Assemble an array of column definitions for passing
267 Object.keys(allCols).forEach(function(thisCol) {
268 // Create the base column object
273 // We may need to process the data going in this
274 // column, so do it if necessary
276 specialCols.hasOwnProperty(thisCol) &&
277 specialCols[thisCol].hasOwnProperty('func')
279 colObj.render = specialCols[thisCol].func;
281 colObj.data = thisCol;
283 colData.push(colObj);
286 // Initialise the datatable
287 $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
288 'aoColumnDefs': [ // Last column shouldn't be sortable or searchable
290 'aTargets': [ 'actions' ],
295 'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending
296 'processing': true, // Display a message when manipulating
297 'iDisplayLength': 10, // 10 results per page
298 'sPaginationType': "full_numbers", // Pagination display
299 'deferRender': true, // Improve performance on big datasets
302 'originalData': data // Enable render functions to access
313 <body id="illrequests" class="ill">
314 [% INCLUDE 'header.inc' %]
315 [% INCLUDE 'cat-search.inc' %]
317 <div id="breadcrumbs">
318 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
319 <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
320 [% IF query_type == 'create' %]
322 [% ELSIF query_type == 'status' %]
327 <div id="doc3" class="yui-t2">
330 <div id="interlibraryloans" class="yui-b">
331 [% IF !backends_available || !has_branch %]
332 <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>
334 [% INCLUDE 'ill-toolbar.inc' %]
337 <h1>Error performing operation</h1>
338 <!-- Dispatch on Status -->
339 <p>We encountered an error:</p>
341 <pre>[% whole.message | html %] ([% whole.status | html %])</pre>
345 [% IF query_type == 'create' %]
346 <h1>New ILL request</h1>
347 [% PROCESS $whole.template %]
349 [% ELSIF query_type == 'confirm' %]
350 <h1>Confirm ILL request</h1>
351 [% PROCESS $whole.template %]
353 [% ELSIF query_type == 'cancel' and !whole.error %]
354 <h1>Cancel a confirmed request</h1>
355 [% PROCESS $whole.template %]
357 [% ELSIF query_type == 'generic_confirm' %]
358 <h1>Place request with partner libraries</h1>
360 [% IF error == 'no_target_email' %]
362 No target email addresses found. Either select at least
363 one partner or check your ILL partner library records.
365 [% ELSIF error == 'no_library_email' %]
367 Your library has no usable email address. Please set it.
369 [% ELSIF error == 'unkown_error' %]
371 Unknown error processing your request. Contact your administrator.
375 <!-- Start of GENERIC_EMAIL case -->
376 [% IF whole.value.partners %]
377 [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %]
378 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
379 <fieldset class="rows">
380 <legend>Interlibrary loan request details</legend>
383 <label for="partner_filter">Filter partner libraries:</label>
384 <input type="text" id="partner_filter">
387 <label for="partners" class="required">Select partner libraries:</label>
388 <select size="5" multiple="true" id="partners" name="partners" required="required">
389 [% FOREACH partner IN whole.value.partners %]
390 <option value=[% partner.email | html %]>
391 [% partner.branchcode _ " - " _ partner.surname %]
398 <label for="subject" class="required">Subject Line</label>
399 <input type="text" name="subject" id="subject" type="text" value="[% whole.value.draft.subject | html %]" required="required" />
402 <label for="body" class="required">Email text:</label>
403 <textarea name="body" id="body" rows="20" cols="80" required="required">[% whole.value.draft.body | html %]</textarea>
406 <input type="hidden" value="generic_confirm" name="method">
407 <input type="hidden" value="draft" name="stage">
408 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
410 <fieldset class="action">
411 <input type="submit" class="btn btn-default" value="Send email"/>
412 <span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span>
416 <fieldset class="rows">
417 <legend>Interlibrary loan request details</legend>
418 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
419 <p>Be sure to provide email addresses for these patrons.</p>
420 <p><span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span></p>
423 <!-- generic_confirm ends here -->
425 [% ELSIF query_type == 'edit_action' %]
426 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
427 <fieldset class="rows">
428 <legend>Request details</legend>
430 [% type = request.get_type %]
431 <li class="borrowernumber">
432 <label for="borrowernumber">Patron ID:</label>
433 [% request.borrowernumber | html %]
435 <li class="biblio_id">
436 <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label>
437 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]">
439 <li class="branchcode">
440 <label for="library" class="branchcode">Library:</label>
441 <select name="branchcode" id="library">
442 [% PROCESS options_for_libraries libraries => Branches.all( selected => request.branchcode ) %]
446 <label class="status">Status:</label>
447 [% stat = request.status %]
448 [% request.capabilities.$stat.name | html %]
451 <label class="updated">Last updated:</label>
452 [% request.updated | $KohaDates with_hours => 1 %]
455 <label class="medium">Request type:</label>
456 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
459 <label class="cost">Cost:</label>
460 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
462 <li class="price_paid">
463 <label class="price_paid">Price paid:</label>
464 <input name="price_paid" id="price_paid" type="text" value="[% request.price_paid | html %]">
467 <label class="req_id">Request number:</label>
468 [% request.id_prefix _ request.illrequest_id | html %]
470 <li class="notesstaff">
471 <label for="notesstaff" class="notesstaff">Staff notes:</label>
472 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff | html %]</textarea>
474 <li class="notesopac">
475 <label for="notesopac" class="notesopac">Opac notes:</label>
476 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac | html %]</textarea>
480 <fieldset class="action">
481 <input type="hidden" value="edit_action" name="method">
482 <input type="hidden" value="form" name="stage">
483 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
484 <input type="hidden" value="[% request.borrowernumber | html %]" name="borrowernumber">
485 <input type="submit" value="Submit">
486 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id | html %]">Cancel</a>
490 [% ELSIF query_type == 'delete_confirm' %]
492 <div class="dialog alert">
493 <h3>Are you sure you wish to delete this request?</h3>
494 <form action="/cgi-bin/koha/ill/ill-requests.pl" method="post">
495 <input type="hidden" name="method" value="delete" />
496 <input type="hidden" name="confirmed" value="1" />
497 <input type="hidden" name="illrequest_id" value="[% request.id | html %]" />
498 <button type="submit" class="btn btn-default btn-sm approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
500 <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>
503 [% ELSIF query_type == 'illview' %]
504 [% req_status = request.status %]
505 <h1>Manage ILL request</h1>
506 <div id="request-toolbar" class="btn-toolbar">
507 <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 %]">
508 <span class="fa fa-pencil"></span>
511 [% FOREACH action IN request.available_actions %]
512 [% IF action.method != 0 %]
513 <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 | html %]&illrequest_id=[% request.illrequest_id | html %]">
514 <span class="fa [% action.ui_method_icon | html %]"></span>
515 [% action.ui_method_name | html %]
519 <a title="Display supplier metadata" id="ill-request-display-metadata" class="btn btn-sm btn-default pull-right" href="#">
520 <span class="fa fa-eye"></span>
521 Display supplier metadata
524 <div class="ill-view-panel panel panel-default">
525 <div class="panel-heading">
526 <h3>Request details</h3>
528 <div class="panel-body">
529 <h4>Details from library</h4>
533 <span class="label orderid">Order ID:</span>
534 [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
536 <li class="borrowernumber">
537 <span class="label borrowernumber">Patron:</span>
538 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
539 <a href="[% borrowerlink | url %]" title="View borrower details">
540 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
544 <li class="biblio_id">
545 <span class="label biblio_id">Bibliographic record ID:</span>
546 [% IF request.biblio_id %]
547 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
552 <li class="branchcode">
553 <span class="label branchcode">Library:</span>
554 [% Branches.GetName(request.branchcode) | html %]
557 <span class="label status">Status:</span>
558 [% request.capabilities.$req_status.name | html %]
561 <span class="label updated">Last updated:</span>
562 [% request.updated | $KohaDates with_hours => 1 %]
565 <span class="label medium">Request type:</span>
566 [% type = request.get_type %]
567 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
570 <span class="label cost">Cost:</span>
571 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
573 <li class="price_paid">
574 <span class="label price_paid">Price paid:</span>
575 [% IF request.price_paid %][% request.price_paid | html %][% ELSE %]<span>N/A</span>[% END %]
578 <span class="label req_id">Request number:</span>
579 [% request.id_prefix _ request.illrequest_id | html %]
581 <li class="notesstaff">
582 <span class="label notes_staff">Staff notes:</span>
583 <p>[% request.notesstaff | html %]</p>
585 <li class="notesopac">
586 <span class="label notes_opac">Notes:</span>
587 <p>[% request.notesopac | html %]</p>
592 <h4>Details from supplier ([% request.backend | html %])</h4>
594 [% FOREACH meta IN request.metadata %]
595 <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
596 <span class="label">[% meta.key | html %]:</span>
597 [% meta.value | html %]
605 <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
606 <div class="modal-dialog">
607 <div class="modal-content">
608 <div class="modal-header">
609 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
610 <h3 id="dataPreviewLabel"> Supplier metadata</h3>
612 <div class="modal-body">
613 <div id="requestattributes">
614 [% FOREACH attr IN request.illrequestattributes %]
615 <div class="requestattr-[% attr.type | html %]">
616 <span class="label">[% attr.type | html %]:</span>
617 [% attr.value | html %]
622 <div class="modal-footer">
623 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
629 <div class="ill-view-panel panel panel-default">
630 <div class="panel-heading">
631 <h3>[% request.illcomments.count | html %] comments</h3>
633 <div class="panel-body">
634 [% IF request.illcomments.count && request.illcomments.count > 0 %]
635 [% FOREACH comment IN request.illcomments %]
636 <div class="rows comment_[% comment.patron.categorycode | html %]">
638 <a href="[% borrowerlink | url %]" title="View borrower details">
639 [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
640 [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
641 <p>[% comment.comment | html %]</p>
646 <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
647 <div id="addcomment" class="content_hidden">
648 <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
649 <input type="hidden" value="save_comment" name="method">
650 <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
651 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
652 <fieldset class="rows">
655 <label class="required" for="comment">Comment: </label>
656 <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
657 <span class="required">Required</span>
661 <fieldset class="action">
662 <input type="submit" value="Submit">
670 [% ELSIF query_type == 'illlist' %]
672 <h1>View ILL requests</h1>
674 <h3>Details for all requests</h3>
676 <table id="ill-requests">
678 <tr id="illview-header">
682 <th>Bibliographic record ID</th>
686 <th>Request number</th>
688 <th class="actions"></th>
691 <tbody id="illview-body">
696 <!-- Custom Backend Action -->
697 [% PROCESS $whole.template %]
706 [% PROCESS backend_jsinclude %]
710 [% INCLUDE 'intranet-bottom.inc' %]