7 [% USE AuthorisedValues %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Koha › ILL requests</title>
11 [% INCLUDE 'doc-head-close.inc' %]
14 <body id="illrequests" class="ill">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'cat-search.inc' %]
18 <div id="breadcrumbs">
19 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
20 <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
21 [% IF query_type == 'create' %]
23 [% ELSIF query_type == 'status' %]
28 <div id="doc3" class="yui-t2">
30 [% IF query_type == 'illlist' %]
31 <div id="illfilter_yui_column" class="yui-b">
32 <form method="get" id="illfilter_form">
33 <fieldset class="brief">
37 <label for="illfilter_status">Status:</label>
38 <select name="illfilter_status" id="illfilter_status">
39 <option value=""></option>
43 <label for="illfilter_dateplaced_start">Date placed between:</label>
44 <input type="text" name="illfilter_dateplaced_start" id="illfilter_dateplaced_start" class="datepicker" />
47 <label for="illfilter_dateplaced_end">and:</label>
48 <input type="text" name="illfilter_dateplaced_end" id="illfilter_dateplaced_end" class="datepicker" />
51 <label for="illfilter_datemodified_start">Updated between:</label>
52 <input type="text" name="illfilter_datemodified_start" id="illfilter_datemodified_start" class="datepicker" />
55 <label for="illfilter_datemodified_end">and:</label>
56 <input type="text" name="illfilter_datemodified_end" id="illfilter_datemodified_end" class="datepicker" />
59 <label for="illfilter_branchname">Library:</label>
60 <select name="illfilter_branchname" id="illfilter_branchname">
61 <option value=""></option>
65 <label for="illfilter_barcode">Cardnumber:</label>
66 <input type="text" name="illfilter_barcode" id="illfilter_barcode" />
69 <fieldset class="action">
70 <input type="submit" value="Search" />
71 <input type="button" value="Clear" id="clear_search" />
78 <div id="interlibraryloans" class="yui-b">
79 [% IF !backends_available || !has_branch %]
80 <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>
82 [% INCLUDE 'ill-toolbar.inc' %]
85 <h1>Error performing operation</h1>
86 <!-- Dispatch on Status -->
87 <p>We encountered an error:</p>
89 <pre>[% whole.message | html %] ([% whole.status | html %])</pre>
93 [% IF query_type == 'create' %]
94 <h1>New ILL request</h1>
95 [% PROCESS $whole.template %]
97 [% ELSIF query_type == 'confirm' %]
98 <h1>Confirm ILL request</h1>
99 [% PROCESS $whole.template %]
101 [% ELSIF query_type == 'cancel' and !whole.error %]
102 <h1>Cancel a confirmed request</h1>
103 [% PROCESS $whole.template %]
105 [% ELSIF query_type == 'generic_confirm' %]
106 <h1>Place request with partner libraries</h1>
108 [% IF error == 'no_target_email' %]
110 No target email addresses found. Either select at least
111 one partner or check your ILL partner library records.
113 [% ELSIF error == 'no_library_email' %]
115 Your library has no usable email address. Please set it.
117 [% ELSIF error == 'unkown_error' %]
119 Unknown error processing your request. Contact your administrator.
123 <!-- Start of GENERIC_EMAIL case -->
124 [% IF whole.value.partners %]
125 [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %]
126 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
127 <fieldset class="rows">
128 <legend>Interlibrary loan request details</legend>
131 <label for="partner_filter">Filter partner libraries:</label>
132 <input type="text" id="partner_filter" />
135 <label for="partners" class="required">Select partner libraries:</label>
136 <select size="5" multiple="true" id="partners" name="partners" required="required">
137 [% FOREACH partner IN whole.value.partners %]
138 <option value=[% partner.email | html %]>
139 [% partner.branchcode _ " - " _ partner.surname %]
146 <label for="subject" class="required">Subject line:</label>
147 <input type="text" name="subject" id="subject" type="text" value="[% whole.value.draft.subject | html %]" required="required" />
150 <label for="body" class="required">Email text:</label>
151 <textarea name="body" id="body" rows="20" cols="80" required="required">[% whole.value.draft.body | html %]</textarea>
154 <input type="hidden" value="generic_confirm" name="method">
155 <input type="hidden" value="draft" name="stage">
156 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
158 <fieldset class="action">
159 <input type="submit" class="btn btn-default" value="Send email"/>
160 <span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span>
164 <fieldset class="rows">
165 <legend>Interlibrary loan request details</legend>
166 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
167 <p>Be sure to provide email addresses for these patrons.</p>
168 <p><span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span></p>
171 <!-- generic_confirm ends here -->
173 [% ELSIF query_type == 'edit_action' %]
174 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
175 <fieldset class="rows">
176 <legend>Request details</legend>
178 [% type = request.get_type %]
179 <li class="borrowernumber">
180 <label for="borrowernumber">Patron ID:</label>
181 [% request.borrowernumber | html %]
183 <li class="biblio_id">
184 <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label>
185 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]">
187 <li class="branchcode">
188 <label for="library" class="branchcode">Library:</label>
189 <select name="branchcode" id="library">
190 [% PROCESS options_for_libraries libraries => Branches.all( selected => request.branchcode ) %]
194 <label class="status">Status:</label>
195 [% stat = request.status %]
196 [% current_alias = request.status_alias %]
197 <select id="status_alias" name="status_alias">
198 [% IF !current_alias %]
199 <option value="" selected>
203 [% request.capabilities.$stat.name | html %]
205 [% FOREACH alias IN AuthorisedValues.Get('ILLSTATUS') %]
206 [% IF alias.authorised_value == current_alias %]
207 <option value="[% alias.authorised_value | html %]" selected>
209 <option value="[% alias.authorised_value | html %]">
211 [% alias.lib | html %]
217 <label class="updated">Last updated:</label>
218 [% request.updated | $KohaDates with_hours => 1 %]
221 <label class="medium">Request type:</label>
222 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
225 <label class="cost">Cost:</label>
226 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
228 <li class="price_paid">
229 <label class="price_paid">Price paid:</label>
230 <input name="price_paid" id="price_paid" type="text" value="[% request.price_paid | html %]">
233 <label class="req_id">Request number:</label>
234 [% request.id_prefix _ request.illrequest_id | html %]
236 <li class="notesstaff">
237 <label for="notesstaff" class="notesstaff">Staff notes:</label>
238 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff | html %]</textarea>
240 <li class="notesopac">
241 <label for="notesopac" class="notesopac">Opac notes:</label>
242 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac | html %]</textarea>
246 <fieldset class="action">
247 <input type="hidden" value="edit_action" name="method">
248 <input type="hidden" value="form" name="stage">
249 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
250 <input type="hidden" value="[% request.borrowernumber | html %]" name="borrowernumber">
251 <input type="submit" value="Submit">
252 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id | html %]">Cancel</a>
256 [% ELSIF query_type == 'delete_confirm' %]
258 <div class="dialog alert">
259 <h3>Are you sure you wish to delete this request?</h3>
260 <form action="/cgi-bin/koha/ill/ill-requests.pl" method="post">
261 <input type="hidden" name="method" value="delete" />
262 <input type="hidden" name="confirmed" value="1" />
263 <input type="hidden" name="illrequest_id" value="[% request.id | html %]" />
264 <button type="submit" class="btn btn-default btn-sm approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
266 <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>
269 [% ELSIF query_type == 'illview' %]
270 [% req_status = request.status %]
273 [% IF error == 'migrate_target' %]
275 The backend you tried to migrate to does not yet support migrations, please try again with an alternative target.
280 <h1>Manage ILL request</h1>
281 <div id="request-toolbar" class="btn-toolbar">
282 <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 %]">
283 <span class="fa fa-pencil"></span>
286 [% FOREACH action IN request.available_actions %]
287 [% IF action.method == 'migrate' %]
288 [% IF backends.size > 2 %]
289 <div class="dropdown btn-group">
290 <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
291 <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
293 <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
294 [% FOREACH backend IN backends %]
295 [% IF backend != request.backend %]
296 <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>
301 [% ELSIF backends.size == 2 %]
302 [% FOREACH backend IN backends %]
303 [% IF backend != request.backend %]
304 <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 %]">
305 <span class="fa [% action.ui_method_icon | html %]"></span>
306 [% action.ui_method_name | html %]
311 [% ELSIF action.method != 0 %]
312 <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 %]">
313 <span class="fa [% action.ui_method_icon | html %]"></span>
314 [% action.ui_method_name | html %]
318 <a title="Display supplier metadata" id="ill-request-display-metadata" class="btn btn-sm btn-default pull-right" href="#">
319 <span class="fa fa-eye"></span>
320 Display supplier metadata
322 <a title="ILL request log" id="ill-request-display-log" class="btn btn-sm btn-default pull-right" href="#">
323 <span class="fa fa-calendar"></span>
327 <div class="ill-view-panel panel panel-default">
328 <div class="panel-heading">
329 <h3>Request details</h3>
331 <div class="panel-body">
332 <h4>Details from library</h4>
336 <span class="label orderid">Order ID:</span>
337 [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
339 <li class="borrowernumber">
340 <span class="label borrowernumber">Patron:</span>
341 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
342 <a href="[% borrowerlink | url %]" title="View borrower details">
343 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
347 <li class="biblio_id">
348 <span class="label biblio_id">Bibliographic record ID:</span>
349 [% IF request.biblio_id %]
350 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
355 <li class="branchcode">
356 <span class="label branchcode">Library:</span>
357 [% Branches.GetName(request.branchcode) | html %]
360 <span class="label status">Status:</span>
361 [% IF request.statusalias %]
362 [% request.statusalias.lib | html %]
364 [% request.capabilities.$req_status.name | html%]
368 <span class="label updated">Last updated:</span>
369 [% request.updated | $KohaDates with_hours => 1 %]
372 <span class="label medium">Request type:</span>
373 [% type = request.get_type %]
374 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
377 <span class="label cost">Cost:</span>
378 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
380 <li class="price_paid">
381 <span class="label price_paid">Price paid:</span>
382 [% IF request.price_paid %][% request.price_paid | html %][% ELSE %]<span>N/A</span>[% END %]
385 <span class="label req_id">Request number:</span>
386 [% request.id_prefix _ request.illrequest_id | html %]
388 <li class="notesstaff">
389 <span class="label notes_staff">Staff notes:</span>
390 <p>[% request.notesstaff | html %]</p>
392 <li class="notesopac">
393 <span class="label notes_opac">Notes:</span>
394 <p>[% request.notesopac | html %]</p>
399 <h4>Details from supplier ([% request.backend | html %])</h4>
401 [% FOREACH meta IN request.metadata %]
402 <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
403 <span class="label">[% meta.key | html %]:</span>
404 [% meta.value | html %]
412 <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
413 <div class="modal-dialog">
414 <div class="modal-content">
415 <div class="modal-header">
416 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
417 <h3 id="dataPreviewLabel"> Supplier metadata</h3>
419 <div class="modal-body">
420 <div id="requestattributes">
421 [% FOREACH attr IN request.illrequestattributes %]
422 <div class="requestattr-[% attr.type | html %]">
423 <span class="label">[% attr.type | html %]:</span>
424 [% attr.value | html %]
429 <div class="modal-footer">
430 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
436 <div id="requestLog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
437 <div class="modal-dialog">
438 <div class="modal-content">
439 <div class="modal-header">
440 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
441 <h3 id="requestLogLabel"> Request log</h3>
443 <div class="modal-body">
444 [% IF request.logs.size > 0 %]
445 [% FOREACH log IN request.logs %]
446 [% tpl = log.template %]
447 [% INCLUDE $tpl log=log %]
450 There are no recorded logs for this request
453 <div class="modal-footer">
454 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
460 <div class="ill-view-panel panel panel-default">
461 <div class="panel-heading">
462 <h3>[% request.illcomments.count | html %] comments</h3>
464 <div class="panel-body">
465 [% IF request.illcomments.count && request.illcomments.count > 0 %]
466 [% FOREACH comment IN request.illcomments %]
467 <div class="rows comment_[% comment.patron.categorycode | html %]">
469 <a href="[% borrowerlink | url %]" title="View borrower details">
470 [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
471 [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
472 <p>[% comment.comment | html %]</p>
477 <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
478 <div id="addcomment" class="content_hidden">
479 <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
480 <input type="hidden" value="save_comment" name="method">
481 <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
482 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
483 <fieldset class="rows">
486 <label class="required" for="comment">Comment: </label>
487 <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
488 <span class="required">Required</span>
492 <fieldset class="action">
493 <input type="submit" value="Submit">
501 [% ELSIF query_type == 'illlist' %]
503 <h1>View ILL requests</h1>
505 <h3>Details for all requests</h3>
507 <table id="ill-requests">
509 <tr id="illview-header">
513 <th>Bibliographic record ID</th>
516 <th class="placed"> </th>
517 <th class="placed_formatted">Date placed</th>
518 <th class="updated"> </th>
519 <th class="updated_formatted">Updated on</th>
520 <th>Request number</th>
522 <th class="patron_cardnumber">Cardnumber</th>
523 <th class="actions"></th>
526 <tbody id="illview-body">
531 <!-- Custom Backend Action -->
532 [% PROCESS $whole.template %]
541 [% PROCESS backend_jsinclude %]
545 [% MACRO jsinclude BLOCK %]
546 [% INCLUDE 'datatables.inc' %]
547 [% INCLUDE 'calendar.inc' %]
548 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
550 $(document).ready(function() {
552 // Illview Datatable setup
556 // Filters that are active
557 var activeFilters = {};
559 // Fields we don't want to display
573 // Fields we need to expand (flatten)
580 // This is auto populated
583 // The core fields that should be displayed first
601 // Filterable columns
604 prep: function(tableData, oData) {
606 tableData.forEach(function(row) {
608 if (row.status_alias) {
609 resolvedName = row.status_alias.lib;
611 resolvedName = getStatusName(
612 oData[0].capabilities[row.status].name
615 uniques[resolvedName] = 1
617 Object.keys(uniques).sort().forEach(function(unique) {
618 $('#illfilter_status').append(
619 '<option value="' + unique +
620 '">' + unique + '</option>'
624 listener: function() {
626 $('#illfilter_status').change(function() {
627 var sel = $('#illfilter_status option:selected').val();
628 if (sel && sel.length > 0) {
629 activeFilters[me] = function() {
630 table.column(5).search(sel);
633 if (activeFilters.hasOwnProperty(me)) {
634 delete activeFilters[me];
640 $('#illfilter_status').val('');
644 prep: function(tableData, oData) {
646 tableData.forEach(function(row) {
647 uniques[row.library.branchname] = 1
649 Object.keys(uniques).sort().forEach(function(unique) {
650 $('#illfilter_branchname').append(
651 '<option value="' + unique +
652 '">' + unique + '</option>'
656 listener: function() {
657 var me = 'pickupBranch';
658 $('#illfilter_branchname').change(function() {
659 var sel = $('#illfilter_branchname option:selected').val();
660 if (sel && sel.length > 0) {
661 activeFilters[me] = function() {
662 table.column(4).search(sel);
665 if (activeFilters.hasOwnProperty(me)) {
666 delete activeFilters[me];
672 $('#illfilter_branchname').val('');
676 listener: function() {
678 $('#illfilter_barcode').change(function() {
679 var val = $('#illfilter_barcode').val();
680 if (val && val.length > 0) {
681 activeFilters[me] = function() {
682 table.column(12).search(val);
685 if (activeFilters.hasOwnProperty(me)) {
686 delete activeFilters[me];
692 $('#illfilter_barcode').val('');
697 $('#illfilter_datemodified_start, #illfilter_datemodified_end').val('');
702 $('#illfilter_dateplaced_start, #illfilter_dateplaced_end').val('');
707 // Remove any fields we're ignoring
708 var removeIgnore = function(dataObj) {
709 dataObj.forEach(function(thisRow) {
710 ignore.forEach(function(thisIgnore) {
711 if (thisRow.hasOwnProperty(thisIgnore)) {
712 delete thisRow[thisIgnore];
718 // Expand any fields we're expanding
719 var expandExpand = function(row) {
720 expand.forEach(function(thisExpand) {
721 if (row.hasOwnProperty(thisExpand)) {
722 if (!expanded.hasOwnProperty(thisExpand)) {
723 expanded[thisExpand] = [];
725 var expandObj = row[thisExpand];
726 Object.keys(expandObj).forEach(
727 function(thisExpandCol) {
728 var expColName = thisExpand + '_' + thisExpandCol;
729 // Keep a list of fields that have been expanded
730 // so we can create toggle links for them
731 if (expanded[thisExpand].indexOf(expColName) == -1) {
732 expanded[thisExpand].push(expColName);
734 expandObj[expColName] =
735 expandObj[thisExpandCol];
736 delete expandObj[thisExpandCol];
739 $.extend(true, row, expandObj);
740 delete row[thisExpand];
745 // Build a de-duped list of all column names
747 core.map(function(thisCore) {
748 allCols[thisCore] = 1;
751 // Strip the expand prefix if it exists, we do this for display
752 var stripPrefix = function(value) {
753 expand.forEach(function(thisExpand) {
754 var regex = new RegExp(thisExpand + '_', 'g');
755 value = value.replace(regex, '');
760 // Our 'render' function for borrowerlink
761 var createPatronLink = function(data, type, row) {
762 var patronLink = '<a title="' + _("View borrower details") + '" ' +
763 'href="/cgi-bin/koha/members/moremember.pl?' +
764 'borrowernumber='+row.borrowernumber+'">';
765 if ( row.patron_firstname ) {
766 patronLink = patronLink + row.patron_firstname + ' ';
768 patronLink = patronLink + row.patron_surname + '</a>';
772 // Our 'render' function for the library name
773 var createLibrary = function(data, type, row) {
774 return row.library.branchname;
777 // Render function for request ID
778 var createRequestId = function(data, type, row) {
779 return row.id_prefix + row.illrequest_id;
782 // Render function for request status
783 var createStatus = function(data, type, row, meta) {
784 if (row.status_alias) {
785 return row.status_alias.lib
786 ? row.status_alias.lib
787 : row.status_alias.authorised_value;
789 var origData = meta.settings.oInit.originalData;
790 if (origData.length > 0) {
791 var status_name = meta.settings.oInit.originalData[0].capabilities[
794 return getStatusName(status_name);
801 var getStatusName = function(origName) {
804 return _("New request");
806 return _("Requested");
807 case "Requested from partners":
808 return _("Requested from partners");
809 case "Request reverted":
810 return _("Request reverted");
811 case "Queued request":
812 return _("Queued request");
813 case "Cancellation requested":
814 return _("Cancellation requested");
816 return _("Completed");
817 case "Delete request":
818 return _("Delete request");
824 // Render function for creating a row's action link
825 var createActionLink = function(data, type, row) {
826 return '<a class="btn btn-default btn-sm" ' +
827 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
828 'method=illview&illrequest_id=' +
830 '">' + _("Manage request") + '</a>';
833 // Columns that require special treatment
837 func: createActionLink
841 func: createPatronLink
844 name: _("Request number"),
845 func: createRequestId
859 name: _("Updated on"),
862 name: _("Cardnumber")
866 // Display the modal containing request supplier metadata
867 $('#ill-request-display-log').on('click', function(e) {
869 $('#requestLog').modal({show:true});
872 // Toggle request attributes in Illview
873 $('#toggle_requestattributes').on('click', function(e) {
875 $('#requestattributes').toggleClass('content_hidden');
878 // Toggle new comment form in Illview
879 $('#toggle_addcomment').on('click', function(e) {
881 $('#addcomment').toggleClass('content_hidden');
884 // Filter partner list
885 $('#partner_filter').keyup(function() {
886 var needle = $('#partner_filter').val();
887 $('#partners > option').each(function() {
888 var regex = new RegExp(needle, 'i');
890 needle.length == 0 ||
891 $(this).is(':selected') ||
892 $(this).text().match(regex)
901 // Display the modal containing request supplier metadata
902 $('#ill-request-display-metadata').on('click', function(e) {
904 $('#dataPreview').modal({show:true});
907 // Get our data from the API and process it prior to passing
910 '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias'
912 var data = JSON.parse(ajax.responseText);
913 // Make a copy, we'll be removing columns next and need
914 // to be able to refer to data that has been removed
915 var dataCopy = $.extend(true, [], data);
916 // Remove all columns we're not interested in
917 removeIgnore(dataCopy);
918 // Expand columns that need it and create an array
919 // of all column names
920 $.each(dataCopy, function(k, row) {
924 // Assemble an array of column definitions for passing
927 Object.keys(allCols).forEach(function(thisCol) {
928 // Create the base column object
934 // We may need to process the data going in this
935 // column, so do it if necessary
937 specialCols.hasOwnProperty(thisCol) &&
938 specialCols[thisCol].hasOwnProperty('func')
940 colObj.render = specialCols[thisCol].func;
942 colObj.data = thisCol;
944 colData.push(colObj);
947 // Initialise the datatable
948 table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
950 { // Last column shouldn't be sortable or searchable
951 'aTargets': [ 'actions' ],
955 { // Hide the two date columns we use just for sorting
956 'aTargets': [ 'placed', 'updated' ],
960 { // When sorting 'placed', we want to use the
961 // unformatted column
962 'aTargets': [ 'placed_formatted'],
965 { // When sorting 'updated', we want to use the
966 // unformatted column
967 'aTargets': [ 'updated_formatted'],
971 'aTargets': [ 'patron_cardnumber' ],
976 'aaSorting': [[ 9, 'desc' ]], // Default sort, updated descending
977 'processing': true, // Display a message when manipulating
978 'sPaginationType': "full_numbers", // Pagination display
979 'deferRender': true, // Improve performance on big datasets
982 'originalData': data, // Enable render functions to access
984 'initComplete': function() {
986 // Prepare any filter elements that need it
987 for (var el in filterable) {
988 if (filterable.hasOwnProperty(el)) {
989 if (filterable[el].hasOwnProperty('prep')) {
990 filterable[el].prep(dataCopy, data);
992 if (filterable[el].hasOwnProperty('listener')) {
993 filterable[el].listener();
1001 // Custom date range filtering
1002 $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
1003 var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate');
1004 var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate');
1005 var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate');
1006 var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate');
1007 var rowPlaced = data[6] ? new Date(data[6]) : null;
1008 var rowModified = data[8] ? new Date(data[8]) : null;
1009 var placedPassed = true;
1010 var modifiedPassed = true;
1011 if (placedStart && rowPlaced && rowPlaced < placedStart) {
1012 placedPassed = false
1014 if (placedEnd && rowPlaced && rowPlaced > placedEnd) {
1015 placedPassed = false;
1017 if (modifiedStart && rowModified && rowModified < modifiedStart) {
1018 modifiedPassed = false
1020 if (modifiedEnd && rowModified && rowModified > modifiedEnd) {
1021 modifiedPassed = false;
1024 return placedPassed && modifiedPassed;
1031 var clearSearch = function() {
1032 table.search('').columns().search('');
1034 for (var filter in filterable) {
1036 filterable.hasOwnProperty(filter) &&
1037 filterable[filter].hasOwnProperty('clear')
1039 filterable[filter].clear();
1045 // Apply any search filters, or clear any previous
1047 $('#illfilter_form').submit(function(event) {
1048 event.preventDefault();
1049 table.search('').columns().search('');
1050 for (var active in activeFilters) {
1051 if (activeFilters.hasOwnProperty(active)) {
1052 activeFilters[active]();
1058 // Clear all filters
1059 $('#clear_search').click(function() {
1067 [% INCLUDE 'intranet-bottom.inc' %]