Bug 23194: Allow HTML in item public notes to be processed on OPAC details
[koha-equinox.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-detail.tt
index d8a93cb..e6bccdf 100644 (file)
 [% INCLUDE 'doc-head-open.inc' %]
 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% title | html %][% FOREACH subtitl IN subtitle %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %] [% subtitl.subfield | html %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% IF ( bidi ) %]
-  [% BLOCK cssinclude %][% Asset.css("css/right-to-left.css") | $raw %][% END %]
-[% END %]
-[% IF ( OpacStarRatings != 'disable' ) %]
-    [% BLOCK cssinclude %][% Asset.css("css/jquery.rating.css") | $raw %][% END %]
-[% END %]
-[% INCLUDE greybox.inc %]
     [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %]
 </head>
+[% BLOCK cssinclude %][% END %]
 [% INCLUDE 'bodytag.inc' bodyid='opac-detail' bodyclass='scrollto' %]
 [% INCLUDE 'masthead.inc' %]
 
 
                                 [% SET rating_avg = ratings.get_avg_rating() %]
                                 [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
-                                [% FOREACH i  IN [ 1 2 3 4 5  ] %]
-                                    [% IF rating_avg_int == i && borrowernumber %]
-                                        <input class="auto-submit-star" type="radio" name="rating"  value="[% i | html %]"  checked="checked" />
-                                    [% ELSIF rating_avg_int == i %]
-                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" checked="checked" disabled="disabled" />
-                                    [% ELSIF borrowernumber  %]
-                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" />
-                                    [% ELSE   %]
-                                        <input class="auto-submit-star" type="radio" name="rating" value="[% i | html %]" disabled="disabled" />
-                                    [% END %]
+
+                                [% IF ( borrowernumber ) %]
+                                    <select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off">
+                                [% ELSE %]
+                                    <select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off">
                                 [% END %]
+                                    [% IF ( rating_avg_int == 0 ) %]
+                                        <option value="" selected="selected"></option>
+                                    [% END %]
+                                    [% FOREACH i IN [ 1 2 3 4 5  ] %]
+                                        [% IF rating_avg_int == i %]
+                                            <option value="[% i | html %]" selected="selected">[% i | html %]</option>
+                                        [% ELSE %]
+                                            <option value="[% i | html %]">[% i | html %]</option>
+                                        [% END %]
+                                    [% END %]
+                                </select>
+                                <img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" />
 
                                 <!-- define some hidden vars for ratings -->
 
                                 [% UNLESS ( rating_readonly ) %]&nbsp;  <input name="rate_button" type="submit" value="Rate me" />[% END %]&nbsp;
 
                                 [% IF my_rating %]
-                                    <span id="rating_value_text">your rating: [% my_rating.rating_value | html %], </span>
+                                    <span id="rating_value_text">Your rating: [% my_rating.rating_value | html %].</span>
+                                    <span id="cancel_rating_text"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
                                 [% ELSE %]
                                     <span id="rating_value_text"></span>
+                                    <span id="cancel_rating_text" style="display:none;"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
                                 [% END %]
 
-                                <span id="rating_text">average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span>
+                                <span id="rating_text">Average rating: [% rating_avg | html %] ([% ratings.count | html %] votes)</span>
                             </div>
                         </form>
                     [% END # / IF OpacStarRatings != 'disable' %]
                                 [% IF ( subscription.closed ) %]
                                     <p class="subscription_closed">This subscription is closed.</p>
                                 [% END %]
+                                [% IF ( subscription.location ) %]
+                                  <p class="subscription_location">Location: [% AuthorisedValues.GetByCode( 'LOC', subscription.location, 1 ) | html %]
+                                [% END %]
                                 [% IF ( subscription.callnumber ) %]
                                   <p class="subscription_callnumber">Call number: [% subscription.callnumber | html %]</p>
                                 [% END %]
                                     [% END %]
                                 </span>[% END %]
                                 [% IF ( subscription.missinglist ) %]
-                                    <p class="subscription_missing">Missing issues: [% subscription.missinglist | html %] </p>
+                                    <p class="subscription_missing">Missing issues: [% subscription.missinglist | html | html_line_break %] </p>
                                 [% END %]
                                 [% IF ( subscription.opacnote ) %]
                                     <p class="subscription_opacnote">[% subscription.opacnote | html | html_line_break %]</p>
                                         [% FOREACH latestserial IN subscription.latestserials %]
                                             <tr>
                                                 <td class="serialseq">[% latestserial.serialseq | html %]</td>
-                                                <td class="publisheddate">[% latestserial.publisheddate | html %]</td>
-                                                <td class="planneddate">[% latestserial.planneddate | html %]</td>
+                                                <td class="publisheddate"><span title="[% latestserial.publisheddate | html %]">[% latestserial.publisheddate | $KohaDates %]</span></td>
+                                                <td class="planneddate"><span title="[% latestserial.planneddate | html %]">[% latestserial.planneddate | $KohaDates %]</span></td>
                                                 <td class="serial_status">
                                                     [% IF (latestserial.status1 ) %]<span>Expected</span>[% END %]
                                                     [% IF (latestserial.status2 ) %]<span>Arrived</span>[% END %]
                     [% END %]
 
                     [% IF ( Koha.Preference('OpacLocationOnDetail') == 'column' && itemdata_location ) %]
-                        <td class="shelving_location">[% ITEM_RESULT.location_description | html %]</td>
+                        <td class="shelving_location"><span class="shelvingloc">[% ITEM_RESULT.location_description | html %]</span></td>
                     [% END %]
 
                     <td class="call_no" property="sku">
                     [% END %]
                     [% IF ( itemdata_copynumber ) %]<td class="copynumber">[% ITEM_RESULT.copynumber | html %]</td>[% END %]
                     <td class="status">[% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT %][% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td>
-                    [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes | html %]</td>[% END %]
+                    [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes | $raw %]</td>[% END %]
                     <td class="date_due"><span title="[% ITEM_RESULT.datedue | html %]">[% ITEM_RESULT.datedue | $KohaDates  as_due_date => 1 %]</span></td>
                         <td class="barcode" property="serialNumber">[% ITEM_RESULT.barcode | html %]</td>
                     [% IF holds_count.defined || show_priority %]
                                             [% r.course.course_name | html %]
                                             <!--[% IF r.course.course_number %] [% r.course.course_number | html %] [% END %]-->
                                             [% IF r.course.section %] [% r.course.section | html %] [% END %]
-                                            [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term ) | html %] [% END %]
+                                            [% IF r.course.term %] [% AuthorisedValues.GetByCode( 'TERM', r.course.term, 1 ) | html %] [% END %]
                                             </a>
                                         </p>
                                     [% END %]
 [% BLOCK jsinclude %]
 [% INCLUDE 'datatables.inc' %]
 [% INCLUDE 'columns_settings.inc' %]
+[% INCLUDE greybox.inc %]
 [% IF ( SocialNetworks ) %]
-    //<![CDATA[
-      {lang: '[% lang | html %]'}
-    //]]>
-    </script>
     <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
 [% END %]
-[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %][% END %]
+[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %][% END %]
 
 [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %]
 
                 { "targets": [ -1 ], "sortable": false, "searchable": false },
                 { "type": "title-string", "targets" : [ "title-string" ] }
                 ],
-            "bKohaColumnsUseNames": true
+            "bKohaColumnsUseNames": true,
+            "autoWidth": false
         }, columns_settings);
 
         KohaTable("#otherholdingst", {
                 { "targets": [ -1 ], "sortable": false, "searchable": false },
                 { "type": "title-string", "targets" : [ "title-string" ] }
                 ],
-            "bKohaColumnsUseNames": true
+            "bKohaColumnsUseNames": true,
+            "autoWidth": false
         }, columns_settings);
 
         var serial_column_settings = [% ColumnsSettings.GetColumns( 'opac', 'biblio-detail', 'subscriptionst', 'json' ) | $raw %];
 
         KohaTable("#subscriptionst", {
             dom: '<"clearfix">t',
+            "sorting": [[ 1, "desc" ]],
             "columnDefs": [
                 { "type": "title-string", "targets" : [ "title-string" ] }
                 ],
+            "autoWidth": false,
             "bKohaColumnsUseNames": true
         }, serial_column_settings);
 
 
     $('input[name="rate_button"]').remove();
 
