From b6c10813ef0fecaf572a30c96d63eb117e4c4266 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Tue, 29 Jun 2021 16:52:25 -0600 Subject: [PATCH] Bug 28642 - Expand IndependentBranches to hide others items and libraries Adds a system preference: IndependentBranchesHideOtherBranchesItems. When on: All library select's will be limited to just the users library. Item lists in search results, title details, item details, holds, and exports will only show items at the users library. --- C4/Context.pm | 4 +++- C4/Items.pm | 9 ++++++++- C4/Search.pm | 6 ++++++ Koha/Template/Plugin/Branches.pm | 5 +++-- catalogue/MARCdetail.pl | 2 ++ catalogue/export.pl | 13 +++++++++++++ catalogue/issuehistory.pl | 8 ++++++-- catalogue/itemsearch.pl | 13 ++++++++++++- catalogue/search.pl | 4 ++++ cataloguing/additem.pl | 7 ++++++- circ/overdue.pl | 7 +++++++ installer/data/mysql/atomicupdate/bug_28642.perl | 5 +++++ koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc | 2 ++ .../prog/en/includes/patron-search.inc | 4 ++++ .../prog/en/modules/admin/preferences/admin.pref | 7 +++++++ .../prog/en/modules/catalogue/advsearch.tt | 4 ++++ .../prog/en/modules/catalogue/itemsearch.tt | 3 +++ .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 12 ++++++++++++ .../prog/en/modules/circ/view_holdsqueue.tt | 4 ++++ .../prog/en/modules/clubs/clubs-add-modify.tt | 4 ++++ .../prog/en/modules/clubs/templates-add-modify.tt | 4 ++++ .../intranet-tmpl/prog/en/modules/members/member.tt | 4 ++++ .../prog/en/modules/members/memberentrygen.tt | 4 ++++ .../prog/en/modules/reports/acquisitions_stats.tt | 3 +++ .../prog/en/modules/reports/bor_issues_top.tt | 11 +++++++++-- .../prog/en/modules/reports/borrowers_stats.tt | 6 ++++++ .../prog/en/modules/reports/cash_register_stats.tt | 2 ++ .../prog/en/modules/reports/cat_issues_top.tt | 7 ++++++- .../prog/en/modules/reports/catalogue_out.tt | 4 ++++ .../prog/en/modules/reports/catalogue_stats.tt | 4 ++++ .../prog/en/modules/reports/issues_avg_stats.tt | 4 ++++ .../prog/en/modules/reports/issues_stats.tt | 12 ++++++++++++ .../prog/en/modules/reports/itemslost.tt | 4 ++++ .../prog/en/modules/reports/itemtypes.tt | 6 ++++++ .../prog/en/modules/reports/reserves_stats.tt | 12 ++++++++++++ .../prog/en/modules/reports/serials_stats.tt | 4 ++++ .../prog/en/modules/serials/checkexpiration.tt | 4 ++++ .../prog/en/modules/serials/subscription-add.tt | 10 +++++++++- .../prog/en/modules/suggestion/suggestion.tt | 8 ++++++++ .../intranet-tmpl/prog/en/modules/tools/export.tt | 4 ++++ .../prog/en/modules/tools/import_borrowers.tt | 6 ++++++ .../prog/en/modules/tools/inventory.tt | 4 ++++ .../prog/en/modules/tools/koha-news.tt | 8 ++++++++ reports/acquisitions_stats.pl | 6 +++++- reports/cash_register_stats.pl | 6 +++++- reserve/request.pl | 4 ++++ reviews/reviewswaiting.pl | 9 +++++++-- tools/batchMod.pl | 6 +++++- tools/export.pl | 10 +++++++++- tools/modborrowers.pl | 6 +++++- 50 files changed, 286 insertions(+), 19 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_28642.perl diff --git a/C4/Context.pm b/C4/Context.pm index db896ad473..75b8b72908 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -946,8 +946,10 @@ sub mybranch { =cut sub only_my_library { + my ( $class, $pref ) = @_; + $pref //= 'IndependentBranches'; return - C4::Context->preference('IndependentBranches') + C4::Context->preference($pref) && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch}; diff --git a/C4/Items.pm b/C4/Items.pm index 1f0d560e86..789293f0f0 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -767,6 +767,8 @@ sub GetItemsInfo { my $userenv = C4::Context->userenv; my $want_not_same_branch = C4::Context->preference("IndependentBranches") && !C4::Context->IsSuperLibrarian(); while ( my $data = $sth->fetchrow_hashref ) { + next if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && $data->{homebranch} ne $userenv->{branch} ); + if ( $data->{borrowernumber} && $want_not_same_branch) { $data->{'NOTSAMEBRANCH'} = $data->{'bcode'} ne $userenv->{branch}; } @@ -864,7 +866,12 @@ sub GetItemsLocationInfo { location, itemcallnumber, cn_sort FROM items, branches as a, branches as b WHERE homebranch = a.branchcode AND holdingbranch = b.branchcode - AND biblionumber = ? + AND biblionumber = ?"; + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') &&( my $mybranch = C4::Context->userenv->{branch} ) ) { + $query .= " + AND homebranch = '$mybranch'"; + } + $query .= " ORDER BY cn_sort ASC"; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); diff --git a/C4/Search.pm b/C4/Search.pm index b0ebedcb57..ac1c07c7fb 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1836,6 +1836,12 @@ sub searchResults { next; } } + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + if ( $item->{homebranch} ne $userenv->{branch} ) { + $items_count--; + next; + } + } my $hbranch = C4::Context->preference('StaffSearchResultsDisplayBranch'); my $otherbranch = $hbranch eq 'homebranch' ? 'holdingbranch' : 'homebranch'; diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 92c83be68c..c42d8df999 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -92,8 +92,9 @@ sub all { } sub InIndependentBranchesMode { - my ( $self ) = @_; - return ( not C4::Context->preference("IndependentBranches") or C4::Context::IsSuperLibrarian ); + my ( $self, $params ) = @_; + my $pref = $params->{syspref} || 'IndependentBranches'; + return ( C4::Context->preference($pref) and not C4::Context::IsSuperLibrarian ); } sub pickup_locations { diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index e275077ac2..a168958aee 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -261,6 +261,7 @@ for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) { # loop through each tag # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary # then construct template. +my ($homebrtagf,$homebrtagsubf) = &GetMarcFromKohaField( "items.homebranch" ); my @fields = $record->fields(); my %witness ; #---- stores the list of subfields used at least once, with the "meaning" of the code @@ -298,6 +299,7 @@ foreach my $field (@fields) { if grep { $kohafield eq $_ } qw( items.dateaccessioned items.onloan items.datelastseen items.datelastborrowed items.replacementpricedate ); } + next if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && $item && $item->{$homebrtagsubf} ne C4::Context->userenv->{'branchname'} ); push @item_loop, $item if $item; } diff --git a/catalogue/export.pl b/catalogue/export.pl index cb6f2d8129..42fb4e4b8d 100755 --- a/catalogue/export.pl +++ b/catalogue/export.pl @@ -40,6 +40,19 @@ if ($op eq "export") { } } + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + my $mybranch = C4::Context->userenv->{branch}; + my ($homebrtagf,$homebrtagsubf) = &GetMarcFromKohaField( "items.homebranch" ); + my @fields = $marc->field($homebrtagf); + my @delete; + foreach my $field (@fields) { + if ( $field->subfield($homebrtagsubf) ne $mybranch ) { + push @delete, $field; + } + } + $marc->delete_fields(@delete) if ( @delete ); + } + if ($format =~ /endnote/) { $marc = marc2endnote($marc); $format = 'endnote'; diff --git a/catalogue/issuehistory.pl b/catalogue/issuehistory.pl index e81ec56de5..c49d76cf2b 100755 --- a/catalogue/issuehistory.pl +++ b/catalogue/issuehistory.pl @@ -42,15 +42,19 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $biblionumber = $query->param('biblionumber'); +my $issue_filter = { biblionumber => $biblionumber }; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $issue_filter->{'item.homebranch'} = C4::Context->userenv->{branch}; +} my @checkouts = Koha::Checkouts->search( - { biblionumber => $biblionumber }, + $issue_filter, { join => 'item', order_by => 'timestamp', } ); my @old_checkouts = Koha::Old::Checkouts->search( - { biblionumber => $biblionumber }, + $issue_filter, { join => 'item', order_by => 'timestamp', diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 0329f4b1d8..223a597eb1 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -114,9 +114,13 @@ if ( defined $format ) { filters => [], }; + # IndependentBranchesHideOtherBranchesItems forces homebranch filter + # if it isn't already set + my $got_branch = 0; foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn)) { if (my @q = $cgi->multi_param($p)) { if ($q[0] ne '') { + if ( $p eq 'homebranch' ) { $got_branch = 1; } my $f = { field => $p, query => \@q, @@ -128,6 +132,9 @@ if ( defined $format ) { } } } + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && ! $got_branch ) { + push @{ $filter->{filters} }, { field => 'homebranch', query => [ C4::Context->userenv->{branch} ] }; + } my @c = $cgi->multi_param('c'); my @fields = $cgi->multi_param('f'); @@ -260,7 +267,11 @@ if ( defined $format ) { # Display the search form -my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } ); +my $library_filter = {}; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $library_filter->{'branchcode'} = C4::Context->userenv->{branch}; +} +my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( $library_filter, { order_by => 'branchname' } ); my @itemtypes; foreach my $itemtype ( Koha::ItemTypes->search ) { push @itemtypes, { diff --git a/catalogue/search.pl b/catalogue/search.pl index 8bd70fc893..36d6347cd8 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -399,6 +399,10 @@ if ( $params->{'multibranchlimit'} ) { } } +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && ! grep { /branch:/ } @limits ) { + push @limits, 'branch: '. C4::Context->userenv->{branch}; +} + for ( my $i=0; $i<@limits; $i++ ) { if ( $limits[$i] =~ /^branch:/ ) { my $branchfield = C4::Context->preference('SearchLimitLibrary'); diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b1e0357398..3ac938cc42 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -873,6 +873,7 @@ foreach my $field (@fields) { } } if (%this_row) { + next if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && $this_row{$branchtagsubfield} ne C4::Context->userenv->{branchname} ); push(@big_array, \%this_row); } } @@ -933,7 +934,11 @@ my @loop_data =(); my $i=0; my $branch = $input->param('branch') || C4::Context->userenv->{branch}; -my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. +my $libraries_filter = {}; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $libraries_filter->{branchcode} = C4::Context->userenv->{branch}; +} +my $libraries = Koha::Libraries->search($libraries_filter, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. for my $library ( @$libraries ) { $library->{selected} = 1 if $library->{branchcode} eq $branch } diff --git a/circ/overdue.pl b/circ/overdue.pl index c402588d19..3bdadfd4b9 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -78,6 +78,13 @@ our $logged_in_user = Koha::Patrons->find( $loggedinuser ); my $dbh = C4::Context->dbh; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && (my $mybranch = C4::Context->userenv->{branch}) ) { + $homebranchfilter = $mybranch; + $holdingbranchfilter = ''; + $filters->{homebranch} = $mybranch; + $filters->{holdingbranch} = $mybranch; +} + my $req; $req = $dbh->prepare( "select categorycode, description from categories order by description"); $req->execute; diff --git a/installer/data/mysql/atomicupdate/bug_28642.perl b/installer/data/mysql/atomicupdate/bug_28642.perl new file mode 100644 index 0000000000..748d5a1c43 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28642.perl @@ -0,0 +1,5 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('IndependentBranchesHideOtherBranchesItems','1','','Hide other branches in selects. Hide items belonging to other branches in search results, holds, biblio and item details, and exports.','YesNo')" ); + NewVersion( $DBversion, 28642, "Add new systempreference IndependentBranchesHideOtherBranchesItems"); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index af01c0e88b..78a0b7b10d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -1,6 +1,7 @@ [% USE raw %] [% USE AuthorisedValues %] [% USE Languages %] +[% USE Branches %] [% IF ( opacfacets ) %] [% IF ( facets_loop ) %]
@@ -45,6 +46,7 @@ [% FOREACH facet IN facets_loo.facets %] [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => facet.facet_label_value ) || facet.facet_label_value %][% END %] [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %] + [% IF ( facets_loo.type_label_HomeLibrary && Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) && facet.facet_link_value != Branches.GetLoggedInBranchcode() ) %][% NEXT %][% END %] [% IF loop.count > 5 && !facet.active %]
  • @@ -242,7 +250,11 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt index 564ab5f54f..8bd2d2e288 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -206,8 +206,12 @@
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt index 8d89d44b4d..55e0425009 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt @@ -84,8 +84,12 @@
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt index 73b3b4348b..acdbfe7514 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt @@ -97,8 +97,12 @@
  • If set, only librarians logged in with this branch will be able to modify this club template.
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt index edcc5e050d..58f87e2a5d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt @@ -191,7 +191,11 @@
  • + [% IF Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) %] + [% SET branches = Branches.all( search_params => { branchcode => Branches.GetLoggedInBranchcode() }, selected => branchcode_filter, only_from_group => 1 ) %] + [% ELSE %] [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %] + [% END %] + [% IF Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) %] + [% PROCESS options_for_libraries libraries => Branches.all( search_params => { branchcode => Branches.GetLoggedInBranchcode() }, selected => userbranch, only_from_group => 1 ) %] + [% ELSE %] [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %] + [% END %] Required
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt index af06dc3e35..099ce5ed2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt @@ -1,3 +1,4 @@ +[% USE Branches %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( do_it ) %]Acquisitions statistics › Results[% ELSE %]Acquisitions statistics[% END %] › Reports › Koha @@ -178,7 +179,9 @@ +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index 4ec821bc6d..b8faba7779 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -108,7 +108,9 @@
  • +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_out.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_out.tt index 522f5cbcca..175ef9d590 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_out.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_out.tt @@ -105,8 +105,12 @@
    1. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt index f976f1cffe..f88c0659ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt @@ -173,8 +173,12 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt index ddf42c2bec..a03ee01416 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt @@ -203,8 +203,12 @@ @@ -268,8 +272,12 @@ @@ -278,8 +286,12 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt index 11552c85fb..d738bbca17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -149,8 +149,12 @@
    2. + [% IF Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) %] + [% PROCESS options_for_libraries libraries => Branches.all( search_params => { branchcode => Branches.GetLoggedInBranchcode() } ) %] + [% ELSE %] [% PROCESS options_for_libraries libraries => Branches.all() %] + [% END %] + [% UNLESS Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) %] Select none to see all libraries + [% END %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt index dabfe169ea..db77a0c904 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt @@ -188,8 +188,12 @@ @@ -198,8 +202,12 @@ @@ -208,8 +216,12 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt index dd7c0e23ce..5bd96ca0b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/serials_stats.tt @@ -95,8 +95,12 @@ Library:
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt index cdd8861dae..cefff1149f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt @@ -47,8 +47,12 @@ [% IF can_change_library %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 789596e4ec..ecd3a5531b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -149,7 +149,14 @@ fieldset.rows table { clear: none; margin: 0; }
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 5234d766a4..d58a35f291 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -579,8 +579,12 @@
  • @@ -666,8 +670,12 @@ [% IF ( displayby != "branchcode" ) %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt index 04b7bc801c..918ddf5f9c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt @@ -137,7 +137,11 @@
  • + [% IF Branches.InIndependentBranchesMode({syspref=>'IndependentBranchesHideOtherBranchesItems'}) %] + + [% ELSE %] + [% END %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt index 4237c8fcc9..d8569eb65c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt @@ -253,10 +253,16 @@
  • [% borrower_field.field | html %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 8edc3739b4..478448a312 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -98,8 +98,12 @@ Current library
  • [% IF (authorised_values) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index 16138cf171..15465d7412 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -98,12 +98,16 @@
  • @@ -263,9 +267,13 @@
  • diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl index 8fe531358e..a8b2f93b36 100755 --- a/reports/acquisitions_stats.pl +++ b/reports/acquisitions_stats.pl @@ -182,7 +182,11 @@ else { my $CGIsepChoice = GetDelimiterChoices; - my @branches = Koha::Libraries->search({}, { order_by => 'branchname' }); + my $libraries_filter = {}; + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $libraries_filter->{branchcode} = C4::Context->userenv->{branch}; + } + my @branches = Koha::Libraries->search($libraries_filter, { order_by => 'branchname' }); my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode'); my $ccode_label; diff --git a/reports/cash_register_stats.pl b/reports/cash_register_stats.pl index 3b790ff8ca..2391e82ae5 100755 --- a/reports/cash_register_stats.pl +++ b/reports/cash_register_stats.pl @@ -192,11 +192,15 @@ if ($do_it) { } +my $libraries_filter = {}; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $libraries_filter->{branchcode} = C4::Context->userenv->{branch}; +} $template->param( beginDate => $fromDate, endDate => $toDate, transaction_type => $transaction_type, - branchloop => Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed, + branchloop => Koha::Libraries->search($libraries_filter, { order_by => ['branchname'] })->unblessed, debit_types => \@debit_types, credit_types => \@credit_types, registerid => $registerid, diff --git a/reserve/request.pl b/reserve/request.pl index bf13c3dfb2..4940ac6474 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -559,6 +559,10 @@ foreach my $biblionumber (@biblionumbers) { unless ( C4::Context->IsSuperLibrarian ) { $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} ); } + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') && $item->{homebranch} ne $userenv->{branch} ) { + $item->{hide} = 1; + $hiddencount++; + } } } diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl index 99a0d3f587..cb0c039919 100755 --- a/reviews/reviewswaiting.pl +++ b/reviews/reviewswaiting.pl @@ -41,7 +41,12 @@ my $status = $query->param('status') || 0; my $reviewid = $query->param('reviewid'); my $page = $query->param('page') || 1; my $count = C4::Context->preference('numSearchResults') || 20; -my $total = Koha::Reviews->search_limited({ approved => $status })->count; +my $review_filter = { approved => $status }; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + # search_limited supplies the borrowernumber relation + $review_filter->{'borrowernumber.branchcode'} = C4::Context->userenv->{branch}; +} +my $total = Koha::Reviews->search_limited($review_filter)->count; if ( $op eq 'approve' ) { my $review = Koha::Reviews->find( $reviewid ); @@ -57,7 +62,7 @@ elsif ( $op eq 'delete' ) { } my $reviews = Koha::Reviews->search_limited( - { approved => $status }, + $review_filter, { rows => $count, page => $page, diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 6354d3bea2..679492a9fd 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -398,7 +398,11 @@ my @loop_data =(); my $i=0; my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; -my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. +my $libraries_filter = {}; +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $libraries_filter->{branchcode} = C4::Context->userenv->{branch}; +} +my $libraries = Koha::Libraries->search($libraries_filter, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. # Adding a default choice, in case the user does not want to modify the branch my $nochange_branch = { branchname => '', value => '', selected => 1 }; diff --git a/tools/export.pl b/tools/export.pl index 588f1b9c93..b3b80421d9 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -71,6 +71,9 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( ); my @branch = $query->multi_param("branch"); +if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + @branch = (C4::Context->userenv->{branch}); +} my @messages; if ( $op eq 'export' ) { @@ -91,6 +94,7 @@ if ( $op eq "export" ) { my @biblionumbers = $query->multi_param("biblionumbers"); my @itemnumbers = $query->multi_param("itemnumbers"); my $strip_items_not_from_libraries = $query->param('strip_items_not_from_libraries'); + $strip_items_not_from_libraries = 1 if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ); my $libraries = Koha::Libraries->search_filtered->unblessed; my $only_export_items_for_branches = $strip_items_not_from_libraries ? \@branch : undef; @@ -271,7 +275,11 @@ else { my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } ); - my $libraries = Koha::Libraries->search_filtered({}, { order_by => ['branchname'] })->unblessed; + my $library_filter = {}; + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $library_filter->{'branchcode'} = C4::Context->userenv->{branch}; + } + my $libraries = Koha::Libraries->search_filtered($library_filter, { order_by => ['branchname'] })->unblessed; for my $library ( @$libraries ) { $library->{selected} = 1 if grep { $library->{branchcode} eq $_ } @branch; } diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index ee896848d1..f5fed1953f 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -152,7 +152,11 @@ if ( $op eq 'show' ) { if @notfoundcardnumbers; # Construct drop-down list values - my $branches = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; + my $library_filter = {}; + if ( C4::Context->only_my_library('IndependentBranchesHideOtherBranchesItems') ) { + $library_filter->{'branchcode'} = C4::Context->userenv->{branch}; + } + my $branches = Koha::Libraries->search($library_filter, { order_by => ['branchname'] })->unblessed; my @branches_option; push @branches_option, { value => $_->{branchcode}, lib => $_->{branchname} } for @$branches; unshift @branches_option, { value => "", lib => "" }; -- 2.25.1