7 [% CASE 'barcode' %]<span>Barcode</span>
8 [% CASE 'itemcallnumber' %]<span>Call number</span>
9 [% CASE 'stocknumber' %]<span>Inventory number</span>
10 [% CASE 'title' %]<span>Title</span>
11 [% CASE 'author' %]<span>Author</span>
12 [% CASE 'publishercode' %]<span>Publisher</span>
13 [% CASE 'publicationyear' %]<span>Publication date</span>
14 [% CASE 'collectiontitle' %]<span>Collection</span>
15 [% CASE 'isbn' %]<span>ISBN</span>
16 [% CASE 'issn' %]<span>ISSN</span>
17 [% CASE 'homebranch' %]<span>Home library</span>
18 [% CASE 'holdingbranch' %]<span>Current location</span>
19 [% CASE 'All libraries' %]<span>All libraries</span>
20 [% CASE 'location' %]<span>Shelving location</span>
21 [% CASE 'All locations' %]<span>All locations</span>
22 [% CASE 'itype' %]<span>Item type</span>
23 [% CASE 'All item types' %]<span>All item types</span>
24 [% CASE 'ccode' %]<span>Collection code</span>
25 [% CASE 'All collection codes' %]<span>All collection codes</span>
26 [% CASE 'notforloan' %]<span>Status</span>
27 [% CASE 'All statuses' %]<span>All statuses</span>
28 [% CASE 'damaged' %]<span>Damaged</span>
29 [% CASE 'itemlost' %]<span>Lost</span>
33 [% BLOCK form_field_select %]
34 <div class="form-field form-field-select">
35 <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
36 <select id="[% name | html %]_op" name="[% name | html %]_op">
37 <option value="=">is</option>
38 <option value="!=" >is not</option>
40 <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
41 <option value="" selected="selected">
42 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
44 [% FOREACH option IN options %]
45 <option value="[% option.value | html %]">[% option.label | html %]</option>
51 [% BLOCK form_field_select_option %]
52 <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
55 [% BLOCK form_field_select_text %]
56 <div class="form-field form-field-select-text">
57 <select name="c" class="form-field-conjunction" disabled="disabled">
58 <option value="and">AND</option>
59 <option value="or">OR</option>
61 <select name="f" class="form-field-column">
62 [% INCLUDE form_field_select_option value='barcode' %]
63 [% INCLUDE form_field_select_option value='itemcallnumber' %]
64 [% INCLUDE form_field_select_option value='stocknumber' %]
65 [% INCLUDE form_field_select_option value='title' %]
66 [% INCLUDE form_field_select_option value='author' %]
67 [% INCLUDE form_field_select_option value='publishercode' %]
68 [% INCLUDE form_field_select_option value='publicationyear' %]
69 [% INCLUDE form_field_select_option value='collectiontitle' %]
70 [% INCLUDE form_field_select_option value='isbn' %]
71 [% INCLUDE form_field_select_option value='issn' %]
72 [% IF items_search_fields.size %]
73 <optgroup label="Custom search fields">
74 [% FOREACH field IN items_search_fields %]
75 [% marcfield = field.tagfield %]
76 [% IF field.tagsubfield %]
77 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
79 <option value="marc:[% marcfield | html %]" data-authorised-values-category="[% field.authorised_values_category | html %]">[% field.label | html %] ([% marcfield | html %])</option>
84 <input type="text" name="q" class="form-field-value" value="" />
85 <input type="hidden" name="op" value="like" />
89 [% BLOCK form_field_radio_yes_no %]
90 <div class="form-field">
91 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
92 <input type="radio" name="[% name | html %]" id="[% name | html %]_indifferent" value="" checked="checked"/>
93 <label for="[% name | html %]_indifferent">Ignore</label>
94 <input type="radio" name="[% name | html %]" id="[% name | html %]_yes" value="yes" />
95 <label for="[% name | html %]_yes">Yes</label>
96 <input type="radio" name="[% name | html %]" id="[% name | html %]_no" value="no" />
97 <label for="[% name | html %]_no">No</label>
101 [%# We need to escape html characters for 'value' and 'label' %]
102 [%- BLOCK escape_html_value_label -%]
103 [%- SET escaped = [] -%]
104 [%- FOR e IN elts -%]
105 [%- value = BLOCK %][% e.value | html %][% END -%]
106 [%- label = BLOCK %][% e.label | html %][% END -%]
107 [%- escaped.push({ 'value' => value, 'label' => label }) -%]
109 [%- To.json(escaped) | $raw -%]
112 [%# Page starts here %]
114 [% SET footerjs = 1 %]
115 [% INCLUDE 'doc-head-open.inc' %]
116 <title>Koha › Catalog › Item search</title>
117 [% INCLUDE 'doc-head-close.inc' %]
118 [% Asset.css("css/itemsearchform.css") | $raw %]
121 <body id="catalog_itemsearch" class="catalog">
122 [% INCLUDE 'header.inc' %]
123 [% INCLUDE 'home-search.inc' %]
124 <div id="breadcrumbs">
125 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
128 <div class="main container-fluid">
130 <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
132 <div id="item-search-block">
134 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
135 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
136 <div id="toolbar" class="btn-toolbar">
137 <fieldset class="action">
138 <div class="btn-group">
139 <button class="btn btn-default"><i class="fa fa-search"></i> Search</button>
144 [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
145 [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
146 [% IF locations.size %]
147 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
151 [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
153 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
155 [% IF notforloans.size %]
156 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
160 [% INCLUDE form_field_select_text %]
161 <p class="hint">You can use the following wildcard characters: % _</p>
162 <p class="hint">% matches any number of characters</p>
163 <p class="hint">_ matches only a single character</p>
166 <div class="form-field">
167 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
168 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
169 <span class="hint">(inclusive)</span>
171 <div class="form-field">
172 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
173 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
174 <span class="hint">(inclusive)</span>
176 [% INCLUDE form_field_radio_yes_no name="damaged" %]
177 [% INCLUDE form_field_radio_yes_no name="itemlost" %]
178 <div class="form-field">
179 <label class="form-field-label" for="issues_op">Checkout count:</label>
180 <select id="issues_op" name="issues_op">
181 <option value=">">></option>
182 <option value="<"><</option>
183 <option value="=">=</option>
184 <option value="!=">!=</option>
186 <input type="text" name="issues" />
188 <div class="form-field">
189 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
190 <select id="datelastborrowed_op" name="datelastborrowed_op">
191 <option value=">">After</option>
192 <option value="<">Before</option>
193 <option value="=">On</option>
195 <input type="text" name="datelastborrowed" />
196 <span class="hint">ISO Format (YYYY-MM-DD)</span>
200 <div class="form-field-radio">
201 <label>Output:</label>
202 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
203 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
204 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
212 <div class="col-md-12">
213 <div id="results-wrapper"></div>
217 [% MACRO jsinclude BLOCK %]
218 [% INCLUDE 'datatables.inc' %]
219 [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
220 [% Asset.js("lib/hc-sticky.js") | $raw %]
221 <script type="text/javascript">
222 var authorised_values = [% authorised_values_json | $raw %];
224 function loadAuthorisedValuesSelect(select) {
225 var selected = select.find('option:selected');
226 var category = selected.data('authorised-values-category');
227 var form_field_value = select.siblings('.form-field-value');
228 if (category && category in authorised_values) {
229 var values = authorised_values[category];
230 var html = '<select name="q" class="form-field-value">\n';
232 var value = values[i];
233 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
235 html += '</select>\n';
236 var new_form_field_value = $(html);
237 new_form_field_value.val(form_field_value.val());
238 form_field_value.replaceWith(new_form_field_value);
240 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
241 html = '<input name="q" type="text" class="form-field-value" />';
242 var new_form_field_value = $(html);
243 form_field_value.replaceWith(new_form_field_value);
248 function addNewField( link ) {
249 var form_field = $('div.form-field-select-text').last();
250 var copy = form_field.clone(true);
251 copy.find('input,select').not('[type="hidden"]').each(function() {
254 copy.find('.form-field-conjunction').prop('disabled', false);
255 form_field.after(copy);
257 copy.find('select.form-field-column').change();
260 function submitForm($form) {
263 + ' <th id="items_title">' + _("Title") + '</th>'
264 + ' <th id="items_pubdate">' + _("Publication date") + '</th>'
265 + ' <th id="items_publisher">' + _("Publisher") + '</th>'
266 + ' <th id="items_collection">' + _("Collection") + '</th>'
267 + ' <th id="items_barcode">' + _("Barcode") + '</th>'
268 + ' <th id="items_callno">' + _("Call number") + '</th>'
269 + ' <th id="items_homebranch">' + _("Home library") + '</th>'
270 + ' <th id="items_holdingbranch">' + _("Current location") + '</th>'
271 + ' <th id="items_location">' + _("Shelving location") + '</th>'
272 + ' <th id="item_inventoryno">' + _("Inventory number") + '</th>'
273 + ' <th id="items_status">' + _("Status") + '</th>'
274 + ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
278 + '<table id="results">'
279 + ' <thead>' + tr + tr + '</thead>'
283 var advSearchLink = $('<a>')
284 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
285 .html(_("Go to advanced search"));
286 var editSearchLink = $('<a>')
288 .html(_("Edit search"))
289 .addClass('btn btn-default btn-xs')
290 .on('click', function(e) {
292 $('#item-search-block').show();
295 var csvExportLink = $('<a>')
297 .html(_("Export results to CSV"))
298 .addClass('btn btn-default btn-xs')
299 .on('click', function(e) {
301 $('#format-csv').prop('checked', true);
302 $('#itemsearchform').submit();
303 $('#format-html').prop('checked', true);
305 var barcodesExportLink = $('<a>')
307 .html(_("Export results to barcodes file"))
308 .addClass('btn btn-default btn-xs')
309 .on('click', function(e) {
311 $('#format-barcodes').prop('checked', true);
312 $('#itemsearchform').submit();
313 $('#format-html').prop('checked', true);
316 var editSearchAndExportLinks = $('<p>')
317 .append(editSearchLink)
319 .append(csvExportLink)
321 .append(barcodesExportLink);
323 var results_heading = $('<div>').addClass('results-heading')
324 .append("<h1>" + _("Item search results") + "</h1>")
325 .append($('<p>').append(advSearchLink))
326 .append(editSearchAndExportLinks);
327 $('#results-wrapper').empty()
328 .append(results_heading)
332 $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
333 if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
334 var name = $(this).parents('select').first().attr('name');
335 var value = $(this).val();
336 params.push({ 'name': name, 'value': value });
338 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
342 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
346 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
347 'fnServerData': function(sSource, aoData, fnCallback) {
348 aoData.push( { 'name': 'format', 'value': 'json' } );
350 aoData.push(params[i]);
357 'success': function(json){
362 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
364 { 'sName': 'title' },
365 { 'sName': 'publicationyear' },
366 { 'sName': 'publishercode' },
367 { 'sName': 'ccode' },
368 { 'sName': 'barcode' },
369 { 'sName': 'itemcallnumber' },
370 { 'sName': 'homebranch' },
371 { 'sName': 'holdingbranch' },
372 { 'sName': 'location' },
373 { 'sName': 'stocknumber' },
374 { 'sName': 'notforloan' },
375 { 'sName': 'issues' },
376 { 'sName': 'checkbox', 'bSortable': false }
378 "sPaginationType": "full_numbers"
380 'sPlaceHolder': 'head:after',
386 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => ccodes %] },
392 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
393 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
394 [% IF locations.size %]
395 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => locations %] },
400 [% IF notforloans.size %]
401 { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => notforloans %] },
411 $(document).ready(function () {
412 Sticky = $("#toolbar");
414 stickTo: "#item-search-block",
415 stickyClass: "floating"
417 // Add the "New field" link.
418 var form_field = $('div.form-field-select-text').last()
419 var NEW_FIELD = _("New field");
420 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
421 button_field_new.click(function(e) {
423 addNewField( $(this) );
425 form_field.append(button_field_new);
427 // If a field is linked to an authorised values list, display the list.
428 $('div.form-field-select-text select').change(function() {
429 loadAuthorisedValuesSelect($(this));
432 // Prevent user to select the 'All ...' option with other options.
433 $('div.form-field-select').each(function() {
434 $(this).find('select').filter(':last').change(function() {
435 values = $(this).val();
436 if (values.length > 1) {
437 var idx = $.inArray('', values);
439 values.splice(idx, 1);
444 $('#itemsearchform').submit(function() {
445 var searchform = $(this);
446 var format = searchform.find('input[name="format"]:checked').val();
447 if (format == 'html') {
448 submitForm(searchform);
449 $("#item-search-block").hide();
458 [% INCLUDE 'intranet-bottom.inc' %]