4 [% BLOCK form_field_select %]
5 <div class="form-field form-field-select">
6 <label class="form-field-label" for="[% name %]">[% label %]</label>
7 <select id="[% name %]_op" name="[% name %]_op">
8 <option value="=">is</option>
9 [% IF CGI.param(name _ '_op') == '!=' %]
10 <option value="!=" selected="selected">is not</option>
12 <option value="!=" >is not</option>
15 [% values = CGI.param(name) %]
16 <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
17 [% IF (values == '') %]
18 <option value="" selected="selected">
22 [% empty_option || "All" %]
24 [% FOREACH option IN options %]
25 [% IF values != '' && values.grep(option.value).size %]
26 <option value="[% option.value %]" selected="selected">[% option.label %]</option>
28 <option value="[% option.value %]">[% option.label %]</option>
35 [% BLOCK form_field_select_option %]
36 [% IF params.f == value %]
37 <option value="[% value %]" selected="selected">[% label %]</option>
39 <option value="[% value %]">[% label %]</option>
43 [% BLOCK form_field_select_text %]
44 <div class="form-field form-field-select-text">
45 [% IF params.exists('c') %]
46 <select name="c" class="form-field-conjunction">
47 <option value="and">AND</option>
48 [% IF params.c == 'or' %]
49 <option value="or" selected="selected">OR</option>
51 <option value="or">OR</option>
55 <select name="c" class="form-field-conjunction" disabled="disabled">
56 <option value="and">AND</option>
57 <option value="or">OR</option>
60 <select name="f" class="form-field-column">
61 [% INCLUDE form_field_select_option value='barcode' label='Barcode' %]
62 [% INCLUDE form_field_select_option value='itemcallnumber' label='Call number' %]
63 [% INCLUDE form_field_select_option value='stocknumber' label='Stock number' %]
64 [% INCLUDE form_field_select_option value='title' label='Title' %]
65 [% INCLUDE form_field_select_option value='author' label='Author' %]
66 [% INCLUDE form_field_select_option value='publishercode' label='Publisher' %]
67 [% INCLUDE form_field_select_option value='publicationdate' label='Publication date' %]
68 [% INCLUDE form_field_select_option value='collectiontitle' label='Collection' %]
69 [% INCLUDE form_field_select_option value='isbn' label='ISBN' %]
70 [% INCLUDE form_field_select_option value='issn' label='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 [% IF params.f == "marc:$marcfield" %]
79 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]" selected="selected">[% field.label %] ([% marcfield %])</option>
81 <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
87 <input type="text" name="q" class="form-field-value" value="[% params.q %]" />
88 <input type="hidden" name="op" value="like" />
92 [% BLOCK form_field_select_text_block %]
93 [% c = CGI.param('c').list %]
94 [% f = CGI.param('f').list %]
95 [% q = CGI.param('q').list %]
96 [% op = CGI.param('op').list %]
98 [% size = q.size - 1 %]
99 [% FOREACH i IN [0 .. size] %]
109 [% params.c = c.$j %]
111 [% INCLUDE form_field_select_text params=params %]
114 [% INCLUDE form_field_select_text %]
118 [% BLOCK form_field_radio_yes_no %]
119 <div class="form-field">
120 <label class="form-field-label">[% label %]:</label>
121 <input type="radio" name="[% name %]" id="[% name %]_indifferent" value="" checked="checked"/>
122 <label for="[% name %]_indifferent">Ignore</label>
123 <input type="radio" name="[% name %]" id="[% name %]_yes" value="yes" />
124 <label for="[% name %]_yes">Yes</label>
125 <input type="radio" name="[% name %]" id="[% name %]_no" value="no" />
126 <label for="[% name %]_no">No</label>
130 [%# Page starts here %]
132 [% INCLUDE 'doc-head-open.inc' %]
133 <title>Koha › Catalog › Item search</title>
134 [% INCLUDE 'doc-head-close.inc' %]
135 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
136 [% INCLUDE 'datatables.inc' %]
137 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
138 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/itemsearchform.css" />
139 <script type="text/javascript">
141 var authorised_values = [% authorised_values_json %];
143 function loadAuthorisedValuesSelect(select) {
144 var selected = select.find('option:selected');
145 var category = selected.data('authorised-values-category');
146 var form_field_value = select.siblings('.form-field-value');
147 if (category && category in authorised_values) {
148 var values = authorised_values[category];
149 var html = '<select name="q" class="form-field-value">\n';
151 var value = values[i];
152 html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
154 html += '</select>\n';
155 var new_form_field_value = $(html);
156 new_form_field_value.val(form_field_value.val());
157 form_field_value.replaceWith(new_form_field_value);
159 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
160 html = '<input name="q" type="text" class="form-field-value" />';
161 var new_form_field_value = $(html);
162 form_field_value.replaceWith(new_form_field_value);
167 function addNewField() {
168 var form_field = $('div.form-field-select-text').last();
169 var copy = form_field.clone(true);
170 copy.find('input,select').not('[type="hidden"]').each(function() {
173 copy.find('.form-field-conjunction').removeAttr('disabled');
174 form_field.after(copy);
175 copy.find('select.form-field-column').change();
178 function submitForm($form) {
181 + ' <th>' + _("Title") + '</th>'
182 + ' <th>' + _("Publication date") + '</th>'
183 + ' <th>' + _("Publisher") + '</th>'
184 + ' <th>' + _("Collection") + '</th>'
185 + ' <th>' + _("Barcode") + '</th>'
186 + ' <th>' + _("Call number") + '</th>'
187 + ' <th>' + _("Home library") + '</th>'
188 + ' <th>' + _("Current location") + '</th>'
189 + ' <th>' + _("Shelving location") + '</th>'
190 + ' <th>' + _("Stock number") + '</th>'
191 + ' <th>' + _("Status") + '</th>'
192 + ' <th>' + _("Checkouts") + '</th>'
196 + '<table id="results">'
197 + ' <thead>' + tr + tr + '</thead>'
200 var results_heading = "<h1>" + _("Item search results") + "</h1>";
201 results_heading += "<p><a href=\"/cgi-bin/koha/catalogue/search.pl\">" + _("Go to advanced search") + "</a></p>";
202 results_heading += "<p><a class=\"editsearchlink\" href=\"#\">" + _("Edit search") + "</a></p>";
203 $('#results-wrapper').empty().html(results_heading + table);
206 $form.find('select,input[type="text"],input[type="hidden"]').not('[disabled]').each(function () {
207 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
209 $form.find('input[type="radio"]:checked').each(function() {
210 params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
213 $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
217 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
218 'fnServerParams': function(aoData) {
219 aoData.push( { 'name': 'format', 'value': 'json' } );
221 aoData.push(params[i]);
224 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
226 { 'sName': 'title' },
227 { 'sName': 'publicationyear' },
228 { 'sName': 'publishercode' },
229 { 'sName': 'collectiontitle' },
230 { 'sName': 'barcode' },
231 { 'sName': 'itemcallnumber' },
232 { 'sName': 'homebranch' },
233 { 'sName': 'holdingbranch' },
234 { 'sName': 'location' },
235 { 'sName': 'stocknumber' },
236 { 'sName': 'notforloan' },
237 { 'sName': 'issues' },
238 { 'sName': 'checkbox', 'bSortable': false }
241 'sPlaceHolder': 'head:after',
249 { 'type': 'select', 'values': [% branches.json %] },
250 { 'type': 'select', 'values': [% branches.json %] },
251 { 'type': 'select', 'values': [% locations.json %] },
253 { 'type': 'select', 'values': [% notforloans.json %] },
260 function hideForm() {
261 $("#item-search-block").hide();
262 $('.editsearchlink').show();
265 $(document).ready(function () {
266 // Add the "New field" link.
267 var form_field = $('div.form-field-select-text').last()
268 var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field">New field</a>');
269 button_field_new.click(function() {
273 form_field.after(button_field_new);
275 // If a field is linked to an authorised values list, display the list.
276 $('div.form-field-select-text select').change(function() {
277 loadAuthorisedValuesSelect($(this));
280 // Prevent user to select the 'All ...' option with other options.
281 $('div.form-field-select').each(function() {
282 $(this).find('select').filter(':last').change(function() {
283 values = $(this).val();
284 if (values.length > 1) {
285 var idx = $.inArray('', values);
287 values.splice(idx, 1);
294 $('#itemsearchform').submit(function() {
295 var searchform = $(this);
296 var format = searchform.find('input[name="format"]:checked').val();
297 if (format == 'html') {
298 submitForm(searchform);
304 $("body").on("click",".editsearchlink",function(e) {
306 $('#item-search-block').show();
314 <body id="catalog_itemsearch" class="catalog">
315 [% INCLUDE 'header.inc' %]
316 <div id="breadcrumbs">
317 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Item search
320 <div id="doc" class="yui-t7">
321 <div id="item-search-block">
323 <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
324 <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
326 [% INCLUDE form_field_select
330 empty_option = "All libraries"
332 [% INCLUDE form_field_select
334 label="Shelving location"
336 empty_option = "All locations"
340 [% INCLUDE form_field_select
344 empty_option = "All item types"
346 [% INCLUDE form_field_select
348 label="Collection code"
350 empty_option = "All collection codes"
352 [% INCLUDE form_field_select
355 options = notforloans
356 empty_option = "All statuses"
360 [% INCLUDE form_field_select_text_block %]
361 <p class="hint">You can use the following wildcard characters: % _</p>
362 <p class="hint">% matches any number of characters</p>
363 <p class="hint">_ matches only a single charcter</p>
366 <div class="form-field">
367 <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
368 [% value = CGI.param('itemcallnumber_from') %]
369 <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% value %]" />
370 <span class="hint">(inclusive)</span>
372 <div class="form-field">
373 [% value = CGI.param('itemcallnumber_to') %]
374 <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
375 <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% value %]" />
376 <span class="hint">(inclusive)</span>
378 [% INCLUDE form_field_radio_yes_no name="damaged" label="Damaged" %]
379 [% INCLUDE form_field_radio_yes_no name="itemlost" label="Lost" %]
380 <div class="form-field">
381 <label class="form-field-label" for="issues_op">Checkout count:</label>
382 <select id="issues_op" name="issues_op">
383 <option value=">">></option>
384 <option value="<"><</option>
385 <option value="=">=</option>
386 <option value="!=">!=</option>
388 <input type="text" name="issues" />
390 <div class="form-field">
391 <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
392 <select id="datelastborrowed_op" name="datelastborrowed_op">
393 <option value=">">After</option>
394 <option value="<">Before</option>
395 <option value="=">On</option>
397 <input type="text" name="datelastborrowed" />
398 <span class="hint">ISO Format (YYYY-MM-DD)</span>
402 <div class="form-field-radio">
403 <label>Output:</label>
404 <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
405 <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
407 <div class="form-actions">
408 <input type="submit" value="Search" />
413 <p><a id="editsearchlink" href="#" style="display:none">Edit search</a></p>
416 <div id="doc3" class="yui-t7">
417 <div id="results-wrapper">
419 [% IF total_rows > 0 %]
420 <p>Found [% total_rows %] results.</p>
422 <p>No results found.</p>
426 [% INCLUDE 'catalogue/itemsearch_items.inc' items = results %]
429 <div id="pagination-bar">
436 [% INCLUDE 'intranet-bottom.inc' %]