Bug 18403: Only display libraries from group in dropdown lists
From where patrons it's about patrons, we do not want to display the libraries from all the system, but only the ones from the group. Test plan: - See the overdues (circ/overdue.pl) and make sure you can only see overdues from patrons part of your group (do not forget to test the CSV export). - Search for patrons, the 'library' filters (headers and left side) should only display libraries from your group - Search for article request by patron's library: only the libraries from your group should be displayed Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
6ef64cda22
commit
e09ed656af
|
|
@ -45,10 +45,35 @@ Koha::Libraries - Koha Library Object set class
|
|||
sub search_filtered {
|
||||
my ( $self, $params, $attributes ) = @_;
|
||||
|
||||
if ( C4::Context::only_my_library ) {
|
||||
$params->{branchcode} = C4::Context->userenv->{branch};
|
||||
my @branchcodes;
|
||||
if ( my $userenv = C4::Context->userenv ) {
|
||||
if ( C4::Context::only_my_library ) {
|
||||
push @branchcodes, $userenv->{branch};
|
||||
}
|
||||
else {
|
||||
my $logged_in_user = Koha::Patrons->find( $userenv->{number} );
|
||||
unless (
|
||||
$logged_in_user->can(
|
||||
{ borrowers => 'view_borrower_infos_from_any_libraries' }
|
||||
)
|
||||
)
|
||||
{
|
||||
if ( my $library_groups = $logged_in_user->library->library_groups )
|
||||
{
|
||||
while ( my $library_group = $library_groups->next ) {
|
||||
push @branchcodes,
|
||||
$library_group->parent->children->get_column('branchcode');
|
||||
}
|
||||
}
|
||||
else {
|
||||
push @branchcodes, $userenv->{branch};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$params->{branchcode} = { -in => \@branchcodes } if @branchcodes;
|
||||
delete $params->{only_from_group};
|
||||
return $self->SUPER::search( $params, $attributes );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,10 +59,11 @@ sub all {
|
|||
my ( $self, $params ) = @_;
|
||||
my $selected = $params->{selected};
|
||||
my $unfiltered = $params->{unfiltered} || 0;
|
||||
my $only_from_group = $params->{only_from_group} || 0;
|
||||
|
||||
my $libraries = $unfiltered
|
||||
? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed
|
||||
: Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed;
|
||||
: Koha::Libraries->search_filtered( { only_from_group => $only_from_group }, { order_by => ['branchname'] } )->unblessed;
|
||||
|
||||
for my $l ( @$libraries ) {
|
||||
if ( defined $selected and $l->{branchcode} eq $selected
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
|||
}
|
||||
);
|
||||
|
||||
our $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $req;
|
||||
|
|
@ -296,6 +298,7 @@ if ($noreport) {
|
|||
}
|
||||
|
||||
push @overduedata, {
|
||||
patron => scalar Koha::Patrons->find( $data->{borrowernumber} ),
|
||||
duedate => $data->{date_due},
|
||||
borrowernumber => $data->{borrowernumber},
|
||||
barcode => $data->{barcode},
|
||||
|
|
@ -369,14 +372,19 @@ sub build_csv {
|
|||
my @lines = ();
|
||||
|
||||
# build header ...
|
||||
my @keys = qw /duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
|
||||
branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype/;
|
||||
my @keys =
|
||||
qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
|
||||
branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype);
|
||||
my $csv = Text::CSV_XS->new();
|
||||
$csv->combine(@keys);
|
||||
push @lines, $csv->string();
|
||||
|
||||
my @private_keys = qw( dueborrowertitle firstname surname phone email address address2 zipcode city country streetnumber streettype );
|
||||
# ... and rest of report
|
||||
foreach my $overdue ( @{ $overdues } ) {
|
||||
unless ( $logged_in_user->can_see_patron_infos( $overdue->{patron} ) ) {
|
||||
$overdue->{$_} = undef for @private_keys;
|
||||
}
|
||||
push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
|
||||
<p>
|
||||
<label for="branchcode">Library: </label>
|
||||
[% SET branches = Branches.all( selected => branchcode_filter ) %]
|
||||
[% SET branches = Branches.all( selected => branchcode_filter, only_my_group => 1 ) %]
|
||||
<select name="branchcode_filter" id="branchcode">
|
||||
[% IF branches.size != 1 %]
|
||||
<option value="">Any</option>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<form id="ar-branchcode-form" method="post">
|
||||
<select name="branchcode" id="branchcode">
|
||||
<option value="">All libraries</option>
|
||||
[% FOREACH b IN Branches.all %]
|
||||
[% FOREACH b IN Branches.all( only_from_group => 1 ) %]
|
||||
[% IF b.branchcode == branchcode %]
|
||||
<option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
|
||||
[% ELSE %]
|
||||
|
|
|
|||
|
|
@ -58,9 +58,12 @@
|
|||
[% FOREACH overdueloo IN overdueloop %]
|
||||
<tr>
|
||||
<td><span title="[% overdueloo.duedate %]">[% overdueloo.duedate | $KohaDates %]</span></td>
|
||||
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% overdueloo.borrowernumber %]">[% overdueloo.surname %][% IF (overdueloo.firstname) %], [% overdueloo.firstname %][% END %] ([% overdueloo.cardnumber %])</a>
|
||||
[% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
|
||||
[% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
|
||||
<td>
|
||||
[% INCLUDE 'patron-title.inc' patron=overdueloo.patron hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]
|
||||
[% IF logged_in_user.can_see_patron_infos( overdueloo.patron ) %]
|
||||
[% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %]
|
||||
[% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td>
|
||||
[% END %]
|
||||
<td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td>
|
||||
<td>[% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% overdueloo.title |html %] [% overdueloo.subtitle %]</a> [% IF ( overdueloo.author ) %], by [% overdueloo.author %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron %][% END %]</td>
|
||||
<td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td>
|
||||
|
|
@ -174,7 +177,7 @@
|
|||
<label>Library of the patron:</label>
|
||||
<select name="branch" id="branch">
|
||||
<option value="">Any</option>
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter, only_from_group => 1 ) %]
|
||||
</select>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@
|
|||
<label for="branchlimit">Library: </label>
|
||||
<select name="branchlimit" id="branchlimit">
|
||||
<option value="">All</option>
|
||||
[% PROCESS options_for_libraries libraries => Branches.all() %]
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( only_from_group => 1 ) %]
|
||||
</select>
|
||||
</li>
|
||||
</ol></fieldset>
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ function filterByFirstLetterSurname(letter) {
|
|||
<li>
|
||||
<label for="branchcode_filter">Library:</label>
|
||||
<select id="branchcode_filter">
|
||||
[% SET libraries = Branches.all() %]
|
||||
[% SET libraries = Branches.all( only_from_group => 1 ) %]
|
||||
[% IF libraries.size != 1 %]
|
||||
<option value="">Any</option>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ function filterByFirstLetterSurname(letter) {
|
|||
</li>
|
||||
<li>
|
||||
<label for="branchcode_filter">Library:</label>
|
||||
[% SET branches = Branches.all( selected => branchcode_filter ) %]
|
||||
[% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
|
||||
<select id="branchcode_filter">
|
||||
[% IF branches.size != 1 %]
|
||||
<option value="">Any</option>
|
||||
|
|
|
|||
|
|
@ -679,7 +679,7 @@ $(document).ready(function() {
|
|||
<li>
|
||||
<label for="libraries" class="required">Library:</label>
|
||||
<select name="branchcode" size="1" id="libraries">
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch ) %]
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %]
|
||||
</select>
|
||||
<span class="required">Required</span>
|
||||
</li>
|
||||
|
|
|
|||
Loading…
Reference in New Issue