Bug 14100: Fix 3 occurrences more
[koha_ffzg] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-reserve.tt
index ecccb6e..a864dde 100644 (file)
@@ -1,10 +1,12 @@
 [% USE Koha %]
-[% INCLUDE 'doc-head-open.inc' %][% LibraryNameTitle or "Koha online" %] catalog ›  Placing a hold
+[% USE KohaDates %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Placing a hold</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% BLOCK cssinclude %][% END %]
 </head>
 
-<body id="opac-holds">
+[% INCLUDE 'bodytag.inc' bodyid='opac-holds' %]
 [% INCLUDE 'masthead.inc' %]
 
 <div class="main">
                             <div id="bad_data" class="alert">ERROR: Internal error: incomplete hold request.</div>
                         [% END %]
 
+                        [% IF ( expired_patron ) %]
+                            <div id="expired_patron" class="alert"><strong>Sorry</strong>, you cannot place holds because your library card has expired.</p><p>Please contact your librarian if you wish to renew your card.</div>
+                        [% END %]
+
                     [% ELSE %]
 
                         [% IF ( none_available ) %]
                             </div>
                         [% END %]
 
+                        [% IF ( new_reserves_allowed ) %]
+                            <div id="new_reserves_allowed" class="alert">
+                                <strong>Sorry,</strong> you can only place [% new_reserves_allowed %] more holds. Please uncheck the checkboxes for the items you wish to not place holds on.
+                            </div>
+                        [% END %]
+
                         <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
                             <input type="hidden" name="place_reserve" value="1"/>
                             <!-- These values are set dynamically by js -->
                                         </p>
 
                                         [% UNLESS ( bibitemloo.holdable ) %]
+                                            [% IF ( bibitemloo.ageRestricted ) %]
+                                                <div class="alert">Sorry, you are too young to reserve this material.</div>
+                                            [% END %]
                                             [% IF ( bibitemloo.already_reserved ) %]
                                                 <div class="alert">You have already requested this title.</div>
                                             [% ELSE %]
                                                         <li class="itype">
                                                             <span class="label">Item type: </span>
                                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
-                                                            [% bibitemloo.description %]
+                                                            [% bibitemloo.translated_description %]
                                                         </li>
                                                     [% END %]
 
-                                                    [% IF showholds || showpriority %]
+                                                    [% SET OPACShowHoldQueueDetails = Koha.Preference('OPACShowHoldQueueDetails') %]
+                                                    [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'priority' %]
                                                         <li class="priority">
-                                                            <span class="label">Holds and priority: </span>
-                                                            [% IF showpriority %] [% bibitemloo.rank %] [% END %]
-                                                            [% IF showholds && showpriority %] out of [% END %]
-                                                            [% IF showholds %] [% bibitemloo.reservecount %] [% END %]
+                                                            <span class="label">Your priority: </span>
+                                                            [% bibitemloo.rank %]
+                                                        </li>
+                                                    [% END %]
+
+                                                    [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'holds' %]
+                                                        <li class="holds-count">
+                                                            <span class="label">Number of holds: </span>
+                                                            [% bibitemloo.reservecount %]
                                                         </li>
                                                     [% END %]
 
                                                             </li>
                                                         [% END # / IF OpacHoldNotes %]
 
-                                                        [% IF ( OPACItemHolds ) %]
+                                                        <li>
+                                                        </li>
+                                                        [% IF bibitemloo.itemholdable %]
                                                             <!-- ITEM HOLDS -->
-                                                            <li class="lradio">
-                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available copy</label>
-                                                                [% UNLESS ( bibitemloo.holdable ) %]
-                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]" id="reqany_[% bibitemloo.biblionumber %]" class="selectany" value="Any" disabled="disabled" />
-                                                                [% ELSE %]
-                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]" id="reqany_[% bibitemloo.biblionumber %]" class="selectany" value="Any" checked="checked" />
-                                                                [% END %]
-
-                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific copy</label>
-                                                                [% UNLESS ( bibitemloo.holdable ) %]
-                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]" id="reqspecific_[% bibitemloo.biblionumber %]" class="selectspecific" disabled="disabled" value="Specific" />
-                                                                [% ELSE %]
-                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]" id="reqspecific_[% bibitemloo.biblionumber %]" class="selectspecific" value="Specific" />
+                                                            <li class="lradio place_on_type" style="display:none;">
+                                                                [% IF NOT bibitemloo.force_hold %]
+                                                                    <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
+                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
+                                                                            id="reqany_[% bibitemloo.biblionumber %]"
+                                                                            class="selectany"
+                                                                            value="Any"
+                                                                            checked="checked"
+                                                                    />
                                                                 [% END %]
+                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
+                                                                <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
+                                                                       id="reqspecific_[% bibitemloo.biblionumber %]"
+                                                                       class="selectspecific"
+                                                                       value="Specific"
+                                                                />
                                                             </li>
