Koha/members/members-home.pl
Jonathan Druart 4efe251f35 Bug 12346: Display the correct number of pending patron modifications on the patron module home page
Due to the way members-home.pl handles the variable $branch, the number
of patron modifications listed on members-home.pl may differ from the
number listed on mainpage.pl. When the librarian clicks this link, he or
she may see a different number than was listed, or none at all!

Test Plan:
0) Set IndependentBranchesPatronModifications = Yes
1) Create a number of modification request for BranchA
2) Log into the staff intranet with a patron without superlibrarian
permissions and set your branch to BranchB
3) Note the modifications alert to does not display on mainpage.pl
4) Click the "Patrons" link to take you to members-home.pl
5) Note the modifictions alert does display on this page
6) Apply this patch
7) Reload members-home.pl, note the alert no longer displays

QA notes: What was the point of the branch variable?

Followed test plan, patch worked as described. Also passed QA test tool
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-09-12 12:08:45 -03:00

78 lines
2.3 KiB
Perl
Executable file

#!/usr/bin/perl
# Parts Copyright Biblibre 2010
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Members;
use Koha::Patron::Modifications;
use Koha::Libraries;
use Koha::List::Patron;
use Koha::Patron::Categories;
my $query = new CGI;
my ($template, $loggedinuser, $cookie, $flags)
= get_template_and_user({template_name => "members/member.tt",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => {borrowers => 1},
debug => 1,
});
my $no_add = 0;
if( Koha::Libraries->search->count < 1){
$no_add = 1;
$template->param(no_branches => 1);
}
my @categories = Koha::Patron::Categories->search_limited;
if(scalar(@categories) < 1){
$no_add = 1;
$template->param(no_categories => 1);
}
else {
$template->param(categories=>\@categories);
}
my $branch =
( C4::Context->preference("IndependentBranchesPatronModifications")
|| C4::Context->preference("IndependentBranches") )
&& !$flags->{'superlibrarian'}
? C4::Context->userenv()->{'branch'}
: undef;
my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count( $branch );
$template->param(
no_add => $no_add,
pending_borrower_modifications => $pending_borrower_modifications,
);
$template->param(
alphabet => C4::Context->preference('alphabet') || join (' ', 'A' .. 'Z'),
patron_lists => [ GetPatronLists() ],
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
);
output_html_with_http_headers $query, $cookie, $template->output;