Bug 26703: catalogue folder
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / itemsearch.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% USE AuthorisedValues %]
5
6 [%- BLOCK form_label -%]
7   [%- SWITCH label -%]
8     [%- CASE 'barcode' %]<span>Barcode</span>
9     [%- CASE 'itemcallnumber' %]<span>Call number</span>
10     [%- CASE 'stocknumber' %]<span>Inventory number</span>
11     [%- CASE 'title' %]<span>Title</span>
12     [%- CASE 'author' %]<span>Author</span>
13     [%- CASE 'publishercode' %]<span>Publisher</span>
14     [%- CASE 'publicationyear' %]<span>Publication date</span>
15     [%- CASE 'collectiontitle' %]<span>Collection title</span>
16     [%- CASE 'isbn' %]<span>ISBN</span>
17     [%- CASE 'issn' %]<span>ISSN</span>
18     [%- CASE 'homebranch' %]<span>Home library</span>
19     [%- CASE 'holdingbranch' %]<span>Current library</span>
20     [%- CASE 'All libraries' %]<span>All libraries</span>
21     [%- CASE 'location' %]<span>Shelving location</span>
22     [%- CASE 'All locations' %]<span>All locations</span>
23     [%- CASE 'itype' %]<span>Item type</span>
24     [%- CASE 'All item types' %]<span>All item types</span>
25     [%- CASE 'ccode' %]<span>Collection</span>
26     [%- CASE 'All collection codes' %]<span>All collections</span>
27     [%- CASE 'notforloan' %]<span>Status</span>
28     [%- CASE 'All statuses' %]<span>All statuses</span>
29     [%- CASE 'damaged' %]<span>Damaged</span>
30     [%- CASE 'itemlost' %]<span>Lost</span>
31     [%- CASE 'withdrawn' %]<span>Withdrawn</span>
32     [%- CASE 'new_status' %]<span>Is new</span>
33   [%- END -%]
34 [%- END -%]
35
36 [% BLOCK form_field_select %]
37   <div class="form-field form-field-select">
38     <label class="form-field-label" for="[% name | html %]">[% INCLUDE form_label label=name %]</label>
39     <select id="[% name | html %]_op" name="[% name | html %]_op">
40       <option value="=">is</option>
41       <option value="!=" >is not</option>
42     </select>
43     <select id="[% name | html %]" name="[% name | html %]" multiple="multiple" size="[% options.size < 4 ? options.size + 1 : 4 | html %]">
44       <option value="" selected="selected">
45         [% IF (empty_option) %][% INCLUDE form_label label=empty_option %][% ELSE %]<span>All</span>[% END %]
46       </option>
47       [% FOREACH option IN options %]
48         <option value="[% option.value | html %]">[% option.label | html %]</option>
49       [% END %]
50     </select>
51   </div>
52 [% END %]
53
54 [% BLOCK form_field_select_option %]
55   <option value="[% value | html %]">[% INCLUDE form_label label=value %]</option>
56 [% END %]
57
58 [% BLOCK form_field_select_text %]
59   <div class="form-field form-field-select-text">
60     <select name="c" class="form-field-conjunction" disabled="disabled">
61       <option value="and">AND</option>
62       <option value="or">OR</option>
63     </select>
64     <select name="f" class="form-field-column">
65       [% INCLUDE form_field_select_option value='barcode' %]
66       [% INCLUDE form_field_select_option value='itemcallnumber' %]
67       [% INCLUDE form_field_select_option value='stocknumber' %]
68       [% INCLUDE form_field_select_option value='title' %]
69       [% INCLUDE form_field_select_option value='author' %]
70       [% INCLUDE form_field_select_option value='publishercode' %]
71       [% INCLUDE form_field_select_option value='publicationyear' %]
72       [% INCLUDE form_field_select_option value='collectiontitle' %]
73       [% INCLUDE form_field_select_option value='isbn' %]
74       [% INCLUDE form_field_select_option value='issn' %]
75       [% IF items_search_fields.size %]
76         <optgroup label="Custom search fields">
77           [% FOREACH field IN items_search_fields %]
78             [% marcfield = field.tagfield %]
79             [% IF field.tagsubfield.defined AND field.tagsubfield != "" %]
80               [% marcfield = marcfield _ '$' _ field.tagsubfield %]
81             [% END %]
82             <option value="marc:[% marcfield | html %]" data-authorised-values-category="[% field.authorised_values_category | html %]">[% field.label | html %] ([% marcfield | html %])</option>
83           [% END %]
84         </optgroup>
85       [% END %]
86     </select>
87     [% IF params.exists('op') %]
88         <select name="op" class="form-field-not">
89            <option value="like">is</option>
90             [% IF params.op == 'not like' %]
91                <option value="not like" selected="selected">is not</option>
92             [% ELSE %]
93                <option value="not like">is not</option>
94             [% END %]
95         </select>
96     [% ELSE %]
97         <select name="op" class="form-field-not">
98            <option value="like">is</option>
99            <option value="not like">is not</option>
100         </select>
101     [% END %]
102     <input type="text" name="q" class="form-field-value" value="" />
103   </div>
104 [% END %]
105
106 [% BLOCK form_field_radio_yes_no %]
107   <div class="form-field [% divclass | html %]">
108     <label class="form-field-label">[% INCLUDE form_label label=name %]:</label>
109     <input type="radio" name="[% name | html %]" id="[% name | html %]_indifferent" value="" checked="checked"/>
110     <label for="[% name | html %]_indifferent">Ignore</label>
111     <input type="radio" name="[% name | html %]" id="[% name | html %]_yes" value="yes" />
112     <label for="[% name | html %]_yes">Yes</label>
113     <input type="radio" name="[% name | html %]" id="[% name | html %]_no" value="no" />
114     <label for="[% name | html %]_no">No</label>
115   </div>
116 [% END %]
117
118 [%# We need to escape html characters for 'value' and 'label' %]
119 [%- BLOCK escape_html_value_label -%]
120     [%- SET escaped = [] -%]
121     [%- FOR e IN elts -%]
122         [%- value = BLOCK %][% e.value | html %][% END -%]
123         [%- label = BLOCK %][% e.label | html %][% END -%]
124         [%- escaped.push({ 'value' => value, 'label' => label }) -%]
125     [%- END -%]
126     [%- To.json(escaped) | $raw -%]
127 [%- END -%]
128
129 [% notforloans = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.notforloan' }) %]
130 [% FOREACH nfl IN notforloans %]
131     [% nfl.value = nfl.authorised_value %]
132     [% nfl.label = nfl.lib %]
133 [% END %]
134
135 [% locations = AuthorisedValues.GetDescriptionsByKohaField({ kohafield = 'items.location' }) %]
136 [% FOREACH loc IN locations %]
137     [% loc.value = loc.authorised_value %]
138     [% loc.label = loc.lib %]
139 [% END %]
140
141 [%# Page starts here %]
142
143 [% SET footerjs = 1 %]
144 [% INCLUDE 'doc-head-open.inc' %]
145   <title>Item search &rsaquo; Catalog &rsaquo; Koha</title>
146   [% INCLUDE 'doc-head-close.inc' %]
147   [% Asset.css("css/itemsearchform.css") | $raw %]
148 </head>
149
150 <body id="catalog_itemsearch" class="catalog">
151   [% INCLUDE 'header.inc' %]
152   [% INCLUDE 'home-search.inc' %]
153
154 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
155     <ol>
156         <li>
157             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
158         </li>
159         <li>
160             <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
161         </li>
162         <li>
163             <a href="#" aria-current="page">
164                 Item search
165             </a>
166         </li>
167     </ol>
168 </nav>
169
170 <div class="main container-fluid">
171     <div class="row">
172         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
173
174     <div id="item-search-block">
175       <h1>Item search</h1>
176       <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p>
177       <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform">
178           <div id="toolbar" class="btn-toolbar">
179               <fieldset class="action">
180                   <div class="btn-group">
181                       <button class="btn btn-default"><i class="fa fa-search"></i> Search</button>
182                   </div>
183               </fieldset>
184           </div>
185           <fieldset>
186             [% INCLUDE form_field_select name="homebranch" options = branches empty_option = "All libraries" %]
187             [% INCLUDE form_field_select name="holdingbranch" options = branches empty_option = "All libraries" %]
188             [% IF locations.size %]
189                 [% INCLUDE form_field_select name="location" options = locations empty_option = "All locations" %]
190             [% END %]
191           </fieldset>
192           <fieldset>
193             [% INCLUDE form_field_select name="itype" options = itemtypes empty_option = "All item types" %]
194             [% IF ccodes.size %]
195                 [% INCLUDE form_field_select name="ccode" options = ccodes empty_option = "All collection codes" %]
196             [% END %]
197             [% IF notforloans.size %]
198                 [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %]
199             [% END %]
200             [% IF itemlosts.size %]
201                 [% INCLUDE form_field_select name="itemlost" options = itemlosts empty_option = "All statuses" %]
202             [% END %]
203             [% IF withdrawns.size %]
204                 [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %]
205             [% END %]
206           </fieldset>
207           <fieldset>
208             [% INCLUDE form_field_select_text %]
209             <p class="hint">You can use the following wildcard characters: % _</p>
210             <p class="hint">% matches any number of characters</p>
211             <p class="hint">_ matches only a single character</p>
212           </fieldset>
213           <fieldset>
214             <div class="form-field">
215               <label class="form-field-label" for="itemcallnumber_from">From call number:</label>
216               <input type="text" id="itemcallnumber_from" name="itemcallnumber_from" value="" />
217               <span class="hint">(inclusive)</span>
218             </div>
219             <div class="form-field">
220               <label class="form-field-label" for="itemcallnumber_to">To call number:</label>
221               <input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
222               <span class="hint">(inclusive)</span>
223             </div>
224             [% INCLUDE form_field_radio_yes_no name="damaged" %]
225             [% IF ( has_new_status ) %]
226                 [% INCLUDE form_field_radio_yes_no name="new_status" divclass='item-new-status' %]
227             [% END %]
228             <div class="form-field">
229               <label class="form-field-label" for="issues_op">Checkout count:</label>
230               <select id="issues_op" name="issues_op">
231                 <option value=">">&gt;</option>
232                 <option value="<">&lt;</option>
233                 <option value="=">=</option>
234                 <option value="!=">!=</option>
235               </select>
236               <input type="text" name="issues" />
237             </div>
238             <div class="form-field">
239               <label class="form-field-label" for="datelastborrowed_op">Last checkout date:</label>
240               <select id="datelastborrowed_op" name="datelastborrowed_op">
241                 <option value=">">After</option>
242                 <option value="<">Before</option>
243                 <option value="=">On</option>
244               </select>
245               <input type="text" name="datelastborrowed" />
246               <span class="hint">ISO Format (YYYY-MM-DD)</span>
247             </div>
248           </fieldset>
249           <fieldset>
250             <div class="form-field-radio">
251               <label>Output:</label>
252               <input type="radio" id="format-html" name="format" value="html" checked="checked" /> <label for="format-html">Screen</label>
253               <input type="radio" id="format-csv" name="format" value="csv" /> <label for="format-csv">CSV</label>
254               <input type="radio" id="format-barcodes" name="format" value="barcodes"/> <label for="format-barcodes">Barcodes file</label>
255             </div>
256           </fieldset>
257       </form>
258     </div>
259     </div>
260   </div>
261     <div class="row">
262         <div class="col-md-12">
263       <div id="results-wrapper"></div>
264         </div>
265       </div>
266
267 [% MACRO jsinclude BLOCK %]
268     [% INCLUDE 'datatables.inc' %]
269     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
270     [% Asset.js("lib/hc-sticky.js") | $raw %]
271     <script>
272         var authorised_values = [% authorised_values_json | $raw %];
273
274         function loadAuthorisedValuesSelect(select) {
275             var selected = select.find('option:selected');
276             var category = selected.data('authorised-values-category');
277             var form_field_value = select.siblings('.form-field-value');
278             if (category && category in authorised_values) {
279                 var values = authorised_values[category];
280                 var html = '<select name="q" class="form-field-value">\n';
281                 for (i in values) {
282                     var value = values[i];
283                     html += '<option value="' + value.authorised_value + '">' + value.lib + '</option>\n';
284                 }
285                 html += '</select>\n';
286                 var new_form_field_value = $(html);
287                 new_form_field_value.val(form_field_value.val());
288                 form_field_value.replaceWith(new_form_field_value);
289             } else {
290                 if (form_field_value.prop('tagName').toLowerCase() == 'select') {
291                     html = '<input name="q" type="text" class="form-field-value" />';
292                     var new_form_field_value = $(html);
293                     form_field_value.replaceWith(new_form_field_value);
294                 }
295             }
296         }
297
298     function addNewField( link ) {
299             var form_field = $('div.form-field-select-text').last();
300             var copy = form_field.clone(true);
301             copy.find('input,select').not('[type="hidden"]').each(function() {
302                 $(this).val('');
303             });
304             copy.find('.form-field-conjunction').prop('disabled', false).val('and');
305             form_field.after(copy);
306       link.remove();
307             copy.find('select.form-field-column').change();
308         }
309
310         function submitForm($form) {
311             var tr = ''
312                 + '    <tr>'
313                 + '      <th id="items_checkbox"></th>'
314                 + '      <th id="items_title">' + _("Title") + '</th>'
315                 + '      <th id="items_pubdate">' + _("Publication date") + '</th>'
316                 + '      <th id="items_publisher">' + _("Publisher") + '</th>'
317                 + '      <th id="items_collection">' + _("Collection") + '</th>'
318                 + '      <th id="items_barcode">' + _("Barcode") + '</th>'
319                 + '      <th id="items_callno">' + _("Call number") + '</th>'
320                 + '      <th id="items_homebranch">' + _("Home library") + '</th>'
321                 + '      <th id="items_holdingbranch">' + _("Current library") + '</th>'
322                 + '      <th id="items_location">' + _("Shelving location") + '</th>'
323                 + '      <th id="items_itype">' + _("Itemtype") + '</th>'
324                 + '      <th id="item_inventoryno">' + _("Inventory number") + '</th>'
325                 + '      <th id="items_status">' + _("Not for loan status") + '</th>'
326                 + '      <th id="items_itemlost">' + _("Lost status") + '</th>'
327                 + '      <th id="items_widthdrawn">' + _("Withdrawn status") + '</th>'
328                 + '      <th id="items_checkouts">' + _("Checkouts") + '</th>'
329                 + '      <th id=""></th>'
330                 + '    </tr>'
331             var table = ''
332                 + '<table id="results">'
333                 + '  <thead>' + tr + tr + '</thead>'
334                 + '  <tbody></tbody>'
335                 + '</table>';
336
337             var advSearchLink = $('<a>')
338                 .attr('href', '/cgi-bin/koha/catalogue/search.pl')
339                 .html(_("Go to advanced search"));
340             var editSearchLink = $('<a>')
341                 .attr('href', '#')
342                 .html(_("Edit search"))
343                 .addClass('btn btn-default btn-xs')
344                 .on('click', function(e) {
345                     e.preventDefault();
346                     $('#item-search-block').show();
347                 });
348
349             function getCheckedItemnumbers () {
350                 var itemnumbers;
351                 try {
352                     itemnumbers = JSON.parse(sessionStorage.getItem('itemsearch_itemnumbers') || '[]');
353                 } catch (e) {
354                     itemnumbers = [];
355                 }
356
357                 return new Set(itemnumbers);
358             }
359
360             function exportItems(format) {
361               var itemnumbers = getCheckedItemnumbers();
362               if (itemnumbers.size > 0) {
363                 var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format;
364                 href += '&itemnumber=' + Array.from(itemnumbers).join('&itemnumber=');
365                 location = href;
366               } else {
367                 $('#format-' + format).prop('checked', true);
368                 $('#itemsearchform').submit();
369                 $('#format-html').prop('checked', true);
370               }
371             }
372
373             var csvExportLink = $('<a>')
374                 .attr('href', '#')
375                 .html("CSV")
376                 .on('click', function(e) {
377                     e.preventDefault();
378                     exportItems('csv');
379                 });
380             var barcodesExportLink = $('<a>')
381                 .attr('href', '#')
382                 .html(_("Barcodes file"))
383                 .on('click', function(e) {
384                     e.preventDefault();
385                     exportItems('barcodes');
386               });
387
388             var exportButton = $('<div>')
389               .addClass('btn-group')
390               .append($('<button>')
391                   .addClass('btn btn-default btn-xs dropdown-toggle')
392                   .attr('id', 'export-button')
393                   .attr('data-toggle', 'dropdown')
394                   .attr('aria-haspopup', 'true')
395                   .attr('aria-expanded', 'false')
396                   .html(_("Export all results to") + ' <span class="caret"></span>'))
397               .append($('<ul>')
398                   .addClass('dropdown-menu')
399                   .append($('<li>').append(csvExportLink))
400                   .append($('<li>').append(barcodesExportLink)));
401
402             var selectVisibleRows = $('<a>')
403               .attr('href', '#')
404               .append('<i class="fa fa-check"></i> ')
405               .append(_("Select visible rows"))
406               .on('click', function(e) {
407                   e.preventDefault();
408                   $('#results input[type="checkbox"]').prop('checked', true).change();
409               });
410             var clearSelection = $('<a>')
411               .attr('href', '#')
412               .append('<i class="fa fa-remove"></i> ')
413               .append(_("Clear selection"))
414               .on('click', function(e) {
415                   e.preventDefault();
416                   sessionStorage.setItem('itemsearch_itemnumbers', '[]');
417                   $('#results input[type="checkbox"]').prop('checked', false).change();
418               });
419             var exportLinks = $('<p>')
420               .append(selectVisibleRows)
421               .append(' ')
422               .append(clearSelection)
423               .append(' | ')
424               .append(exportButton);
425
426             var results_heading = $('<div>').addClass('results-heading')
427                 .append("<h1>" + _("Item search results") + "</h1>")
428                 .append($('<p>').append(advSearchLink))
429                 .append($('<p>').append(editSearchLink))
430                 .append(exportLinks);
431             $('#results-wrapper').empty()
432                 .append(results_heading)
433                 .append(table);
434
435             var params = [];
436             $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
437                 if ( $(this).prop('tagName').toLowerCase() == 'option' ) {
438                     var name = $(this).parents('select').first().attr('name');
439                     var value = $(this).val();
440                     params.push({ 'name': name, 'value': value });
441                 } else {
442                     params.push({ 'name': $(this).attr('name'), 'value': $(this).val() });
443                 }
444             });
445
446             $('#results').dataTable($.extend(true, {}, dataTablesDefaults, {
447                 'bDestroy': true,
448                 'bServerSide': true,
449                 'bProcessing': true,
450                 'sAjaxSource': '/cgi-bin/koha/catalogue/itemsearch.pl',
451                 'fnServerData': function(sSource, aoData, fnCallback) {
452                     aoData.push( { 'name': 'format', 'value': 'json' } );
453                     for (i in params) {
454                         aoData.push(params[i]);
455                     }
456                     $.ajax({
457                         'dataType': 'json',
458                         'type': 'POST',
459                         'url': sSource,
460                         'data': aoData,
461                         'success': function(json){
462                             fnCallback(json);
463                         }
464                     });
465                 },
466                 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
467                 'aaSorting': [[1, 'asc']],
468                 'aoColumns': [
469                     { 'sName': 'checkbox', 'bSortable': false },
470                     { 'sName': 'title' },
471                     { 'sName': 'publicationyear' },
472                     { 'sName': 'publishercode' },
473                     { 'sName': 'ccode' },
474                     { 'sName': 'barcode' },
475                     { 'sName': 'itemcallnumber' },
476                     { 'sName': 'homebranch' },
477                     { 'sName': 'holdingbranch' },
478                     { 'sName': 'location' },
479                     { 'sName': 'itype'},
480                     { 'sName': 'stocknumber' },
481                     { 'sName': 'notforloan' },
482                     { 'sName': 'itemlost' },
483                     { 'sName': 'withdrawn' },
484                     { 'sName': 'issues' },
485                     { 'sName': 'actions', 'bSortable': false }
486                 ],
487                 "sPaginationType": "full_numbers",
488                 fixedHeader: false // There is a bug on this view
489             })).columnFilter({
490                 'sPlaceHolder': 'head:after',
491                 'aoColumns': [
492                     null,
493                     { 'type': 'text' },
494                     { 'type': 'text' },
495                     { 'type': 'text' },
496                     [% IF ccodes.size %]
497                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => ccodes %] },
498                     [% ELSE %]
499                         null,
500                     [% END %]
501                     { 'type': 'text' },
502                     { 'type': 'text' },
503                     { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
504                     { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => branches %] },
505                     [% IF locations.size %]
506                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => locations %] },
507                     [% ELSE %]
508                         null,
509                     [% END %]
510                     [% IF itemtypes.size %]
511                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemtypes %] },
512                     [% ELSE %]
513                         null,
514                     [% END %]
515                     { 'type': 'text' },
516                     [% IF notforloans.size %]
517                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => notforloans %] },
518                     [% ELSE %]
519                         null,
520                     [% END %]
521                     [% IF itemlosts.size %]
522                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => itemlosts %] },
523                     [% ELSE %]
524                         null,
525                     [% END %]
526                     [% IF withdrawns.size %]
527                         { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => withdrawns %] },
528                     [% ELSE %]
529                         null,
530                     [% END %]
531                     { 'type': 'text' },
532                     null
533                 ]
534             });
535             $('#results').on('draw.dt', function (e, settings) {
536                 var itemnumbers = getCheckedItemnumbers();
537                 $(this).find('input[type="checkbox"][name="itemnumber"]').each(function () {
538                     var itemnumber = this.value;
539                     if (itemnumbers.has(itemnumber)) {
540                         this.checked = true;
541                     }
542                 });
543             });
544
545             sessionStorage.setItem('itemsearch_itemnumbers', '[]');
546
547             $('#results').on('change', 'input[type="checkbox"]', function() {
548               var itemnumber = this.value;
549               var itemnumbers = getCheckedItemnumbers();
550               if (this.checked) {
551                   itemnumbers.add(itemnumber);
552               } else {
553                   itemnumbers.delete(itemnumber);
554               }
555               sessionStorage.setItem('itemsearch_itemnumbers', JSON.stringify(Array.from(itemnumbers)));
556
557               var caret = ' <span class="caret">';
558               if (itemnumbers.size > 0) {
559                 $('#export-button').html(_("Export selected results (%s) to").format(itemnumbers.size) + caret);
560               } else {
561                 $('#export-button').html(_("Export all results to") + caret);
562               }
563             });
564         }
565         var Sticky;
566         $(document).ready(function () {
567             Sticky = $("#toolbar");
568             Sticky.hcSticky({
569                 stickTo: "#item-search-block",
570                 stickyClass: "floating"
571             });
572             // Add the "New field" link.
573             var form_field = $('div.form-field-select-text').last()
574             var NEW_FIELD = _("New field");
575       var button_field_new = $('<a href="#" class="button-field-new" title="Add a new field"><i class="fa fa-plus"></i> ' + NEW_FIELD + '</a>');
576       button_field_new.click(function(e) {
577           e.preventDefault();
578           addNewField( $(this) );
579             });
580       form_field.append(button_field_new);
581
582             // If a field is linked to an authorised values list, display the list.
583             $('div.form-field-select-text select[name="f"]').change(function() {
584                 loadAuthorisedValuesSelect($(this));
585             }).change();
586
587             // Prevent user to select the 'All ...' option with other options.
588             $('div.form-field-select').each(function() {
589                 $(this).find('select').filter(':last').change(function() {
590                     values = $(this).val();
591                     if (values.length > 1) {
592                         var idx = $.inArray('', values);
593                         if (idx != -1) {
594                             values.splice(idx, 1);
595                             $(this).val(values);
596                         }
597                     }
598                 });
599             });
600
601             $('#itemsearchform').submit(function() {
602                 var searchform = $(this);
603                 var format = searchform.find('input[name="format"]:checked').val();
604                 if (format == 'html') {
605                     submitForm(searchform);
606                     $("#item-search-block").hide();
607                     return false;
608                 }
609             });
610         });
611     </script>
612 [% END %]
613
614 [% INCLUDE 'intranet-bottom.inc' %]