Bug 14659: (QA followup) switch to using Koha::Patron::Categories
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-advsearch.tt
index c55eccc..28591bd 100644 (file)
@@ -1,11 +1,10 @@
 [% USE Koha %]
 [% INCLUDE 'doc-head-open.inc' %]
-[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %]
-    catalog › Advanced search
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Advanced search</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% BLOCK cssinclude %][% END %]
 </head>
-<body id="advsearch" class="scrollto">
+[% INCLUDE 'bodytag.inc' bodyid='advsearch' bodyclass='scrollto' %]
 [% INCLUDE 'masthead.inc' %]
 <form action="/cgi-bin/koha/opac-search.pl" method="get">
     <div class="main">
                                             [% ELSE %]
                                                 <option value="sn">Standard number</option>
                                             [% END %]
-                                            <option value="sn">Standard number</option>
                                             <option value="nb">&nbsp;&nbsp;&nbsp;&nbsp; ISBN</option>
                                             <option value="ns">&nbsp;&nbsp;&nbsp;&nbsp; ISSN</option>
-                                            [% IF ( numbersphr) %]
-                                                <option value="lcn,phr">&nbsp;&nbsp;&nbsp;&nbsp; Call number</option>
-                                            [% ELSE %]
-                                                <option value="lcn">&nbsp;&nbsp;&nbsp;&nbsp; Call number</option>
-                                            [% END %]
                                         [% ELSE %]
                                             <option value="nb">ISBN</option>
                                         [% END %]
                     </div> <!-- /BOOLEAN SEARCH OPTIONS -->
                 </div> <!-- / .span12 -->
             </div> <!-- / .row-fluid -->
-        </div> <!-- / .container-fluid -->
-    </div> <!-- / .main -->
                     <div class="text-center">
                         <!-- SEARCH BUTTONS -->
                         [% PROCESS searchbuttons %]
                         <!-- /SEARCH BUTTONS -->
                     </div>
 
-    <div class="main">
-        <div class="container-fluid">
             <div class="row-fluid">
+              [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('itemtype').size > 0     and not expanded_options ) or
+                      ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('itemtype').size > 0 and expanded_options ) ) %]
                 <div class="span12">
                     <div id="advsearches" class="toptabs">
                         <ul>
                                     <legend>Limit to any of the following:</legend>
                                     <div class="row-fluid">
                                         [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
-                                            <div class="span3"><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') %]-[% itemtypeloo.number %]" name="limit" value="mc-[% itemtypeloo.ccl %]:[% itemtypeloo.code %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') %]-[% itemtypeloo.number %]">[% UNLESS ( noItemTypeImages ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl %]" alt="[% itemtypeloo.description %]" />[% END %]&nbsp;[% END %]
-                                            [% itemtypeloo.description %]</label></div>
+                                            [% IF (advsearchloo.advanced_search_type != 'itemtypes') OR (((!itemtypeloo.searchcategory) AND (itemtypeloo.cat == 0)) OR (itemtypeloo.cat == 1)) %]
+                                                <div class="span3">
+                                                    <input type="checkbox"
+                                                        id="[% itemtypeloo.ccl FILTER remove(',') %]-[% itemtypeloo.number %]"
+                                                        name="[% IF ( itemtypeloo.cat == 1 ) %]searchcat[% ELSE %]limit[% END %]"
+                                                        value="[% IF ( itemtypeloo.cat == 1 ) %][% itemtypeloo.code %][% ELSE %]mc-[% itemtypeloo.ccl %]:[% itemtypeloo.code %][% END %]"
+                                                    />
+                                                    <label for="[% itemtypeloo.ccl FILTER remove(',') %]-[% itemtypeloo.number %]">
+                                                        [% UNLESS ( noItemTypeImages ) %]
+                                                            [% IF ( itemtypeloo.imageurl ) %]
+                                                                <img border="0" src="[% itemtypeloo.imageurl %]" alt="[% itemtypeloo.description %]" />
+                                                            [% END %]
+                                                            &nbsp;
+                                                        [% END %]
+                                                        [% itemtypeloo.description %]
+                                                    </label>
+                                                </div>
                                             [% IF ( loop.last ) %]</div>[% ELSE %][% UNLESS ( loop.count % 4 ) %]</div><div class="row-fluid">[% END %][% END %]