-                                                        [% END # / IF OPACItemHolds %]
+                                                        [% END # / IF bibitemloo.itemholdable %]
                                                     </ul>
 
-                                                    [% IF ( OPACItemHolds ) %]
+                                                    [% IF bibitemloo.itemholdable %]
                                                         <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
-                                                            <caption>Select a specific copy:</caption>
+                                                            <caption>Select a specific item:</caption>
                                                             <tr>
-                                                                <th>Copy</th>
+                                                                <th>Copy number</th>
                                                                 [% IF ( item_level_itypes ) %]
                                                                     <th>Item type</th>
                                                                 [% END %]
 
                                                             [% FOREACH itemLoo IN bibitemloo.itemLoop %]
                                                                 <tr class="[% itemLoo.backgroundcolor %]">
-                                                                    <td class="copy">
+                                                                    <td class="copynumber">
                                                                         [% IF ( itemLoo.available ) %]
                                                                             <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]" value="[% itemLoo.itemnumber %]" />
                                                                         [% ELSE %]
-                                                                            <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]" />
+                                                                            <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]"
+                                                                                   style="display:none;" />
                                                                             <img src="[% interface %]/lib/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
                                                                         [% END %]
 
                                                                                     <img src="[% itemLoo.imageurl %]" alt="" />
                                                                                 [% END %]
                                                                             [% END %]
-                                                                            [% itemLoo.description %]
+                                                                            [% itemLoo.translated_description %]
                                                                         </td>
                                                                     [% END %]
 
                                                                                 [% END %]
                                                                                 [% itemLoo.ExpectedAtLibrary %] since
                                                                                 [% IF ( itemLoo.waitingdate ) %]
