@@ -, +, @@ lists - See the overdues (circ/overdue.pl) and make sure you can only see overdues from - Search for patrons, the 'library' filters (headers and left side) should only - Search for article request by patron's library: only the libraries from your --- Koha/Libraries.pm | 29 ++++++++++++++++++++-- Koha/Template/Plugin/Branches.pm | 3 ++- circ/overdue.pl | 12 +++++++-- .../prog/en/includes/patron-search.inc | 2 +- .../prog/en/modules/circ/article-requests.tt | 2 +- .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 11 +++++--- .../prog/en/modules/circ/view_holdsqueue.tt | 2 +- .../prog/en/modules/common/patron_search.tt | 2 +- .../prog/en/modules/members/member.tt | 2 +- .../prog/en/modules/members/memberentrygen.tt | 2 +- 10 files changed, 52 insertions(+), 15 deletions(-) --- a/Koha/Libraries.pm +++ a/Koha/Libraries.pm @@ -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 ); } --- a/Koha/Template/Plugin/Branches.pm +++ a/Koha/Template/Plugin/Branches.pm @@ -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 --- a/circ/overdue.pl +++ a/circ/overdue.pl @@ -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; @@ -297,6 +299,7 @@ if ($noreport) { my $dt = dt_from_string($data->{date_due}, 'sql'); push @overduedata, { + patron => Koha::Patrons->find( $data->{borrowernumber} ), duedate => output_pref($dt), borrowernumber => $data->{borrowernumber}, barcode => $data->{barcode}, @@ -370,14 +373,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); } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -85,7 +85,7 @@

- [% SET branches = Branches.all( selected => branchcode_filter ) %] + [% SET branches = Branches.all( selected => branchcode_filter, only_my_group => 1 ) %] - [% FOREACH b IN Branches.all %] + [% FOREACH b IN Branches.all( only_from_group => 1 ) %] [% IF b.branchcode == branchcode %] [% ELSE %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt @@ -121,9 +121,12 @@ [% FOREACH overdueloo IN overdueloop %] [% overdueloo.duedate %] - [% overdueloo.surname %][% IF (overdueloo.firstname) %], [% overdueloo.firstname %][% END %] ([% overdueloo.cardnumber %]) - [% IF ( overdueloo.email ) %][email][% END %] - [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %] + + [% 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 ) %][email][% END %] + [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %] + [% END %] [% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %] [% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% overdueloo.title |html %] [% overdueloo.subtitle %] [% IF ( overdueloo.author ) %], by [% overdueloo.author %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron %][% END %] [% overdueloo.barcode %] @@ -237,7 +240,7 @@ --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -206,7 +206,7 @@ $(document).ready(function() {