Bug 22605: Add ability to edit a search on staff interface
[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>Advanced search &rsaquo; Catalog &rsaquo; Koha</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 or selected == ln_loo.iso639_2_code ) %]
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
32 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
33     <ol>
34         <li>
35             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
36         </li>
37         <li>
38             <a href="#" aria-current="page">
39                 Advanced search
40             </a>
41         </li>
42     </ol>
43 </nav>
44
45 <div class="main container-fluid">
46     <div class="row">
47         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
48
49 <form action="search.pl" method="get">
50 <div id="advanced-search">
51 <input type="hidden" name="advsearch" value="1"/>
52 <h1>Advanced search</h1>
53 <p>
54   <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a>
55   [% IF searchid %]
56       <div id="previous_search_link"></div>
57   [% END %]
58 </p>
59
60 <!-- SEARCH BUTTONS -->
61 <div id="toolbar" class="btn-toolbar">
62     <fieldset class="action" id="submit1">
63         <div class="btn-group">
64             <button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button>
65         </div>
66         <div class="btn-group">
67         [% IF ( expanded_options ) %]
68             <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>
69         </div>
70         [% ELSE %]
71             <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>
72         </div>
73         [% END %]
74         <div class="btn-group">
75             <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>
76         </div>
77     </fieldset>
78 </div>
79 <!-- /SEARCH BUTTONS -->
80
81
82 [% IF ( outer_servers_loop ) %]
83 <!-- DATABASES -->
84
85 <fieldset>
86         <legend>Select local databases</legend>
87                 [% FOREACH local_servers_loo IN local_servers_loop %]
88 [% 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 %]
89 </fieldset>
90 <!-- /DATABASES -->
91 [% END %]
92
93 [% IF ( outer_servers_loop ) %]
94 <!-- REMOTE DATABASES -->
95 <fieldset id="databases">
96     <legend>Select remote databases</legend>
97                 [% FOREACH outer_servers_loo IN outer_servers_loop %]
98                 [% 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 %]
99 <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>
100                 [% END %]
101     </fieldset>
102 <!-- /REMOTE DATABASES -->
103 [% END %]
104
105 <!-- BOOLEAN SEARCH OPTIONS -->
106     <fieldset id="searchterms">
107     <legend>Search for </legend>
108     [% FOREACH query IN queries %]
109         [% IF ( expanded_options ) %]
110         <div class="search-term-row">
111             [% SET opindex = loop.index - 1 %]
112             <select name="op">
113             [% IF operators.$opindex == 'OR' %]
114                 <option value="AND">and</option>
115                 <option value="OR" selected="selected">or</option>
116                 <option value="NOT">not</option>
117             [% ELSIF operators.$opindex == 'NOT' %]
118                 <option value="AND">and</option>
119                 <option value="OR">or</option>
120                 <option value="NOT" selected="selected">not</option>
121             [% ELSE %]
122                 <option value="AND" selected="selected">and</option>
123                 <option value="OR">or</option>
124                 <option value="NOT">not</option>
125             [% END %]
126             </select>
127         [% ELSE %]
128         <div>
129         [% END %]
130         [% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %]
131         [% INCLUDE 'search_indexes.inc' %]
132         <input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" />
133         [% IF ( expanded_options ) %]
134             <a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>
135           [% IF ( loop.first ) %]
136             <label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" />
137           [% END %]
138         [% END %]
139                 </div>
140     [% END %]
141     [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
142         [% IF ( expanded_options ) %]
143             <p>
144                 [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
145                     <label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
146                 [% END %]
147                 <span id="weight_search">
148                     <label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
149                 </span>
150             <p>
151         [% ELSE %]
152             <input type="hidden" name="weight_search" value="1" />
153         [% END %]
154     [% END %]
155     </fieldset>
156 <!-- /BOOLEAN SEARCH OPTIONS -->
157
158 </div>
159 <!-- MC-TYPE LIMITS -->
160       <div id="advsearches" class="toptabs">
161       <ul>
162       [% FOREACH advsearchloo IN advancedsearchesloop %]
163         <li id="advsearch-tab-[% advsearchloo.advanced_search_type | html %]">
164            <a href="#advsearch-[% advsearchloo.advanced_search_type | uri %]">
165            [% IF ( advsearchloo.advanced_search_type == 'itemtypes' ) %]Item type
166            [% ELSIF ( advsearchloo.advanced_search_type == 'ccode' ) %]Collection
167            [% ELSIF ( advsearchloo.advanced_search_type == 'loc' ) %]Shelving location
168            [% ELSE %]Something else
169            [% END %]
170            </a>
171         </li>
172       [% END %]
173       </ul>
174     [% FOREACH advsearchloo IN advancedsearchesloop %]
175     <div id="advsearch-[% advsearchloo.advanced_search_type | html %]" class="advsearch">
176     <h4>Limit to any of the following:</h4>
177     <table>
178         <tr>
179     [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
180         <td>
181             [% SET limit_key = 'mc-' _ itemtypeloo.ccl _ "_" _ itemtypeloo.code %]
182             [% IF limits.$limit_key.defined %]
183                 [% limits.delete( limit_key ) %]
184                 <input type="checkbox" checked="checked" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/>
185             [% ELSE %]
186                 <input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/>
187             [% END %]
188             <label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">
189         [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
190             [% IF ( itemtypeloo.imageurl ) %]
191                 <img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />
192             [% END %]
193                 &nbsp;
194         [% END %]
195         [% itemtypeloo.description | html %]
196             </label>
197         </td>
198         [% IF ( loop.last ) %]
199         </tr>
200         [% ELSE %]
201             [% UNLESS ( loop.count % 5 ) %]
202         </tr>
203         <tr>
204             [% END %]
205         [% END %]
206     [% END %]
207     </table>
208     </div>
209     [% END %]
210 <!-- /MC-TYPE LIMIT -->
211 [% IF ( expanded_options ) %]
212 <!-- BASIC LIMITS -->
213  <fieldset id="basiclimits">
214         <legend>Limits</legend>
215 <fieldset id="pubrange">
216 <!-- PUB / COPY YEAR LIMIT --><!-- FIXME: add publication,copyright,acquisition options -->
217         <p><label for="limit-yr">Year: </label>
218         [% SET year_limit_key = 'yr,st-numeric' %]
219         <input type="text" size="15" name="limit-yr" id="limit-yr" value="[% limits.$year_limit_key.0 | html %]"/>&nbsp;&nbsp;(format: yyyy-yyyy)</p>
220         [% IF limits.$year_limit_key.defined %]
221             [% limits.delete(year_limit_key) %]
222         [% END %]
223 <!-- /PUB / COPY YEAR LIMIT -->
224 </fieldset>
225 <fieldset id="language">
226 <!-- LANGUAGE LIMIT -->
227     <p>
228         <label for="language-limit">Language: </label>
229         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-limit' ln_index='ln' selected = limits.${'ln,rtrn'}.0 %]
230         [% limits.delete( 'ln,rtrn' ) %]
231         <label for="language-original-limit">Language of original: </label>
232         [% PROCESS language_limit_select ln_loop=search_languages_loop ln_id='language-original-limit' ln_index='language-original' selected = limits.${'language-original,rtrn'}.0 %]
233         [% limits.delete( 'language-original,rtrn' ) %]
234     </p>
235 <!-- /LANGUAGE LIMIT -->
236 </fieldset>
237 </fieldset>
238 <!-- /BASIC LIMITS -->
239 [% END %]
240
241
242 [% IF ( UNIMARC ) %]
243 [% INCLUDE 'subtypes_unimarc.inc' %]
244 [% ELSE %]
245 [% PROCESS 'subtype_limits.inc' %]
246 <!-- SUBTYPE LIMITS -->
247         <fieldset id="subtype">
248         <legend>Subtype limits</legend><p>
249
250         <fieldset id="current_subtype_limits"><legend>Current subtype limits</legend>
251         [% FOREACH subtype IN ['aud','fic','bio','ctype','l-format'] %]
252             [% FOREACH limit IN limits.$subtype %]
253                 <span>
254                     <input name="limit" value="[% subtype | html %]:[% limit | html %]" type="hidden">
255                     <label for="subtype_limit_[% loop.index() | html %]">[% PROCESS subtype_limits_description subtype_limit = subtype _':' _ limit %]</label>
256                     <input type="checkbox" class="toggle_limit" name="subtype_limit_[% loop.index() | html %]" checked="checked">
257                 </span>
258            [% END %]
259             [% limits.delete( subtype ) %]
260         [% END %]
261         </fieldset>
262
263         <select name="limit" class="subtype">
264             <option value="" selected="selected" class="menuheader">Any audience</option>
265                         <option value="aud:a">Preschool</option>
266                         <option value="aud:b">Primary</option>
267                         <option value="aud:c">Pre-adolescent</option>
268                         <option value="aud:d">Adolescent</option>
269                         <option value="aud:e">Adult</option>
270                         <option value="aud:f">Specialized</option>
271                         <option value="aud:g">General</option>
272                         <option value="aud:j">Juvenile</option>
273         </select>
274         
275         <select name="limit" class="subtype">
276             <option value="" selected="selected" class="menuheader">Any content</option>
277             <option value="fic:1" >Fiction</option>
278             <option value="fic:0" >Non-fiction</option>
279             <option value="bio:b" >Biography</option>
280             <option value="mus:j" >Musical recording</option>
281             <option value="mus:i" >Non-musical recording</option>
282         </select>
283
284         
285         <select name="limit" class="subtype">
286             <option value="" selected="selected" class="menuheader">Any format</option>
287             <option value="l-format:ta" >Regular print</option>
288             <option value="l-format:tb" >Large print</option>
289             <option value="l-format:tc or l-format:fb">Braille</option>
290             <option value="" >-----------</option>
291             <option value="l-format:sd" >CD audio</option>
292             <option value="l-format:ss" >Cassette recording</option>
293             <option value="l-format:vf" >VHS tape / Videocassette</option>
294             <option value="l-format:vd" >DVD video / Videodisc</option>
295             <option value="l-format:co" >CD software</option>
296             <option value="l-format:cr" >Website</option>
297         </select>
298         
299         <select name="limit" class="subtype">
300             <option value="" >Additional content types</option>
301             <option value="ctype:a" >Abstracts / Summaries</option>
302             <option value="ctype:b" >Bibliographies</option>
303             <option value="ctype:c" >Catalogs</option>
304             <option value="ctype:d" >Dictionaries</option>
305             <option value="ctype:e" >Encyclopedias </option>
306             <option value="ctype:f" >Handbooks</option>
307             <option value="ctype:g" >Legal articles</option>
308             <option value="ctype:i" >Indexes</option>
309             <option value="ctype:j" >Patent document</option>
310             <option value="ctype:k" >Discographies</option>
311             <option value="ctype:l" >Legislation</option>
312             <option value="ctype:m" >Theses</option>
313             <option value="ctype:n" >Surveys</option>
314             <option value="ctype:o" >Reviews</option>
315             <option value="ctype:p" >Programmed texts</option>
316             <option value="ctype:q" >Filmographies</option>
317             <option value="ctype:r" >Directories</option>
318             <option value="ctype:s" >Statistics</option>
319             <option value="ctype:t" >Technical reports</option>
320             <option value="ctype:v" >Legal cases and case notes</option>
321             <option value="ctype:w" >Law reports and digests</option>
322             <option value="ctype:z" >Treaties </option>
323         </select>
324        </p>
325
326 </fieldset>
327 [% END %]
328
329 <!-- AVAILABILITY LIMITS -->
330     <fieldset id="availability"><legend>Location and availability</legend>
331 <fieldset id="currently-avail">
332         [% IF limit_available %]
333             <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available"  checked="checked" /></p>
334         [% ELSE %]
335             <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
336         [% END %]
337 </fieldset>
338
339 <fieldset id="select-libs">
340         <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop">
341         <option value="">All libraries</option>
342         [%# FIXME Should not we filter the libraries displayed? %]
343         [% PROCESS options_for_libraries prefix => "branch:" libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1, selected => limits.branch.0 ) %]
344         [% limits.delete('branch') %]
345         </select></p>
346         [% IF search_groups %]
347             <p>OR</p>
348
349             <p>
350                 <label for="categoryloop">Groups of libraries: </label>
351                 <select name="limit" id="categoryloop">
352                     <option value=""> -- none -- </option>
353                     [% FOREACH sg IN search_groups %]
354                         [% UNLESS sg.branchcode %]
355                             [% IF limits.multibranchlimit.0 == sg.id %]
356                                 <option selected="selected" value="multibranchlimit:[% sg.id | html %]">[% sg.title | html %]</option>
357                             [% ELSE %]
358                                 <option value="multibranchlimit:[% sg.id | html %]">[% sg.title | html %]</option>
359                             [% END %]
360                         [% END %]
361                     [% END %]
362                     [% limits.delete('multibranchlimit') %]
363                 </select>
364             </p>
365     [% END %]
366 </fieldset>
367     </fieldset>
368 <!-- /AVAILABILITY LIMITS -->
369
370 <!-- OTHER LIMITS (facets, etc.) -->
371 [% IF limits.size %]
372 <fieldset id=""><legend>Other limits</legend>
373     <p>
374     [% FOREACH key IN limits.keys %]
375         [% FOREACH limit IN limits.$key %]
376             <span>
377                 <input type="hidden" name="limit" value="[% key | html %]:[% limit | html %]">
378                 <label for="other_[% key _ loop.index() | html %]">[% key | html %]:[% limit | html %]</label>
379                 <input type="checkbox" class="toggle_limit" name="other_[% key _ loop.index() | html %]" checked="checked">
380             </span>
381         [% END %]
382     [% END %]
383     </p>
384 </fieldset>
385 [% END %]
386 <!-- /OTHER LIMITS (facets, etc.) -->
387
388 <!-- RANK LIMITS -->
389 <fieldset id="sortby"><legend>Sorting</legend>
390     <p>
391     <label for="sort_by">Sort by: </label><select id="sort_by" name="sort_by">
392   [% INCLUDE 'resort_form.inc' sort_by = sort %]
393     </select>
394         </p>
395 </fieldset>
396 </div>
397 <!-- /RANK LIMITS -->
398 </form>
399 </div>
400 </div>
401
402 [% MACRO jsinclude BLOCK %]
403     [% Asset.js("lib/hc-sticky.js") | $raw %]
404     [% Asset.js("js/browser.js") | $raw %]
405     <script>
406         /**
407          *  Function add_field();
408          *  This function allows to display a new field to search.
409          */
410         function add_field() {
411             var ButtonPlus = document.getElementById("ButtonPlus");
412             var line = ButtonPlus.parentNode;
413             var dad  = line.parentNode;
414             dad.appendChild(line.cloneNode(true));
415             line.removeChild(ButtonPlus);
416         }
417
418         var Sticky;
419         $(document).ready(function() {
420             $("input[name=q]:eq(0)").focus();
421             $('#advsearches').tabs();
422             Sticky = $("#toolbar");
423             Sticky.hcSticky({
424                 stickTo: ".main",
425                 stickyClass: "floating"
426             });
427             [% IF search_groups %]
428                 function branch_limit() {
429                     if( $("#branchloop").val() != "" ){
430                         $("#categoryloop").val("").prop('disabled',true);
431                     } else {
432                         $("#categoryloop").prop('disabled',false);
433                     }
434                     if ( $("#categoryloop").val() != "" ){
435                         $("#branchloop").val("").prop('disabled',true);
436                     } else {
437                         $("#branchloop").prop('disabled',false);
438                     }
439                 }
440                 branch_limit();
441                 $("#branchloop,#categoryloop").on("change",function(){
442                     branch_limit();
443                 });
444             [% END %]
445
446             if( $("#current_subtype_limits input").length == 0 ){
447                 $("#current_subtype_limits").hide();
448             }
449             $(".toggle_limit").on('click',function(){
450                 $(this).siblings("[type='hidden']").prop('disabled', !this.checked);
451             });
452
453             [% IF searchid %]
454                 browser = KOHA.browser('[% searchid | html %]');
455                 browser.show_back_link();
456             [% END %]
457
458         });
459     </script>
460 [% END %]
461
462 [% INCLUDE 'intranet-bottom.inc' %]