4 [% USE AuthorisedValues %]
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 location</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>
35 [% BLOCK form_field_select %]
36 <div class="form-field form-field-select">
37 <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
38 <select id="[% name | html %]_op" name="[% name | html %]_op">
39 <option value="=">is</option>
40 <option value="!=" >is not</option>
42 <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
43 <option value="" selected="selected">
44 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
46 [% FOREACH option IN options %]
47 <option value="[% option.value | html %]">[% option.label | html %]</option>
53 [% BLOCK form_field_select_option %]
54 <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
57 [% BLOCK form_field_select_text %]
58 <div class="form-field form-field-select-text">
59 <select name="c" class="form-field-conjunction" disabled="disabled">
60 <option value="and">AND</option>
61 <option value="or">OR</option>
63 <select name="f" class="form-field-column">
64 [% INCLUDE form_field_select_option value='barcode' %]
65 [% INCLUDE form_field_select_option value='itemcallnumber' %]
66 [% INCLUDE form_field_select_option value='stocknumber' %]
67 [% INCLUDE form_field_select_option value='title' %]
68 [% INCLUDE form_field_select_option value='author' %]
69 [% INCLUDE form_field_select_option value='publishercode' %]
70 [% INCLUDE form_field_select_option value='publicationyear' %]
71 [% INCLUDE form_field_select_option value='collectiontitle' %]
72 [% INCLUDE form_field_select_option value='isbn' %]
73 [% INCLUDE form_field_select_option value='issn' %]
74 [% IF items_search_fields.size %]
75 <optgroup label="Custom search fields">
76 [% FOREACH field IN items_search_fields %]
77 [% marcfield = field.tagfield %]
78 [% IF field.tagsubfield.defined AND field.tagsubfield != "" %]
79 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
81 <option value="marc:[% marcfield | html %]" data-authorised-values-category="[% field.authorised_values_category | html %]">[% field.label | html %] ([% marcfield | html %])</option>
86 <input type="text" name="q" class="form-field-value" value="" />
87 <input type="hidden" name="op" value="like" />
91 [% BLOCK form_field_radio_yes_no %]
92 <div class="form-field">
93 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
94 <input type="radio" name="[% name | html %]" id="[% name | html %]_indifferent" value="" checked="checked"/>
95 <label for="[% name | html %]_indifferent">Ignore</label>
96 <input type="radio" name="[% name | html %]" id="[% name | html %]_yes" value="yes" />
97 <label for="[% name | html %]_yes">Yes</label>
98 <input type="radio" name="[% name | html %]" id="[% name | html %]_no" value="no" />
99 <label for="[% name | html %]_no">No</label>
103 [%# We need to escape html characters for 'value' and 'label' %]
104 [%- BLOCK escape_html_value_label -%]
105 [%- SET escaped = [] -%]
106 [%- FOR e IN elts -%]
107 [%- value = BLOCK %][% e.value | html %][% END -%]
108 [%- label = BLOCK %][% e.label | html %][% END -%]
109 [%- escaped.push({ 'value' => value, 'label' => label }) -%]
111 [%- To.json(escaped) | $raw -%]
114 [% notforloans = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.notforloan' }) %]
115 [% FOREACH nfl IN notforloans %]
116 [% nfl.value = nfl.authorised_value %]
117 [% nfl.label = nfl.lib %]
120 [% locations = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.location' }) %]
121 [% FOREACH loc IN locations %]
122 [% loc.value = loc.authorised_value %]
123 [% loc.label = loc.lib %]
126 [%# Page starts here %]
128 [% SET footerjs = 1 %]
129 [% INCLUDE 'doc-head-open.inc' %]
130 <title>Koha › Catalog › Item search</title>
131 [% INCLUDE 'doc-head-close.inc' %]
132 [% Asset.css("css/itemsearchform.css") | $raw %]
135 <body id="catalog_itemsearch" class="catalog">
136 [% INCLUDE 'header.inc' %]
137 [% INCLUDE 'home-search.inc' %]
138 <div id="breadcrumbs">
139 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
142 <div class="main container-fluid">
144 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
146 <div id="item-search-block">
148 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
149 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
150 <div id="toolbar" class="btn-toolbar">
151 <fieldset class="action">
152 <div class="btn-group">
153 <button class="btn btn-default"><i class="fa fa-search"></i> Search</button>
158 [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
159 [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
160 [% IF locations.size %]
161 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
165 [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
167 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
169 [% IF notforloans.size %]
170 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
172 [% IF itemlosts.size %]
173 [% INCLUDE form_field_select name="itemlost" options = itemlosts empty_option = "All statuses" %]
175 [% IF withdrawns.size %]
176 [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %]
180 [% INCLUDE form_field_select_text %]
181 <p class="hint">You can use the following wildcard characters: % _</p>
182 <p class="hint">% matches any number of characters</p>
183 <p class="hint">_ matches only a single character</p>
186 <div class="form-field">
187 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
188 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
189 <span class="hint">(inclusive)</span>
191 <div class="form-field">
192 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
193 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
194 <span class="hint">(inclusive)</span>
196 [% INCLUDE form_field_radio_yes_no name="damaged" %]
197 <div class="form-field">
198 <label class="form-field-label" for="issues_op">Checkout count:</label>
199 <select id="issues_op" name="issues_op">
200 <option value=">">></option>
201 <option value="<"><</option>
202 <option value="=">=</option>
203 <option value="!=">!=</option>
205 <input type="text" name="issues" />
207 <div class="form-field">
208 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
209 <select id="datelastborrowed_op" name="datelastborrowed_op">
210 <option value=">">After</option>
211 <option value="<">Before</option>
212 <option value="=">On</option>
214 <input type="text" name="datelastborrowed" />
215 <span class="hint">ISO Format (YYYY-MM-DD)</span>
219 <div class="form-field-radio">
220 <label>Output:</label>
221 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
222 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
223 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
231 <div class="col-md-12">
232 <div id="results-wrapper"></div>
236 [% MACRO jsinclude BLOCK %]
237 [% INCLUDE 'datatables.inc' %]
238 [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
239 [% Asset.js("lib/hc-sticky.js") | $raw %]
241 var authorised_values = [% authorised_values_json | $raw %];
243 function loadAuthorisedValuesSelect(select) {
244 var selected = select.find('option:selected');
245 var category = selected.data('authorised-values-category');
246 var form_field_value = select.siblings('.form-field-value');
247 if (category && category in authorised_values) {
248 var values = authorised_values[category];
249 var html = '<select name="q" class="form-field-value">\n';
251 var value = values[i];
252 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
254 html += '</select>\n';
255 var new_form_field_value = $(html);
256 new_form_field_value.val(form_field_value.val());
257 form_field_value.replaceWith(new_form_field_value);
259 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
260 html = '<input name="q" type="text" class="form-field-value" />';
261 var new_form_field_value = $(html);
262 form_field_value.replaceWith(new_form_field_value);
267 function addNewField( link ) {
268 var form_field = $('div.form-field-select-text').last();
269 var copy = form_field.clone(true);
270 copy.find('input,select').not('[type="hidden"]').each(function() {
273 copy.find('.form-field-conjunction').prop('disabled', false).val('and');
274 form_field.after(copy);
276 copy.find('select.form-field-column').change();
279 function submitForm($form) {
282 + ' <th id="items_checkbox"></th>'
283 + ' <th id="items_title">' + _("Title") + '</th>'
284 + ' <th id="items_pubdate">' + _("Publication date") + '</th>'
285 + ' <th id="items_publisher">' + _("Publisher") + '</th>'
286 + ' <th id="items_collection">' + _("Collection") + '</th>'
287 + ' <th id="items_barcode">' + _("Barcode") + '</th>'
288 + ' <th id="items_callno">' + _("Call number") + '</th>'
289 + ' <th id="items_homebranch">' + _("Home library") + '</th>'
290 + ' <th id="items_holdingbranch">' + _("Current location") + '</th>'
291 + ' <th id="items_location">' + _("Shelving location") + '</th>'
292 + ' <th id="items_itype">' + _("Itemtype") + '</th>'
293 + ' <th id="item_inventoryno">' + _("Inventory number") + '</th>'
294 + ' <th id="items_status">' + _("Not for loan status") + '</th>'
295 + ' <th id="items_itemlost">' + _("Lost status") + '</th>'
296 + ' <th id="items_widthdrawn">' + _("Withdrawn status") + '</th>'
297 + ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
301 + '<table id="results">'
302 + ' <thead>' + tr + tr + '</thead>'
306 var advSearchLink = $('<a>')
307 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
308 .html(_("Go to advanced search"));
309 var editSearchLink = $('<a>')
311 .html(_("Edit search"))
312 .addClass('btn btn-default btn-xs')
313 .on('click', function(e) {
315 $('#item-search-block').show();
318 function getCheckedItemnumbers () {
321 itemnumbers = JSON.parse(sessionStorage.getItem('itemsearch_itemnumbers') || '[]');
326 return new Set(itemnumbers);
329 function exportItems(format) {
330 var itemnumbers = getCheckedItemnumbers();
331 if (itemnumbers.size > 0) {
332 var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format;
333 href += '&itemnumber=' + Array.from(itemnumbers).join('&itemnumber=');
336 $('#format-' + format).prop('checked', true);
337 $('#itemsearchform').submit();
338 $('#format-html').prop('checked', true);
342 var csvExportLink = $('<a>')
345 .on('click', function(e) {
349 var barcodesExportLink = $('<a>')
351 .html(_("Barcodes file"))
352 .on('click', function(e) {
354 exportItems('barcodes');
357 var exportButton = $('<div>')
358 .addClass('btn-group')
359 .append($('<button>')
360 .addClass('btn btn-default btn-xs dropdown-toggle')
361 .attr('id', 'export-button')
362 .attr('data-toggle', 'dropdown')
363 .attr('aria-haspopup', 'true')
364 .attr('aria-expanded', 'false')
365 .html(_("Export all results to") + ' <span class="caret"></span>'))
367 .addClass('dropdown-menu')
368 .append($('<li>').append(csvExportLink))
369 .append($('<li>').append(barcodesExportLink)));
371 var selectVisibleRows = $('<a>')
373 .append('<i class="fa fa-check"></i> ')
374 .append(_("Select visible rows"))
375 .on('click', function(e) {
377 $('#results input[type="checkbox"]').prop('checked', true).change();
379 var clearSelection = $('<a>')
381 .append('<i class="fa fa-remove"></i> ')
382 .append(_("Clear selection"))
383 .on('click', function(e) {
385 sessionStorage.setItem('itemsearch_itemnumbers', '[]');
386 $('#results input[type="checkbox"]').prop('checked', false).change();
388 var exportLinks = $('<p>')
389 .append(selectVisibleRows)
391 .append(clearSelection)
393 .append(exportButton);
395 var results_heading = $('<div>').addClass('results-heading')
396 .append("<h1>" + _("Item search results") + "</h1>")
397 .append($('<p>').append(advSearchLink))
398 .append($('<p>').append(editSearchLink))
399 .append(exportLinks);
400 $('#results-wrapper').empty()
401 .append(results_heading)
405 $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
406 if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
407 var name = $(this).parents('select').first().attr('name');
408 var value = $(this).val();
409 params.push({ 'name': name, 'value': value });
411 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
415 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
419 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
420 'fnServerData': function(sSource, aoData, fnCallback) {
421 aoData.push( { 'name': 'format', 'value': 'json' } );
423 aoData.push(params[i]);
430 'success': function(json){
435 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
436 'aaSorting': [[1, 'asc']],
438 { 'sName': 'checkbox', 'bSortable': false },
439 { 'sName': 'title' },
440 { 'sName': 'publicationyear' },
441 { 'sName': 'publishercode' },
442 { 'sName': 'ccode' },
443 { 'sName': 'barcode' },
444 { 'sName': 'itemcallnumber' },
445 { 'sName': 'homebranch' },
446 { 'sName': 'holdingbranch' },
447 { 'sName': 'location' },
449 { 'sName': 'stocknumber' },
450 { 'sName': 'notforloan' },
451 { 'sName': 'itemlost' },
452 { 'sName': 'withdrawn' },
453 { 'sName': 'issues' },
454 { 'sName': 'actions', 'bSortable': false }
456 "sPaginationType": "full_numbers"
458 'sPlaceHolder': 'head:after',
465 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => ccodes %] },
471 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
472 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
473 [% IF locations.size %]
474 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => locations %] },
478 [% IF itemtypes.size %]
479 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemtypes %] },
484 [% IF notforloans.size %]
485 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => notforloans %] },
489 [% IF itemlosts.size %]
490 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemlosts %] },
494 [% IF withdrawns.size %]
495 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => withdrawns %] },
503 $('#results').on('draw.dt', function (e, settings) {
504 var itemnumbers = getCheckedItemnumbers();
505 $(this).find('input[type="checkbox"][name="itemnumber"]').each(function () {
506 var itemnumber = this.value;
507 if (itemnumbers.has(itemnumber)) {
513 sessionStorage.setItem('itemsearch_itemnumbers', '[]');
515 $('#results').on('change', 'input[type="checkbox"]', function() {
516 var itemnumber = this.value;
517 var itemnumbers = getCheckedItemnumbers();
519 itemnumbers.add(itemnumber);
521 itemnumbers.delete(itemnumber);
523 sessionStorage.setItem('itemsearch_itemnumbers', JSON.stringify(Array.from(itemnumbers)));
525 var caret = ' <span class="caret">';
526 if (itemnumbers.size > 0) {
527 $('#export-button').html(_("Export selected results (%s) to").format(itemnumbers.size) + caret);
529 $('#export-button').html(_("Export all results to") + caret);
534 $(document).ready(function () {
535 Sticky = $("#toolbar");
537 stickTo: "#item-search-block",
538 stickyClass: "floating"
540 // Add the "New field" link.
541 var form_field = $('div.form-field-select-text').last()
542 var NEW_FIELD = _("New field");
543 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
544 button_field_new.click(function(e) {
546 addNewField( $(this) );
548 form_field.append(button_field_new);
550 // If a field is linked to an authorised values list, display the list.
551 $('div.form-field-select-text select[name="f"]').change(function() {
552 loadAuthorisedValuesSelect($(this));
555 // Prevent user to select the 'All ...' option with other options.
556 $('div.form-field-select').each(function() {
557 $(this).find('select').filter(':last').change(function() {
558 values = $(this).val();
559 if (values.length > 1) {
560 var idx = $.inArray('', values);
562 values.splice(idx, 1);
569 $('#itemsearchform').submit(function() {
570 var searchform = $(this);
571 var format = searchform.find('input[name="format"]:checked').val();
572 if (format == 'html') {
573 submitForm(searchform);
574 $("#item-search-block").hide();
582 [% INCLUDE 'intranet-bottom.inc' %]