6 [% CASE 'barcode' %]<span>Barcode</span>
7 [% CASE 'itemcallnumber' %]<span>Call number</span>
8 [% CASE 'stocknumber' %]<span>Inventory number</span>
9 [% CASE 'title' %]<span>Title</span>
10 [% CASE 'author' %]<span>Author</span>
11 [% CASE 'publishercode' %]<span>Publisher</span>
12 [% CASE 'publicationyear' %]<span>Publication date</span>
13 [% CASE 'collectiontitle' %]<span>Collection</span>
14 [% CASE 'isbn' %]<span>ISBN</span>
15 [% CASE 'issn' %]<span>ISSN</span>
16 [% CASE 'homebranch' %]<span>Home library</span>
17 [% CASE 'holdingbranch' %]<span>Current location</span>
18 [% CASE 'All libraries' %]<span>All libraries</span>
19 [% CASE 'location' %]<span>Shelving location</span>
20 [% CASE 'All locations' %]<span>All locations</span>
21 [% CASE 'itype' %]<span>Item type</span>
22 [% CASE 'All item types' %]<span>All item types</span>
23 [% CASE 'ccode' %]<span>Collection code</span>
24 [% CASE 'All collection codes' %]<span>All collection codes</span>
25 [% CASE 'notforloan' %]<span>Status</span>
26 [% CASE 'All statuses' %]<span>All statuses</span>
27 [% CASE 'damaged' %]<span>Damaged</span>
28 [% CASE 'itemlost' %]<span>Lost</span>
32 [% BLOCK form_field_select %]
33 <div class="form-field form-field-select">
34 <label class="form-field-label" for="[% name %]">[% INCLUDE form_label label=name %]</label>
35 <select id="[% name %]_op" name="[% name %]_op">
36 <option value="=">is</option>
37 <option value="!=" >is not</option>
39 <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
40 <option value="" selected="selected">
41 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
43 [% FOREACH option IN options %]
44 <option value="[% option.value %]">[% option.label %]</option>
50 [% BLOCK form_field_select_option %]
51 <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
54 [% BLOCK form_field_select_text %]
55 <div class="form-field form-field-select-text">
56 <select name="c" class="form-field-conjunction" disabled="disabled">
57 <option value="and">AND</option>
58 <option value="or">OR</option>
60 <select name="f" class="form-field-column">
61 [% INCLUDE form_field_select_option value='barcode' %]
62 [% INCLUDE form_field_select_option value='itemcallnumber' %]
63 [% INCLUDE form_field_select_option value='stocknumber' %]
64 [% INCLUDE form_field_select_option value='title' %]
65 [% INCLUDE form_field_select_option value='author' %]
66 [% INCLUDE form_field_select_option value='publishercode' %]
67 [% INCLUDE form_field_select_option value='publicationyear' %]
68 [% INCLUDE form_field_select_option value='collectiontitle' %]
69 [% INCLUDE form_field_select_option value='isbn' %]
70 [% INCLUDE form_field_select_option value='issn' %]
71 [% IF items_search_fields.size %]
72 <optgroup label="Custom search fields">
73 [% FOREACH field IN items_search_fields %]
74 [% marcfield = field.tagfield %]
75 [% IF field.tagsubfield %]
76 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
78 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
83 <input type="text" name="q" class="form-field-value" value="" />
84 <input type="hidden" name="op" value="like" />
88 [% BLOCK form_field_radio_yes_no %]
89 <div class="form-field">
90 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
91 <input type="radio" name="[% name %]" id="[% name %]_indifferent" value="" checked="checked"/>
92 <label for="[% name %]_indifferent">Ignore</label>
93 <input type="radio" name="[% name %]" id="[% name %]_yes" value="yes" />
94 <label for="[% name %]_yes">Yes</label>
95 <input type="radio" name="[% name %]" id="[% name %]_no" value="no" />
96 <label for="[% name %]_no">No</label>
100 [%# Page starts here %]
102 [% SET footerjs = 1 %]
103 [% INCLUDE 'doc-head-open.inc' %]
104 <title>Koha › Catalog › Item search</title>
105 [% INCLUDE 'doc-head-close.inc' %]
106 [% Asset.css("css/itemsearchform.css") %]
107 [% Asset.css("css/datatables.css") %]
110 <body id="catalog_itemsearch" class="catalog">
111 [% INCLUDE 'header.inc' %]
112 [% INCLUDE 'home-search.inc' %]
113 <div id="breadcrumbs">
114 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
117 <div class="main container-fluid">
119 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
121 <div id="item-search-block">
123 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
124 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
125 <div id="toolbar" class="btn-toolbar">
126 <fieldset class="action">
127 <div class="btn-group">
128 <button class="btn btn-default btn-sm"><i class="fa fa-search"></i> Search</button>
133 [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
134 [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
135 [% IF locations.size %]
136 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
140 [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
142 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
144 [% IF notforloans.size %]
145 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
149 [% INCLUDE form_field_select_text %]
150 <p class="hint">You can use the following wildcard characters: % _</p>
151 <p class="hint">% matches any number of characters</p>
152 <p class="hint">_ matches only a single character</p>
155 <div class="form-field">
156 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
157 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
158 <span class="hint">(inclusive)</span>
160 <div class="form-field">
161 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
162 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
163 <span class="hint">(inclusive)</span>
165 [% INCLUDE form_field_radio_yes_no name="damaged" %]
166 [% INCLUDE form_field_radio_yes_no name="itemlost" %]
167 <div class="form-field">
168 <label class="form-field-label" for="issues_op">Checkout count:</label>
169 <select id="issues_op" name="issues_op">
170 <option value=">">></option>
171 <option value="<"><</option>
172 <option value="=">=</option>
173 <option value="!=">!=</option>
175 <input type="text" name="issues" />
177 <div class="form-field">
178 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
179 <select id="datelastborrowed_op" name="datelastborrowed_op">
180 <option value=">">After</option>
181 <option value="<">Before</option>
182 <option value="=">On</option>
184 <input type="text" name="datelastborrowed" />
185 <span class="hint">ISO Format (YYYY-MM-DD)</span>
189 <div class="form-field-radio">
190 <label>Output:</label>
191 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
192 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
193 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
201 <div class="col-md-12">
202 <div id="results-wrapper"></div>
206 [% MACRO jsinclude BLOCK %]
207 [% INCLUDE 'datatables.inc' %]
208 [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") %]
209 [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") %]
210 <script type="text/javascript">
211 var authorised_values = [% authorised_values_json %];
213 function loadAuthorisedValuesSelect(select) {
214 var selected = select.find('option:selected');
215 var category = selected.data('authorised-values-category');
216 var form_field_value = select.siblings('.form-field-value');
217 if (category && category in authorised_values) {
218 var values = authorised_values[category];
219 var html = '<select name="q" class="form-field-value">\n';
221 var value = values[i];
222 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
224 html += '</select>\n';
225 var new_form_field_value = $(html);
226 new_form_field_value.val(form_field_value.val());
227 form_field_value.replaceWith(new_form_field_value);
229 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
230 html = '<input name="q" type="text" class="form-field-value" />';
231 var new_form_field_value = $(html);
232 form_field_value.replaceWith(new_form_field_value);
237 function addNewField( link ) {
238 var form_field = $('div.form-field-select-text').last();
239 var copy = form_field.clone(true);
240 copy.find('input,select').not('[type="hidden"]').each(function() {
243 copy.find('.form-field-conjunction').prop('disabled', false);
244 form_field.after(copy);
246 copy.find('select.form-field-column').change();
249 function submitForm($form) {
252 + ' <th id="items_title">' + _("Title") + '</th>'
253 + ' <th id="items_pubdate">' + _("Publication date") + '</th>'
254 + ' <th id="items_publisher">' + _("Publisher") + '</th>'
255 + ' <th id="items_collection">' + _("Collection") + '</th>'
256 + ' <th id="items_barcode">' + _("Barcode") + '</th>'
257 + ' <th id="items_callno">' + _("Call number") + '</th>'
258 + ' <th id="items_homebranch">' + _("Home library") + '</th>'
259 + ' <th id="items_holdingbranch">' + _("Current location") + '</th>'
260 + ' <th id="items_location">' + _("Shelving location") + '</th>'
261 + ' <th id="item_inventoryno">' + _("Inventory number") + '</th>'
262 + ' <th id="items_status">' + _("Status") + '</th>'
263 + ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
267 + '<table id="results">'
268 + ' <thead>' + tr + tr + '</thead>'
272 var advSearchLink = $('<a>')
273 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
274 .html(_("Go to advanced search"));
275 var editSearchLink = $('<a>')
277 .html(_("Edit search"))
278 .addClass('btn btn-default btn-xs')
279 .on('click', function(e) {
281 $('#item-search-block').show();
284 var csvExportLink = $('<a>')
286 .html(_("Export results to CSV"))
287 .addClass('btn btn-default btn-xs')
288 .on('click', function(e) {
290 $('#format-csv').prop('checked', true);
291 $('#itemsearchform').submit();
292 $('#format-html').prop('checked', true);
294 var barcodesExportLink = $('<a>')
296 .html(_("Export results to barcodes file"))
297 .addClass('btn btn-default btn-xs')
298 .on('click', function(e) {
300 $('#format-barcodes').prop('checked', true);
301 $('#itemsearchform').submit();
302 $('#format-html').prop('checked', true);
305 var editSearchAndExportLinks = $('<p>')
306 .append(editSearchLink)
308 .append(csvExportLink)
310 .append(barcodesExportLink);
312 var results_heading = $('<div>').addClass('results-heading')
313 .append("<h1>" + _("Item search results") + "</h1>")
314 .append($('<p>').append(advSearchLink))
315 .append(editSearchAndExportLinks);
316 $('#results-wrapper').empty()
317 .append(results_heading)
321 $form.find('select').not(':disabled').find('option:selected').each(function () {
322 var name = $(this).parents('select').first().attr('name');
323 var value = $(this).val();
324 params.push({ 'name': name, 'value': value });
326 $form.find('input[type="text"],input[type="hidden"]').not(':disabled').each(function () {
327 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
329 $form.find('input[type="radio"]:checked').each(function() {
330 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
333 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
337 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
338 'fnServerData': function(sSource, aoData, fnCallback) {
339 aoData.push( { 'name': 'format', 'value': 'json' } );
341 aoData.push(params[i]);
348 'success': function(json){
353 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
355 { 'sName': 'title' },
356 { 'sName': 'publicationyear' },
357 { 'sName': 'publishercode' },
358 { 'sName': 'ccode' },
359 { 'sName': 'barcode' },
360 { 'sName': 'itemcallnumber' },
361 { 'sName': 'homebranch' },
362 { 'sName': 'holdingbranch' },
363 { 'sName': 'location' },
364 { 'sName': 'stocknumber' },
365 { 'sName': 'notforloan' },
366 { 'sName': 'issues' },
367 { 'sName': 'checkbox', 'bSortable': false }
369 "sPaginationType": "full_numbers"
371 'sPlaceHolder': 'head:after',
377 { 'type': 'select', 'values': [% ccodes.json %] },
383 { 'type': 'select', 'values': [% branches.json %] },
384 { 'type': 'select', 'values': [% branches.json %] },
385 [% IF locations.size %]
386 { 'type': 'select', 'values': [% locations.json %] },
391 [% IF notforloans.size %]
392 { 'type': 'select', 'values': [% notforloans.json %] },
402 $(document).ready(function () {
403 $('#toolbar').fixFloat();
404 // Add the "New field" link.
405 var form_field = $('div.form-field-select-text').last()
406 var NEW_FIELD = _("New field");
407 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
408 button_field_new.click(function(e) {
410 addNewField( $(this) );
412 form_field.append(button_field_new);
414 // If a field is linked to an authorised values list, display the list.
415 $('div.form-field-select-text select').change(function() {
416 loadAuthorisedValuesSelect($(this));
419 // Prevent user to select the 'All ...' option with other options.
420 $('div.form-field-select').each(function() {
421 $(this).find('select').filter(':last').change(function() {
422 values = $(this).val();
423 if (values.length > 1) {
424 var idx = $.inArray('', values);
426 values.splice(idx, 1);
431 $('#itemsearchform').submit(function() {
432 var searchform = $(this);
433 var format = searchform.find('input[name="format"]:checked').val();
434 if (format == 'html') {
435 submitForm(searchform);
436 $("#item-search-block").hide();
445 [% INCLUDE 'intranet-bottom.inc' %]