Bug 2093: Add OPAC Summary for logged-in users

This patch adds a summary to the OPAC once the user has logged in that
shows the users number of checkouts, overdues, holds pending, holds
waiting and total fines. We also have a syspref OPACUserSummary to turn
this feature on and off. Default is ON.

To test:
1) Apply patch and update database
2) Set up some checkouts, overdues, holds pending AND waiting and fines
for a user
3) Log into OPAC as that user, see summary. Confirm links all work as
expected
4) Confirm that if there are no checkouts / overdues etc that the link
disappears from the summary
5) Turn OPACUserSummary OFF and confirm the summary does not show on the
mainpage.

Sponsored-by: Catalyst IT

Signed-off-by: Hugo Agud <hagud@orex.es>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Aleisha Amohia 2017-04-26 05:18:13 +00:00 committed by Jonathan Druart
parent 3d6e33134e
commit 657c417a87
5 changed files with 54 additions and 1 deletions

View file

@ -0,0 +1 @@
INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES ('OPACUserSummary', 1, NULL, "Show the summary of a logged in user's checkouts, overdues, holds and fines on the mainpage", 'YesNo');

View file

@ -395,6 +395,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OPACUserCSS','',NULL,'Add CSS to be included in the OPAC in an embedded <style> tag.','free'),
('OPACUserJS','','70|10','Define custom javascript for inclusion in OPAC','Textarea'),
('opacuserlogin','1',NULL,'Enable or disable display of user login features','YesNo'),
('OPACUserSummary', 1, NULL, "Show the summary of a logged in user's checkouts, overdues, holds and fines on the mainpage", 'YesNo'),
('OPACViewOthersSuggestions','0',NULL,'If ON, allows all suggestions to be displayed in the OPAC','YesNo'),
('OPACXSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on OPAC','Free'),
('OPACXSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on OPAC','Free'),

View file

@ -1,5 +1,11 @@
OPAC:
Appearance:
-
- pref: OPACUserSummary
choices:
yes: Show
no: "Don't show"
- "a summary of a logged in user's checkouts, overdues, holds and fines on the mainpage"
-
- For search results in the OPAC, show the item's
- pref: OPACResultsLibrary

View file

@ -1,5 +1,6 @@
[% USE Koha %]
[% USE Branches %]
[% USE Price %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
@ -133,7 +134,30 @@
</form>
</div> <!-- /#login -->
[% END # /casAuthentication %]
[% END # / loggedinusername %]
[% ELSE %]
[% IF Koha.Preference('OPACUserSummary') %]
<div id="user_summary">
<h1>Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</span></a></h1>
<ul id="user_summary_shortcuts">
[% IF checkouts && checkouts > 0 %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% checkouts %] checkout(s)</a></li>
[% END %]
[% IF overdues && overdues > 0 %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% overdues %] overdue(s)</a></li>
[% END %]
[% IF holds_pending && holds_pending > 0 %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% holds_pending %] hold(s) pending</a></li>
[% END %]
[% IF holds_waiting && holds_waiting > 0 %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% holds_waiting %] hold(s) waiting</a></li>
[% END %]
[% IF total_owing && total_owing > 0 %]
<li><a href="/cgi-bin/koha/opac-account.pl">[% total_owing | $Price %] due</a></li>
[% END %]
</ul>
</div>
[% END %]
[% END # /loggedinusername %]
[% END # /opacuserlogin %]
[% IF ( OpacNavRight ) %]
<div id="opacnavright">

View file

@ -25,6 +25,10 @@ use C4::Output;
use C4::NewsChannels; # GetNewsToDisplay
use C4::Languages qw(getTranslatedLanguages accept_language);
use C4::Koha qw( GetDailyQuote );
use C4::Members;
use C4::Overdues;
use C4::Reserves;
use Koha::Checkouts;
my $input = new CGI;
my $dbh = C4::Context->dbh;
@ -62,7 +66,24 @@ my $koha_news_count = scalar @$all_koha_news;
my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
my $checkouts = Koha::Checkouts->search({ borrowernumber => $borrowernumber })->count;
my ( $overdues_count, $overdues ) = checkoverdues($borrowernumber);
my @holds = GetReservesFromBorrowernumber($borrowernumber);
my $holds_pending = 0;
foreach my $hold (@holds) {
if (not defined($hold->{found})){
$holds_pending++;
}
}
my @holds_waiting = GetReservesFromBorrowernumber($borrowernumber, 'W');
my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
$template->param(
checkouts => $checkouts,
overdues => $overdues_count,
holds_pending => $holds_pending,
holds_waiting => scalar @holds_waiting,
total_owing => $total,
koha_news => $all_koha_news,
koha_news_count => $koha_news_count,
branchcode => $homebranch,