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

(-)a/Koha/Patron.pm (+34 lines)
Lines 2281-2286 sub virtualshelves { Link Here
2281
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2281
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2282
}
2282
}
2283
2283
2284
=head3 get_savings
2285
2286
    my $savings = $patron->get_savings;
2287
2288
Use the replacement price of patron's old and current issues to calculate how much they have 'saved' by using the library.
2289
2290
=cut
2291
2292
sub get_savings {
2293
    my ( $self ) = @_;
2294
2295
    my $savings = 0;
2296
2297
    # get old issues
2298
    my $old_issues_rs = $self->_result->old_issues;
2299
    my @old_itemnumbers = $old_issues_rs->get_column('itemnumber')->all;
2300
2301
    foreach my $itemnumber ( @old_itemnumbers ) {
2302
        my $item = Koha::Items->find( $itemnumber );
2303
        $savings += $item->replacementprice;
2304
    }
2305
2306
    # get current issues
2307
    my $issues_rs = $self->_result->issues;
2308
    my @itemnumbers = $issues_rs->get_column('itemnumber')->all;
2309
2310
    foreach my $itemnumber ( @itemnumbers ) {
2311
        my $item = Koha::Items->find( $itemnumber );
2312
        $savings += $item->replacementprice;
2313
    }
2314
2315
    return $savings;
2316
}
2317
2284
=head2 Internal methods
2318
=head2 Internal methods
2285
2319
2286
=head3 _type
2320
=head3 _type
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (+8 lines)
Lines 300-305 Link Here
300
                                            </li>
300
                                            </li>
301
                                        [% END %]
301
                                        [% END %]
302
                                    [% END %]
302
                                    [% END %]
303
                                    [% IF savings %]
304
                                        <li>
305
                                            <a href="/cgi-bin/koha/opac-user.pl">
306
                                                <span class="count_label">[% savings | $Price with_symbol => 1 %]</span>
307
                                                total savings
308
                                            </a>
309
                                        </li>
310
                                    [% END %]
303
                                </ul>
311
                                </ul>
304
                            </div>
312
                            </div>
305
                        [% END %]
313
                        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (+7 lines)
Lines 4-9 Link Here
4
[% USE TablesSettings %]
4
[% USE TablesSettings %]
5
[% USE AdditionalContents %]
5
[% USE AdditionalContents %]
6
[% USE Asset %]
6
[% USE Asset %]
7
[% USE Price %]
7
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
8
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", 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 ) %]
9
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
[% INCLUDE 'doc-head-open.inc' %]
Lines 54-59 Link Here
54
                    [% ELSE %]
55
                    [% ELSE %]
55
                        <div id="opac-user-readingrec">
56
                        <div id="opac-user-readingrec">
56
57
58
                        [% IF savings %]
59
                            <div class="alert alert-info">
60
                                Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog.
61
                            </div>
62
                        [% END %]
63
57
                            <div class="resultscontrol resort js-hide">
64
                            <div class="resultscontrol resort js-hide">
58
                                <form id="sortform" action="/cgi-bin/koha/opac-readingrecord.pl" method="get">
65
                                <form id="sortform" action="/cgi-bin/koha/opac-readingrecord.pl" method="get">
59
                                    [% UNLESS ( limit ) %]<input type="hidden" name="limit" value="full" />[% END %]
66
                                    [% 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 164-169 if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') Link Here
164
    }
164
    }
165
}
165
}
166
166
167
my $saving_display = C4::Context->preference('OPACShowSavings');
168
if ( $saving_display =~ /user/ ) {
169
    $template->param( savings => $patron->get_savings );
170
}
171
167
# pass on any renew errors to the template for displaying
172
# pass on any renew errors to the template for displaying
168
my $renew_error = $query->param('renew_error');
173
my $renew_error = $query->param('renew_error');
169
174
170
- 

Return to bug 31051