4 [% USE AuthorisedValues %]
6 [%- BLOCK form_label -%]
8 [%- CASE 'barcode' %]<span>Barcode</span>
9 [%- CASE 'itemcallnumber' %]<span>Call number</span>
10 [%- CASE 'stocknumber' %]<span>Inventory number</span>
11 [%- CASE 'title' %]<span>Title</span>
12 [%- CASE 'author' %]<span>Author</span>
13 [%- CASE 'publishercode' %]<span>Publisher</span>
14 [%- CASE 'publicationyear' %]<span>Publication date</span>
15 [%- CASE 'collectiontitle' %]<span>Collection title</span>
16 [%- CASE 'isbn' %]<span>ISBN</span>
17 [%- CASE 'issn' %]<span>ISSN</span>
18 [%- CASE 'homebranch' %]<span>Home library</span>
19 [%- CASE 'holdingbranch' %]<span>Current library</span>
20 [%- CASE 'All libraries' %]<span>All libraries</span>
21 [%- CASE 'location' %]<span>Shelving location</span>
22 [%- CASE 'All locations' %]<span>All locations</span>
23 [%- CASE 'itype' %]<span>Item type</span>
24 [%- CASE 'All item types' %]<span>All item types</span>
25 [%- CASE 'ccode' %]<span>Collection</span>
26 [%- CASE 'All collection codes' %]<span>All collections</span>
27 [%- CASE 'notforloan' %]<span>Status</span>
28 [%- CASE 'All statuses' %]<span>All statuses</span>
29 [%- CASE 'damaged' %]<span>Damaged</span>
30 [%- CASE 'itemlost' %]<span>Lost</span>
31 [%- CASE 'withdrawn' %]<span>Withdrawn</span>
32 [%- CASE 'new_status' %]<span>Is new</span>
36 [% BLOCK form_field_select %]
37 <div class="form-field form-field-select">
38 <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
39 <select id="[% name | html %]_op" name="[% name | html %]_op">
40 <option value="=">is</option>
41 <option value="!=" >is not</option>
43 <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
44 <option value="" selected="selected">
45 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
47 [% FOREACH option IN options %]
48 <option value="[% option.value | html %]">[% option.label | html %]</option>
54 [% BLOCK form_field_select_option %]
55 <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
58 [% BLOCK form_field_select_text %]
59 <div class="form-field form-field-select-text">
60 <select name="c" class="form-field-conjunction" disabled="disabled">
61 <option value="and">AND</option>
62 <option value="or">OR</option>
64 <select name="f" class="form-field-column">
65 [% INCLUDE form_field_select_option value='barcode' %]
66 [% INCLUDE form_field_select_option value='itemcallnumber' %]
67 [% INCLUDE form_field_select_option value='stocknumber' %]
68 [% INCLUDE form_field_select_option value='title' %]
69 [% INCLUDE form_field_select_option value='author' %]
70 [% INCLUDE form_field_select_option value='publishercode' %]
71 [% INCLUDE form_field_select_option value='publicationyear' %]
72 [% INCLUDE form_field_select_option value='collectiontitle' %]
73 [% INCLUDE form_field_select_option value='isbn' %]
74 [% INCLUDE form_field_select_option value='issn' %]
75 [% IF items_search_fields.size %]
76 <optgroup label="Custom search fields">
77 [% FOREACH field IN items_search_fields %]
78 [% marcfield = field.tagfield %]
79 [% IF field.tagsubfield.defined AND field.tagsubfield != "" %]
80 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
82 <option value="marc:[% marcfield | html %]" data-authorised-values-category="[% field.authorised_values_category | html %]">[% field.label | html %] ([% marcfield | html %])</option>
87 [% IF params.exists('op') %]
88 <select name="op" class="form-field-not">
89 <option value="like">is</option>
90 [% IF params.op == 'not like' %]
91 <option value="not like" selected="selected">is not</option>
93 <option value="not like">is not</option>
97 <select name="op" class="form-field-not">
98 <option value="like">is</option>
99 <option value="not like">is not</option>
102 <input type="text" name="q" class="form-field-value" value="" />
106 [% BLOCK form_field_radio_yes_no %]
107 <div class="form-field [% divclass | html %]">
108 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
109 <input type="radio" name="[% name | html %]" id="[% name | html %]_indifferent" value="" checked="checked"/>
110 <label for="[% name | html %]_indifferent">Ignore</label>
111 <input type="radio" name="[% name | html %]" id="[% name | html %]_yes" value="yes" />
112 <label for="[% name | html %]_yes">Yes</label>
113 <input type="radio" name="[% name | html %]" id="[% name | html %]_no" value="no" />
114 <label for="[% name | html %]_no">No</label>
118 [%# We need to escape html characters for 'value' and 'label' %]
119 [%- BLOCK escape_html_value_label -%]
120 [%- SET escaped = [] -%]
121 [%- FOR e IN elts -%]
122 [%- value = BLOCK %][% e.value | html %][% END -%]
123 [%- label = BLOCK %][% e.label | html %][% END -%]
124 [%- escaped.push({ 'value' => value, 'label' => label }) -%]
126 [%- To.json(escaped) | $raw -%]
129 [% notforloans = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.notforloan' }) %]
130 [% FOREACH nfl IN notforloans %]
131 [% nfl.value = nfl.authorised_value %]
132 [% nfl.label = nfl.lib %]
135 [% locations = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.location' }) %]
136 [% FOREACH loc IN locations %]
137 [% loc.value = loc.authorised_value %]
138 [% loc.label = loc.lib %]
141 [%# Page starts here %]
143 [% SET footerjs = 1 %]
144 [% INCLUDE 'doc-head-open.inc' %]
145 <title>Item search › Catalog › Koha</title>
146 [% INCLUDE 'doc-head-close.inc' %]
147 [% Asset.css("css/itemsearchform.css") | $raw %]
150 <body id="catalog_itemsearch" class="catalog">
151 [% WRAPPER 'header.inc' %]
152 [% INCLUDE 'home-search.inc' %]
155 [% WRAPPER 'sub-header.inc' %]
156 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
159 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
162 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
165 <a href="#" aria-current="page">
173 <div class="main container-fluid">
175 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
177 <div id="item-search-block">
180 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
181 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
182 <div id="toolbar" class="btn-toolbar">
183 <fieldset class="action">
184 <div class="btn-group">
185 <button class="btn btn-default"><i class="fa fa-search"></i> Search</button>
190 [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
191 [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
192 [% IF locations.size %]
193 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
197 [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
199 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
201 [% IF notforloans.size %]
202 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
204 [% IF itemlosts.size %]
205 [% INCLUDE form_field_select name="itemlost" options = itemlosts empty_option = "All statuses" %]
207 [% IF withdrawns.size %]
208 [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %]
210 <div class="form-field">
211 <label class="form-field-label">Availability:</label>
212 <input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/>
213 <label for="onloan_indifferent">Ignore</label>
214 <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" />
215 <label for="onloan_yes">Checked out</label>
219 [% INCLUDE form_field_select_text %]
220 <p class="hint">You can use the following wildcard characters: % _</p>
221 <p class="hint">% matches any number of characters</p>
222 <p class="hint">_ matches only a single character</p>
225 <div class="form-field">
226 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
227 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
228 <span class="hint">(inclusive)</span>
230 <div class="form-field">
231 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
232 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
233 <span class="hint">(inclusive)</span>
235 [% INCLUDE form_field_radio_yes_no name="damaged" %]
236 [% IF ( has_new_status ) %]
237 [% INCLUDE form_field_radio_yes_no name="new_status" divclass='item-new-status' %]
239 <div class="form-field">
240 <label class="form-field-label" for="issues_op">Checkout count:</label>
241 <select id="issues_op" name="issues_op">
242 <option value=">">></option>
243 <option value="<"><</option>
244 <option value="=">=</option>
245 <option value="!=">!=</option>
247 <input type="text" name="issues" />
249 <div class="form-field">
250 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
251 <select id="datelastborrowed_op" name="datelastborrowed_op">
252 <option value=">">After</option>
253 <option value="<">Before</option>
254 <option value="=">On</option>
256 <input type="text" name="datelastborrowed" />
257 <span class="hint">ISO Format (YYYY-MM-DD)</span>
261 <div class="form-field-radio">
262 <label>Output:</label>
263 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
264 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
265 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
273 <div class="col-md-12">
274 <div id="results-wrapper"></div>
278 [% MACRO jsinclude BLOCK %]
279 [% INCLUDE 'datatables.inc' %]
280 [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
281 [% Asset.js("lib/hc-sticky.js") | $raw %]
283 var authorised_values = [% authorised_values_json | $raw %];
285 function loadAuthorisedValuesSelect(select) {
286 var selected = select.find('option:selected');
287 var category = selected.data('authorised-values-category');
288 var form_field_value = select.siblings('.form-field-value');
289 if (category && category in authorised_values) {
290 var values = authorised_values[category];
291 var html = '<select name="q" class="form-field-value">\n';
293 var value = values[i];
294 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
296 html += '</select>\n';
297 var new_form_field_value = $(html);
298 new_form_field_value.val(form_field_value.val());
299 form_field_value.replaceWith(new_form_field_value);
301 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
302 html = '<input name="q" type="text" class="form-field-value" />';
303 var new_form_field_value = $(html);
304 form_field_value.replaceWith(new_form_field_value);
309 function addNewField( link ) {
310 var form_field = $('div.form-field-select-text').last();
311 var copy = form_field.clone(true);
312 copy.find('input,select').not('[type="hidden"]').each(function() {
315 copy.find('.form-field-conjunction').prop('disabled', false).val('and');
316 form_field.after(copy);
318 copy.find('select.form-field-column').change();
321 function submitForm($form) {
324 + ' <th id="items_checkbox"></th>'
325 + ' <th id="items_title">' + _("Title") + '</th>'
326 + ' <th id="items_pubdate">' + _("Publication date") + '</th>'
327 + ' <th id="items_publisher">' + _("Publisher") + '</th>'
328 + ' <th id="items_collection">' + _("Collection") + '</th>'
329 + ' <th id="items_barcode">' + _("Barcode") + '</th>'
330 + ' <th id="items_enumchron">' + _("Serial enumeration") + '</th>'
331 + ' <th id="items_callno">' + _("Call number") + '</th>'
332 + ' <th id="items_homebranch">' + _("Home library") + '</th>'
333 + ' <th id="items_holdingbranch">' + _("Current library") + '</th>'
334 + ' <th id="items_location">' + _("Shelving location") + '</th>'
335 + ' <th id="items_itype">' + _("Itemtype") + '</th>'
336 + ' <th id="item_inventoryno">' + _("Inventory number") + '</th>'
337 + ' <th id="items_status">' + _("Not for loan status") + '</th>'
338 + ' <th id="items_itemlost">' + _("Lost status") + '</th>'
339 + ' <th id="items_widthdrawn">' + _("Withdrawn status") + '</th>'
340 + ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
341 + ' <th id="items_date_due">' + _("Due date") + '</th>'
345 + '<table id="results">'
346 + ' <thead>' + tr + tr + '</thead>'
350 var advSearchLink = $('<a>')
351 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
352 .html(_("Go to advanced search"));
353 var editSearchLink = $('<a>')
355 .html(_("Edit search"))
356 .addClass('btn btn-default btn-xs')
357 .on('click', function(e) {
359 $('#item-search-block').show();
362 function getCheckedItemnumbers () {
365 itemnumbers = JSON.parse(sessionStorage.getItem('itemsearch_itemnumbers') || '[]');
370 return new Set(itemnumbers);
373 function exportItems(format) {
374 var itemnumbers = getCheckedItemnumbers();
375 if (itemnumbers.size > 0) {
376 var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format;
377 href += '&itemnumber=' + Array.from(itemnumbers).join('&itemnumber=');
380 $('#format-' + format).prop('checked', true);
381 $('#itemsearchform').submit();
382 $('#format-html').prop('checked', true);
386 var csvExportLink = $('<a>')
389 .on('click', function(e) {
393 var barcodesExportLink = $('<a>')
395 .html(_("Barcodes file"))
396 .on('click', function(e) {
398 exportItems('barcodes');
401 var exportButton = $('<div>')
402 .addClass('btn-group')
403 .append($('<button>')
404 .addClass('btn btn-default btn-xs dropdown-toggle')
405 .attr('id', 'export-button')
406 .attr('data-toggle', 'dropdown')
407 .attr('aria-haspopup', 'true')
408 .attr('aria-expanded', 'false')
409 .html(_("Export all results to") + ' <span class="caret"></span>'))
411 .addClass('dropdown-menu')
412 .append($('<li>').append(csvExportLink))
413 .append($('<li>').append(barcodesExportLink)));
415 var selectVisibleRows = $('<a>')
417 .append('<i class="fa fa-check"></i> ')
418 .append(_("Select visible rows"))
419 .on('click', function(e) {
421 $('#results input[type="checkbox"]').prop('checked', true).change();
423 var clearSelection = $('<a>')
425 .append('<i class="fa fa-remove"></i> ')
426 .append(_("Clear selection"))
427 .on('click', function(e) {
429 sessionStorage.setItem('itemsearch_itemnumbers', '[]');
430 $('#results input[type="checkbox"]').prop('checked', false).change();
432 var exportLinks = $('<p>')
433 .append(selectVisibleRows)
435 .append(clearSelection)
437 .append(exportButton);
439 var results_heading = $('<div>').addClass('results-heading')
440 .append("<h1>" + _("Item search results") + "</h1>")
441 .append($('<p>').append(advSearchLink))
442 .append($('<p>').append(editSearchLink))
443 .append(exportLinks);
444 $('#results-wrapper').empty()
445 .append(results_heading)
449 $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
450 if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
451 var name = $(this).parents('select').first().attr('name');
452 var value = $(this).val();
453 params.push({ 'name': name, 'value': value });
455 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
459 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
463 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
464 'fnServerData': function(sSource, aoData, fnCallback) {
465 aoData.push( { 'name': 'format', 'value': 'json' } );
467 aoData.push(params[i]);
474 'success': function(json){
479 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
480 'aaSorting': [[1, 'asc']],
482 { 'sName': 'checkbox', 'bSortable': false },
483 { 'sName': 'title' },
484 { 'sName': 'publicationyear' },
485 { 'sName': 'publishercode' },
486 { 'sName': 'ccode' },
487 { 'sName': 'barcode' },
488 { 'sName': 'enumchron' },
489 { 'sName': 'itemcallnumber' },
490 { 'sName': 'homebranch' },
491 { 'sName': 'holdingbranch' },
492 { 'sName': 'location' },
494 { 'sName': 'stocknumber' },
495 { 'sName': 'notforloan' },
496 { 'sName': 'itemlost' },
497 { 'sName': 'withdrawn' },
498 { 'sName': 'issues' },
499 { 'sName': 'date_due' },
500 { 'sName': 'actions', 'bSortable': false }
502 "sPaginationType": "full_numbers",
503 fixedHeader: false // There is a bug on this view
505 'sPlaceHolder': 'head:after',
512 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => ccodes %] },
519 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
520 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
521 [% IF locations.size %]
522 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => locations %] },
526 [% IF itemtypes.size %]
527 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemtypes %] },
532 [% IF notforloans.size %]
533 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => notforloans %] },
537 [% IF itemlosts.size %]
538 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemlosts %] },
542 [% IF withdrawns.size %]
543 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => withdrawns %] },
552 $('#results').on('draw.dt', function (e, settings) {
553 var itemnumbers = getCheckedItemnumbers();
554 $(this).find('input[type="checkbox"][name="itemnumber"]').each(function () {
555 var itemnumber = this.value;
556 if (itemnumbers.has(itemnumber)) {
562 sessionStorage.setItem('itemsearch_itemnumbers', '[]');
564 $('#results').on('change', 'input[type="checkbox"]', function() {
565 var itemnumber = this.value;
566 var itemnumbers = getCheckedItemnumbers();
568 itemnumbers.add(itemnumber);
570 itemnumbers.delete(itemnumber);
572 sessionStorage.setItem('itemsearch_itemnumbers', JSON.stringify(Array.from(itemnumbers)));
574 var caret = ' <span class="caret">';
575 if (itemnumbers.size > 0) {
576 $('#export-button').html(_("Export selected results (%s) to").format(itemnumbers.size) + caret);
578 $('#export-button').html(_("Export all results to") + caret);
583 $(document).ready(function () {
584 Sticky = $("#toolbar");
586 stickTo: "#item-search-block",
587 stickyClass: "floating"
589 // Add the "New field" link.
590 var form_field = $('div.form-field-select-text').last()
591 var NEW_FIELD = _("New field");
592 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
593 button_field_new.click(function(e) {
595 addNewField( $(this) );
597 form_field.append(button_field_new);
599 // If a field is linked to an authorised values list, display the list.
600 $('div.form-field-select-text select[name="f"]').change(function() {
601 loadAuthorisedValuesSelect($(this));
604 // Prevent user to select the 'All ...' option with other options.
605 $('div.form-field-select').each(function() {
606 $(this).find('select').filter(':last').change(function() {
607 values = $(this).val();
608 if (values.length > 1) {
609 var idx = $.inArray('', values);
611 values.splice(idx, 1);
618 $('#itemsearchform').submit(function() {
619 var searchform = $(this);
620 var format = searchform.find('input[name="format"]:checked').val();
621 if (format == 'html') {
622 submitForm(searchform);
623 $("#item-search-block").hide();
631 [% INCLUDE 'intranet-bottom.inc' %]