7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › ILL requests</title>
9 [% INCLUDE 'doc-head-close.inc' %]
12 <body id="illrequests" class="ill">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
16 <div id="breadcrumbs">
17 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
18 <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
19 [% IF query_type == 'create' %]
21 [% ELSIF query_type == 'status' %]
26 <div id="doc3" class="yui-t2">
28 [% IF query_type == 'illlist' %]
29 <div id="illfilter_yui_column" class="yui-b">
30 <form method="get" id="illfilter_form">
31 <fieldset class="brief">
35 <label for="illfilter_status">Status:</label>
36 <select name="illfilter_status" id="illfilter_status">
37 <option value=""></option>
41 <label for="illfilter_dateplaced_start">Date placed between:</label>
42 <input type="text" name="illfilter_dateplaced_start" id="illfilter_dateplaced_start" class="datepicker" />
45 <label for="illfilter_dateplaced_end">and:</label>
46 <input type="text" name="illfilter_dateplaced_end" id="illfilter_dateplaced_end" class="datepicker" />
49 <label for="illfilter_datemodified_start">Updated between:</label>
50 <input type="text" name="illfilter_datemodified_start" id="illfilter_datemodified_start" class="datepicker" />
53 <label for="illfilter_datemodified_end">and:</label>
54 <input type="text" name="illfilter_datemodified_end" id="illfilter_datemodified_end" class="datepicker" />
57 <label for="illfilter_branchname">Library:</label>
58 <select name="illfilter_branchname" id="illfilter_branchname">
59 <option value=""></option>
63 <label for="illfilter_barcode">Cardnumber:</label>
64 <input type="text" name="illfilter_barcode" id="illfilter_barcode" />
67 <fieldset class="action">
68 <input type="submit" value="Search" />
69 <input type="button" value="Clear" id="clear_search" />
76 <div id="interlibraryloans" class="yui-b">
77 [% IF !backends_available || !has_branch %]
78 <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>
80 [% INCLUDE 'ill-toolbar.inc' %]
83 <h1>Error performing operation</h1>
84 <!-- Dispatch on Status -->
85 <p>We encountered an error:</p>
87 <pre>[% whole.message | html %] ([% whole.status | html %])</pre>
91 [% IF query_type == 'create' %]
92 <h1>New ILL request</h1>
93 [% PROCESS $whole.template %]
95 [% ELSIF query_type == 'confirm' %]
96 <h1>Confirm ILL request</h1>
97 [% PROCESS $whole.template %]
99 [% ELSIF query_type == 'cancel' and !whole.error %]
100 <h1>Cancel a confirmed request</h1>
101 [% PROCESS $whole.template %]
103 [% ELSIF query_type == 'generic_confirm' %]
104 <h1>Place request with partner libraries</h1>
106 [% IF error == 'no_target_email' %]
108 No target email addresses found. Either select at least
109 one partner or check your ILL partner library records.
111 [% ELSIF error == 'no_library_email' %]
113 Your library has no usable email address. Please set it.
115 [% ELSIF error == 'unkown_error' %]
117 Unknown error processing your request. Contact your administrator.
121 <!-- Start of GENERIC_EMAIL case -->
122 [% IF whole.value.partners %]
123 [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %]
124 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
125 <fieldset class="rows">
126 <legend>Interlibrary loan request details</legend>
129 <label for="partner_filter">Filter partner libraries:</label>
130 <input type="text" id="partner_filter" />
133 <label for="partners" class="required">Select partner libraries:</label>
134 <select size="5" multiple="true" id="partners" name="partners" required="required">
135 [% FOREACH partner IN whole.value.partners %]
136 <option value=[% partner.email | html %]>
137 [% partner.branchcode _ " - " _ partner.surname %]
144 <label for="subject" class="required">Subject line:</label>
145 <input type="text" name="subject" id="subject" type="text" value="[% whole.value.draft.subject | html %]" required="required" />
148 <label for="body" class="required">Email text:</label>
149 <textarea name="body" id="body" rows="20" cols="80" required="required">[% whole.value.draft.body | html %]</textarea>
152 <input type="hidden" value="generic_confirm" name="method">
153 <input type="hidden" value="draft" name="stage">
154 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
156 <fieldset class="action">
157 <input type="submit" class="btn btn-default" value="Send email"/>
158 <span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span>
162 <fieldset class="rows">
163 <legend>Interlibrary loan request details</legend>
164 <p>No partners have been defined yet. Please create appropriate patron records (by default ILLLIBS category).</p>
165 <p>Be sure to provide email addresses for these patrons.</p>
166 <p><span><a href="[% ill_url | url %]" title="Return to request details">Cancel</a></span></p>
169 <!-- generic_confirm ends here -->
171 [% ELSIF query_type == 'edit_action' %]
172 <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl">
173 <fieldset class="rows">
174 <legend>Request details</legend>
176 [% type = request.get_type %]
177 <li class="borrowernumber">
178 <label for="borrowernumber">Patron ID:</label>
179 [% request.borrowernumber | html %]
181 <li class="biblio_id">
182 <label for="biblio_id" class="biblio_id">Bibliographic record ID:</label>
183 <input name="biblio_id" id="biblio_id" type="text" value="[% request.biblio_id | html %]">
185 <li class="branchcode">
186 <label for="library" class="branchcode">Library:</label>
187 <select name="branchcode" id="library">
188 [% PROCESS options_for_libraries libraries => Branches.all( selected => request.branchcode ) %]
192 <label class="status">Status:</label>
193 [% stat = request.status %]
194 [% current_alias = request.status_alias %]
195 <select id="status_alias" name="status_alias">
196 [% IF !current_alias %]
197 <option value="" selected>
201 [% request.capabilities.$stat.name | html %]
203 [% FOREACH alias IN status_aliases %]
204 [% IF alias.id == current_alias %]
205 <option value="[% alias.id %]" selected>
207 <option value="[% alias.id %]">
209 [% alias.lib | html %]
215 <label class="updated">Last updated:</label>
216 [% request.updated | $KohaDates with_hours => 1 %]
219 <label class="medium">Request type:</label>
220 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
223 <label class="cost">Cost:</label>
224 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
226 <li class="price_paid">
227 <label class="price_paid">Price paid:</label>
228 <input name="price_paid" id="price_paid" type="text" value="[% request.price_paid | html %]">
231 <label class="req_id">Request number:</label>
232 [% request.id_prefix _ request.illrequest_id | html %]
234 <li class="notesstaff">
235 <label for="notesstaff" class="notesstaff">Staff notes:</label>
236 <textarea name="notesstaff" id="notesstaff" rows="5">[% request.notesstaff | html %]</textarea>
238 <li class="notesopac">
239 <label for="notesopac" class="notesopac">Opac notes:</label>
240 <textarea name="notesopac" id="notesopac" rows="5">[% request.notesopac | html %]</textarea>
244 <fieldset class="action">
245 <input type="hidden" value="edit_action" name="method">
246 <input type="hidden" value="form" name="stage">
247 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
248 <input type="hidden" value="[% request.borrowernumber | html %]" name="borrowernumber">
249 <input type="submit" value="Submit">
250 <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=[% request.id | html %]">Cancel</a>
254 [% ELSIF query_type == 'delete_confirm' %]
256 <div class="dialog alert">
257 <h3>Are you sure you wish to delete this request?</h3>
258 <form action="/cgi-bin/koha/ill/ill-requests.pl" method="post">
259 <input type="hidden" name="method" value="delete" />
260 <input type="hidden" name="confirmed" value="1" />
261 <input type="hidden" name="illrequest_id" value="[% request.id | html %]" />
262 <button type="submit" class="btn btn-default btn-sm approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
264 <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>
267 [% ELSIF query_type == 'illview' %]
268 [% req_status = request.status %]
271 [% IF error == 'migrate_target' %]
273 The backend you tried to migrate to does not yet support migrations, please try again with an alternative target.
278 <h1>Manage ILL request</h1>
279 <div id="request-toolbar" class="btn-toolbar">
280 <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 %]">
281 <span class="fa fa-pencil"></span>
284 [% FOREACH action IN request.available_actions %]
285 [% IF action.method == 'migrate' %]
286 [% IF backends.size > 2 %]
287 <div class="dropdown btn-group">
288 <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
289 <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
291 <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
292 [% FOREACH backend IN backends %]
293 [% IF backend != request.backend %]
294 <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>
299 [% ELSIF backends.size == 2 %]
300 [% FOREACH backend IN backends %]
301 [% IF backend != request.backend %]
302 <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 %]">
303 <span class="fa [% action.ui_method_icon | html %]"></span>
304 [% action.ui_method_name | html %]
309 [% ELSIF action.method != 0 %]
310 <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 %]">
311 <span class="fa [% action.ui_method_icon | html %]"></span>
312 [% action.ui_method_name | html %]
316 <a title="Display supplier metadata" id="ill-request-display-metadata" class="btn btn-sm btn-default pull-right" href="#">
317 <span class="fa fa-eye"></span>
318 Display supplier metadata
321 <div class="ill-view-panel panel panel-default">
322 <div class="panel-heading">
323 <h3>Request details</h3>
325 <div class="panel-body">
326 <h4>Details from library</h4>
330 <span class="label orderid">Order ID:</span>
331 [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
333 <li class="borrowernumber">
334 <span class="label borrowernumber">Patron:</span>
335 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
336 <a href="[% borrowerlink | url %]" title="View borrower details">
337 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
341 <li class="biblio_id">
342 <span class="label biblio_id">Bibliographic record ID:</span>
343 [% IF request.biblio_id %]
344 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
349 <li class="branchcode">
350 <span class="label branchcode">Library:</span>
351 [% Branches.GetName(request.branchcode) | html %]
354 <span class="label status">Status:</span>
355 [% IF request.statusalias %]
356 [% request.statusalias.lib | html %]
358 [% request.capabilities.$req_status.name | html%]
362 <span class="label updated">Last updated:</span>
363 [% request.updated | $KohaDates with_hours => 1 %]
366 <span class="label medium">Request type:</span>
367 [% type = request.get_type %]
368 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
371 <span class="label cost">Cost:</span>
372 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
374 <li class="price_paid">
375 <span class="label price_paid">Price paid:</span>
376 [% IF request.price_paid %][% request.price_paid | html %][% ELSE %]<span>N/A</span>[% END %]
379 <span class="label req_id">Request number:</span>
380 [% request.id_prefix _ request.illrequest_id | html %]
382 <li class="notesstaff">
383 <span class="label notes_staff">Staff notes:</span>
384 <p>[% request.notesstaff | html %]</p>
386 <li class="notesopac">
387 <span class="label notes_opac">Notes:</span>
388 <p>[% request.notesopac | html %]</p>
393 <h4>Details from supplier ([% request.backend | html %])</h4>
395 [% FOREACH meta IN request.metadata %]
396 <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
397 <span class="label">[% meta.key | html %]:</span>
398 [% meta.value | html %]
406 <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
407 <div class="modal-dialog">
408 <div class="modal-content">
409 <div class="modal-header">
410 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
411 <h3 id="dataPreviewLabel"> Supplier metadata</h3>
413 <div class="modal-body">
414 <div id="requestattributes">
415 [% FOREACH attr IN request.illrequestattributes %]
416 <div class="requestattr-[% attr.type | html %]">
417 <span class="label">[% attr.type | html %]:</span>
418 [% attr.value | html %]
423 <div class="modal-footer">
424 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
430 <div class="ill-view-panel panel panel-default">
431 <div class="panel-heading">
432 <h3>[% request.illcomments.count | html %] comments</h3>
434 <div class="panel-body">
435 [% IF request.illcomments.count && request.illcomments.count > 0 %]
436 [% FOREACH comment IN request.illcomments %]
437 <div class="rows comment_[% comment.patron.categorycode | html %]">
439 <a href="[% borrowerlink | url %]" title="View borrower details">
440 [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
441 [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
442 <p>[% comment.comment | html %]</p>
447 <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
448 <div id="addcomment" class="content_hidden">
449 <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
450 <input type="hidden" value="save_comment" name="method">
451 <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
452 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
453 <fieldset class="rows">
456 <label class="required" for="comment">Comment: </label>
457 <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
458 <span class="required">Required</span>
462 <fieldset class="action">
463 <input type="submit" value="Submit">
471 [% ELSIF query_type == 'illlist' %]
473 <h1>View ILL requests</h1>
475 <h3>Details for all requests</h3>
477 <table id="ill-requests">
479 <tr id="illview-header">
483 <th>Bibliographic record ID</th>
486 <th class="placed"> </th>
487 <th class="placed_formatted">Date placed</th>
488 <th class="updated"> </th>
489 <th class="updated_formatted">Updated on</th>
490 <th>Request number</th>
492 <th class="patron_cardnumber">Cardnumber</th>
493 <th class="actions"></th>
496 <tbody id="illview-body">
501 <!-- Custom Backend Action -->
502 [% PROCESS $whole.template %]
511 [% PROCESS backend_jsinclude %]
515 [% MACRO jsinclude BLOCK %]
516 [% INCLUDE 'datatables.inc' %]
517 [% INCLUDE 'calendar.inc' %]
518 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
520 $(document).ready(function() {
522 // Illview Datatable setup
526 // Filters that are active
527 var activeFilters = {};
529 // Fields we don't want to display
543 // Fields we need to expand (flatten)
550 // This is auto populated
553 // The core fields that should be displayed first
571 // Filterable columns
574 prep: function(tableData, oData) {
576 tableData.forEach(function(row) {
577 var resolvedName = getStatusName(
578 oData[0].capabilities[row.status].name
580 uniques[resolvedName] = 1
582 Object.keys(uniques).sort().forEach(function(unique) {
583 $('#illfilter_status').append(
584 '<option value="' + unique +
585 '">' + unique + '</option>'
589 listener: function() {
591 $('#illfilter_status').change(function() {
592 var sel = $('#illfilter_status option:selected').val();
593 if (sel && sel.length > 0) {
594 activeFilters[me] = function() {
595 table.column(5).search(sel);
598 if (activeFilters.hasOwnProperty(me)) {
599 delete activeFilters[me];
605 $('#illfilter_status').val('');
609 prep: function(tableData, oData) {
611 tableData.forEach(function(row) {
612 uniques[row.library.branchname] = 1
614 Object.keys(uniques).sort().forEach(function(unique) {
615 $('#illfilter_branchname').append(
616 '<option value="' + unique +
617 '">' + unique + '</option>'
621 listener: function() {
622 var me = 'pickupBranch';
623 $('#illfilter_branchname').change(function() {
624 var sel = $('#illfilter_branchname option:selected').val();
625 if (sel && sel.length > 0) {
626 activeFilters[me] = function() {
627 table.column(4).search(sel);
630 if (activeFilters.hasOwnProperty(me)) {
631 delete activeFilters[me];
637 $('#illfilter_branchname').val('');
641 listener: function() {
643 $('#illfilter_barcode').change(function() {
644 var val = $('#illfilter_barcode').val();
645 if (val && val.length > 0) {
646 activeFilters[me] = function() {
647 table.column(12).search(val);
650 if (activeFilters.hasOwnProperty(me)) {
651 delete activeFilters[me];
657 $('#illfilter_barcode').val('');
662 $('#illfilter_datemodified_start, #illfilter_datemodified_end').val('');
667 $('#illfilter_dateplaced_start, #illfilter_dateplaced_end').val('');
672 // Remove any fields we're ignoring
673 var removeIgnore = function(dataObj) {
674 dataObj.forEach(function(thisRow) {
675 ignore.forEach(function(thisIgnore) {
676 if (thisRow.hasOwnProperty(thisIgnore)) {
677 delete thisRow[thisIgnore];
683 // Expand any fields we're expanding
684 var expandExpand = function(row) {
685 expand.forEach(function(thisExpand) {
686 if (row.hasOwnProperty(thisExpand)) {
687 if (!expanded.hasOwnProperty(thisExpand)) {
688 expanded[thisExpand] = [];
690 var expandObj = row[thisExpand];
691 Object.keys(expandObj).forEach(
692 function(thisExpandCol) {
693 var expColName = thisExpand + '_' + thisExpandCol;
694 // Keep a list of fields that have been expanded
695 // so we can create toggle links for them
696 if (expanded[thisExpand].indexOf(expColName) == -1) {
697 expanded[thisExpand].push(expColName);
699 expandObj[expColName] =
700 expandObj[thisExpandCol];
701 delete expandObj[thisExpandCol];
704 $.extend(true, row, expandObj);
705 delete row[thisExpand];
710 // Build a de-duped list of all column names
712 core.map(function(thisCore) {
713 allCols[thisCore] = 1;
716 // Strip the expand prefix if it exists, we do this for display
717 var stripPrefix = function(value) {
718 expand.forEach(function(thisExpand) {
719 var regex = new RegExp(thisExpand + '_', 'g');
720 value = value.replace(regex, '');
725 // Our 'render' function for borrowerlink
726 var createPatronLink = function(data, type, row) {
727 var patronLink = '<a title="' + _("View borrower details") + '" ' +
728 'href="/cgi-bin/koha/members/moremember.pl?' +
729 'borrowernumber='+row.borrowernumber+'">';
730 if ( row.patron_firstname ) {
731 patronLink = patronLink + row.patron_firstname + ' ';
733 patronLink = patronLink + row.patron_surname + '</a>';
737 // Our 'render' function for the library name
738 var createLibrary = function(data, type, row) {
739 return row.library.branchname;
742 // Render function for request ID
743 var createRequestId = function(data, type, row) {
744 return row.id_prefix + row.illrequest_id;
747 // Render function for request status
748 var createStatus = function(data, type, row, meta) {
749 if (row.status_alias) {
750 return row.status_alias.lib ? row.status_alias.lib : 'N/A';
752 var origData = meta.settings.oInit.originalData;
753 if (origData.length > 0) {
754 var status_name = meta.settings.oInit.originalData[0].capabilities[
757 return getStatusName(status_name);
764 var getStatusName = function(origName) {
767 return _("New request");
769 return _("Requested");
770 case "Requested from partners":
771 return _("Requested from partners");
772 case "Request reverted":
773 return _("Request reverted");
774 case "Queued request":
775 return _("Queued request");
776 case "Cancellation requested":
777 return _("Cancellation requested");
779 return _("Completed");
780 case "Delete request":
781 return _("Delete request");
787 // Render function for creating a row's action link
788 var createActionLink = function(data, type, row) {
789 return '<a class="btn btn-default btn-sm" ' +
790 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
791 'method=illview&illrequest_id=' +
793 '">' + _("Manage request") + '</a>';
796 // Columns that require special treatment
800 func: createActionLink
804 func: createPatronLink
807 name: _("Request number"),
808 func: createRequestId
822 name: _("Updated on"),
825 name: _("Cardnumber")
829 // Toggle request attributes in Illview
830 $('#toggle_requestattributes').on('click', function(e) {
832 $('#requestattributes').toggleClass('content_hidden');
835 // Toggle new comment form in Illview
836 $('#toggle_addcomment').on('click', function(e) {
838 $('#addcomment').toggleClass('content_hidden');
841 // Filter partner list
842 $('#partner_filter').keyup(function() {
843 var needle = $('#partner_filter').val();
844 $('#partners > option').each(function() {
845 var regex = new RegExp(needle, 'i');
847 needle.length == 0 ||
848 $(this).is(':selected') ||
849 $(this).text().match(regex)
858 // Display the modal containing request supplier metadata
859 $('#ill-request-display-metadata').on('click', function(e) {
861 $('#dataPreview').modal({show:true});
864 // Get our data from the API and process it prior to passing
867 '/api/v1/illrequests?embed=metadata,patron,capabilities,library'
869 var data = JSON.parse(ajax.responseText);
870 // Make a copy, we'll be removing columns next and need
871 // to be able to refer to data that has been removed
872 var dataCopy = $.extend(true, [], data);
873 // Remove all columns we're not interested in
874 removeIgnore(dataCopy);
875 // Expand columns that need it and create an array
876 // of all column names
877 $.each(dataCopy, function(k, row) {
881 // Assemble an array of column definitions for passing
884 Object.keys(allCols).forEach(function(thisCol) {
885 // Create the base column object
891 // We may need to process the data going in this
892 // column, so do it if necessary
894 specialCols.hasOwnProperty(thisCol) &&
895 specialCols[thisCol].hasOwnProperty('func')
897 colObj.render = specialCols[thisCol].func;
899 colObj.data = thisCol;
901 colData.push(colObj);
904 // Initialise the datatable
905 table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
907 { // Last column shouldn't be sortable or searchable
908 'aTargets': [ 'actions' ],
912 { // Hide the two date columns we use just for sorting
913 'aTargets': [ 'placed', 'updated' ],
917 { // When sorting 'placed', we want to use the
918 // unformatted column
919 'aTargets': [ 'placed_formatted'],
922 { // When sorting 'updated', we want to use the
923 // unformatted column
924 'aTargets': [ 'updated_formatted'],
928 'aTargets': [ 'patron_cardnumber' ],
933 'aaSorting': [[ 9, 'desc' ]], // Default sort, updated descending
934 'processing': true, // Display a message when manipulating
935 'sPaginationType': "full_numbers", // Pagination display
936 'deferRender': true, // Improve performance on big datasets
939 'originalData': data, // Enable render functions to access
941 'initComplete': function() {
943 // Prepare any filter elements that need it
944 for (var el in filterable) {
945 if (filterable.hasOwnProperty(el)) {
946 if (filterable[el].hasOwnProperty('prep')) {
947 filterable[el].prep(dataCopy, data);
949 if (filterable[el].hasOwnProperty('listener')) {
950 filterable[el].listener();
958 // Custom date range filtering
959 $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
960 var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate');
961 var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate');
962 var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate');
963 var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate');
964 var rowPlaced = data[6] ? new Date(data[6]) : null;
965 var rowModified = data[8] ? new Date(data[8]) : null;
966 var placedPassed = true;
967 var modifiedPassed = true;
968 if (placedStart && rowPlaced && rowPlaced < placedStart) {
971 if (placedEnd && rowPlaced && rowPlaced > placedEnd) {
972 placedPassed = false;
974 if (modifiedStart && rowModified && rowModified < modifiedStart) {
975 modifiedPassed = false
977 if (modifiedEnd && rowModified && rowModified > modifiedEnd) {
978 modifiedPassed = false;
981 return placedPassed && modifiedPassed;
988 var clearSearch = function() {
989 table.search('').columns().search('');
991 for (var filter in filterable) {
993 filterable.hasOwnProperty(filter) &&
994 filterable[filter].hasOwnProperty('clear')
996 filterable[filter].clear();
1002 // Apply any search filters, or clear any previous
1004 $('#illfilter_form').submit(function(event) {
1005 event.preventDefault();
1006 table.search('').columns().search('');
1007 for (var active in activeFilters) {
1008 if (activeFilters.hasOwnProperty(active)) {
1009 activeFilters[active]();
1015 // Clear all filters
1016 $('#clear_search').click(function() {
1024 [% INCLUDE 'intranet-bottom.inc' %]