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

(-)a/Koha/Patron.pm (+34 lines)
Lines 2196-2201 sub virtualshelves { Link Here
2196
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2196
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2197
}
2197
}
2198
2198
2199
=head3 get_savings
2200
2201
    my $savings = $patron->get_savings;
2202
2203
Use the replacement price of patron's old and current issues to calculate how much they have 'saved' by using the library.
2204
2205
=cut
2206
2207
sub get_savings {
2208
    my ( $self ) = @_;
2209
2210
    my $savings = 0;
2211
2212
    # get old issues
2213
    my $old_issues_rs = $self->_result->old_issues;
2214
    my @old_itemnumbers = $old_issues_rs->get_column('itemnumber')->all;
2215
2216
    foreach my $itemnumber ( @old_itemnumbers ) {
2217
        my $item = Koha::Items->find( $itemnumber );
2218
        $savings += $item->replacementprice;
2219
    }
2220
2221
    # get current issues
2222
    my $issues_rs = $self->_result->issues;
2223
    my @itemnumbers = $issues_rs->get_column('itemnumber')->all;
2224
2225
    foreach my $itemnumber ( @itemnumbers ) {
2226
        my $item = Koha::Items->find( $itemnumber );
2227
        $savings += $item->replacementprice;
2228
    }
2229
2230
    return $savings;
2231
}
2232
2199
=head2 Internal methods
2233
=head2 Internal methods
2200
2234
2201
=head3 _type
2235
=head3 _type
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (+8 lines)
Lines 280-285 Link Here
280
                                            </li>
280
                                            </li>
281
                                        [% END %]
281
                                        [% END %]
282
                                    [% END %]
282
                                    [% END %]
283
                                    [% IF savings %]
284
                                        <li>
285
                                            <a href="/cgi-bin/koha/opac-user.pl">
286
                                                <span class="count_label">[% savings | $Price with_symbol => 1 %]</span>
287
                                                total savings
288
                                            </a>
289
                                        </li>
290
                                    [% END %]
283
                                </ul>
291
                                </ul>
284
                            </div>
292
                            </div>
285
                        [% END %]
293
                        [% 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