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
323 <div class="ill-view-panel panel panel-default">
324 <div class="panel-heading">
325 <h3>Request details</h3>
327 <div class="panel-body">
328 <h4>Details from library</h4>
332 <span class="label orderid">Order ID:</span>
333 [% IF request.orderid %][% request.orderid | html %][% ELSE %]<span>N/A</span>[% END %]
335 <li class="borrowernumber">
336 <span class="label borrowernumber">Patron:</span>
337 [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
338 <a href="[% borrowerlink | url %]" title="View borrower details">
339 [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" | html %]
343 <li class="biblio_id">
344 <span class="label biblio_id">Bibliographic record ID:</span>
345 [% IF request.biblio_id %]
346 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% request.biblio_id | uri %]">[% request.biblio_id | html %]</a>
351 <li class="branchcode">
352 <span class="label branchcode">Library:</span>
353 [% Branches.GetName(request.branchcode) | html %]
356 <span class="label status">Status:</span>
357 [% IF request.statusalias %]
358 [% request.statusalias.lib | html %]
360 [% request.capabilities.$req_status.name | html%]
364 <span class="label updated">Last updated:</span>
365 [% request.updated | $KohaDates with_hours => 1 %]
368 <span class="label medium">Request type:</span>
369 [% type = request.get_type %]
370 [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
373 <span class="label cost">Cost:</span>
374 [% IF request.cost %][% request.cost | html %][% ELSE %]<span>N/A</span>[% END %]
376 <li class="price_paid">
377 <span class="label price_paid">Price paid:</span>
378 [% IF request.price_paid %][% request.price_paid | html %][% ELSE %]<span>N/A</span>[% END %]
381 <span class="label req_id">Request number:</span>
382 [% request.id_prefix _ request.illrequest_id | html %]
384 <li class="notesstaff">
385 <span class="label notes_staff">Staff notes:</span>
386 <p>[% request.notesstaff | html %]</p>
388 <li class="notesopac">
389 <span class="label notes_opac">Notes:</span>
390 <p>[% request.notesopac | html %]</p>
395 <h4>Details from supplier ([% request.backend | html %])</h4>
397 [% FOREACH meta IN request.metadata %]
398 <li class="requestmeta-[% meta.key.replace('\s','_') | html %]">
399 <span class="label">[% meta.key | html %]:</span>
400 [% meta.value | html %]
408 <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
409 <div class="modal-dialog">
410 <div class="modal-content">
411 <div class="modal-header">
412 <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
413 <h3 id="dataPreviewLabel"> Supplier metadata</h3>
415 <div class="modal-body">
416 <div id="requestattributes">
417 [% FOREACH attr IN request.illrequestattributes %]
418 <div class="requestattr-[% attr.type | html %]">
419 <span class="label">[% attr.type | html %]:</span>
420 [% attr.value | html %]
425 <div class="modal-footer">
426 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
432 <div class="ill-view-panel panel panel-default">
433 <div class="panel-heading">
434 <h3>[% request.illcomments.count | html %] comments</h3>
436 <div class="panel-body">
437 [% IF request.illcomments.count && request.illcomments.count > 0 %]
438 [% FOREACH comment IN request.illcomments %]
439 <div class="rows comment_[% comment.patron.categorycode | html %]">
441 <a href="[% borrowerlink | url %]" title="View borrower details">
442 [% comment.patron.firstname _ " " _ comment.patron.surname _ " [" _ comment.patron.cardnumber _ "]" | html %]</a>
443 [% comment.timestamp | $KohaDates with_hours => 1 %]</h5>
444 <p>[% comment.comment | html %]</p>
449 <h3><a id="toggle_addcomment" href="#">Add comment</a></h3>
450 <div id="addcomment" class="content_hidden">
451 <form class="validated" method="post" action="/cgi-bin/koha/ill/ill-requests.pl">
452 <input type="hidden" value="save_comment" name="method">
453 <input type="hidden" value="[% csrf_token | html %]" name="csrf_token">
454 <input type="hidden" value="[% request.illrequest_id | html %]" name="illrequest_id">
455 <fieldset class="rows">
458 <label class="required" for="comment">Comment: </label>
459 <textarea class="required" required="required" cols="80" rows="10" id="comment" name="comment"></textarea>
460 <span class="required">Required</span>
464 <fieldset class="action">
465 <input type="submit" value="Submit">
473 [% ELSIF query_type == 'illlist' %]
475 <h1>View ILL requests</h1>
477 <h3>Details for all requests</h3>
479 <table id="ill-requests">
481 <tr id="illview-header">
485 <th>Bibliographic record ID</th>
488 <th class="placed"> </th>
489 <th class="placed_formatted">Date placed</th>
490 <th class="updated"> </th>
491 <th class="updated_formatted">Updated on</th>
492 <th>Request number</th>
494 <th class="patron_cardnumber">Cardnumber</th>
495 <th class="actions"></th>
498 <tbody id="illview-body">
503 <!-- Custom Backend Action -->
504 [% PROCESS $whole.template %]
513 [% PROCESS backend_jsinclude %]
517 [% MACRO jsinclude BLOCK %]
518 [% INCLUDE 'datatables.inc' %]
519 [% INCLUDE 'calendar.inc' %]
520 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
522 $(document).ready(function() {
524 // Illview Datatable setup
528 // Filters that are active
529 var activeFilters = {};
531 // Fields we don't want to display
545 // Fields we need to expand (flatten)
552 // This is auto populated
555 // The core fields that should be displayed first
573 // Filterable columns
576 prep: function(tableData, oData) {
578 tableData.forEach(function(row) {
580 if (row.status_alias) {
581 resolvedName = row.status_alias.lib;
583 resolvedName = getStatusName(
584 oData[0].capabilities[row.status].name
587 uniques[resolvedName] = 1
589 Object.keys(uniques).sort().forEach(function(unique) {
590 $('#illfilter_status').append(
591 '<option value="' + unique +
592 '">' + unique + '</option>'
596 listener: function() {
598 $('#illfilter_status').change(function() {
599 var sel = $('#illfilter_status option:selected').val();
600 if (sel && sel.length > 0) {
601 activeFilters[me] = function() {
602 table.column(5).search(sel);
605 if (activeFilters.hasOwnProperty(me)) {
606 delete activeFilters[me];
612 $('#illfilter_status').val('');
616 prep: function(tableData, oData) {
618 tableData.forEach(function(row) {
619 uniques[row.library.branchname] = 1
621 Object.keys(uniques).sort().forEach(function(unique) {
622 $('#illfilter_branchname').append(
623 '<option value="' + unique +
624 '">' + unique + '</option>'
628 listener: function() {
629 var me = 'pickupBranch';
630 $('#illfilter_branchname').change(function() {
631 var sel = $('#illfilter_branchname option:selected').val();
632 if (sel && sel.length > 0) {
633 activeFilters[me] = function() {
634 table.column(4).search(sel);
637 if (activeFilters.hasOwnProperty(me)) {
638 delete activeFilters[me];
644 $('#illfilter_branchname').val('');
648 listener: function() {
650 $('#illfilter_barcode').change(function() {
651 var val = $('#illfilter_barcode').val();
652 if (val && val.length > 0) {
653 activeFilters[me] = function() {
654 table.column(12).search(val);
657 if (activeFilters.hasOwnProperty(me)) {
658 delete activeFilters[me];
664 $('#illfilter_barcode').val('');
669 $('#illfilter_datemodified_start, #illfilter_datemodified_end').val('');
674 $('#illfilter_dateplaced_start, #illfilter_dateplaced_end').val('');
679 // Remove any fields we're ignoring
680 var removeIgnore = function(dataObj) {
681 dataObj.forEach(function(thisRow) {
682 ignore.forEach(function(thisIgnore) {
683 if (thisRow.hasOwnProperty(thisIgnore)) {
684 delete thisRow[thisIgnore];
690 // Expand any fields we're expanding
691 var expandExpand = function(row) {
692 expand.forEach(function(thisExpand) {
693 if (row.hasOwnProperty(thisExpand)) {
694 if (!expanded.hasOwnProperty(thisExpand)) {
695 expanded[thisExpand] = [];
697 var expandObj = row[thisExpand];
698 Object.keys(expandObj).forEach(
699 function(thisExpandCol) {
700 var expColName = thisExpand + '_' + thisExpandCol;
701 // Keep a list of fields that have been expanded
702 // so we can create toggle links for them
703 if (expanded[thisExpand].indexOf(expColName) == -1) {
704 expanded[thisExpand].push(expColName);
706 expandObj[expColName] =
707 expandObj[thisExpandCol];
708 delete expandObj[thisExpandCol];
711 $.extend(true, row, expandObj);
712 delete row[thisExpand];
717 // Build a de-duped list of all column names
719 core.map(function(thisCore) {
720 allCols[thisCore] = 1;
723 // Strip the expand prefix if it exists, we do this for display
724 var stripPrefix = function(value) {
725 expand.forEach(function(thisExpand) {
726 var regex = new RegExp(thisExpand + '_', 'g');
727 value = value.replace(regex, '');
732 // Our 'render' function for borrowerlink
733 var createPatronLink = function(data, type, row) {
734 var patronLink = '<a title="' + _("View borrower details") + '" ' +
735 'href="/cgi-bin/koha/members/moremember.pl?' +
736 'borrowernumber='+row.borrowernumber+'">';
737 if ( row.patron_firstname ) {
738 patronLink = patronLink + row.patron_firstname + ' ';
740 patronLink = patronLink + row.patron_surname + '</a>';
744 // Our 'render' function for the library name
745 var createLibrary = function(data, type, row) {
746 return row.library.branchname;
749 // Render function for request ID
750 var createRequestId = function(data, type, row) {
751 return row.id_prefix + row.illrequest_id;
754 // Render function for request status
755 var createStatus = function(data, type, row, meta) {
756 if (row.status_alias) {
757 return row.status_alias.lib
758 ? row.status_alias.lib
759 : row.status_alias.authorised_value;
761 var origData = meta.settings.oInit.originalData;
762 if (origData.length > 0) {
763 var status_name = meta.settings.oInit.originalData[0].capabilities[
766 return getStatusName(status_name);
773 var getStatusName = function(origName) {
776 return _("New request");
778 return _("Requested");
779 case "Requested from partners":
780 return _("Requested from partners");
781 case "Request reverted":
782 return _("Request reverted");
783 case "Queued request":
784 return _("Queued request");
785 case "Cancellation requested":
786 return _("Cancellation requested");
788 return _("Completed");
789 case "Delete request":
790 return _("Delete request");
796 // Render function for creating a row's action link
797 var createActionLink = function(data, type, row) {
798 return '<a class="btn btn-default btn-sm" ' +
799 'href="/cgi-bin/koha/ill/ill-requests.pl?' +
800 'method=illview&illrequest_id=' +
802 '">' + _("Manage request") + '</a>';
805 // Columns that require special treatment
809 func: createActionLink
813 func: createPatronLink
816 name: _("Request number"),
817 func: createRequestId
831 name: _("Updated on"),
834 name: _("Cardnumber")
838 // Toggle request attributes in Illview
839 $('#toggle_requestattributes').on('click', function(e) {
841 $('#requestattributes').toggleClass('content_hidden');
844 // Toggle new comment form in Illview
845 $('#toggle_addcomment').on('click', function(e) {
847 $('#addcomment').toggleClass('content_hidden');
850 // Filter partner list
851 $('#partner_filter').keyup(function() {
852 var needle = $('#partner_filter').val();
853 $('#partners > option').each(function() {
854 var regex = new RegExp(needle, 'i');
856 needle.length == 0 ||
857 $(this).is(':selected') ||
858 $(this).text().match(regex)
867 // Display the modal containing request supplier metadata
868 $('#ill-request-display-metadata').on('click', function(e) {
870 $('#dataPreview').modal({show:true});
873 // Get our data from the API and process it prior to passing
876 '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias'
878 var data = JSON.parse(ajax.responseText);
879 // Make a copy, we'll be removing columns next and need
880 // to be able to refer to data that has been removed
881 var dataCopy = $.extend(true, [], data);
882 // Remove all columns we're not interested in
883 removeIgnore(dataCopy);
884 // Expand columns that need it and create an array
885 // of all column names
886 $.each(dataCopy, function(k, row) {
890 // Assemble an array of column definitions for passing
893 Object.keys(allCols).forEach(function(thisCol) {
894 // Create the base column object
900 // We may need to process the data going in this
901 // column, so do it if necessary
903 specialCols.hasOwnProperty(thisCol) &&
904 specialCols[thisCol].hasOwnProperty('func')
906 colObj.render = specialCols[thisCol].func;
908 colObj.data = thisCol;
910 colData.push(colObj);
913 // Initialise the datatable
914 table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, {
916 { // Last column shouldn't be sortable or searchable
917 'aTargets': [ 'actions' ],
921 { // Hide the two date columns we use just for sorting
922 'aTargets': [ 'placed', 'updated' ],
926 { // When sorting 'placed', we want to use the
927 // unformatted column
928 'aTargets': [ 'placed_formatted'],
931 { // When sorting 'updated', we want to use the
932 // unformatted column
933 'aTargets': [ 'updated_formatted'],
937 'aTargets': [ 'patron_cardnumber' ],
942 'aaSorting': [[ 9, 'desc' ]], // Default sort, updated descending
943 'processing': true, // Display a message when manipulating
944 'sPaginationType': "full_numbers", // Pagination display
945 'deferRender': true, // Improve performance on big datasets
948 'originalData': data, // Enable render functions to access
950 'initComplete': function() {
952 // Prepare any filter elements that need it
953 for (var el in filterable) {
954 if (filterable.hasOwnProperty(el)) {
955 if (filterable[el].hasOwnProperty('prep')) {
956 filterable[el].prep(dataCopy, data);
958 if (filterable[el].hasOwnProperty('listener')) {
959 filterable[el].listener();
967 // Custom date range filtering
968 $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
969 var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate');
970 var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate');
971 var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate');
972 var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate');
973 var rowPlaced = data[6] ? new Date(data[6]) : null;
974 var rowModified = data[8] ? new Date(data[8]) : null;
975 var placedPassed = true;
976 var modifiedPassed = true;
977 if (placedStart && rowPlaced && rowPlaced < placedStart) {
980 if (placedEnd && rowPlaced && rowPlaced > placedEnd) {
981 placedPassed = false;
983 if (modifiedStart && rowModified && rowModified < modifiedStart) {
984 modifiedPassed = false
986 if (modifiedEnd && rowModified && rowModified > modifiedEnd) {
987 modifiedPassed = false;
990 return placedPassed && modifiedPassed;
997 var clearSearch = function() {
998 table.search('').columns().search('');
1000 for (var filter in filterable) {
1002 filterable.hasOwnProperty(filter) &&
1003 filterable[filter].hasOwnProperty('clear')
1005 filterable[filter].clear();
1011 // Apply any search filters, or clear any previous
1013 $('#illfilter_form').submit(function(event) {
1014 event.preventDefault();
1015 table.search('').columns().search('');
1016 for (var active in activeFilters) {
1017 if (activeFilters.hasOwnProperty(active)) {
1018 activeFilters[active]();
1024 // Clear all filters
1025 $('#clear_search').click(function() {
1033 [% INCLUDE 'intranet-bottom.inc' %]