+                                            [% END %]
                                         [% END %]
                                 </fieldset>
                             </div> <!-- / #advsearch-[% advsearchloo.advanced_search_type %] -->
                         [% END # / FOREACH advancedsearchesloop %]
                     </div> <!-- / #advsearches -->
                 </div> <!-- / .span12 -->
+              [% END %]
 
                 <div class="row-fluid">
+                  [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('pubdate').size > 0     and not expanded_options ) or
+                          ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('pubdate').size > 0 and expanded_options ) ) %]
                     <div class="span3">
                         <div id="pubrange">
                             <!-- PUB RANGE OPTION -->
                             <!-- /PUB RANGE OPTION -->
                         </div>
                     </div>
+                  [% END %]
 
+                  [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('language').size > 0     and not expanded_options ) or
+                          ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('language').size > 0 and expanded_options ) ) %]
                     <div class="span3">
                         <div id="langfilter">
                             <fieldset>
                             </fieldset>
                         </div> <!-- / #langfilter -->
                     </div> <!-- / .span3 -->
+                  [% END %]
 
+                  [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('location').size > 0     and not expanded_options ) or
+                          ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('location').size > 0 and expanded_options ) ) %]
                     [% UNLESS ( singleBranchMode ) %]
                         <div class="span3">
                             <!-- AVAILABILITY LIMITS -->
                             <!-- /AVAILABILITY LIMITS -->
                         </div> <!-- / .span3 -->
                     [% END # / UNLESS singleBranchMode %]
+                  [% END %]
 
+                  [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('sorting').size > 0     and not expanded_options ) or
+                          ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('sorting').size > 0 and expanded_options ) ) %]
                     <div class="span3">
                     <!-- RANK LIMITS -->
                         <div id="sortby">
                         </div>
                     <!-- RANK LIMITS -->
                     </div> <!-- / .span3 -->
+                  [% END %]
                 </div> <!-- / .row-fluid -->
 
-                [% IF ( expanded_options ) %]
+                [% IF ( ( OpacAdvSearchOptions     and OpacAdvSearchOptions.grep('subtype').size > 0     and not expanded_options ) or
+                        ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.grep('subtype').size > 0 and expanded_options ) ) %]
                     <div class="row-fluid">
                         [% IF ( usmarc ) %]
                             <!-- SUBTYPE LIMITS -->
                                     <div class="span3">
                                         <fieldset>
                                             <legend>Audience</legend>
-                                            <select name="limit" class="subtype">
+                                            <select id="subtype_audience" name="limit" class="subtype">
                                             <option value="" selected="selected" class="menuheader">Any audience</option>
                                                 <option value="aud:a">Preschool</option>
                                                 <option value="aud:b">Primary</option>
                                     <div class="span3">
                                         <fieldset>
                                             <legend>Content</legend>
-                                            <select name="limit" class="subtype">
+                                            <select id="subtype_content"  name="limit" class="subtype">
                                                 <option value="" selected="selected" class="menuheader">Any content</option>
                                                 <option value="fic:1">Fiction</option>
-                                                <option value="fic:0">Non fiction</option>
+                                                <option value="fic:0">Non-fiction</option>
                                                 <option value="bio:b">Biography</option>
                                                 <option value="mus:j">Musical recording</option>
                                                 <option value="mus:i">Non-musical recording</option>
                                     <div class="span3">
                                         <fieldset>
                                             <legend>Format</legend>
-                                            <select name="limit" class="subtype">
+                                            <select id="subtype_format" name="limit" class="subtype">
                                                 <option value="" selected="selected" class="menuheader">Any format</option>
                                                 <option value="l-format:ta">Regular print</option>
                                                 <option value="l-format:tb">Large print</option>
                                     <div class="span3">
                                         <fieldset>
                                             <legend>Additional content types for books/printed materials</legend>
-                                            <select name="limit" class="subtype">
+                                            <select id="subtype_additional" name="limit" class="subtype">
                                                 <option value="">Any</option>
                                                 <option value="ctype:a">Abstracts/summaries</option>
                                                 <option value="ctype:b">Bibliographies</option>
                                         </fieldset>
                                     </div> <!-- / .span3 -->
                                 </div> <!-- / #subtypes -->
