Bug 2093: (follow-up) Add OPAC dashboard for logged-in users
This patch: - hides the dashboard if there is no dashboard information to display - changes '5.00 due' to '5.00 due in fines and charges' for translation - uses Koha::Holds in place of deprecated C4::Reserves methods To test, confirm all the right information for holds still shows, and confirm the dashboard is hidden if there are no checkouts, holds, fines or overdues. 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:
parent
ffee02e41d
commit
506d669424
2 changed files with 15 additions and 16 deletions
|
@ -135,24 +135,24 @@
|
|||
</div> <!-- /#login -->
|
||||
[% END # /casAuthentication %]
|
||||
[% ELSE %]
|
||||
[% IF Koha.Preference('OPACUserSummary') %]
|
||||
[% IF Koha.Preference('OPACUserSummary') && dashboard_info %]
|
||||
<div id="user_summary">
|
||||
<h3>Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</span></a></h3>
|
||||
<ul id="user_summary_shortcuts">
|
||||
[% IF checkouts && checkouts > 0 %]
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts"><span class="user_checkouts_count count_label">[% checkouts %]</span> Checkout(s)</a></li>
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts"><span class="user_checkouts_count count_label">[% checkouts %]</span> checkout(s)</a></li>
|
||||
[% END %]
|
||||
[% IF overdues && overdues > 0 %]
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues"><span class="user_overdues_count count_label">[% overdues %]</span> Overdue(s)</a></li>
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues"><span class="user_overdues_count count_label">[% overdues %]</span> overdue(s)</a></li>
|
||||
[% END %]
|
||||
[% IF holds_pending && holds_pending > 0 %]
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_pending_count count_label">[% holds_pending %]</span> Hold(s) pending</a></li>
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_pending_count count_label">[% holds_pending %]</span> hold(s) pending</a></li>
|
||||
[% END %]
|
||||
[% IF holds_waiting && holds_waiting > 0 %]
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_waiting_count count_label">[% holds_waiting %]</span> Hold(s) waiting</a></li>
|
||||
<li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_waiting_count count_label">[% holds_waiting %]</span> hold(s) waiting</a></li>
|
||||
[% END %]
|
||||
[% IF total_owing && total_owing > 0 %]
|
||||
<li><a href="/cgi-bin/koha/opac-account.pl"><span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span> Due</a></li>
|
||||
<li><a href="/cgi-bin/koha/opac-account.pl"><span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span> due in fines and charges</a></li>
|
||||
[% END %]
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -27,8 +27,8 @@ use C4::Languages qw(getTranslatedLanguages accept_language);
|
|||
use C4::Koha qw( GetDailyQuote );
|
||||
use C4::Members;
|
||||
use C4::Overdues;
|
||||
use C4::Reserves;
|
||||
use Koha::Checkouts;
|
||||
use Koha::Holds;
|
||||
|
||||
my $input = new CGI;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
@ -66,23 +66,22 @@ 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
|
||||
|
||||
# For dashboard
|
||||
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 $holds_pending = Koha::Holds->search({ borrowernumber => $borrowernumber, found => undef })->count;
|
||||
my $holds_waiting = Koha::Holds->search({ borrowernumber => $borrowernumber })->waiting->count;
|
||||
my ( $total , $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
|
||||
|
||||
if ( $checkouts > 0 || $overdues_count > 0 || $holds_pending > 0 || $holds_waiting > 0 || $total > 0 ) {
|
||||
$template->param( dashboard_info => 1 );
|
||||
}
|
||||
|
||||
$template->param(
|
||||
checkouts => $checkouts,
|
||||
overdues => $overdues_count,
|
||||
holds_pending => $holds_pending,
|
||||
holds_waiting => scalar @holds_waiting,
|
||||
holds_waiting => $holds_waiting,
|
||||
total_owing => $total,
|
||||
koha_news => $all_koha_news,
|
||||
koha_news_count => $koha_news_count,
|
||||
|
|
Loading…
Reference in a new issue