-    $(function () {
-      $(".auto-submit-star").rating({
-        cancel: _("Cancel rating"),
-        callback: function (value, link) {
-
-          // if the new value equals the old value, dont execute callback...
-          // just do nothing!
-          if ($("#rating_value").attr("value") != value) {
-
-            $(function () {
-
-              $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
+    var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true;
+    $('#star_rating').barrating({
+        theme: 'fontawesome-stars',
+        showSelectedRating: false,
+        allowEmpty: true,
+        deselectable: false,
+        readonly: rating_enabled,
+        onSelect: function(value, text) {
+            $("#rating-loading").show();
+            $.post("/cgi-bin/koha/opac-ratings-ajax.pl", {
                 rating_old_value: $("#rating_value").attr("value"),
                 borrowernumber: "[% borrowernumber | html %]",
                 biblionumber: "[% biblio.biblionumber | html %]",
                 rating_value: value,
                 auth_error: value
-              }, function (data) {
-
-                if (data.auth_status != 'ok') {
-                  window.alert(_("Your CGI session cookie is not current. Please refresh the page and try again."));
-                } else {
-                  $("#rating_value").val(data.rating_value);
-
-                  if (data.rating_value) {
-                    $("#rating_value_text").text(_("your rating: %s, ").format(data.rating_value));
-                  } else {
-                    $("#rating_value_text").text('');
-                  }
-
-                  $("#rating_text").text(_("average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
-
-                }
-              }, "json");
-            });
-          };
+            }, function (data) {
+                    $("#rating_value").val(data.rating_value);
+                    if (data.rating_value) {
+                        $("#rating_value_text").text(_("Your rating: %s, ").format(data.rating_value));
+                        $("#cancel_rating_text").show();
+                    } else {
+                        $("#rating_value_text").text('');
+                        $("#cancel_rating_text").hide();
+                    }
+                    $("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total));
+                    $("#rating-loading").hide();
+            }, "json");
         }
-      });
     });
-    // -----------------------------------------------------
+
+    $("#cancel_rating_text a").on("click", function(e){
+        e.preventDefault();
+        $("#star_rating").barrating("set", "");
+    });
+
 [% END # / IF ( OpacStarRatings != 'disable' )%]
 
 [% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %]
             }
         }
     [% END # / IF IDreamBooksReviews || IDreamBooksReadometer %]
-
-//]]>
 </script>
 
 [% IF OPACPopupAuthorsSearch %]