-                            [% END # / IF usmarc %]
+                            <!-- SUBTYPE LIMITS -->
+                        [% END # / IF usmarc %]
 
                             [% IF ( UNIMARC ) %]
                                 <div id="subtypes_unimarc">
                                     [% INCLUDE 'subtypes_unimarc.inc' %]
                                 </div>
                             [% END %]
-                        </div> <!-- / .span4 -->
+
                     </div> <!-- / .row-fluid -->
                 [% END # / IF expanded_options %]
             </div> <!-- / .row-fluid -->
-        </div> <!-- / .container-fluid -->
-    </div> <!-- / .main -->
 
-        <div class="container-fluid">
+        [% IF ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.size > 0 and expanded_options ) or
+              ( OpacAdvSearchOptions     and OpacAdvSearchOptions.size > 0     and not expanded_options ) %]
             <div class="row-fluid">
                 <div class="span12">
                     <div class="text-center">
                     </div>
                 </div> <!-- / .span12 -->
             </div> <!-- / .row-fluid -->
-        </div> <!-- / .container-fluid -->
+        [% END %]
+   </div> <!-- / .main -->
 </form>
 
 [% INCLUDE 'opac-bottom.inc' %]
 [% BLOCK searchbuttons %]
     <p>
         <input class="btn btn-success" type="submit" accesskey="s" name="do" title="Search" value="Search" />
-        [% IF ( expanded_options ) %]
-            <a href="/cgi-bin/koha/opac-search.pl?expanded_options=0">[Fewer options]</a>
-        [% ELSE %]
-            <a href="/cgi-bin/koha/opac-search.pl?expanded_options=1">[More options]</a>
+
+        [% IF ( OpacAdvSearchMoreOptions and OpacAdvSearchMoreOptions.size > 0 ) %]
+            [% IF expanded_options %]
+                <a href="/cgi-bin/koha/opac-search.pl?expanded_options=0" class="btn btn-default more-less-options">Fewer options</a>
+            [% ELSIF not expanded_options %]
+                <a href="/cgi-bin/koha/opac-search.pl?expanded_options=1" class="btn btn-default more-less-options">More options</a>
+            [% END %]
         [% END %]
-        <a href="/cgi-bin/koha/opac-search.pl?do=Clear">[New search]</a>
+
+        <a href="/cgi-bin/koha/opac-search.pl?do=Clear" class="btn btn-default new-search">New search</a>
     </p>
 [% END %]
 
 [% BLOCK jsinclude %]
+<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.deserialize.min.js"></script>
+<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
 <script type="text/javascript">//<![CDATA[
-    $(document).ready(function() {
-        $('#advsearches').tabs();
+$(document).ready(function() {
+    $('#advsearches').tabs();
+    jQuery.cookie.json = true;
+    //$('#advsearches > ul').tabs();
+
+    [% IF ( ReturnToSearch ) %]
+        if (form_serialized = jQuery.cookie("form_serialized")) {
+            $('#advsearch form').deserialize(form_serialized);
+        }
+        if (form_serialized_limits = jQuery.cookie("form_serialized_limits")) {
+            $('#language-limit')     .val(form_serialized_limits[0]);
+            $('#branchloop')         .val(form_serialized_limits[1]);
+            $('#subtype_audience')   .val(form_serialized_limits[2]);
+            $('#subtype_content')    .val(form_serialized_limits[3]);
+            $('#subtype_format')     .val(form_serialized_limits[4]);
+            $('#subtype_additional') .val(form_serialized_limits[5]);
+            $('#locloop')            .val(form_serialized_limits[6]);
+        }
+    [% ELSE %]
+        //Clear all form cookies
+        jQuery.removeCookie("form_serialized", { path: '/'});
+        jQuery.removeCookie("form_serialized_itype", { path: '/'});
+        jQuery.removeCookie("form_serialized_limits", { path: '/'});
+        jQuery.removeCookie("num_paragraph", { path: '/'});
+        jQuery.removeCookie("search_path_code", { path: '/'});
+    [% END %]
+    $('#advsearch form').submit(function() {
+        form_serialized = $(this).serialize();
+        jQuery.cookie("form_serialized", form_serialized,{ path: '/'});
+        form_serialized_limits = [
+            $('#language-limit').val(),   $('#branchloop').val(),
+            $('#subtype_audience').val(), $('#subtype_content').val(),
+            $('#subtype_format').val(),   $('#subtype_additional').val(),
+            $('#locloop').val()
+        ];
+        jQuery.cookie("form_serialized_limits", form_serialized_limits,{ path: '/'});
+        [% IF ( expanded_options ) %]
+        var numPar = $("#booleansearch fieldset p").size();
+        if (numPar > [% search_boxes_count %]){
+            jQuery.cookie("num_paragraph", numPar,{ path: '/'});
+        }else{
+            jQuery.removeCookie("num_paragraph", { path: '/'});
+        }
+        jQuery.cookie("search_path_code", 'exs',{ path: '/'});
+        [% ELSE %]
+        jQuery.cookie("search_path_code", 'ads',{ path: '/'});
+        jQuery.removeCookie("num_paragraph", { path: '/'});
+        [% END %]
     });
+
+});
     /* This function allows to display a new field to search.
     */
     $(document).on("click", '.ButtonPlus', function(e) {
     });
     //]]>
 </script>
-[% END %]
\ No newline at end of file
+[% END %]