Bug 7607: Remove empty inputs when submitting search form
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / advsearch.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE Asset %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 </head>
10
11 [%- BLOCK language_limit_select -%]
12 <select name="limit" id="[% ln_id | html %]">
13     <option value="">No limit</option>
14     [% FOREACH ln_loo IN ln_loop %]
15         [% IF ( ln_loo.selected ) %]
16             <option value="[% ln_index | html %],rtrn:[% ln_loo.iso639_2_code | html %]" selected="selected">
17                 [% ln_loo.language_description | html %]
18             </option>
19         [% ELSE %]
20             <option value="[% ln_index | html %],rtrn:[% ln_loo.iso639_2_code | html %]">
21                 [% ln_loo.language_description | html %]
22             </option>
23         [% END %]
24     [% END %]
25 </select>
26 [%- END -%]
27
28 <body id="catalog_advsearch" class="catalog">
29 [% INCLUDE 'header.inc' %]
30 [% INCLUDE 'adv-search.inc' %]
31 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Advanced search</div>
32
33 <div class="main container-fluid">
34     <div class="row">
35         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
36
37 <form action="search.pl" method="get">
38 <div id="advanced-search">
39 <input type="hidden" name="advsearch" value="1"/>
40 <h1>Advanced search</h1>
41 <p>
42   <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a>
43   [% IF searchid %]
44       <div id="previous_search_link"></div>
45   [% END %]
46 </p>
47
48 <!-- SEARCH BUTTONS -->
49 <div id="toolbar" class="btn-toolbar">
50     <fieldset class="action" id="submit1">
51         <div class="btn-group">
52             <button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button>
53         </div>
54         <div class="btn-group">
55         [% IF ( expanded_options ) %]
56             <a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=0" class="btn btn-link"><i class="fa fa-search-minus"></i> Fewer options</a>
57         </div>
58         [% ELSE %]
59             <a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=1" class="btn btn-link"><i class="fa fa-search-plus"></i> More options</a>
60         </div>
61         [% END %]
62         <div class="btn-group">
63             <a href="/cgi-bin/koha/catalogue/search.pl?do=Clear&expanded_options=[% expanded_options | uri %]" class="btn btn-link"><i class="fa fa-trash"></i> Clear fields</a>
64         </div>
65     </fieldset>
66 </div>
67 <!-- /SEARCH BUTTONS -->
68
69
70 [% IF ( outer_servers_loop ) %]
71 <!-- DATABASES -->
72
73 <fieldset>
74         <legend>Select local databases</legend>
75                 [% FOREACH local_servers_loo IN local_servers_loop %]
76 [% IF ( local_servers_loo.checked ) %]<input type="checkbox" id="[% local_servers_loo.id | html %]" name="[% local_servers_loo.name | html %]" checked="checked" value="[% local_servers_loo.value | html %]" />[% ELSE %]<input type="checkbox" id="[% local_servers_loo.id | html %]" name="[% local_servers_loo.name | html %]" value="[% local_servers_loo.value | html %]" />[% END %]<label for="[% local_servers_loo.id | html %]"><img width="16" height="16" alt="[% local_servers_loo.id | html %]" src="[% themelang | html %]/img/[% local_servers_loo.icon | html %]" /> [% local_servers_loo.label | html %]</label>[% END %]
77 </fieldset>
78 <!-- /DATABASES -->
79 [% END %]
80
81 [% IF ( outer_servers_loop ) %]
82 <!-- REMOTE DATABASES -->
83 <fieldset id="databases">
84     <legend>Select remote databases</legend>
85                 [% FOREACH outer_servers_loo IN outer_servers_loop %]
86                 [% IF ( outer_servers_loo.checked ) %]<input type="checkbox" id="[% outer_servers_loo.id | html %]" name="[% outer_servers_loo.name | html %]" checked="checked" value="[% outer_servers_loo.value | html %]" />[% ELSE %]<input type="checkbox" id="[% outer_servers_loo.id | html %]" name="[% outer_servers_loo.name | html %]" value="[% outer_servers_loo.value | html %]" />[% END %]
87 <label for="[% outer_servers_loo.id | html %]"><img alt="[% outer_servers_loo.id | html %]" src="[% themelang | html %]/images/[% outer_servers_loo.icon | html %]" />[% outer_servers_loo.label | html %]</label>
88                 [% END %]
89     </fieldset>
90 <!-- /REMOTE DATABASES -->
91 [% END %]
92
93 <!-- BOOLEAN SEARCH OPTIONS -->
94     <fieldset id="searchterms">
95     <legend>Search for </legend>
96     [% FOREACH search_box IN search_boxes_loop %]
97         [% IF ( search_boxes_label ) %]
98         <div class="search_set" style="text-indent: 4.5em;">
99         [% ELSE %]
100         <div class="search_set">
101         [% END %]
102                         [% IF ( expanded_options ) %]
103             [% IF ( search_box.boolean ) %]
104                 <select name="op">
105                     <option value="and" selected="selected">and</option>
106                     <option value="or">or</option>
107                     <option value="not">not</option>
108                 </select>
109             [% END %] 
110                         [% END %]
111                         [% INCLUDE 'search_indexes.inc' %]
112                         <input type="text" size="30" name="q" title="Enter search terms" value="" />
113             [% IF ( expanded_options ) %]
114                 [% IF ( search_box.add_field ) %]
115                     <a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>
116                                 [% END %]
117               [% IF ( search_box.scan_index ) %]
118                 <label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" />
119               [% END %]
120             [% END %]
121                 </div>
122     [% END %]
123     [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
124         [% IF ( expanded_options ) %]
125             <p>
126                 [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
127                     <label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
128                 [% END %]
129                 <span id="weight_search">
130                     <label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
131                 </span>
132             <p>
133         [% ELSE %]
134             <input type="hidden" name="weight_search" value="1" />
135         [% END %]
136     [% END %]
137     </fieldset>
138 <!-- /BOOLEAN SEARCH OPTIONS -->
139
140 </div>
141 <!-- MC-TYPE LIMITS -->
142       <div id="advsearches" class="toptabs">
143       <ul>
144       [% FOREACH advsearchloo IN advancedsearchesloop %]
145         <li id="advsearch-tab-[% advsearchloo.advanced_search_type | html %]">
146            <a href="#advsearch-[% advsearchloo.advanced_search_type | uri %]">
147            [% IF ( advsearchloo.advanced_search_type == 'itemtypes' ) %]Item type
148            [% ELSIF ( advsearchloo.advanced_search_type == 'ccode' ) %]Collection
149            [% ELSIF ( advsearchloo.advanced_search_type == 'loc' ) %]Shelving location
150            [% ELSE %]Something else
151            [% END %]
152            </a>
153         </li>
154       [% END %]
155       </ul>
156     [% FOREACH advsearchloo IN advancedsearchesloop %]
157     <div id="advsearch-[% advsearchloo.advanced_search_type | html %]" class="advsearch">
158     <h4>Limit to any of the following:</h4>
159     <table>
160         <tr>
161     [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
162         <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
163         [% itemtypeloo.description | html %]</label></td>
164         [% IF ( loop.last ) %]</tr>[% ELSE %][% UNLESS ( loop.count % 5 ) %]</tr><tr>[% END %][% END %]
165     [% END %]
166     </table>
167     </div>
168     [% END %]
169 <!-- /MC-TYPE LIMIT -->
170 [% IF ( expanded_options ) %]
171 <!-- BASIC LIMITS -->
172  <fieldset id="basiclimits">
173         <legend>Limits</legend>
174 <fieldset id="pubrange">
175 <!-- PUB / COPY YEAR LIMIT --><!-- FIXME: add publication,copyright,acquisition options -->
176         <p><label for="limit-yr">Year: </label>
177                 <input type="text" size="15" name="limit-yr" id="limit-yr" value=""/>&nbsp;&nbsp;(format: yyyy-yyyy)</p>
178 <!-- /PUB / COPY YEAR LIMIT -->
179 </fieldset>
180 <fieldset id="language">
181 <!-- LANGUAGE LIMIT -->
182     <p>
183         <label for="language-limit">Language: </label>
184         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-limit' ln_index='ln' %]
185         <label for="language-original-limit">Language of original: </label>
186         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-original-limit' ln_index='language-original' %]
187     </p>
188 <!-- /LANGUAGE LIMIT -->
189 </fieldset>
190 </fieldset>
191 <!-- /BASIC LIMITS -->
192 [% END %]
193
194
195 [% IF ( UNIMARC ) %]
196 [% INCLUDE 'subtypes_unimarc.inc' %]
197 [% ELSE %]
198 <!-- SUBTYPE LIMITS -->
199         <fieldset id="subtype">
200         <legend>Subtype limits</legend><p>
201         
202         <select name="limit" class="subtype">
203             <option value="" selected="selected" class="menuheader">Any audience</option>
204                         <option value="aud:a">Preschool</option>
205                         <option value="aud:b">Primary</option>
206                         <option value="aud:c">Pre-adolescent</option>
207                         <option value="aud:d">Adolescent</option>
208                         <option value="aud:e">Adult</option>
209                         <option value="aud:f">Specialized</option>
210                         <option value="aud:g">General</option>
211                         <option value="aud:j">Juvenile</option>
212         </select>
213         
214         <select name="limit" class="subtype">
215             <option value="" selected="selected" class="menuheader">Any content</option>
216             <option value="fic:1" >Fiction</option>
217             <option value="fic:0" >Non-fiction</option>
218             <option value="bio:b" >Biography</option>
219             <option value="mus:j" >Musical recording</option>
220             <option value="mus:i" >Non-musical recording</option>
221         </select>
222
223         
224         <select name="limit" class="subtype">
225             <option value="" selected="selected" class="menuheader">Any format</option>
226             <option value="l-format:ta" >Regular print</option>
227             <option value="l-format:tb" >Large print</option>
228             <option value="l-format:tc or l-format:fb">Braille</option>
229             <option value="" >-----------</option>
230             <option value="l-format:sd" >CD audio</option>
231             <option value="l-format:ss" >Cassette recording</option>
232             <option value="l-format:vf" >VHS tape / Videocassette</option>
233             <option value="l-format:vd" >DVD video / Videodisc</option>
234             <option value="l-format:co" >CD software</option>
235             <option value="l-format:cr" >Website</option>
236         </select>
237         
238         <select name="limit" class="subtype">
239             <option value="" >Additional content types</option>
240             <option value="ctype:a" >Abstracts / Summaries</option>
241             <option value="ctype:b" >Bibliographies</option>
242             <option value="ctype:c" >Catalogs</option>
243             <option value="ctype:d" >Dictionaries</option>
244             <option value="ctype:e" >Encyclopedias </option>
245             <option value="ctype:f" >Handbooks</option>
246             <option value="ctype:g" >Legal articles</option>
247             <option value="ctype:i" >Indexes</option>
248             <option value="ctype:j" >Patent document</option>
249             <option value="ctype:k" >Discographies</option>
250             <option value="ctype:l" >Legislation</option>
251             <option value="ctype:m" >Theses</option>
252             <option value="ctype:n" >Surveys</option>
253             <option value="ctype:o" >Reviews</option>
254             <option value="ctype:p" >Programmed texts</option>
255             <option value="ctype:q" >Filmographies</option>
256             <option value="ctype:r" >Directories</option>
257             <option value="ctype:s" >Statistics</option>
258             <option value="ctype:t" >Technical reports</option>
259             <option value="ctype:v" >Legal cases and case notes</option>
260             <option value="ctype:w" >Law reports and digests</option>
261             <option value="ctype:z" >Treaties </option>
262         </select>
263        </p>
264
265 </fieldset>
266 [% END %]
267
268 <!-- AVAILABILITY LIMITS -->
269     <fieldset id="availability"><legend>Location and availability</legend>
270 <fieldset id="currently-avail">
271         <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
272 </fieldset>
273
274 <fieldset id="select-libs">
275         <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop">
276         <option value="">All libraries</option>
277         [%# FIXME Should not we filter the libraries displayed? %]
278         [% PROCESS options_for_libraries prefix => "branch:" libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
279         </select></p>
280     <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
281         [% IF search_groups %]
282             <p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. -->
283
284             <p>
285                 <label for="categoryloop">Groups of libraries: </label>
286                 <select name="multibranchlimit" id="categoryloop">
287                     <option value=""> -- none -- </option>
288                     [% FOREACH sg IN search_groups %]
289                         [% UNLESS sg.branchcode %]
290                             <option value="[% sg.id | html %]">[% sg.title | html %]</option>
291                         [% END %]
292                     [% END %]
293                 </select>
294             </p>
295     [% END %]
296 </fieldset>
297     </fieldset>
298 <!-- /AVAILABILITY LIMITS -->
299
300 <!-- RANK LIMITS -->
301 <fieldset id="sortby"><legend>Sorting</legend>
302     <p>
303     <label for="sort_by">Sort by: </label><select id="sort_by" name="sort_by">
304   [% INCLUDE 'resort_form.inc' %]
305     </select>
306         </p>
307 </fieldset>
308 </div>
309 <!-- /RANK LIMITS -->
310 </form>
311 </div>
312 </div>
313
314 [% MACRO jsinclude BLOCK %]
315     [% Asset.js("lib/hc-sticky.js") | $raw %]
316     [% Asset.js("js/browser.js") | $raw %]
317     <script>
318         /**
319          *  Function add_field();
320          *  This function allows to display a new field to search.
321          */
322         function add_field() {
323             var ButtonPlus = document.getElementById("ButtonPlus");
324             var line = ButtonPlus.parentNode;
325             var dad  = line.parentNode;
326             dad.appendChild(line.cloneNode(true));
327             line.removeChild(ButtonPlus);
328         }
329         var Sticky;
330         $(document).ready(function() {
331             $("input[name=q]:eq(0)").focus();
332             $('#advsearches').tabs();
333             Sticky = $("#toolbar");
334             Sticky.hcSticky({
335                 stickTo: ".main",
336                 stickyClass: "floating"
337             });
338             $("#branchloop").on("change",function(){
339                 if( this.value != ""){
340                     document.getElementById("categoryloop").disabled=true;
341                 } else {
342                     document.getElementById("categoryloop").disabled=false;
343                 }
344             });
345
346             [% IF searchid %]
347                 browser = KOHA.browser('[% searchid | html %]');
348                 browser.show_back_link();
349             [% END %]
350
351         });
352     </script>
353 [% END %]
354
355 [% INCLUDE 'intranet-bottom.inc' %]