Bug 10904: Limit patron update request management by branch
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / itemsearch.tt
1 [% USE CGI %]
2 [% USE JSON.Escape %]
3
4 [% BLOCK form_label %]
5   [% SWITCH label %]
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 'publicationdate' %]<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 '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>
28   [% END %]
29 [% END %]
30
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       [% IF CGI.param(name _ '_op') == '!=' %]
37         <option value="!=" selected="selected">is not</option>
38       [% ELSE %]
39         <option value="!=" >is not</option>
40       [% END %]
41     </select>
42     [% values = CGI.param(name) %]
43     <select id="[% name %]" name="[% name %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 %]">
44       [% IF (values == '') %]
45         <option value="" selected="selected">
46       [% ELSE %]
47         <option value="">
48       [% END %]
49         [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
50       </option>
51       [% FOREACH option IN options %]
52         [% IF values != '' && values.grep(option.value).size %]
53           <option value="[% option.value %]" selected="selected">[% option.label %]</option>
54         [% ELSE %]
55           <option value="[% option.value %]">[% option.label %]</option>
56         [% END %]
57       [% END %]
58     </select>
59   </div>
60 [% END %]
61
62 [% BLOCK form_field_select_option %]
63   [% IF params.f == value %]
64     <option value="[% value %]" selected="selected">[% INCLUDE form_label label=value %]</option>
65   [% ELSE %]
66     <option value="[% value %]">[% INCLUDE form_label label=value %]</option>
67   [% END %]
68 [% END %]
69
70 [% BLOCK form_field_select_text %]
71   <div class="form-field form-field-select-text">
72     [% IF params.exists('c') %]
73       <select name="c" class="form-field-conjunction">
74         <option value="and">AND</option>
75         [% IF params.c == 'or' %]
76           <option value="or" selected="selected">OR</option>
77         [% ELSE %]
78           <option value="or">OR</option>
79         [% END %]
80       </select>
81     [% ELSE %]
82       <select name="c" class="form-field-conjunction" disabled="disabled">
83         <option value="and">AND</option>
84         <option value="or">OR</option>
85       </select>
86     [% END %]
87     <select name="f" class="form-field-column">
88       [% INCLUDE form_field_select_option value='barcode' %]
89       [% INCLUDE form_field_select_option value='itemcallnumber' %]
90       [% INCLUDE form_field_select_option value='stocknumber' %]
91       [% INCLUDE form_field_select_option value='title' %]
92       [% INCLUDE form_field_select_option value='author' %]
93       [% INCLUDE form_field_select_option value='publishercode' %]
94       [% INCLUDE form_field_select_option value='publicationdate' %]
95       [% INCLUDE form_field_select_option value='collectiontitle' %]
96       [% INCLUDE form_field_select_option value='isbn' %]
97       [% INCLUDE form_field_select_option value='issn' %]
98       [% IF items_search_fields.size %]
99         <optgroup label="Custom search fields">
100           [% FOREACH field IN items_search_fields %]
101             [% marcfield = field.tagfield %]
102             [% IF field.tagsubfield %]
103               [% marcfield = marcfield _ '$' _ field.tagsubfield %]
104             [% END %]
105             [% IF params.f == "marc:$marcfield" %]
106               <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]" selected="selected">[% field.label %] ([% marcfield %])</option>
107             [% ELSE %]
108               <option value="marc:[% marcfield %]" data-authorised-values-category="[% field.authorised_values_category %]">[% field.label %] ([% marcfield %])</option>
109             [% END %]
110           [% END %]
111         </optgroup>
112       [% END %]
113     </select>
114     <input type="text" name="q" class="form-field-value" value="[% params.q %]" />
115     <input type="hidden" name="op" value="like" />
116   </div>
117 [% END %]
118
119 [% BLOCK form_field_select_text_block %]
120   [% c = CGI.param('c').list %]
121   [% f = CGI.param('f').list %]
122   [% q = CGI.param('q').list %]
123   [% op = CGI.param('op').list %]
124   [% IF q.size %]
125     [% size = q.size - 1 %]
126     [% FOREACH i IN [0 .. size] %]
127       [%
128         params = {
129           f => f.$i
130           q = q.$i
131           op = op.$i
132         }
133       %]
134       [% IF i > 0 %]
135         [% j = i - 1 %]
136         [% params.c = c.$j %]
137       [% END %]
138       [% INCLUDE form_field_select_text params=params %]
139     [% END %]
140   [% ELSE %]
141     [% INCLUDE form_field_select_text %]
142   [% END %]
143 [% END %]
144
145 [% BLOCK form_field_radio_yes_no %]
146   <div class="form-field">
147     <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
148     <input type="radio" name="[% name %]" id="[% name %]_indifferent" value="" checked="checked"/>
149     <label for="[% name %]_indifferent">Ignore</label>
150     <input type="radio" name="[% name %]" id="[% name %]_yes" value="yes" />
151     <label for="[% name %]_yes">Yes</label>
152     <input type="radio" name="[% name %]" id="[% name %]_no" value="no" />
153     <label for="[% name %]_no">No</label>
154   </div>
155 [% END %]
156
157 [%# Page starts here %]
158
159 [% INCLUDE 'doc-head-open.inc' %]
160   <title>Koha &rsaquo; Catalog &rsaquo; Item search</title>
161   [% INCLUDE 'doc-head-close.inc' %]
162   <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
163   [% INCLUDE 'datatables.inc' %]
164   <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
165   <link rel="stylesheet" type="text/css" href="[% themelang %]/css/itemsearchform.css" />
166   <script type="text/javascript">
167     //<![CDATA[
168     var authorised_values = [% authorised_values_json %];
169
170     function loadAuthorisedValuesSelect(select) {
171       var selected = select.find('option:selected');
172       var category = selected.data('authorised-values-category');
173       var form_field_value = select.siblings('.form-field-value');
174       if (category && category in authorised_values) {
175         var values = authorised_values[category];
176         var html = '<select name="q" class="form-field-value">\n';
177         for (i in values) {
178           var value = values[i];
179           html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
180         }
181         html += '</select>\n';
182         var new_form_field_value = $(html);
183         new_form_field_value.val(form_field_value.val());
184         form_field_value.replaceWith(new_form_field_value);
185       } else {
186         if (form_field_value.prop('tagName').toLowerCase() == 'select') {
187           html = '<input name="q" type="text" class="form-field-value" />';
188           var new_form_field_value = $(html);
189           form_field_value.replaceWith(new_form_field_value);
190         }
191       }
192     }
193
194     function addNewField() {
195       var form_field = $('div.form-field-select-text').last();
196       var copy = form_field.clone(true);
197       copy.find('input,select').not('[type="hidden"]').each(function() {
198         $(this).val('');
199       });
200       copy.find('.form-field-conjunction').removeAttr('disabled');
201       form_field.after(copy);
202       copy.find('select.form-field-column').change();
203     }
204
205     function submitForm($form) {
206       var tr = ''
207         + '    <tr>'
208         + '      <th>' + _("Title") + '</th>'
209         + '      <th>' + _("Publication date") + '</th>'
210         + '      <th>' + _("Publisher") + '</th>'
211         + '      <th>' + _("Collection") + '</th>'
212         + '      <th>' + _("Barcode") + '</th>'
213         + '      <th>' + _("Call number") + '</th>'
214         + '      <th>' + _("Home library") + '</th>'
215         + '      <th>' + _("Current location") + '</th>'
216         + '      <th>' + _("Shelving location") + '</th>'
217         + '      <th>' + _("Inventory number") + '</th>'
218         + '      <th>' + _("Status") + '</th>'
219         + '      <th>' + _("Checkouts") + '</th>'
220         + '      <th></th>'
221         + '    </tr>'
222       var table = ''
223         + '<table id="results">'
224         + '  <thead>' + tr + tr + '</thead>'
225         + '  <tbody></tbody>'
226         + '</table>';
227       var results_heading = "<h1>" + _("Item search results") + "</h1>";
228       results_heading += "<p><a href=\"/cgi-bin/koha/catalogue/search.pl\">" + _("Go to advanced search") + "</a></p>";
229       results_heading += "<p><a class=\"editsearchlink\" href=\"#\">" + _("Edit search") + "</a></p>";
230       $('#results-wrapper').empty().html(results_heading + table);
231
232       var params = [];
233       $form.find('select,input[type="text"],input[type="hidden"]').not('[disabled]').each(function () {
234         params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
235       });
236       $form.find('input[type="radio"]:checked').each(function() {
237         params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
238       });
239
240       $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
241         'bDestroy': true,
242         'bServerSide': true,
243         'bProcessing': true,
244         'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
245         'fnServerData': function(sSource, aoData, fnCallback) {
246           aoData.push( { 'name': 'format', 'value': 'json' } );
247           for (i in params) {
248             aoData.push(params[i]);
249           }
250           $.ajax({
251               'dataType': 'json',
252               'type': 'POST',
253               'url': sSource,
254               'data': aoData,
255               'success': function(json){
256                   fnCallback(json);
257               }
258           });
259         },
260         'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
261         'aoColumns': [
262           { 'sName': 'title' },
263           { 'sName': 'publicationyear' },
264           { 'sName': 'publishercode' },
265           { 'sName': 'collectiontitle' },
266           { 'sName': 'barcode' },
267           { 'sName': 'itemcallnumber' },
268           { 'sName': 'homebranch' },
269           { 'sName': 'holdingbranch' },
270           { 'sName': 'location' },
271           { 'sName': 'stocknumber' },
272           { 'sName': 'notforloan' },
273           { 'sName': 'issues' },
274           { 'sName': 'checkbox', 'bSortable': false }
275         ],
276         "sPaginationType": "full_numbers"
277       })).columnFilter({
278         'sPlaceHolder': 'head:after',
279         'aoColumns': [
280           { 'type': 'text' },
281           { 'type': 'text' },
282           { 'type': 'text' },
283           { 'type': 'text' },
284           { 'type': 'text' },
285           { 'type': 'text' },
286           { 'type': 'select', 'values': [% branches.json %] },
287           { 'type': 'select', 'values': [% branches.json %] },
288           { 'type': 'select', 'values': [% locations.json %] },
289           { 'type': 'text' },
290           { 'type': 'select', 'values': [% notforloans.json %] },
291           { 'type': 'text' },
292           null
293         ]
294       });
295     }
296
297     function hideForm() {
298       $("#item-search-block").hide();
299       $('.editsearchlink').show();
300     }
301
302     $(document).ready(function () {
303       // Add the "New field" link.
304       var form_field = $('div.form-field-select-text').last()
305       var NEW_FIELD = _("New field");
306       var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field">' + NEW_FIELD + '</a>');
307       button_field_new.click(function() {
308         addNewField();
309         return false;
310       });
311       form_field.after(button_field_new);
312
313       // If a field is linked to an authorised values list, display the list.
314       $('div.form-field-select-text select').change(function() {
315         loadAuthorisedValuesSelect($(this));
316       }).change();
317
318       // Prevent user to select the 'All ...' option with other options.
319       $('div.form-field-select').each(function() {
320         $(this).find('select').filter(':last').change(function() {
321           values = $(this).val();
322           if (values.length > 1) {
323             var idx = $.inArray('', values);
324             if (idx != -1) {
325               values.splice(idx, 1);
326               $(this).val(values);
327             }
328           }
329         });
330       });
331
332       $('#itemsearchform').submit(function() {
333         var searchform = $(this);
334         var format = searchform.find('input[name="format"]:checked').val();
335         if (format == 'html') {
336           submitForm(searchform);
337           hideForm();
338           return false;
339         }
340       });
341
342       $("body").on("click",".editsearchlink",function(e) {
343         e.preventDefault();
344         $('#item-search-block').show();
345         $(this).hide();
346         return false;
347       });
348     });
349     //]]>
350   </script>
351 </head>
352 <body id="catalog_itemsearch" class="catalog">
353   [% INCLUDE 'header.inc' %]
354   <div id="breadcrumbs">
355     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; Item search
356   </div>
357
358   <div id="doc" class="yui-t7">
359     <div id="item-search-block">
360       <h1>Item search</h1>
361       <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
362       <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
363           <fieldset>
364             [% INCLUDE form_field_select
365               name="homebranch"
366               options = branches
367               empty_option = "All libraries"
368             %]
369             [% INCLUDE form_field_select
370               name="location"
371               options = locations
372               empty_option = "All locations"
373             %]
374           </fieldset>
375           <fieldset>
376             [% INCLUDE form_field_select
377               name="itype"
378               options = itemtypes
379               empty_option = "All item types"
380             %]
381             [% INCLUDE form_field_select
382               name="ccode"
383               options = ccodes
384               empty_option = "All collection codes"
385             %]
386             [% INCLUDE form_field_select
387               name="notforloan"
388               options = notforloans
389               empty_option = "All statuses"
390             %]
391           </fieldset>
392           <fieldset>
393             [% INCLUDE form_field_select_text_block %]
394             <p class="hint">You can use the following wildcard characters: % _</p>
395             <p class="hint">% matches any number of characters</p>
396             <p class="hint">_ matches only a single character</p>
397           </fieldset>
398           <fieldset>
399             <div class="form-field">
400               <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
401               [% value = CGI.param('itemcallnumber_from') %]
402               <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="[% value %]" />
403               <span class="hint">(inclusive)</span>
404             </div>
405             <div class="form-field">
406               [% value = CGI.param('itemcallnumber_to') %]
407               <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
408               <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="[% value %]" />
409               <span class="hint">(inclusive)</span>
410             </div>
411             [% INCLUDE form_field_radio_yes_no name="damaged" %]
412             [% INCLUDE form_field_radio_yes_no name="itemlost" %]
413             <div class="form-field">
414               <label class="form-field-label" for="issues_op">Checkout count:</label>
415               <select id="issues_op" name="issues_op">
416                 <option value=">">&gt;</option>
417                 <option value="<">&lt;</option>
418                 <option value="=">=</option>
419                 <option value="!=">!=</option>
420               </select>
421               <input type="text" name="issues" />
422             </div>
423             <div class="form-field">
424               <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
425               <select id="datelastborrowed_op" name="datelastborrowed_op">
426                 <option value=">">After</option>
427                 <option value="<">Before</option>
428                 <option value="=">On</option>
429               </select>
430               <input type="text" name="datelastborrowed" />
431               <span class="hint">ISO Format (YYYY-MM-DD)</span>
432             </div>
433           </fieldset>
434           <fieldset>
435             <div class="form-field-radio">
436               <label>Output:</label>
437               <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
438               <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
439             </div>
440             <div class="form-actions">
441               <input type="submit" value="Search" />
442             </div>
443           </fieldset>
444       </form>
445
446       <p><a id="editsearchlink" href="#" style="display:none">Edit search</a></p>
447     </div>
448   </div>
449   <div id="doc3" class="yui-t7">
450       <div id="results-wrapper">
451         [% IF search_done %]
452           [% IF total_rows > 0 %]
453             <p>Found [% total_rows %] results.</p>
454           [% ELSE %]
455             <p>No results found.</p>
456           [% END %]
457
458           [% IF results %]
459             [% INCLUDE 'catalogue/itemsearch_items.inc' items = results %]
460           [% END %]
461
462           <div id="pagination-bar">
463             [% pagination_bar %]
464           </div>
465
466         [% END %]
467       </div>
468
469     [% INCLUDE 'intranet-bottom.inc' %]