View | Details | Raw Unified | Return to bug 25110
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 56-62 OPAC: Link Here
56
            - "Show star-ratings on"
56
            - "Show star-ratings on"
57
            - pref: OpacStarRatings
57
            - pref: OpacStarRatings
58
              choices:
58
              choices:
59
                  all: "results and details"
59
                  all: "results, details, and user"
60
                  disable: "no"
60
                  disable: "no"
61
                  details: "only details"
61
                  details: "only details"
62
            - "pages."
62
            - "pages."
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc (+41 lines)
Line 0 Link Here
1
<form method="post" action="/cgi-bin/koha/opac-ratings.pl">
2
    <div class="results_summary ratings" id="rating-[% item.itemnumber | html %]">
3
4
        [% SET rating_avg = item.ratings.get_avg_rating() %]
5
        [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %]
6
7
        <select class="star_rating" id="star_rating-[% item.itemnumber | html %]" name="rating" autocomplete="off" data-biblionumber="[% item.biblionumber | html %]" data-context="rating-[% item.itemnumber | html %]">
8
9
            [% IF ( rating_avg_int == 0 ) %]
10
                <option value="" selected="selected"></option>
11
            [% END %]
12
            [% FOREACH i IN [ 1 2 3 4 5  ] %]
13
                [% IF rating_avg_int == i %]
14
                    <option value="[% i | html %]" selected="selected">[% i | html %]</option>
15
                [% ELSE %]
16
                    <option value="[% i | html %]">[% i | html %]</option>
17
                [% END %]
18
            [% END %]
19
        </select>
20
        <img id="rating-loading" style="display:none" src="[% interface | html %]/[% theme | html %]/images/spinner-small.gif" alt="" />
21
22
        <!-- define some hidden vars for ratings -->
23
24
        <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" />
25
        <input type="hidden" name="rating_value" class="rating_value" value="[% item.my_rating.rating_value | html %]" />
26
27
        <input name="rate_button" type="submit" value="Rate me" />
28
29
        [% IF item.my_rating %]
30
            <div>
31
                <span class="rating_value_text">Your rating: [% item.my_rating.rating_value | html %].</span>
32
                <span class="cancel_rating_text"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
33
            </div>
34
        [% ELSE %]
35
            <span class="rating_value_text"></span>
36
            <span class="cancel_rating_text" style="display:none;"><a href="#" data-context="star_rating-[% item.itemnumber | html %]"><i class="fa fa-remove"></i> Cancel rating</a>.</span>
37
        [% END %]
38
39
        <div class="rating_text">Average rating: [% rating_avg | html %] ([% item.ratings.count | html %] votes)</div>
40
    </div>
41
</form>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-18 / +10 lines)
Lines 145-168 Link Here
145
                                                [% END %]
145
                                                [% END %]
146
                                                <p class="results-summary item-details">[% issue.author | html %]</p>
146
                                                <p class="results-summary item-details">[% issue.author | html %]</p>
147
147
148
                                                    [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' && issue.my_rating ) %]
148
                                                    [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' ) %]
149
                                                        <div class="results_summary ratings">
149
                                                        [% INCLUDE 'user-star-ratings.inc' item=issue %]
150
                                                            <div class="br-wrapper br-theme-fontawesome-stars">
150
                                                    [% END %]
151
                                                                <div class="br-widget br-readonly">
152
                                                                    [% FOREACH i IN [ 1 2 3 4 5  ] %]
153
                                                                        [% IF issue.my_rating.rating_value == i %]
154
                                                                            <a href="#" class="br-selected br-current"></a>
155
                                                                        [% ELSIF issue.my_rating.rating_value > i %]
156
                                                                            <a href="#" class="br-selected"></a>
157
                                                                        [% ELSE %]
158
                                                                            <a href="#"></a>
159
                                                                        [% END %]
160
                                                                    [% END %]
161
                                                                </div>
162
                                                            </div>
163
                                                            Rated on [% issue.my_rating.timestamp | $KohaDates %]
164
                                                        </div> <!-- / .results_summary -->
165
                                                    [% END # / IF OpacStarRatings %]
166
151
167
                                                </td>
152
                                                </td>
168
                                                <td>
153
                                                <td>
Lines 235-239 Link Here
235
            }
220
            }
236
        });
221
        });
237
    });
222
    });
223
    var borrowernumber = "[% borrowernumber | html %]";
224
    var MSG_YOUR_RATING = _("Your rating: %s, ");
225
    var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)");
238
</script>
226
</script>
227
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
228
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
229
        [% Asset.js("js/ratings.js") | $raw %]
230
    [% END %]
239
[% END %]
231
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+11 lines)
Lines 294-299 Link Here
294
                                                <td class="title">
294
                                                <td class="title">
295
                                                    <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=ISSUE %]</a>
295
                                                    <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ISSUE.biblionumber | html %]">[% INCLUDE 'biblio-title.inc' biblio=ISSUE %]</a>
296
                                                    [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %]
296
                                                    [% IF ( ISSUE.enumchron ) %] [% ISSUE.enumchron | html %][% END %]
297
298
                                                    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
299
                                                        [% INCLUDE 'user-star-ratings.inc' item=ISSUE %]
300
                                                    [% END %]
297
                                                </td>
301
                                                </td>
298
302
299
                                                <td class="author">[% ISSUE.author | html %]</td>
303
                                                <td class="author">[% ISSUE.author | html %]</td>
Lines 963-969 Link Here
963
            }
967
            }
964
        });
968
        });
965
        //]]>
969
        //]]>
970
        var borrowernumber = "[% borrowernumber | html %]";
971
        var MSG_YOUR_RATING = _("Your rating: %s, ");
972
        var MSG_AVERAGE_RATING = _("Average rating: %s (%s votes)");
966
    </script>
973
    </script>
974
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
975
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
976
        [% Asset.js("js/ratings.js") | $raw %]
977
    [% END %]
967
    [% IF Koha.Preference('OverDriveCirculation') %]
978
    [% IF Koha.Preference('OverDriveCirculation') %]
968
    [% Asset.js("js/overdrive.js") | $raw %]
979
    [% Asset.js("js/overdrive.js") | $raw %]
969
    <script>
980
    <script>
(-)a/opac/opac-user.pl (-1 / +7 lines)
Lines 43-48 use Koha::Patrons; Link Here
43
use Koha::Patron::Messages;
43
use Koha::Patron::Messages;
44
use Koha::Patron::Discharge;
44
use Koha::Patron::Discharge;
45
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::Ratings;
46
use Koha::Token;
47
use Koha::Token;
47
48
48
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
49
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
Lines 267-272 if ( $pending_checkouts->count ) { # Useless test Link Here
267
            $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
268
            $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
268
        }
269
        }
269
270
271
        if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
272
            my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} });
273
            $issue->{ratings} = $ratings;
274
            $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
275
        }
276
270
        $issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber});
277
        $issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber});
271
        push @issuedat, $issue;
278
        push @issuedat, $issue;
272
        $count++;
279
        $count++;
273
- 

Return to bug 25110