-                                                                                    [% itemLoo.waitingdate %]
+                                                                                    [% itemLoo.waitingdate | $KohaDates %]
                                                                                 [% ELSE %]
                                                                                     [% IF ( itemLoo.reservedate ) %]
                                                                                         [% itemLoo.reservedate %]
                                                                 </tr>
                                                             [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
                                                         </table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
-                                                    [% END # / IF ( OPACItemHolds )%]
+                                                    [% END # / IF ( bibitemloo.itemholdable )%]
                                                 </div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
                                             </fieldset>
                                         [% END # / IF ( bibitemloo.holdable ) %]
 [% INCLUDE 'calendar.inc' %]
 <script type="text/javascript">
 // <![CDATA[
-    var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
+    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
     var ForceHoldNotesReasons=new Array(
-       _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."),
+       _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific item information may be helpful."),
        "*** Add a new reason above this line ***" );
        // NOTE: Do not renumber reasons; this will affect use of existing ones.
 
             $(this).closest("td").find("input").val("");
             e.preventDefault();
         });
+
+    // Select the first item available
+    function select_first_available(id){
+        var radios = $("input:radio[name='checkitem_" + id + "']");
+        $(radios).first().attr("checked", "checked");
+    }
+
     $(document).ready(function() {
         $("#hold-request-form").preventDoubleFormSubmit();
         var copiesRowId = null;
         var wasSpecific = false;
         var lastCopiesRowId = null;
+
+        $(".toggle-hold-options").show();
+        $(".hold-options").hide();
+        $(".holddatefrom,.holddateto").prop("readOnly", true);
+
         $(".checkitem").parent().click(function(e){
             if(e.target.tagName.toLowerCase() == 'td'){
                 $(this).find("input.checkitem").each( function() {
-                    $(this).attr('checked', !$(this).attr('checked'));
+                    $(this).attr('checked', 'checked');
                 });
             }
         });
+
+        // click on a first td check the confirmjs checkbox
+        $("td.hold").click(function(e){
+          if(e.target.tagName.toLowerCase() == 'td'){
+            $(this).find("input.confirmjs").each( function() {
+               $(this).attr('checked', !$(this).attr('checked'));
+               $(this).change();
+            });
+          }
+        });
+
+        $(".toggle-hold-options").on("click",function(e){
+            e.preventDefault();
+            toggleLink = $(this);
+            var optionsID = this.id.replace("toggle-hold-options-","");
+            $("#hold-options-"+optionsID).toggle(0, function() {
+                toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
+            });
+        });
+
         // Hides all 'specific copy' table rows on load.
         $(".copiesrow").hide();
 
+        [% FOREACH bibitemloo IN bibitemloop %]
+          [% IF bibitemloo.force_hold %]
+            $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
+            $("#reqspecific_[% bibitemloo.biblionumber %]").click();
+            $("#copiesrow_[% bibitemloo.biblionumber %]").show();
+          [% END %]
+        [% END %]
+
         // Insert reasons for forced hold notes
         $(".forcenotesreason").each(function(){
             biblioNum = suffixOf($(this).attr("id"), "_");
             }
         });
 
-        $("#place_on_hdr").show();
-        $(".place_on_type").show();
-        $("#place_on_hdr,.place_on_type,.toggle-hold-options").show();
-        $(".hold-options").hide();
-        $(".holddatefrom,.holddateto").prop("readOnly", true);
-
         $(".date-format").each(function(){
             if($(this).hasClass("to")){ var op = "to"; }
             if($(this).hasClass("from")){ var op = "from"; }
         $(".confirmjs_hold").each(function(){
             var bib = $(this).attr("title");
             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
-            html += "value=\"" + bib + "\"/> " + _("Place a hold on") + " </label> ";
+            html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
             $(this).html(html);
         });
         $(".confirmjs_nohold").each(function(){
             var bib = $(this).attr("title");
             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
-            html += "value=\"" + bib + "\"/>" + _("Place a hold on: ") + "</label>";
+            html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
             $(this).html(html);
         });
 
-        // Make sure a specific item was selected where specified
-        // before moving on to a new item.
-        function changeSelection (newCopiesRowId, isSpecific) {
-            if (copiesRowId && ((copiesRowId != newCopiesRowId) || (wasSpecific != isSpecific))) {
-                var biblioNum = suffixOf(copiesRowId, "_");
-
-                // If the 'specific copy' radio button was checked
-                  if (wasSpecific && (copiesRowId != newCopiesRowId)) {
-                    // Find the selected copy
-                    var item = $(".checkitem_" + biblioNum + ":checked");
-                    if ($(item).size() == 0) {
-                        alert(MSG_NO_COPY_SELECTED);
-                        return false;
-                    }
-                }
-            }
-            copiesRowId = newCopiesRowId;
-            wasSpecific = isSpecific;
-            return true;
-        }
+        // expand or collapse the copiesrow tr
+        function toggle_copiesrow(biblioNum) {
+            var checkbox = $("input:checkbox[value='"+biblioNum+"']");
+            newCopiesRowId = "#copiesrow_" + biblioNum;
+            var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
+            // If the checkbox is checked AND we want a specific item, we display the items block
+            if ( $(checkbox).is(":checked") && select_specific ) {
+                $(newCopiesRowId).show();
+            } else {
+                $(newCopiesRowId).hide();
+             }
+        };
 
-        // When 'specific copy' radio button is clicked
-        $(".selectspecific").click(function() {
+        $("#place_on_hdr").show();
 
-            // Make sure all other specific copy table rows are hidden
-            biblioNum = suffixOf($(this).attr("id"), "_");
-            newCopiesRowId = "#copiesrow_" + biblioNum;
+        $(".place_on_type").show();
+        // onload, selectany is checked
+        $(".selectany").attr("checked", "checked");
+
+        // If the user is *allowed* to choose a specific item
+        // The first one is preselected
+        $("table.copiesrow").each(function(){
+            var id = suffixOf($(this).attr("id"), "_");
+            select_first_available(id);
+        });
 
-            if (!changeSelection(newCopiesRowId, true)) {
-                return false;
+        // On confirmsjs change
+        $(".confirmjs").change(function(){
+            var id = suffixOf($(this).attr("id"), "_");
+            // If I m checked, I enable radio buttons
+            if ( $(this).is(":checked") ) {
+                $("#reqspecific_" + id).attr("disabled", false);
+                $("#reqany_" + id).attr("disabled", false);
             }
+            // Else its are disabled
+            else {
+                $("#reqspecific_" + id).attr("disabled", "disabled");
+                $("#reqany_" + id).attr("disabled", "disabled");
+            }
+            // expand or collaspe the items block
+            toggle_copiesrow(id);
+        });
 
-            // Show the specific copy table for this radio button.
-            $(newCopiesRowId).show();
+        // When 'specific copy' or 'first available' radio button is clicked
+        $(".selectspecific, .selectany").click(function() {
+            var id = suffixOf($(this).attr("id"), "_");
+            toggle_copiesrow(id);
         });
 
-        // When 'first available' radion button is clicked
-        $(".selectany").click(function() {
-            // Make sure all other specific copy table rows are hidden
+        // Show or hide holds notes
+        $(".shownotes").click(function(){
             biblioNum = suffixOf($(this).attr("id"), "_");
-            newCopiesRowId = "#copiesrow_" + biblioNum;
-
-            if (!changeSelection(newCopiesRowId, false)) {
-                return false;
-            }
-
-            // Hide the copies table row
-            $(newCopiesRowId).hide();
+            $("#notesrow_"+biblioNum).toggle();
         });
 
         // When 'Place Hold' button is clicked
             var biblionumbers = "";
             var selections = "";
 
+            [% IF new_reserves_allowed %]
+                if ($(".confirmjs:checked").size() > [% new_reserves_allowed %] ) {
+                    alert(MSG_MAX_HOLDS_EXCEEDED);
+                    return false;
+                }
+            [% END %]
+
             if ($(".confirmjs:checked").size() == 0) {
                 alert(MSG_NO_RECORD_SELECTED);
                 return false;
             });
 
             if (badBib) {
-                alert(MSG_NO_COPY_SELECTED);
+                alert(MSG_NO_ITEM_SELECTED);
                 return false;
             }
 
             return true;
         });
 
-        $(".toggle-hold-options").on("click",function(e){
-            e.preventDefault();
-            toggleLink = $(this);
-            var optionsID = this.id.replace("toggle-hold-options-","");
-            $("#hold-options-"+optionsID).toggle(0, function() {
-                toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
-            });
-        });
-
         [% FOREACH bibitemloo IN bibitemloop %]
             [% IF ( bibitemloo.holdable ) %]
                 // http://jqueryui.com/demos/datepicker/#date-range