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

(-)a/Koha/Patron.pm (+34 lines)
Lines 2184-2189 sub decoded_secret { Link Here
2184
    return $self->secret;
2184
    return $self->secret;
2185
}
2185
}
2186
2186
2187
=head3 get_savings
2188
2189
    my $savings = $patron->get_savings;
2190
2191
Use the replacement price of patron's old and current issues to calculate how much they have 'saved' by using the library.
2192
2193
=cut
2194
2195
sub get_savings {
2196
    my ( $self ) = @_;
2197
2198
    my $savings = 0;
2199
2200
    # get old issues
2201
    my $old_issues_rs = $self->_result->old_issues;
2202
    my @old_itemnumbers = $old_issues_rs->get_column('itemnumber')->all;
2203
2204
    foreach my $itemnumber ( @old_itemnumbers ) {
2205
        my $item = Koha::Items->find( $itemnumber );
2206
        $savings += $item->replacementprice;
2207
    }
2208
2209
    # get current issues
2210
    my $issues_rs = $self->_result->issues;
2211
    my @itemnumbers = $issues_rs->get_column('itemnumber')->all;
2212
2213
    foreach my $itemnumber ( @itemnumbers ) {
2214
        my $item = Koha::Items->find( $itemnumber );
2215
        $savings += $item->replacementprice;
2216
    }
2217
2218
    return $savings;
2219
}
2220
2187
=head2 Internal methods
2221
=head2 Internal methods
2188
2222
2189
=head3 _type
2223
=head3 _type
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (+8 lines)
Lines 278-283 Link Here
278
                                            </li>
278
                                            </li>
279
                                        [% END %]
279
                                        [% END %]
280
                                    [% END %]
280
                                    [% END %]
281
                                    [% IF savings %]
282
                                        <li>
283
                                            <a href="/cgi-bin/koha/opac-user.pl">
284
                                                <span class="count_label">[% savings | $Price with_symbol => 1 %]</span>
285
                                                total savings
286
                                            </a>
287
                                        </li>
288
                                    [% END %]
281
                                </ul>
289
                                </ul>
282
                            </div>
290
                            </div>
283
                        [% END %]
291
                        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (+7 lines)
Lines 3-8 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE TablesSettings %]
4
[% USE TablesSettings %]
5
[% USE AdditionalContents %]
5
[% USE AdditionalContents %]
6
[% USE Price %]
6
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
7
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
7
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
8
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
Lines 53-58 Link Here
53
                    [% ELSE %]
54
                    [% ELSE %]
54
                        <div id="opac-user-readingrec">
55
                        <div id="opac-user-readingrec">
55
56
57
                        [% IF savings %]
58
                            <div class="alert alert-info">
59
                                Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog.
60
                            </div>
61
                        [% END %]
62
56
                            <div class="resultscontrol resort js-hide">
63
                            <div class="resultscontrol resort js-hide">
57
                                <form id="sortform" action="/cgi-bin/koha/opac-readingrecord.pl" method="get">
64
                                <form id="sortform" action="/cgi-bin/koha/opac-readingrecord.pl" method="get">
58
                                    [% UNLESS ( limit ) %]<input type="hidden" name="limit" value="full" />[% END %]
65
                                    [% UNLESS ( limit ) %]<input type="hidden" name="limit" value="full" />[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+6 lines)
Lines 162-167 Link Here
162
                        </div>
162
                        </div>
163
                    [% END # / IF patron_flagged %]
163
                    [% END # / IF patron_flagged %]
164
164
165
                    [% IF savings %]
166
                        <div class="alert alert-info">
167
                            Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog.
168
                        </div>
169
                    [% END %]
170
165
                    <div class="alert alert-info" id="notesaved" style="display:none;"></div>
171
                    <div class="alert alert-info" id="notesaved" style="display:none;"></div>
166
                    [% IF ( OpacMySummaryNote ) %]
172
                    [% IF ( OpacMySummaryNote ) %]
167
                        [% PROCESS koha_news_block news => OpacMySummaryNote %]
173
                        [% PROCESS koha_news_block news => OpacMySummaryNote %]
(-)a/opac/opac-main.pl (-1 / +7 lines)
Lines 94-100 if ( $patron ) { Link Here
94
            });
94
            });
95
    my $patron_note = $patron->opacnote;
95
    my $patron_note = $patron->opacnote;
96
    my $total = $patron->account->balance;
96
    my $total = $patron->account->balance;
97
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_note || $patron_messages->count ) {
97
    my $saving_display = C4::Context->preference('OPACShowSavings');
98
    my $savings = 0;
99
    if ( $saving_display =~ /summary/ ) {
100
        $savings = $patron->get_savings;
101
    }
102
    if  ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 || $patron_note || $patron_messages->count || $savings > 0 ) {
98
        $template->param(
103
        $template->param(
99
            dashboard_info => 1,
104
            dashboard_info => 1,
100
            checkouts           => $checkouts,
105
            checkouts           => $checkouts,
Lines 104-109 if ( $patron ) { Link Here
104
            total_owing         => $total,
109
            total_owing         => $total,
105
            patron_messages     => $patron_messages,
110
            patron_messages     => $patron_messages,
106
            opacnote            => $patron_note,
111
            opacnote            => $patron_note,
112
            savings             => $savings,
107
        );
113
        );
108
    }
114
    }
109
}
115
}
(-)a/opac/opac-readingrecord.pl (+6 lines)
Lines 141-146 for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above Link Here
141
	$template->param(JacketImages=>1);
141
	$template->param(JacketImages=>1);
142
}
142
}
143
143
144
my $saving_display = C4::Context->preference('OPACShowSavings');
145
if ( $saving_display =~ /checkouthistory/ ) {
146
    my $patron = Koha::Patrons->find( $borrowernumber );
147
    $template->param( savings => $patron->get_savings );
148
}
149
144
$template->param(
150
$template->param(
145
    READING_RECORD => $issues,
151
    READING_RECORD => $issues,
146
    limit          => $limit,
152
    limit          => $limit,
(-)a/opac/opac-user.pl (-1 / +5 lines)
Lines 167-172 if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') Link Here
167
    }
167
    }
168
}
168
}
169
169
170
my $saving_display = C4::Context->preference('OPACShowSavings');
171
if ( $saving_display =~ /user/ ) {
172
    $template->param( savings => $patron->get_savings );
173
}
174
170
# pass on any renew errors to the template for displaying
175
# pass on any renew errors to the template for displaying
171
my $renew_error = $query->param('renew_error');
176
my $renew_error = $query->param('renew_error');
172
177
173
- 

Return to bug 31051