5 [% CASE 'barcode' %]<span>Barcode</span>
6 [% CASE 'itemcallnumber' %]<span>Call number</span>
7 [% CASE 'stocknumber' %]<span>Inventory number</span>
8 [% CASE 'title' %]<span>Title</span>
9 [% CASE 'author' %]<span>Author</span>
10 [% CASE 'publishercode' %]<span>Publisher</span>
11 [% CASE 'publicationyear' %]<span>Publication date</span>
12 [% CASE 'collectiontitle' %]<span>Collection</span>
13 [% CASE 'isbn' %]<span>ISBN</span>
14 [% CASE 'issn' %]<span>ISSN</span>
15 [% CASE 'homebranch' %]<span>Home library</span>
16 [% CASE 'holdingbranch' %]<span>Current location</span>
17 [% CASE 'All libraries' %]<span>All libraries</span>
18 [% CASE 'location' %]<span>Shelving location</span>
19 [% CASE 'All locations' %]<span>All locations</span>
20 [% CASE 'itype' %]<span>Item type</span>
21 [% CASE 'All item types' %]<span>All item types</span>
22 [% CASE 'ccode' %]<span>Collection code</span>
23 [% CASE 'All collection codes' %]<span>All collection codes</span>
24 [% CASE 'notforloan' %]<span>Status</span>
25 [% CASE 'All statuses' %]<span>All statuses</span>
26 [% CASE 'damaged' %]<span>Damaged</span>
27 [% CASE 'itemlost' %]<span>Lost</span>
31 [% BLOCK form_field_select %]
32 <div class="form-field form-field-select">
33 <label class="form-field-label" for="[% name %]">[% INCLUDE form_label label=name %]</label>
34 <select id="[% name %]_op" name="[% name %]_op">
35 <option value="=">is</option>
36 <option value="!=" >is not</option>
38 <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
39 <option value="" selected="selected">
40 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
42 [% FOREACH option IN options %]
43 <option value="[% option.value %]">[% option.label %]</option>
49 [% BLOCK form_field_select_option %]
50 <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
53 [% BLOCK form_field_select_text %]
54 <div class="form-field form-field-select-text">
55 <select name="c" class="form-field-conjunction" disabled="disabled">
56 <option value="and">AND</option>
57 <option value="or">OR</option>
59 <select name="f" class="form-field-column">
60 [% INCLUDE form_field_select_option value='barcode' %]
61 [% INCLUDE form_field_select_option value='itemcallnumber' %]
62 [% INCLUDE form_field_select_option value='stocknumber' %]
63 [% INCLUDE form_field_select_option value='title' %]
64 [% INCLUDE form_field_select_option value='author' %]
65 [% INCLUDE form_field_select_option value='publishercode' %]
66 [% INCLUDE form_field_select_option value='publicationyear' %]
67 [% INCLUDE form_field_select_option value='collectiontitle' %]
68 [% INCLUDE form_field_select_option value='isbn' %]
69 [% INCLUDE form_field_select_option value='issn' %]
70 [% IF items_search_fields.size %]
71 <optgroup label="Custom search fields">
72 [% FOREACH field IN items_search_fields %]
73 [% marcfield = field.tagfield %]
74 [% IF field.tagsubfield %]
75 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
77 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
82 <input type="text" name="q" class="form-field-value" value="" />
83 <input type="hidden" name="op" value="like" />
87 [% BLOCK form_field_radio_yes_no %]
88 <div class="form-field">
89 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
90 <input type="radio" name="[% name %]" id="[% name %]_indifferent" value="" checked="checked"/>
91 <label for="[% name %]_indifferent">Ignore</label>
92 <input type="radio" name="[% name %]" id="[% name %]_yes" value="yes" />
93 <label for="[% name %]_yes">Yes</label>
94 <input type="radio" name="[% name %]" id="[% name %]_no" value="no" />
95 <label for="[% name %]_no">No</label>
99 [%# Page starts here %]
101 [% SET footerjs = 1 %]
102 [% INCLUDE 'doc-head-open.inc' %]
103 <title>Koha › Catalog › Item search</title>
104 [% INCLUDE 'doc-head-close.inc' %]
105 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/itemsearchform.css" />
106 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
109 <body id="catalog_itemsearch" class="catalog">
110 [% INCLUDE 'header.inc' %]
111 [% INCLUDE 'home-search.inc' %]
112 <div id="breadcrumbs">
113 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
116 <div id="doc" class="yui-t7">
117 <div id="item-search-block">
119 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
120 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
121 <div id="toolbar" class="btn-toolbar">
122 <fieldset class="action">
123 <div class="btn-group">
124 <button class="btn btn-default btn-sm"><i class="fa fa-search"></i> Search</button>
129 [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
130 [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
131 [% IF locations.size %]
132 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
136 [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
137 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
138 [% IF notforloans.size %]
139 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
143 [% INCLUDE form_field_select_text %]
144 <p class="hint">You can use the following wildcard characters: % _</p>
145 <p class="hint">% matches any number of characters</p>
146 <p class="hint">_ matches only a single character</p>
149 <div class="form-field">
150 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
151 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
152 <span class="hint">(inclusive)</span>
154 <div class="form-field">
155 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
156 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
157 <span class="hint">(inclusive)</span>
159 [% INCLUDE form_field_radio_yes_no name="damaged" %]
160 [% INCLUDE form_field_radio_yes_no name="itemlost" %]
161 <div class="form-field">
162 <label class="form-field-label" for="issues_op">Checkout count:</label>
163 <select id="issues_op" name="issues_op">
164 <option value=">">></option>
165 <option value="<"><</option>
166 <option value="=">=</option>
167 <option value="!=">!=</option>
169 <input type="text" name="issues" />
171 <div class="form-field">
172 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
173 <select id="datelastborrowed_op" name="datelastborrowed_op">
174 <option value=">">After</option>
175 <option value="<">Before</option>
176 <option value="=">On</option>
178 <input type="text" name="datelastborrowed" />
179 <span class="hint">ISO Format (YYYY-MM-DD)</span>
183 <div class="form-field-radio">
184 <label>Output:</label>
185 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
186 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
187 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
193 <div id="doc3" class="yui-t7">
194 <div id="results-wrapper"></div>
196 [% MACRO jsinclude BLOCK %]
197 [% INCLUDE 'datatables.inc' %]
198 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
199 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
200 <script type="text/javascript">
201 var authorised_values = [% authorised_values_json %];
203 function loadAuthorisedValuesSelect(select) {
204 var selected = select.find('option:selected');
205 var category = selected.data('authorised-values-category');
206 var form_field_value = select.siblings('.form-field-value');
207 if (category && category in authorised_values) {
208 var values = authorised_values[category];
209 var html = '<select name="q" class="form-field-value">\n';
211 var value = values[i];
212 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
214 html += '</select>\n';
215 var new_form_field_value = $(html);
216 new_form_field_value.val(form_field_value.val());
217 form_field_value.replaceWith(new_form_field_value);
219 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
220 html = '<input name="q" type="text" class="form-field-value" />';
221 var new_form_field_value = $(html);
222 form_field_value.replaceWith(new_form_field_value);
227 function addNewField( link ) {
228 var form_field = $('div.form-field-select-text').last();
229 var copy = form_field.clone(true);
230 copy.find('input,select').not('[type="hidden"]').each(function() {
233 copy.find('.form-field-conjunction').prop('disabled', false);
234 form_field.after(copy);
236 copy.find('select.form-field-column').change();
239 function submitForm($form) {
242 + ' <th id="items_title">' + _("Title") + '</th>'
243 + ' <th id="items_pubdate">' + _("Publication date") + '</th>'
244 + ' <th id="items_publisher">' + _("Publisher") + '</th>'
245 + ' <th id="items_collection">' + _("Collection") + '</th>'
246 + ' <th id="items_barcode">' + _("Barcode") + '</th>'
247 + ' <th id="items_callno">' + _("Call number") + '</th>'
248 + ' <th id="items_homebranch">' + _("Home library") + '</th>'
249 + ' <th id="items_holdingbranch">' + _("Current location") + '</th>'
250 + ' <th id="items_location">' + _("Shelving location") + '</th>'
251 + ' <th id="item_inventoryno">' + _("Inventory number") + '</th>'
252 + ' <th id="items_status">' + _("Status") + '</th>'
253 + ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
257 + '<table id="results">'
258 + ' <thead>' + tr + tr + '</thead>'
262 var advSearchLink = $('<a>')
263 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
264 .html(_("Go to advanced search"));
265 var editSearchLink = $('<a>')
267 .html(_("Edit search"))
268 .addClass('btn btn-default btn-xs')
269 .on('click', function(e) {
271 $('#item-search-block').show();
274 var csvExportLink = $('<a>')
276 .html(_("Export results to CSV"))
277 .addClass('btn btn-default btn-xs')
278 .on('click', function(e) {
280 $('#format-csv').prop('checked', true);
281 $('#itemsearchform').submit();
282 $('#format-html').prop('checked', true);
284 var barcodesExportLink = $('<a>')
286 .html(_("Export results to barcodes file"))
287 .addClass('btn btn-default btn-xs')
288 .on('click', function(e) {
290 $('#format-barcodes').prop('checked', true);
291 $('#itemsearchform').submit();
292 $('#format-html').prop('checked', true);
295 var editSearchAndExportLinks = $('<p>')
296 .append(editSearchLink)
298 .append(csvExportLink)
300 .append(barcodesExportLink);
302 var results_heading = $('<div>').addClass('results-heading')
303 .append("<h1>" + _("Item search results") + "</h1>")
304 .append($('<p>').append(advSearchLink))
305 .append(editSearchAndExportLinks);
306 $('#results-wrapper').empty()
307 .append(results_heading)
311 $form.find('select').not(':disabled').find('option:selected').each(function () {
312 var name = $(this).parents('select').first().attr('name');
313 var value = $(this).val();
314 params.push({ 'name': name, 'value': value });
316 $form.find('input[type="text"],input[type="hidden"]').not(':disabled').each(function () {
317 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
319 $form.find('input[type="radio"]:checked').each(function() {
320 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
323 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
327 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
328 'fnServerData': function(sSource, aoData, fnCallback) {
329 aoData.push( { 'name': 'format', 'value': 'json' } );
331 aoData.push(params[i]);
338 'success': function(json){
343 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
345 { 'sName': 'title' },
346 { 'sName': 'publicationyear' },
347 { 'sName': 'publishercode' },
348 { 'sName': 'ccode' },
349 { 'sName': 'barcode' },
350 { 'sName': 'itemcallnumber' },
351 { 'sName': 'homebranch' },
352 { 'sName': 'holdingbranch' },
353 { 'sName': 'location' },
354 { 'sName': 'stocknumber' },
355 { 'sName': 'notforloan' },
356 { 'sName': 'issues' },
357 { 'sName': 'checkbox', 'bSortable': false }
359 "sPaginationType": "full_numbers"
361 'sPlaceHolder': 'head:after',
366 { 'type': 'select', 'values': [% ccodes.json %] },
369 { 'type': 'select', 'values': [% branches.json %] },
370 { 'type': 'select', 'values': [% branches.json %] },
371 [% IF locations.size %]
372 { 'type': 'select', 'values': [% locations.json %] },
377 [% IF notforloans.size %]
378 { 'type': 'select', 'values': [% notforloans.json %] },
388 $(document).ready(function () {
389 $('#toolbar').fixFloat();
390 // Add the "New field" link.
391 var form_field = $('div.form-field-select-text').last()
392 var NEW_FIELD = _("New field");
393 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
394 button_field_new.click(function(e) {
396 addNewField( $(this) );
398 form_field.append(button_field_new);
400 // If a field is linked to an authorised values list, display the list.
401 $('div.form-field-select-text select').change(function() {
402 loadAuthorisedValuesSelect($(this));
405 // Prevent user to select the 'All ...' option with other options.
406 $('div.form-field-select').each(function() {
407 $(this).find('select').filter(':last').change(function() {
408 values = $(this).val();
409 if (values.length > 1) {
410 var idx = $.inArray('', values);
412 values.splice(idx, 1);
417 $('#itemsearchform').submit(function() {
418 var searchform = $(this);
419 var format = searchform.find('input[name="format"]:checked').val();
420 if (format == 'html') {
421 submitForm(searchform);
422 $("#item-search-block").hide();
431 [% INCLUDE 'intranet-bottom.inc' %]