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 [% IF CGI.param(name _ '_op') == '!=' %]
38 <option value="!=" selected="selected">is not</option>
40 <option value="!=" >is not</option>
43 [% values = CGI.param(name) %]
44 <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
45 [% IF (values == '') %]
46 <option value="" selected="selected">
50 [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
52 [% FOREACH option IN options %]
53 [% IF values != '' && values.grep(option.value).size %]
54 <option value="[% option.value %]" selected="selected">[% option.label %]</option>
56 <option value="[% option.value %]">[% option.label %]</option>
63 [% BLOCK form_field_select_option %]
64 [% IF params.f == value %]
65 <option value="[% value %]" selected="selected">[% INCLUDE form_label label=value %]</option>
67 <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
71 [% BLOCK form_field_select_text %]
72 <div class="form-field form-field-select-text">
73 [% IF params.exists('c') %]
74 <select name="c" class="form-field-conjunction">
75 <option value="and">AND</option>
76 [% IF params.c == 'or' %]
77 <option value="or" selected="selected">OR</option>
79 <option value="or">OR</option>
83 <select name="c" class="form-field-conjunction" disabled="disabled">
84 <option value="and">AND</option>
85 <option value="or">OR</option>
88 <select name="f" class="form-field-column">
89 [% INCLUDE form_field_select_option value='barcode' %]
90 [% INCLUDE form_field_select_option value='itemcallnumber' %]
91 [% INCLUDE form_field_select_option value='stocknumber' %]
92 [% INCLUDE form_field_select_option value='title' %]
93 [% INCLUDE form_field_select_option value='author' %]
94 [% INCLUDE form_field_select_option value='publishercode' %]
95 [% INCLUDE form_field_select_option value='publicationyear' %]
96 [% INCLUDE form_field_select_option value='collectiontitle' %]
97 [% INCLUDE form_field_select_option value='isbn' %]
98 [% INCLUDE form_field_select_option value='issn' %]
99 [% IF items_search_fields.size %]
100 <optgroup label="Custom search fields">
101 [% FOREACH field IN items_search_fields %]
102 [% marcfield = field.tagfield %]
103 [% IF field.tagsubfield %]
104 [% marcfield = marcfield _ '$' _ field.tagsubfield %]
106 [% IF params.f == "marc:$marcfield" %]
107 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]" selected="selected">[% field.label %] ([% marcfield %])</option>
109 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
115 <input type="text" name="q" class="form-field-value" value="[% params.q %]" />
116 <input type="hidden" name="op" value="like" />
120 [% BLOCK form_field_select_text_block %]
121 [% c = CGI.param('c').list %]
122 [% f = CGI.param('f').list %]
123 [% q = CGI.param('q').list %]
124 [% op = CGI.param('op').list %]
126 [% size = q.size - 1 %]
127 [% FOREACH i IN [0 .. size] %]
137 [% params.c = c.$j %]
139 [% INCLUDE form_field_select_text params=params %]
142 [% INCLUDE form_field_select_text %]
146 [% BLOCK form_field_radio_yes_no %]
147 <div class="form-field">
148 <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
149 <input type="radio" name="[% name %]" id="[% name %]_indifferent" value="" checked="checked"/>
150 <label for="[% name %]_indifferent">Ignore</label>
151 <input type="radio" name="[% name %]" id="[% name %]_yes" value="yes" />
152 <label for="[% name %]_yes">Yes</label>
153 <input type="radio" name="[% name %]" id="[% name %]_no" value="no" />
154 <label for="[% name %]_no">No</label>
158 [%# Page starts here %]
160 [% INCLUDE 'doc-head-open.inc' %]
161 <title>Koha › Catalog › Item search</title>
162 [% INCLUDE 'doc-head-close.inc' %]
163 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
164 [% INCLUDE 'datatables.inc' %]
165 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
166 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
167 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/itemsearchform.css" />
168 <script type="text/javascript">
170 var authorised_values = [% authorised_values_json %];
172 function loadAuthorisedValuesSelect(select) {
173 var selected = select.find('option:selected');
174 var category = selected.data('authorised-values-category');
175 var form_field_value = select.siblings('.form-field-value');
176 if (category && category in authorised_values) {
177 var values = authorised_values[category];
178 var html = '<select name="q" class="form-field-value">\n';
180 var value = values[i];
181 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
183 html += '</select>\n';
184 var new_form_field_value = $(html);
185 new_form_field_value.val(form_field_value.val());
186 form_field_value.replaceWith(new_form_field_value);
188 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
189 html = '<input name="q" type="text" class="form-field-value" />';
190 var new_form_field_value = $(html);
191 form_field_value.replaceWith(new_form_field_value);
196 function addNewField() {
197 var form_field = $('div.form-field-select-text').last();
198 var copy = form_field.clone(true);
199 copy.find('input,select').not('[type="hidden"]').each(function() {
202 copy.find('.form-field-conjunction').prop('disabled', false);
203 form_field.after(copy);
204 copy.find('select.form-field-column').change();
207 function submitForm($form) {
210 + ' <th>' + _("Title") + '</th>'
211 + ' <th>' + _("Publication date") + '</th>'
212 + ' <th>' + _("Publisher") + '</th>'
213 + ' <th>' + _("Collection") + '</th>'
214 + ' <th>' + _("Barcode") + '</th>'
215 + ' <th>' + _("Call number") + '</th>'
216 + ' <th>' + _("Home library") + '</th>'
217 + ' <th>' + _("Current location") + '</th>'
218 + ' <th>' + _("Shelving location") + '</th>'
219 + ' <th>' + _("Inventory number") + '</th>'
220 + ' <th>' + _("Status") + '</th>'
221 + ' <th>' + _("Checkouts") + '</th>'
225 + '<table id="results">'
226 + ' <thead>' + tr + tr + '</thead>'
230 var advSearchLink = $('<a>')
231 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
232 .html(_("Go to advanced search"));
233 var editSearchLink = $('<a>')
235 .html(_("Edit search"))
236 .addClass('btn btn-default btn-xs')
237 .on('click', function(e) {
239 $('#item-search-block').show();
242 var csvExportLink = $('<a>')
244 .html(_("Export results to CSV"))
245 .addClass('btn btn-default btn-xs')
246 .on('click', function(e) {
248 $('#format-csv').prop('checked', true);
249 $('#itemsearchform').submit();
250 $('#format-html').prop('checked', true);
252 var barcodesExportLink = $('<a>')
254 .html(_("Export results to barcodes file"))
255 .addClass('btn btn-default btn-xs')
256 .on('click', function(e) {
258 $('#format-barcodes').prop('checked', true);
259 $('#itemsearchform').submit();
260 $('#format-html').prop('checked', true);
263 var editSearchAndExportLinks = $('<p>')
264 .append(editSearchLink)
266 .append(csvExportLink)
268 .append(barcodesExportLink);
270 var results_heading = $('<div>').addClass('results-heading')
271 .append("<h1>" + _("Item search results") + "</h1>")
272 .append($('<p>').append(advSearchLink))
273 .append(editSearchAndExportLinks);
274 $('#results-wrapper').empty()
275 .append(results_heading)
279 $form.find('select').not(':disabled').find('option:selected').each(function () {
280 var name = $(this).parents('select').first().attr('name');
281 var value = $(this).val();
282 params.push({ 'name': name, 'value': value });
284 $form.find('input[type="text"],input[type="hidden"]').not(':disabled').each(function () {
285 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
287 $form.find('input[type="radio"]:checked').each(function() {
288 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
291 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
295 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
296 'fnServerData': function(sSource, aoData, fnCallback) {
297 aoData.push( { 'name': 'format', 'value': 'json' } );
299 aoData.push(params[i]);
306 'success': function(json){
311 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
313 { 'sName': 'title' },
314 { 'sName': 'publicationyear' },
315 { 'sName': 'publishercode' },
316 { 'sName': 'collectiontitle' },
317 { 'sName': 'barcode' },
318 { 'sName': 'itemcallnumber' },
319 { 'sName': 'homebranch' },
320 { 'sName': 'holdingbranch' },
321 { 'sName': 'location' },
322 { 'sName': 'stocknumber' },
323 { 'sName': 'notforloan' },
324 { 'sName': 'issues' },
325 { 'sName': 'checkbox', 'bSortable': false }
327 "sPaginationType": "full_numbers"
329 'sPlaceHolder': 'head:after',
337 { 'type': 'select', 'values': [% branches.json %] },
338 { 'type': 'select', 'values': [% branches.json %] },
339 [% IF locations.size %]
340 { 'type': 'select', 'values': [% locations.json %] },
345 [% IF notforloans.size %]
346 { 'type': 'select', 'values': [% notforloans.json %] },
356 $(document).ready(function () {
357 $('#toolbar').fixFloat();
358 // Add the "New field" link.
359 var form_field = $('div.form-field-select-text').last()
360 var NEW_FIELD = _("New field");
361 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field">' + NEW_FIELD + '</a>');
362 button_field_new.click(function() {
366 form_field.after(button_field_new);
368 // If a field is linked to an authorised values list, display the list.
369 $('div.form-field-select-text select').change(function() {
370 loadAuthorisedValuesSelect($(this));
373 // Prevent user to select the 'All ...' option with other options.
374 $('div.form-field-select').each(function() {
375 $(this).find('select').filter(':last').change(function() {
376 values = $(this).val();
377 if (values.length > 1) {
378 var idx = $.inArray('', values);
380 values.splice(idx, 1);
387 $('#itemsearchform').submit(function() {
388 var searchform = $(this);
389 var format = searchform.find('input[name="format"]:checked').val();
390 if (format == 'html') {
391 submitForm(searchform);
392 $("#item-search-block").hide();
400 <body id="catalog_itemsearch" class="catalog">
401 [% INCLUDE 'header.inc' %]
402 [% INCLUDE 'home-search.inc' %]
403 <div id="breadcrumbs">
404 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
407 <div id="doc" class="yui-t7">
408 <div id="item-search-block">
410 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
411 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
412 <div id="toolbar" class="btn-toolbar">
413 <fieldset class="action">
414 <div class="btn-group">
415 <button class="btn btn-default btn-sm"><i class="fa fa-search"></i> Search</button>
420 [% INCLUDE form_field_select
423 empty_option = "All libraries"
425 [% INCLUDE form_field_select
428 empty_option = "All libraries"
430 [% IF locations.size %]
431 [% INCLUDE form_field_select
434 empty_option = "All locations"
439 [% INCLUDE form_field_select
442 empty_option = "All item types"
444 [% INCLUDE form_field_select
447 empty_option = "All collection codes"
449 [% IF notforloans.size %]
450 [% INCLUDE form_field_select
452 options = notforloans
453 empty_option = "All statuses"
458 [% INCLUDE form_field_select_text_block %]
459 <p class="hint">You can use the following wildcard characters: % _</p>
460 <p class="hint">% matches any number of characters</p>
461 <p class="hint">_ matches only a single character</p>
464 <div class="form-field">
465 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
466 [% value = CGI.param('itemcallnumber_from') %]
467 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% value %]" />
468 <span class="hint">(inclusive)</span>
470 <div class="form-field">
471 [% value = CGI.param('itemcallnumber_to') %]
472 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
473 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% value %]" />
474 <span class="hint">(inclusive)</span>
476 [% INCLUDE form_field_radio_yes_no name="damaged" %]
477 [% INCLUDE form_field_radio_yes_no name="itemlost" %]
478 <div class="form-field">
479 <label class="form-field-label" for="issues_op">Checkout count:</label>
480 <select id="issues_op" name="issues_op">
481 <option value=">">></option>
482 <option value="<"><</option>
483 <option value="=">=</option>
484 <option value="!=">!=</option>
486 <input type="text" name="issues" />
488 <div class="form-field">
489 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
490 <select id="datelastborrowed_op" name="datelastborrowed_op">
491 <option value=">">After</option>
492 <option value="<">Before</option>
493 <option value="=">On</option>
495 <input type="text" name="datelastborrowed" />
496 <span class="hint">ISO Format (YYYY-MM-DD)</span>
500 <div class="form-field-radio">
501 <label>Output:</label>
502 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
503 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
504 <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
510 <div id="doc3" class="yui-t7">
511 <div id="results-wrapper"></div>
513 [% INCLUDE 'intranet-bottom.inc' %]