From 1b94349b59cf917d5e3c3e1932fc3980c2e04d98 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 4 Feb 2016 15:24:23 +0000
Subject: [PATCH] Bug 15758: Koha::Libraries - Remove GetBranches
---
C4/Auth.pm | 4 +-
C4/Branch.pm | 69 ----------------------
C4/Circulation.pm | 13 ++--
C4/Context.pm | 6 ++
C4/ILSDI/Services.pm | 7 +--
C4/Items.pm | 1 +
C4/Overdues.pm | 4 +-
C4/Search.pm | 15 ++---
C4/ShelfBrowser.pm | 5 +-
C4/XSLT.pm | 8 ++-
Koha/Libraries.pm | 21 ++++++-
Koha/Template/Plugin/Branches.pm | 21 ++-----
acqui/add_user_search.pl | 5 --
acqui/addorderiso2709.pl | 1 -
acqui/basket.pl | 5 +-
acqui/basketheader.pl | 2 -
acqui/invoices.pl | 21 -------
acqui/lateorders.pl | 1 -
acqui/neworderempty.pl | 1 -
acqui/newordersubscription.pl | 14 -----
acqui/orderreceive.pl | 1 -
admin/add_user_search.pl | 5 --
admin/aqbudgets.pl | 15 -----
admin/authorised_values.pl | 5 +-
admin/branch_transfer_limits.pl | 14 -----
admin/categories.pl | 12 ++--
admin/item_circulation_alerts.pl | 16 -----
admin/patron-attr-types.pl | 14 ++---
admin/smart-rules.pl | 2 +-
admin/transport-cost-matrix.pl | 9 +--
catalogue/detail.pl | 8 +--
catalogue/itemsearch.pl | 11 +---
catalogue/search.pl | 8 ++-
cataloguing/addbiblio.pl | 18 ++----
cataloguing/value_builder/unimarc_field_4XX.pl | 1 -
circ/add_message.pl | 1 -
circ/bookcount.pl | 9 +--
circ/branchtransfers.pl | 15 ++---
circ/circulation.pl | 3 -
circ/del_message.pl | 1 -
circ/returns.pl | 23 ++------
circ/selectbranchprinter.pl | 10 +---
circ/transferstoreceive.pl | 12 ++--
.../prog/en/includes/branch-selector.inc | 6 +-
.../prog/en/includes/subscriptions-search.inc | 9 +--
.../prog/en/modules/acqui/invoices.tt | 11 +---
.../prog/en/modules/admin/aqbudgets.tt | 3 +-
.../en/modules/admin/branch_transfer_limits.tt | 14 ++---
.../en/modules/admin/item_circulation_alerts.tt | 11 +---
.../prog/en/modules/admin/smart-rules.tt | 4 +-
koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 3 +-
.../prog/en/modules/catalogue/advsearch.tt | 4 +-
.../prog/en/modules/catalogue/detail.tt | 4 +-
.../prog/en/modules/circ/bookcount.tt | 7 ++-
.../prog/en/modules/circ/branchtransfers.tt | 6 +-
.../intranet-tmpl/prog/en/modules/circ/returns.tt | 10 ++--
.../prog/en/modules/common/patron_search.tt | 8 ++-
.../prog/en/modules/reports/borrowers_stats.tt | 2 +-
.../prog/en/modules/reserve/request.tt | 14 ++---
.../rotating_collections/transferCollection.tt | 11 +---
.../prog/en/modules/serials/serials-search.tt | 9 +--
.../prog/en/modules/serials/subscription-add.tt | 10 ++--
.../prog/en/modules/suggestion/suggestion.tt | 17 ++++--
.../intranet-tmpl/prog/en/modules/tools/export.tt | 3 +-
.../prog/en/modules/tools/holidays.tt | 1 -
.../prog/en/modules/tools/inventory.tt | 2 +-
.../prog/en/modules/tools/koha-news.tt | 31 +++-------
.../bootstrap/en/includes/item-status.inc | 4 +-
.../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 6 +-
.../bootstrap/en/modules/opac-topissues.tt | 3 +-
members/deletemem.pl | 1 -
members/guarantor_search.pl | 5 --
members/memberentry.pl | 1 -
members/pay.pl | 1 -
members/paycollect.pl | 1 -
members/readingrec.pl | 4 --
members/routing-lists.pl | 3 -
opac/opac-basket.pl | 6 +-
opac/opac-detail.pl | 16 +++--
opac/opac-reserve.pl | 15 ++---
opac/opac-search.pl | 14 ++---
opac/opac-topissues.pl | 3 +-
opac/opac-user.pl | 1 -
patroncards/add_user_search.pl | 5 --
reports/acquisitions_stats.pl | 8 +--
reports/borrowers_stats.pl | 5 +-
reports/issues_avg_stats.pl | 1 -
reports/issues_by_borrower_category.plugin | 2 -
reserve/request.pl | 20 ++-----
rotating_collections/transferCollection.pl | 13 ----
serials/add_user_search.pl | 5 --
serials/serials-search.pl | 15 -----
serials/subscription-add.pl | 24 +-------
suggestion/suggestion.pl | 31 ++--------
svc/cataloguing/framework | 8 +--
t/db_dependent/Circulation/GetIssues.t | 8 +--
t/db_dependent/Overdues.t | 5 +-
tools/export.pl | 53 ++++++-----------
tools/holidays.pl | 5 --
tools/inventory.pl | 1 -
tools/koha-news.pl | 4 --
tools/letter.pl | 1 -
tools/newHolidays.pl | 11 ++--
103 files changed, 278 insertions(+), 668 deletions(-)
diff --git a/C4/Auth.pm b/C4/Auth.pm
index d65401b..4aeef89 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -1072,7 +1072,7 @@ sub checkauth {
$branchcode = $query->param('branch');
$branchname = Koha::Libraries->find($branchcode)->branchname;
}
- my $branches = C4::Branch::GetBranches();
+ my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
# we have to check they are coming from the right ip range
@@ -1511,7 +1511,7 @@ sub check_api_auth {
$branchcode = $query->param('branch');
$branchname = Koha::Libraries->find($branchcode)->branchname;
}
- my $branches = C4::Branch::GetBranches();
+ my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
foreach my $br ( keys %$branches ) {
# now we work with the treatment of ip
diff --git a/C4/Branch.pm b/C4/Branch.pm
index 8cedd8b..63ceafa 100644
--- a/C4/Branch.pm
+++ b/C4/Branch.pm
@@ -30,7 +30,6 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&GetBranch
- &GetBranches
);
@EXPORT_OK = qw( &onlymine );
}
@@ -49,76 +48,8 @@ The functions in this module deal with branches.
=head1 FUNCTIONS
-=head2 GetBranches
-
- $branches = &GetBranches();
-
-Returns informations about ALL branches, IndependentBranches Insensitive.
-
-Create a branch selector with the following code.
-
-=head3 in PERL SCRIPT
-
- my $branches = GetBranches;
- my @branchloop;
- foreach my $thisbranch (sort keys %$branches) {
- my $selected = 1 if $thisbranch eq $branch;
- my %row =(value => $thisbranch,
- selected => $selected,
- branchname => $branches->{$thisbranch}->{branchname},
- );
- push @branchloop, \%row;
- }
-
-=head3 in TEMPLATE
-
- <select name="branch" id="branch">
- <option value=""></option>
- [% FOREACH branchloo IN branchloop %]
- [% IF ( branchloo.selected ) %]
- <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
- [% ELSE %]
- <option value="[% branchloo.value %]" >[% branchloo.branchname %]</option>
- [% END %]
- [% END %]
- </select>
-
=cut
-sub GetBranches {
- my ($onlymine) = @_;
-
- # returns a reference to a hash of references to ALL branches...
- my %branches;
- my $dbh = C4::Context->dbh;
- my $sth;
- my $query = "SELECT * FROM branches";
- my @bind_parameters;
- if ( $onlymine && C4::Context->userenv && C4::Context->userenv->{branch} ) {
- $query .= ' WHERE branchcode = ? ';
- push @bind_parameters, C4::Context->userenv->{branch};
- }
- $query .= " ORDER BY branchname";
- $sth = $dbh->prepare($query);
- $sth->execute(@bind_parameters);
-
- my $relations_sth =
- $dbh->prepare("SELECT branchcode,categorycode FROM branchrelations");
- $relations_sth->execute();
- my %relations;
- while ( my $rel = $relations_sth->fetchrow_hashref ) {
- push @{ $relations{ $rel->{branchcode} } }, $rel->{categorycode};
- }
-
- while ( my $branch = $sth->fetchrow_hashref ) {
- foreach my $cat ( @{ $relations{ $branch->{branchcode} } } ) {
- $branch->{category}{$cat} = 1;
- }
- $branches{ $branch->{'branchcode'} } = $branch;
- }
- return ( \%branches );
-}
-
sub onlymine {
return
C4::Context->preference('IndependentBranches')
diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 90bc68b..4ed74e6 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -33,7 +33,6 @@ use C4::Accounts;
use C4::ItemCirculationAlertPreference;
use C4::Message;
use C4::Debug;
-use C4::Branch; # GetBranches
use C4::Log; # logaction
use C4::Koha qw(
GetAuthorisedValueByCode
@@ -307,7 +306,6 @@ sub transferbook {
my ( $tbr, $barcode, $ignoreRs ) = @_;
my $messages;
my $dotransfer = 1;
- my $branches = GetBranches();
my $itemnumber = GetItemnumberFromBarcode( $barcode );
my $issue = GetItemIssue($itemnumber);
my $biblio = GetBiblioFromItemNumber($itemnumber);
@@ -336,7 +334,10 @@ sub transferbook {
}
# if is permanent...
- if ( $hbr && $branches->{$hbr}->{'PE'} ) {
+ # FIXME Is this still used by someone?
+ # See other FIXME in AddReturn
+ my $library = Koha::Libraries->find($hbr);
+ if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
$messages->{'IsPermanent'} = $hbr;
$dotransfer = 0;
}
@@ -1875,8 +1876,10 @@ sub AddReturn {
# check if the book is in a permanent collection....
# FIXME -- This 'PE' attribute is largely undocumented. afaict, there's no user interface that reflects this functionality.
if ( $returnbranch ) {
- my $branches = GetBranches(); # a potentially expensive call for a non-feature.
- $branches->{$returnbranch}->{PE} and $messages->{'IsPermanent'} = $returnbranch;
+ my $library = Koha::Libraries->find($returnbranch);
+ if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
+ $messages->{'IsPermanent'} = $returnbranch;
+ }
}
# check if the return is allowed at this branch
diff --git a/C4/Context.pm b/C4/Context.pm
index 341438a..42fbcee 100644
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@ -1127,6 +1127,12 @@ sub interface {
return $context->{interface} // 'opac';
}
+# always returns a string for OK comparison via "eq" or "ne"
+sub mybranch {
+ C4::Context->userenv or return '';
+ return C4::Context->userenv->{branch} || '';
+}
+
1;
__END__
diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm
index 60cbc62..e3643c2 100644
--- a/C4/ILSDI/Services.pm
+++ b/C4/ILSDI/Services.pm
@@ -23,7 +23,6 @@ use warnings;
use C4::Members;
use C4::Items;
use C4::Circulation;
-use C4::Branch;
use C4::Accounts;
use C4::Biblio;
use C4::Reserves qw(AddReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest);
@@ -622,8 +621,7 @@ sub HoldTitle {
# Pickup branch management
if ( $cgi->param('pickup_location') ) {
$branch = $cgi->param('pickup_location');
- my $branches = GetBranches;
- return { code => 'LocationNotFound' } unless $$branches{$branch};
+ return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
} else { # if the request provide no branch, use the borrower's branch
$branch = $$borrower{branchcode};
}
@@ -700,8 +698,7 @@ sub HoldItem {
my $branch;
if ( $cgi->param('pickup_location') ) {
$branch = $cgi->param('pickup_location');
- my $branches = GetBranches();
- return { code => 'LocationNotFound' } unless $$branches{$branch};
+ return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
} else { # if the request provide no branch, use the borrower's branch
$branch = $$borrower{branchcode};
}
diff --git a/C4/Items.pm b/C4/Items.pm
index 125f81d..c288301 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -1328,6 +1328,7 @@ sub GetItemsInfo {
COALESCE( localization.translation, itemtypes.description ) AS translated_description,
itemtypes.notforloan as notforloan_per_itemtype,
holding.branchurl,
+ holding.branchcode,
holding.branchname,
holding.opac_info as holding_branch_opac_info,
home.opac_info as home_branch_opac_info
diff --git a/C4/Overdues.pm b/C4/Overdues.pm
index 37711ba..202fe79 100644
--- a/C4/Overdues.pm
+++ b/C4/Overdues.pm
@@ -34,6 +34,7 @@ use C4::Log; # logaction
use C4::Debug;
use C4::Budgets qw(GetCurrency);
use Koha::DateUtils;
+use Koha::Libraries;
use vars qw($VERSION @ISA @EXPORT);
@@ -774,8 +775,7 @@ sub GetBranchcodesWithOverdueRules {
|);
if ( $branchcodes->[0] eq '' ) {
# If a default rule exists, all branches should be returned
- my $availbranches = C4::Branch::GetBranches();
- return keys %$availbranches;
+ return map { $_->branchcode } Koha::Libraries->search({}, { order_by => 'branchname' });
}
return @$branchcodes;
}
diff --git a/C4/Search.pm b/C4/Search.pm
index d8b72da..9b9c72c 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -28,7 +28,6 @@ use C4::Search::PazPar2;
use XML::Simple;
use C4::Members qw(GetHideLostItemsPreference);
use C4::XSLT;
-use C4::Branch;
use C4::Reserves; # GetReserveStatus
use C4::Debug;
use C4::Charset;
@@ -332,6 +331,8 @@ sub getRecords {
my @servers = @$servers_ref;
my @sort_by = @$sort_by_ref;
+ $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
+
# Initialize variables for the ZOOM connection and results object
my $zconn;
my @zconns;
@@ -846,6 +847,8 @@ sub pazGetRecords {
$query_type, $scan
) = @_;
+ $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
+
my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
$paz->init();
$paz->search($simple_query);
@@ -1816,14 +1819,8 @@ sub searchResults {
}
#Build branchnames hash
- #find branchname
- #get branch information.....
- my %branches;
- my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches"); # FIXME : use C4::Branch::GetBranches
- $bsth->execute();
- while ( my $bdata = $bsth->fetchrow_hashref ) {
- $branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'};
- }
+ my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
+
# FIXME - We build an authorised values hash here, using the default framework
# though it is possible to have different authvals for different fws.
diff --git a/C4/ShelfBrowser.pm b/C4/ShelfBrowser.pm
index 3af36a5..13dd916 100644
--- a/C4/ShelfBrowser.pm
+++ b/C4/ShelfBrowser.pm
@@ -23,9 +23,9 @@ use strict;
use warnings;
use C4::Biblio;
-use C4::Branch;
use C4::Context;
use C4::Koha;
+use Koha::Libraries;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
@@ -118,7 +118,6 @@ sub GetNearbyItems {
if $gap <= $num_each_side;
my $dbh = C4::Context->dbh;
- my $branches = GetBranches();
my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
$sth_get_item_details->execute($itemnumber);
@@ -130,7 +129,7 @@ sub GetNearbyItems {
if (C4::Context->preference('ShelfBrowserUsesHomeBranch') &&
defined($item_details_result->{'homebranch'})) {
$start_homebranch->{code} = $item_details_result->{'homebranch'};
- $start_homebranch->{description} = $branches->{$item_details_result->{'homebranch'}}{branchname};
+ $start_homebranch->{description} = Koha::Libraries->find($item_details_result->{'homebranch'})->branchname;
}
if (C4::Context->preference('ShelfBrowserUsesLocation') &&
defined($item_details_result->{'location'})) {
diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 7a94f2c..e90e2d1 100644
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -32,6 +32,7 @@ use C4::Biblio;
use C4::Circulation;
use C4::Reserves;
use Koha::XSLT_Handler;
+use Koha::Libraries;
use Encode;
@@ -247,7 +248,8 @@ sub buildKohaItemsNamespace {
my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
- my $branches = GetBranches();
+ my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
+
my $itemtypes = GetItemTypes();
my $location = "";
my $ccode = "";
@@ -288,8 +290,8 @@ sub buildKohaItemsNamespace {
} else {
$status = "available";
}
- my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):'';
- my $holdingbranch = $item->{holdingbranch}? xml_escape($branches->{$item->{holdingbranch}}->{'branchname'}):'';
+ my $homebranch = $item->{homebranch}? xml_escape($branches{$item->{homebranch}}->{'branchname'}):'';
+ my $holdingbranch = $item->{holdingbranch}? xml_escape($branches{$item->{holdingbranch}}->{'branchname'}):'';
$location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):'';
$ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):'';
my $itemcallnumber = xml_escape($item->{itemcallnumber});
diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm
index eeb3213..eb41184 100644
--- a/Koha/Libraries.pm
+++ b/Koha/Libraries.pm
@@ -21,8 +21,9 @@ use Modern::Perl;
use Carp;
-use Koha::Database;
+use C4::Context;
+use Koha::Database;
use Koha::Library;
use base qw(Koha::Objects);
@@ -37,6 +38,24 @@ Koha::Libraries - Koha Library Object set class
=cut
+=head3 search_filtered
+
+=cut
+
+sub search_filtered {
+ my ( $self, $params, $attributes ) = @_;
+
+ if ( C4::Context->preference('IndependentBranches')
+ and C4::Context->userenv
+ and not C4::Context->IsSuperLibrarian()
+ and C4::Context->userenv->{branch}
+ ) {
+ $params->{branchcode} = C4::Context->userenv->{branch};
+ }
+
+ return $self->SUPER::search( $params, $attributes );
+}
+
=head3 type
=cut
diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm
index df9d04e..b41d3e4 100644
--- a/Koha/Template/Plugin/Branches.pm
+++ b/Koha/Template/Plugin/Branches.pm
@@ -25,6 +25,7 @@ use base qw( Template::Plugin );
use C4::Koha;
use C4::Context;
+use Koha::Libraries;
sub GetName {
my ( $self, $branchcode ) = @_;
@@ -57,21 +58,11 @@ sub GetURL {
sub all {
my ( $self, $params ) = @_;
my $selected = $params->{selected};
- my $dbh = C4::Context->dbh;
- my @params;
- my $query = q|
- SELECT branchcode, branchname
- FROM branches
- |;
- if ( C4::Context->preference('IndependentBranches')
- and C4::Context->userenv
- && !C4::Context->IsSuperLibrarian()
- and C4::Context->userenv->{branch} )
- {
- $query .= q| WHERE branchcode = ? |;
- push @params, C4::Context->userenv->{branch};
- }
- my $libraries = $dbh->selectall_arrayref( $query, { Slice => {} }, @params );
+ my $unfiltered = $params->{unfiltered} || 0;
+
+ my $libraries = $unfiltered
+ ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed
+ : Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed;
for my $l ( @$libraries ) {
if ( $selected and $l->{branchcode} eq $selected
diff --git a/acqui/add_user_search.pl b/acqui/add_user_search.pl
index ab1f1ca..d2481c6 100755
--- a/acqui/add_user_search.pl
+++ b/acqui/add_user_search.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch qw( GetBranches );
use C4::Output;
use C4::Members;
@@ -52,9 +51,6 @@ my $search_patrons_with_acq_perm_only =
( $referer =~ m|acqui/basket.pl| )
? 1 : 0;
-my $onlymine = C4::Branch::onlymine;
-my $branches = C4::Branch::GetBranches( $onlymine );
-
my $patron_categories = Koha::Patron::Categories->search_limited;
$template->param(
patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
@@ -64,7 +60,6 @@ $template->param(
selection_type => 'add',
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
- branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );
diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index 5656d77..b04d7a8 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -39,7 +39,6 @@ use C4::Koha;
use C4::Budgets;
use C4::Acquisition;
use C4::Suggestions; # GetSuggestion
-use C4::Branch; # GetBranches
use C4::Members;
use Koha::Number::Price;
diff --git a/acqui/basket.pl b/acqui/basket.pl
index decf0f4..2a9d3af 100755
--- a/acqui/basket.pl
+++ b/acqui/basket.pl
@@ -28,13 +28,13 @@ use C4::Output;
use CGI qw ( -utf8 );
use C4::Acquisition;
use C4::Budgets;
-use C4::Branch;
use C4::Contract;
use C4::Debug;
use C4::Biblio;
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket
use C4::Items;
use C4::Suggestions;
+use Koha::Libraries;
use Date::Calc qw/Add_Delta_Days/;
=head1 NAME
@@ -226,6 +226,7 @@ if ( $op eq 'delete_confirm' ) {
exit 1;
}
}
+
if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
push @branches_loop, {
branchcode => $userenv->{branch},
@@ -235,7 +236,7 @@ if ( $op eq 'delete_confirm' ) {
}
} else {
# get branches
- my $branches = C4::Branch::GetBranches;
+ my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
my @branchcodes = sort {
$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
} keys %$branches;
diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl
index b52db3e..454fc33 100755
--- a/acqui/basketheader.pl
+++ b/acqui/basketheader.pl
@@ -50,7 +50,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth;
-use C4::Branch;
use C4::Output;
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
use C4::Contract qw/GetContracts/;
@@ -72,7 +71,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
#parameters:
my $booksellerid = $input->param('booksellerid');
my $basketno = $input->param('basketno');
-my $branches = GetBranches;
my $basket;
my $op = $input ->param('op');
my $is_an_edit= $input ->param('is_an_edit');
diff --git a/acqui/invoices.pl b/acqui/invoices.pl
index 48adb80..436c5c2 100755
--- a/acqui/invoices.pl
+++ b/acqui/invoices.pl
@@ -34,7 +34,6 @@ use C4::Auth;
use C4::Output;
use C4::Acquisition qw/GetInvoices/;
-use C4::Branch qw/GetBranches/;
use C4::Budgets;
use Koha::DateUtils;
@@ -105,24 +104,6 @@ foreach (@suppliers) {
};
}
-# Build branches list
-my $branches = GetBranches();
-my $branches_loop = [];
-my $branchname;
-foreach ( sort keys %$branches ) {
- my $selected = 0;
- if ( $branch && $branch eq $_ ) {
- $selected = 1;
- $branchname = $branches->{$_}->{'branchname'};
- }
- push @{$branches_loop},
- {
- branchcode => $_,
- branchname => $branches->{$_}->{branchname},
- selected => $selected,
- };
-}
-
my $budgets = GetBudgets();
my @budgets_loop;
foreach my $budget (@$budgets) {
@@ -147,9 +128,7 @@ $template->param(
publisher => $publisher,
publicationyear => $publicationyear,
branch => $branch,
- branchname => $branchname,
suppliers_loop => $suppliers_loop,
- branches_loop => $branches_loop,
);
output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl
index 2d6fdc5..3bb2fed 100755
--- a/acqui/lateorders.pl
+++ b/acqui/lateorders.pl
@@ -52,7 +52,6 @@ use C4::Output;
use C4::Context;
use C4::Acquisition;
use C4::Letters;
-use C4::Branch; # GetBranches
use Koha::DateUtils;
my $input = new CGI;
diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index b8a94b3..2bca626 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -81,7 +81,6 @@ use C4::Biblio; # GetBiblioData GetMarcPrice
use C4::Items; #PrepareItemRecord
use C4::Output;
use C4::Koha;
-use C4::Branch; # GetBranches
use C4::Members;
use C4::Search qw/FindDuplicate/;
diff --git a/acqui/newordersubscription.pl b/acqui/newordersubscription.pl
index 7353dc9..81bc18d 100755
--- a/acqui/newordersubscription.pl
+++ b/acqui/newordersubscription.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Acquisition;
use C4::Auth;
-use C4::Branch;
use C4::Context;
use C4::Output;
use C4::Serials;
@@ -76,18 +75,6 @@ foreach my $sub (@subscriptions) {
}
}
-my $branches = GetBranches();
-my @branches_loop;
-foreach (sort keys %$branches){
- my $selected = 0;
- $selected = 1 if defined $branch && $branch eq $_;
- push @branches_loop, {
- branchcode => $_,
- branchname => $branches->{$_}->{branchname},
- selected => $selected,
- };
-}
-
$template->param(
subs_loop => \@subscriptions,
title_filter => $title,
@@ -96,7 +83,6 @@ $template->param(
publisher_filter => $publisher,
supplier_filter => $supplier,
branch_filter => $branch,
- branches_loop => \@branches_loop,
done_searched => $searched,
routing => $routing,
booksellerid => $booksellerid,
diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl
index b07ee0f..d815022 100755
--- a/acqui/orderreceive.pl
+++ b/acqui/orderreceive.pl
@@ -69,7 +69,6 @@ use C4::Auth;
use C4::Output;
use C4::Budgets qw/ GetBudget GetBudgetHierarchy CanUserUseBudget GetBudgetPeriods /;
use C4::Members;
-use C4::Branch; # GetBranches
use C4::Items;
use C4::Biblio;
use C4::Suggestions;
diff --git a/admin/add_user_search.pl b/admin/add_user_search.pl
index 4f0391a..ba3989a 100755
--- a/admin/add_user_search.pl
+++ b/admin/add_user_search.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch qw( GetBranches );
use C4::Output;
use C4::Members;
@@ -53,9 +52,6 @@ my $search_patrons_with_acq_perm_only =
( $referer =~ m|admin/aqbudgets.pl| )
? 1 : 0;
-my $onlymine = C4::Branch::onlymine;
-my $branches = C4::Branch::GetBranches( $onlymine );
-
my $patron_categories = Koha::Patron::Categories->search_limited;
$template->param(
patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
@@ -65,7 +61,6 @@ $template->param(
selection_type => $selection_type,
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
- branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );
diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl
index a6fda8c..3aa95b4 100755
--- a/admin/aqbudgets.pl
+++ b/admin/aqbudgets.pl
@@ -26,7 +26,6 @@ use List::Util qw/min/;
use Koha::Database;
use C4::Auth qw/get_user_subpermissions/;
-use C4::Branch; # GetBranches
use C4::Auth;
use C4::Acquisition;
use C4::Budgets;
@@ -140,18 +139,6 @@ if ($op eq 'add_form') {
}
$budget_parent = GetBudget($budget_parent_id);
- # build branches select
- my $branches = GetBranches;
- my @branchloop_select;
- foreach my $thisbranch ( sort keys %$branches ) {
- my %row = (
- value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
- );
- $row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'};
- push @branchloop_select, \%row;
- }
-
# populates the YUI planning button
my $categories = GetAuthorisedValueCategories();
my @auth_cats_loop1 = ();
@@ -199,7 +186,6 @@ if ($op eq 'add_form') {
budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
budget_parent_id => $budget_parent->{'budget_id'},
budget_parent_name => $budget_parent->{'budget_name'},
- branchloop_select => \@branchloop_select,
%$period,
%$budget,
);
@@ -257,7 +243,6 @@ if ($op eq 'add_form') {
}
if ( $op eq 'list' ) {
- my $branches = GetBranches();
$template->param(
budget_id => $budget_id,
%$period,
diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl
index 0f00126..86c0931 100755
--- a/admin/authorised_values.pl
+++ b/admin/authorised_values.pl
@@ -21,12 +21,12 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch;
use C4::Context;
use C4::Koha;
use C4::Output;
use Koha::AuthorisedValues;
+use Koha::Libraries;
my $input = new CGI;
my $id = $input->param('id');
@@ -56,9 +56,8 @@ if ($op eq 'add_form') {
$category = $input->param('category');
}
- my $branches = GetBranches;
+ my $branches = Koha::Libraries->search->unblessed;
my @branches_loop;
-
foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) {
my $selected = ( grep {$_ eq $branchcode} @$selected_branches ) ? 1 : 0;
push @branches_loop, {
diff --git a/admin/branch_transfer_limits.pl b/admin/branch_transfer_limits.pl
index d1e59c7..3c46146 100755
--- a/admin/branch_transfer_limits.pl
+++ b/admin/branch_transfer_limits.pl
@@ -26,7 +26,6 @@ use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Koha;
-use C4::Branch;
use C4::Circulation qw{ IsBranchTransferAllowed DeleteBranchTransferLimits CreateBranchTransferLimit };
my $input = new CGI;
@@ -50,18 +49,6 @@ else
$branchcode = $input->param('branchcode');
}
-# Getting the branches for user selection
-my $branches = GetBranches();
-my @branch_loop;
-for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
- my %row =(value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
- selected => $thisbranch eq $branchcode ? 1 : 0,
- );
- push @branch_loop, \%row;
-}
-
-
# Set the template language for the correct limit type using $limitType
my $limitType = C4::Context->preference("BranchTransferLimitsType") || "ccode";
@@ -132,7 +119,6 @@ foreach my $code ( @codes ) {
$template->param(
branchcount => $branchcount,
codes_loop => \@codes_loop,
- branch_loop => \@branch_loop,
branchcode_loop => \@branchcode_loop,
branchcode => $branchcode,
limitType => $limitType,
diff --git a/admin/categories.pl b/admin/categories.pl
index 1370b58..1d5b015 100755
--- a/admin/categories.pl
+++ b/admin/categories.pl
@@ -23,13 +23,13 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth;
-use C4::Branch;
use C4::Output;
use C4::Form::MessagingPreferences;
use Koha::Borrowers;
use Koha::Database;
use Koha::DateUtils;
use Koha::Patron::Categories;
+use Koha::Libraries;
my $input = new CGI;
my $searchfield = $input->param('description') // q||;
@@ -55,13 +55,13 @@ if ( $op eq 'add_form' ) {
$selected_branches = $category->branch_limitations;
}
- my $branches = GetBranches;
+ my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
my @branches_loop;
- foreach my $branchcode ( sort { uc( $branches->{$a}->{branchname} ) cmp uc( $branches->{$b}->{branchname} ) } keys %$branches ) {
- my $selected = ( grep { $_ eq $branchcode } @$selected_branches ) ? 1 : 0;
+ foreach my $branch ( @$branches ) {
+ my $selected = ( grep { $_->{branchcode} eq $branch } @$selected_branches ) ? 1 : 0;
push @branches_loop,
- { branchcode => $branchcode,
- branchname => $branches->{$branchcode}->{branchname},
+ { branchcode => $branch->{branchcode},
+ branchname => $branches->{branchname},
selected => $selected,
};
}
diff --git a/admin/item_circulation_alerts.pl b/admin/item_circulation_alerts.pl
index 3e6e6dd..5e9c463 100755
--- a/admin/item_circulation_alerts.pl
+++ b/admin/item_circulation_alerts.pl
@@ -26,7 +26,6 @@ use JSON;
use C4::Auth;
use C4::Context;
-use C4::Branch;
use C4::ItemCirculationAlertPreference;
use C4::Output;
@@ -51,28 +50,13 @@ sub show {
}
);
- my $br = GetBranches;
my $branch = $input->param('branch') || '*';
- my @branches = (
- {
- branchcode => '*',
- branchname => 'Default',
- },
- sort { $a->{branchname} cmp $b->{branchname} } values %$br,
- );
- for (@branches) {
- $_->{selected} = "selected" if ($branch eq $_->{branchcode});
- }
- my $branch_name = exists($br->{$branch}) && $br->{$branch}->{branchname};
-
my @categories = Koha::Patron::Categories->search_limited;
my @item_types = Koha::ItemTypes->search;
my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
my $grid_checkin = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
$template->param(branch => $branch);
- $template->param(branch_name => $branch_name || 'Default');
- $template->param(branches => \@branches);
$template->param(categories => \@categories);
$template->param(item_types => \@item_types);
$template->param(grid_checkout => $grid_checkout);
diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl
index 03dd4d6..b015dfb 100755
--- a/admin/patron-attr-types.pl
+++ b/admin/patron-attr-types.pl
@@ -25,12 +25,12 @@ use CGI qw ( -utf8 );
use List::MoreUtils qw/uniq/;
use C4::Auth;
-use C4::Branch;
use C4::Context;
use C4::Output;
use C4::Koha;
use C4::Members::AttributeTypes;
+use Koha::Libraries;
use Koha::Patron::Categories;
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
@@ -84,7 +84,7 @@ exit 0;
sub add_attribute_type_form {
my $template = shift;
- my $branches = GetBranches;
+ my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
my @branches_loop;
foreach my $branch (sort keys %$branches) {
push @branches_loop, {
@@ -260,14 +260,14 @@ sub edit_attribute_type_form {
pa_classes( $template, $attr_type->class );
- my $branches = GetBranches;
+ my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
my @branches_loop;
my $selected_branches = $attr_type->branches;
- foreach my $branch (sort keys %$branches) {
- my $selected = ( grep {$$_{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
+ foreach my $branch (@$branches) {
+ my $selected = ( grep {$_->{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
push @branches_loop, {
- branchcode => $branches->{$branch}{branchcode},
- branchname => $branches->{$branch}{branchname},
+ branchcode => $branch->{branchcode},
+ branchname => $branch->{branchname},
selected => $selected,
};
}
diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl
index 87c09f3..0363e74 100755
--- a/admin/smart-rules.pl
+++ b/admin/smart-rules.pl
@@ -25,7 +25,7 @@ use C4::Output;
use C4::Auth;
use C4::Koha;
use C4::Debug;
-use C4::Branch; # GetBranches
+use C4::Branch;
use Koha::DateUtils;
use Koha::Database;
use Koha::IssuingRule;
diff --git a/admin/transport-cost-matrix.pl b/admin/transport-cost-matrix.pl
index 55fd912..0aab030 100755
--- a/admin/transport-cost-matrix.pl
+++ b/admin/transport-cost-matrix.pl
@@ -25,9 +25,10 @@ use C4::Output;
use C4::Auth;
use C4::Koha;
use C4::Debug;
-use C4::Branch; # GetBranches
use C4::HoldsQueue qw(TransportCostMatrix UpdateTransportCostMatrix);
+use Koha::Libraries;
+
use Data::Dumper;
my $input = new CGI;
@@ -50,11 +51,7 @@ unless ($update) {
$have_matrix = keys %$cost_matrix if $cost_matrix;
}
-my $branches = GetBranches();
-my @branchloop = map { code => $_,
- name => $branches->{$_}->{'branchname'} },
- sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
- keys %$branches;
+my @branchloop = map { code => $_->branchcode, name => $_->branchname }, Koha::Libraries->search({}, { order_by => 'branchname' });
my (@branchfromloop, @errors);
foreach my $branchfrom ( @branchloop ) {
my $fromcode = $branchfrom->{code};
diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index fe8a15d..39eb757 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -28,7 +28,6 @@ use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Circulation;
-use C4::Branch;
use C4::Reserves;
use C4::Members; # to use GetMember
use C4::Serials;
@@ -118,7 +117,6 @@ my $marchostsarray = GetMarcHosts($record,$marcflavour);
my $subtitle = GetRecordValue('subtitle', $record, $fw);
# Get Branches, Itemtypes and Locations
-my $branches = GetBranches();
my $itemtypes = GetItemTypes();
my $dbh = C4::Context->dbh;
@@ -237,7 +235,7 @@ foreach my $item (@items) {
$item->{ReservedForBorrowernumber} = $reservedfor;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
- $item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
+ $item->{ExpectedAtLibrary} = $expectedAt;
$item->{Reservedcardnumber} = $ItemBorrowerReserveInfo->{'cardnumber'};
# Check waiting status
$item->{waitingdate} = $wait;
@@ -248,8 +246,8 @@ foreach my $item (@items) {
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
$item->{transfertwhen} = $transfertwhen;
- $item->{transfertfrom} = $branches->{$transfertfrom}{branchname};
- $item->{transfertto} = $branches->{$transfertto}{branchname};
+ $item->{transfertfrom} = $transfertfrom;
+ $item->{transfertto} = $transfertto;
$item->{nocancel} = 1;
}
diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl
index 0378e48..1556a93 100755
--- a/catalogue/itemsearch.pl
+++ b/catalogue/itemsearch.pl
@@ -25,11 +25,11 @@ use C4::Auth;
use C4::Output;
use C4::Items;
use C4::Biblio;
-use C4::Branch;
use C4::Koha;
use Koha::Item::Search::Field qw(GetItemSearchFields);
use Koha::ItemTypes;
+use Koha::Libraries;
my $cgi = new CGI;
my %params = $cgi->Vars;
@@ -247,14 +247,7 @@ if (scalar keys %params > 0) {
if ($format eq 'html') {
# Retrieve data required for the form.
- my $branches = GetBranches();
- my @branches;
- foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches) {
- push @branches, {
- value => $branchcode,
- label => $branches->{$branchcode}->{branchname},
- };
- }
+ my @branches = map { value => $_->branchcode => label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } );
my @locations;
foreach my $location (@$location_values) {
push @locations, {
diff --git a/catalogue/search.pl b/catalogue/search.pl
index 528ed22..2cfbbab 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -149,7 +149,6 @@ use C4::Koha;
use C4::Members qw(GetMember);
use URI::Escape;
use POSIX qw(ceil floor);
-use C4::Branch; # GetBranches
use C4::Search::History;
use Koha::LibraryCategories;
@@ -229,7 +228,10 @@ if($cgi->cookie("holdfor")){
my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
-$template->param(searchdomainloop => $categories);
+$template->param(
+ selected_branchcode => ( C4::Context->IsSuperLibrarian ? C4::Context->userenv : '' ),
+ searchdomainloop => $categories
+);
# load the Type stuff
my $itemtypes = GetItemTypes;
@@ -512,7 +514,7 @@ my $facets; # this object stores the faceted results that display on the left-ha
my $results_hashref;
eval {
- ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$query_type,$scan);
};
# This sorts the facets into alphabetical order
diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index e34557c..9eac700 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -31,11 +31,12 @@ use C4::Context;
use MARC::Record;
use C4::Log;
use C4::Koha; # XXX subfield_is_koha_internal_p
-use C4::Branch; # XXX subfield_is_koha_internal_p
use C4::ClassSource;
use C4::ImportBatch;
use C4::Charset;
+use Koha::Libraries;
+
use Date::Calc qw(Today);
use MARC::File::USMARC;
use MARC::File::XML;
@@ -171,18 +172,11 @@ sub build_authorized_values_list {
#---- branch
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- #Use GetBranches($onlymine)
- my $onlymine =
- C4::Context->preference('IndependentBranches')
- && C4::Context->userenv
- && !C4::Context->IsSuperLibrarian()
- && C4::Context->userenv->{branch};
- my $branches = GetBranches($onlymine);
- foreach my $thisbranch ( sort keys %$branches ) {
- push @authorised_values, $thisbranch;
- $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
+ my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']});
+ while ( my $l = $libraries->next ) {
+ push @authorised_values, $l->branchcode;;
+ $authorised_lib{$l->branchcode} = $l->branchname;
}
-
}
elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
push @authorised_values, ""
diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl
index 092b0f1..3eb78f3 100755
--- a/cataloguing/value_builder/unimarc_field_4XX.pl
+++ b/cataloguing/value_builder/unimarc_field_4XX.pl
@@ -31,7 +31,6 @@ use C4::Output;
use C4::Biblio;
use C4::Koha;
use MARC::Record;
-use C4::Branch; # GetBranches
use Koha::ItemTypes;
diff --git a/circ/add_message.pl b/circ/add_message.pl
index 912314a..9d04d2d 100755
--- a/circ/add_message.pl
+++ b/circ/add_message.pl
@@ -30,7 +30,6 @@ use C4::Accounts;
use C4::Stats;
use C4::Koha;
use C4::Overdues;
-use C4::Branch; # GetBranches
my $input = new CGI;
diff --git a/circ/bookcount.pl b/circ/bookcount.pl
index d4d3e54..2976a05 100755
--- a/circ/bookcount.pl
+++ b/circ/bookcount.pl
@@ -29,7 +29,6 @@ use C4::Circulation;
use C4::Output;
use C4::Koha;
use C4::Auth;
-use C4::Branch; # GetBranches
use C4::Biblio; # GetBiblioItemData
use Koha::DateUtils;
use Koha::Libraries;
@@ -38,14 +37,10 @@ my $input = new CGI;
my $itm = $input->param('itm');
my $bi = $input->param('bi');
my $biblionumber = $input->param('biblionumber');
-my $branches = GetBranches;
my $idata = itemdatanum($itm);
my $data = GetBiblioItemData($bi);
-my $homebranch = $branches->{ $idata->{'homebranch'} }->{'branchname'};
-my $holdingbranch = $branches->{ $idata->{'holdingbranch'} }->{'branchname'};
-
my $lastmove = lastmove($itm);
my $lastdate;
@@ -83,8 +78,8 @@ $template->param(
author => $data->{'author'},
barcode => $idata->{'barcode'},
biblioitemnumber => $bi,
- homebranch => $homebranch,
- holdingbranch => $holdingbranch,
+ homebranch => $idata->{homebranch},
+ holdingbranch => $idata->{holdingbranch},
lastdate => $lastdate ? $lastdate : 0,
count => $count,
libraries => $libraries,
diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl
index 8b7bddd..eb0a4f7 100755
--- a/circ/branchtransfers.pl
+++ b/circ/branchtransfers.pl
@@ -29,7 +29,6 @@ use C4::Reserves;
use C4::Biblio;
use C4::Items;
use C4::Auth qw/:DEFAULT get_session/;
-use C4::Branch; # GetBranches
use C4::Koha;
use C4::Members;
@@ -61,8 +60,6 @@ my ($template, $user, $cookie) = get_template_and_user(
}
);
-my $branches = GetBranches;
-
my $messages;
my $found;
my $reserved;
@@ -131,8 +128,7 @@ if ($barcode) {
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'};
$item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
- $item{'frbrname'} = $branches->{$frbranchcd}->{'branchname'};
- $item{'tobrname'} = $branches->{$tobranchcd}->{'branchname'};
+ $item{'tobrname'} = $tobranchcd;
# }
$item{counter} = 0;
$item{barcode} = $barcode;
@@ -164,8 +160,7 @@ foreach ( $query->param ) {
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'};
$item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
- $item{'frbrname'} = $branches->{$frbcd}->{'branchname'};
- $item{'tobrname'} = $branches->{$tobcd}->{'branchname'};
+ $item{'tobrname'} = $tobcd;
push( @trsfitemloop, \%item );
}
@@ -196,16 +191,16 @@ foreach my $code ( keys %$messages ) {
$err{errbadcode} = 1;
}
elsif ( $code eq "NotAllowed" ) {
- warn "NotAllowed: $messages->{'NotAllowed'} to " . $branches->{ $messages->{'NotAllowed'} }->{'branchname'};
+ warn "NotAllowed: $messages->{'NotAllowed'} to branchcode " . $messages->{'NotAllowed'};
# Do we really want a error log message here? --atz
$err{errnotallowed} = 1;
my ( $tbr, $typecode ) = split( /::/, $messages->{'NotAllowed'} );
- $err{tbr} = $branches->{ $tbr }->{'branchname'};
+ $err{tbr} = $tbr;
$err{code} = $typecode;
}
elsif ( $code eq 'IsPermanent' ) {
$err{errispermanent} = 1;
- $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+ $err{msg} = $messages->{'IsPermanent'};
}
elsif ( $code eq 'WasReturned' ) {
$err{errwasreturned} = 1;
diff --git a/circ/circulation.pl b/circ/circulation.pl
index 3944cc7..24e6efb 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -30,7 +30,6 @@ use DateTime::Duration;
use C4::Output;
use C4::Print;
use C4::Auth qw/:DEFAULT get_session haspermission/;
-use C4::Branch; # GetBranches
use C4::Koha; # GetPrinter
use C4::Circulation;
use C4::Utils::DataTables::Members;
@@ -133,8 +132,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
}
);
-my $branches = GetBranches();
-
my $force_allow_issue = $query->param('forceallow') || 0;
if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) {
$force_allow_issue = 0;
diff --git a/circ/del_message.pl b/circ/del_message.pl
index 6b8d560..933ca13 100755
--- a/circ/del_message.pl
+++ b/circ/del_message.pl
@@ -30,7 +30,6 @@ use C4::Accounts;
use C4::Stats;
use C4::Koha;
use C4::Overdues;
-use C4::Branch; # GetBranches
my $input = new CGI;
diff --git a/circ/returns.pl b/circ/returns.pl
index b294124..ba98c95 100755
--- a/circ/returns.pl
+++ b/circ/returns.pl
@@ -44,7 +44,6 @@ use C4::Reserves;
use C4::Biblio;
use C4::Items;
use C4::Members;
-use C4::Branch; # GetBranches
use C4::Koha; # FIXME : is it still useful ?
use C4::RotatingCollections;
use Koha::DateUtils;
@@ -82,7 +81,6 @@ if ( $query->param('print_slip') ) {
#####################
#Global vars
-my $branches = GetBranches();
my $printers = GetPrinters();
my $userenv = C4::Context->userenv;
my $userenv_branch = $userenv->{'branch'} // '';
@@ -388,7 +386,6 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
);
my $reserve = $messages->{'ResFound'};
- my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
$template->param(
@@ -414,7 +411,6 @@ if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
#
if ( $messages->{'ResFound'}) {
my $reserve = $messages->{'ResFound'};
- my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
@@ -434,8 +430,7 @@ if ( $messages->{'ResFound'}) {
# same params for Waiting or Reserved
$template->param(
found => 1,
- currentbranch => $branches->{$userenv_branch}->{'branchname'},
- destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
+ destbranchname => $reserve->{'branchcode'},
name => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
borfirstname => $borr->{'firstname'},
borsurname => $borr->{'surname'},
@@ -471,7 +466,7 @@ foreach my $code ( keys %$messages ) {
elsif ( $code eq 'NotIssued' ) {
$err{notissued} = 1;
$err{msg} = '';
- $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'} if $messages->{'IsPermanent'};
+ $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
}
elsif ( $code eq 'LocalUse' ) {
$err{localuse} = 1;
@@ -498,8 +493,7 @@ foreach my $code ( keys %$messages ) {
elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
$err{ispermanent} = 1;
- $err{msg} =
- $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
+ $err{msg} = $messages->{'IsPermanent'};
}
}
elsif ( $code eq 'WrongTransfer' ) {
@@ -601,18 +595,9 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
}
push @riloop, \%ri;
}
-my ($genbrname, $genprname);
-if (my $b = $branches->{$userenv_branch}) {
- $genbrname = $b->{'branchname'};
-}
-if (my $p = $printers->{$printer}) {
- $genprname = $p->{'printername'};
-}
+
$template->param(
riloop => \@riloop,
- genbrname => $genbrname,
- genprname => $genprname,
- branchname => $genbrname,
printer => $printer,
errmsgloop => \@errmsgloop,
exemptfine => $exemptfine,
diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl
index db7d7f1..2804489 100755
--- a/circ/selectbranchprinter.pl
+++ b/circ/selectbranchprinter.pl
@@ -26,7 +26,6 @@ use C4::Output;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Print; # GetPrinters
use C4::Koha;
-use C4::Branch; # GetBranches
use Koha::Libraries;
@@ -47,7 +46,6 @@ my $sessionID = $query->cookie("CGISESSID");
my $session = get_session($sessionID);
# try to get the branch and printer settings from http, fallback to userenv
-my $branches = GetBranches();
my $printers = GetPrinters();
my $branch = $query->param('branch' );
my $printer = $query->param('printer');
@@ -58,9 +56,9 @@ my $userenv_printer = C4::Context->userenv->{'branchprinter'} || '';
my @updated;
# $session lddines here are doing the updating
-if ($branch and $branches->{$branch}) {
+if ( $branch and my $library = Koha::Libraries->find($branch) ) {
if (! $userenv_branch or $userenv_branch ne $branch ) {
- my $branchname = Koha::Libraries->find($branch)->branchname;
+ my $branchname = $library->branchname;
$template->param(LoginBranchname => $branchname); # update template for new branch
$template->param(LoginBranchcode => $branch); # update template for new branch
$session->param('branchname', $branchname); # update sesssion in DB
@@ -94,10 +92,6 @@ if ($printer) {
$template->param(updated => \@updated) if (scalar @updated);
-unless ($branches->{$branch}) {
- $branch = (keys %$branches)[0]; # if branch didn't really exist, then replace it w/ one that does
-}
-
my @printkeys = sort keys %$printers;
if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
$printer = $printkeys[0]; # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl
index 4be2bcb..a67f799 100755
--- a/circ/transferstoreceive.pl
+++ b/circ/transferstoreceive.pl
@@ -23,7 +23,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Output;
-use C4::Branch; # GetBranches
use C4::Auth;
use Koha::DateUtils;
use C4::Biblio;
@@ -37,6 +36,7 @@ use Date::Calc qw(
use C4::Koha;
use C4::Reserves;
+use Koha::Libraries;
my $input = new CGI;
my $itemnumber = $input->param('itemnumber');
@@ -56,18 +56,18 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $default = C4::Context->userenv->{'branch'};
# get the all the branches for reference
-my $branches = GetBranches();
+my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' });
my @branchesloop;
my $latetransfers;
-foreach my $br ( keys %$branches ) {
+while ( my $library = $libraries->next ) {
my @transferloop;
my %branchloop;
my @gettransfers =
- GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
+ GetTransfersFromTo( $library->branchcode, $default );
if (@gettransfers) {
- $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
- $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
+ $branchloop{'branchname'} = $library->branchname;
+ $branchloop{'branchcode'} = $library->branchcode;
foreach my $num (@gettransfers) {
my %getransf;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc
index f3aa11a..bb17ec1 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc
@@ -10,12 +10,12 @@ END %]
[% FOREACH branch IN branches %]
<div class="branchgriditem">
[% IF branch.selected || (selectall == 1) %]
- <input id="branch_[% branch.value %]" type="checkbox" name="branch" value="[% branch.value %]" checked="checked" />
+ <input id="branch_[% branch.branchcode %]" type="checkbox" name="branch" value="[% branch.branchcode %]" checked="checked" />
[% ELSE %]
- <input id="branch_[% branch.value %]" type="checkbox" name="branch" value="[% branch.value %]" />
+ <input id="branch_[% branch.branchcode %]" type="checkbox" name="branch" value="[% branch.branchcode %]" />
[% END %]
- <label for="branch_[% branch.value %]">[% branch.branchname %]</label>
+ <label for="branch_[% branch.branchcode %]">[% branch.branchname %]</label>
</div>
[% IF loop.count() % 4 == 0 && !loop.last() %]
</div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc
index 4f6f1ca..94650f6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc
@@ -30,13 +30,8 @@
<label for="branch">Library:</label>
<select id="branch" name="branch_filter">
<option value="">All</option>
- [% FOREACH branch IN branches_loop %]
- [% IF (branch.selected) %]
- <option selected="branch.selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% ELSE %]
- <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% END %]
- [% END %]
+ [%# FIXME Should not we filter the libraries? %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
</select>
</li>
</ol>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
index e458af1..d1e6b59 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
@@ -262,7 +262,7 @@ $(document).ready(function() {
<li>Publication year: [% publicationyear %]</li>
[% END %]
[% IF ( branch ) %]
- <li>Library: [% branchname %]</li>
+ <li>Library: [% Branches.GetName( branch ) %]</li>
[% END %]
</ul>
</p>
@@ -348,13 +348,8 @@ $(document).ready(function() {
<label for="branch">Library:</label>
<select id="branch" name="branch">
<option value="">All</option>
- [% FOREACH branch IN branches_loop %]
- [% IF ( branch.selected ) %]
- <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% ELSE %]
- <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% END %]
- [% END %]
+ [%# FIXME Should not we filter the libraries %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
</select>
</li>
</ol>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt
index 198b597..7aec860 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt
@@ -1,3 +1,4 @@
+[% USE Branches %]
[% USE Price %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Administration › Funds[% IF op == 'add_form' %] › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
@@ -521,7 +522,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
<label for="budget_branchcode">Library: </label>
<select name="budget_branchcode" id="budget_branchcode">
<option value=""></option>
- [% PROCESS options_for_libraries libraries => branchloop_select %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
</select>
</li>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt
index 1cc394e..f4f46ad 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt
@@ -58,16 +58,10 @@
<h1>Library [% branchcode %] - [% Branches.GetName( branchcode ) %] Checkin and transfer policy</h1>
<form method="get" action="/cgi-bin/koha/admin/branch_transfer_limits.pl" id="selectlibrary">
<label for="branchselect">Select a library :</label>
- <select name="branchcode" id="branchselect">
- [% FOREACH branch_loo IN branch_loop %]
- [% IF ( branch_loo.selected ) %]
- <option value="[% branch_loo.value %]" selected="selected">[% branch_loo.branchname %]</option>
- [% ELSE %]
- <option value="[% branch_loo.value %]">[% branch_loo.branchname %]</option>
- [% END %]
- [% END %]
- </select>
- <input type="submit" value="Choose" />
+ <select name="branchcode" id="branchselect">
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1 ) %]
+ </select>
+ <input type="submit" value="Choose" />
</form>
<p class="help">Check the boxes for the libraries you accept to checkin items from.</p>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt
index b55709c..b38bc44 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt
@@ -103,13 +103,8 @@ $(function(){
<h2>Select a library:</h2>
<form id="branch_selector" method="get" action="/cgi-bin/koha/admin/item_circulation_alerts.pl">
<select id="branch" name="branch">
-[% FOREACH branche IN branches %]
-[% IF ( branche.selected ) %]
-<option value="[% branche.branchcode %]" selected="selected">[% branche.branchname %]</option>
-[% ELSE %]
-<option value="[% branche.branchcode %]">[% branche.branchname %]</option>
-[% END %]
-[% END %]
+ <option value="*">Default</option>
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
</select>
<input type="submit" name="pick" value="Pick" />
</form>
@@ -141,7 +136,7 @@ $(function(){
</div>
</div>
-<h2>Circulation alerts for [% branch_name %]</h2>
+<h2>Circulation alerts for [% Branches.GetName( branch ) || 'Default' %]</h2>
<p>Click on the grid to toggle the settings.</p>
<div id="alerttabs" class="toptabs">
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
index 4efa1b5..1af2ddb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
@@ -136,7 +136,7 @@ $(document).ready(function() {
Select a library :
<select name="branch" id="branch" style="width:20em;">
<option value="*">All libraries</option>
- [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch ) %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
</select>
</form>
[% IF ( definedbranch ) %]
@@ -144,7 +144,7 @@ $(document).ready(function() {
<label for="tobranch"><strong>Clone these rules to:</strong></label>
<input type="hidden" name="frombranch" value="[% current_branch %]" />
<select name="tobranch" id="tobranch">
- [% FOREACH l IN Branches.all() %]
+ [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
<option value="[% l.value %]">[% l.branchname %]</option>
[% END %]
</select>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
index 06124c2..3c7b778 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
@@ -1,3 +1,4 @@
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha ›
[% IF ( nopermission ) %]Access denied[% END %]
@@ -57,7 +58,7 @@
<p><label for="branch">Library:</label>
<select name="branch" id="branch" class="input" tabindex="3">
<option value="">My library</option>
- [% FOREACH l IN Branches.all() %]
+ [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
<option value="[% l.branchcode %]">[% l.branchname %]</option>
[% END %]
</select>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
index d26befc..1b2f88d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
@@ -1,3 +1,4 @@
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Catalog › Advanced search</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -238,7 +239,8 @@
<fieldset id="select-libs">
<p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
<option value="">All libraries</option>
- [% PROCESS options_for_libraries libraries => Branches.all() %]
+ [%# FIXME Should not we filter the libraries displayed? %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
</select></p>
<!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
[% IF ( searchdomainloop ) %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
index d32cc50..46b9006 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -644,7 +644,7 @@ function verify_images() {
: due [% item.datedue %]
</span>
[% ELSIF ( item.transfertwhen ) %]
- <span class="intransit">In transit from [% item.transfertfrom %] to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
+ <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) %] to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
[% END %]
[% IF ( item.itemlost ) %]
@@ -700,7 +700,7 @@ function verify_images() {
[% IF ( item.waitingdate ) %]
at[% ELSE %]for delivery at
[% END %]
- [% item.ExpectedAtLibrary %]
+ [% Branches.GetName( item.ExpectedAtLibrary ) %]
[% IF ( item.waitingdate ) %]
since [% item.waitingdate | $KohaDates %]
[% ELSE %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt
index ab21db6..fd8a39d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt
@@ -1,4 +1,5 @@
[% USE KohaDates %]
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Circulation › Circulation statistics for [% title %]</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -26,9 +27,9 @@ $(document).ready(function(){
<h3>Barcode [% barcode %]</h3>
<table>
<tr><th>Home library</th><th>Current library</th><th>Date arrived<br />at current library </th><th>Number of checkouts<br />since last transfer</th></tr>
-
- <tr><td>[% homebranch %]</td>
- <td>[% holdingbranch %]</td>
+
+ <tr><td>[% Branches.GetName( homebranch ) %]</td>
+ <td>[% Branches.GetName( holdingbranch ) %]</td>
<td>[% IF ( lastdate ) %][% lastdate | $KohaDates %][% ELSE %]Item has no transfer record[% END %]</td>
<td>[% count %]</td>
</tr>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt
index 0b2f618..185164e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt
@@ -111,7 +111,7 @@
<li>No Item with barcode: [% errmsgloo.msg %]</li>
[% END %]
[% IF ( errmsgloo.errispermanent ) %]
- <li>Please return item to home library: [% errmsgloo.msg %]</li>
+ <li>Please return item to home library: [% Branches.GetName( errmsgloo.msg ) %]</li>
[% END %]
[% IF ( errmsgloo.errnotallowed ) %]
<li>Transfer is not allowed for:
@@ -121,7 +121,7 @@
[% ELSE %]
<li>Collection code: <b>[% AuthorisedValues.GetByCode( 'CCODE', errmsgloo.code ) %]</b></li>
[% END %]
- <li>Destination library: <b>[% errmsgloo.tbr %]</b></li>
+ <li>Destination library: <b>[% Branches.GetName( errmsgloo.tbr ) %]</b></li>
</ol>
</li>
[% END %]
@@ -187,7 +187,7 @@
<td class="tf-itemcallnumber">[% trsfitemloo.itemcallnumber %]</td>
<td class="tf-itemtype">[% ItemTypes.GetDescription( trsfitemloo.itemtype ) %]</td>
<td class="tf-ccode">[% AuthorisedValues.GetByCode( 'CCODE', trsfitemloo.ccode ) %]</td>
- <td class="tf-destination">[% trsfitemloo.tobrname %]</td>
+ <td class="tf-destination">[% Branches.GetName( trsfitemloo.tobrname ) %]</td>
</tr>
[% END %]
</table>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
index cbe445d..eb4a285 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
@@ -227,10 +227,10 @@ $(document).ready(function () {
[% IF ( boremail ) %]<li><a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a></li>[% END %]
[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]</ul>
- [% IF ( transfertodo ) %]
- <h4><strong>Transfer to:</strong> [% destbranchname %]</h4>
- [% ELSE %]
- <h4><strong>Hold at</strong> [% destbranchname %]</h4>
+ [% IF ( transfertodo ) %]
+ <h4><strong>Transfer to:</strong> [% Branches.GetName( destbranchname ) %]</h4>
+ [% ELSE %]
+ <h4><strong>Hold at</strong> [% Branches.GetName( destbranchname ) %]</h4>
[% END %]
<form method="post" action="returns.pl" class="confirm">
<input type="hidden" name="cancel_reserve" value="0" />
@@ -450,7 +450,7 @@ $(document).ready(function () {
<p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
[% END %]
[% IF ( errmsgloo.ispermanent ) %]
- <p class="problem">Please return item to: [% errmsgloo.msg %]</p>
+ <p class="problem">Please return item to: [% Branches.GetName( errmsgloo.msg ) %]</p>
[% END %]
[% IF ( errmsgloo.notissued ) %]
<p class="problem">Not checked out.</p>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
index 20af6d0..edc8d57 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
@@ -1,4 +1,5 @@
[% USE Koha %]
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Patron search</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -179,11 +180,12 @@ function filterByFirstLetterSurname(letter) {
<li>
<label for="branchcode_filter">Library:</label>
<select id="branchcode_filter">
- [% IF branches.size != 1 %]
+ [% SET libraries = Branches.all() %]
+ [% IF libraries.size != 1 %]
<option value="">Any</option>
[% END %]
- [% FOREACH branch IN branches %]
- <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
+ [% FOREACH l IN libraries %]
+ <option value="[% l.branchcode %]">[% l.branchname %]</option>
[% END %]
</select>
</li>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt
index 7ce4bf1..0221c2e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt
@@ -143,7 +143,7 @@
<td>
<select name="Filter" size="1" id="branch">
<option value=""></option>
- [% FOREACH l IN Branches.all() %]
+ [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
<option value="[% l.branchcode %]">[% l.branchcode %] - [% l.branchname || 'UNKNOWN' %]</option>
[% END %]
</select>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
index 608bac9..2405647 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -14,10 +14,10 @@
<script type="text/javascript">
// <![CDATA[
var MSG_CONFIRM_DELETE_HOLD = _("Are you sure you want to cancel this hold?");
-var patron_homebranch = "[% borrower_branchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
+var patron_homebranch = "[% Branches.GetName( borrower_branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
[% itemloo.itemnumber %]: {
- homebranch: "[% itemloo.homebranchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
+ homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
holdallowed: [% itemloo.holdallowed %]
},
[% END %][% END %][% END %]
@@ -496,10 +496,10 @@ function checkMultiHold() {
[% itemloo.barcode %]
</td>
<td>
- [% itemloo.homebranchname %]
+ [% Branches.GetName( itemloo.homebranch ) %]
</td>
<td>
- [% itemloo.holdingbranchname %]
+ [% Branches.GetName( itemloo.holdingbranch ) %]
</td>
<td>
[% itemloo.itemcallnumber %]
@@ -518,8 +518,8 @@ function checkMultiHold() {
[% ELSE %]
<span title="0000-00-00">
[% IF ( itemloo.transfertwhen ) %]
- In transit from [% itemloo.transfertfrom %],
- to [% itemloo.transfertto %], since [% itemloo.transfertwhen %]
+ In transit from [% Branches.GetName( itemloo.transfertfrom ) %],
+ to [% Branches.GetName( itemloo.transfertto ) %], since [% itemloo.transfertwhen %]
[% END %]
</span>
[% END %]
@@ -537,7 +537,7 @@ function checkMultiHold() {
Can't be cancelled when item is in transit
[% ELSE %]
[% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
- [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedForBorrowernumber %]">[% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemloo.ExpectedAtLibrary %]
+ [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedForBorrowernumber %]">[% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% Branches.GetName( itemloo.ExpectedAtLibrary ) %]
since
[% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber %]&CancelBorrowerNumber=[% itemloo.ReservedForBorrowernumber %]&CancelItemnumber=[% itemloo.itemnumber %]" onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt
index 1228827..43f76a4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt
@@ -1,3 +1,4 @@
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Tools › Rotating collections › Transfer collection</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -37,13 +38,7 @@
<li>
<label for="toBranch">Choose your library:</label>
<select id="toBranch" name="toBranch">
- [% FOREACH branchoptionloo IN branchoptionloop %]
- [% IF ( branchoptionloo.selected ) %]
- <option value="[% branchoptionloo.code %]" selected="selected">[% branchoptionloo.name %]</option>
- [% ELSE %]
- <option value="[% branchoptionloo.code %]">[% branchoptionloo.name %]</option>
- [% END %]
- [% END %]
+ [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
</select>
</li>
</ol>
@@ -61,4 +56,4 @@
[% INCLUDE 'tools-menu.inc' %]
</div>
</div> <!-- /#bd -->
-[% INCLUDE 'intranet-bottom.inc' %]
\ No newline at end of file
+[% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
index 7f407dd..fbe3295 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
@@ -89,13 +89,8 @@
<label for="branch">Library:</label>
<select id="branch" name="branch_filter">
<option value="">All</option>
- [% FOREACH branch IN branches_loop %]
- [% IF ( branch.selected ) %]
- <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% ELSE %]
- <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
- [% END %]
- [% END %]
+ [%# FIXME Should not we filter the libraries? %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
</select>
</li>
[% IF locations %]
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 cc2575c..b9698c7 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
@@ -559,12 +559,10 @@ $(document).ready(function() {
[% UNLESS ( Independentbranches ) %]
<option value="">None</option>
[% END %]
- [% FOREACH branchloo IN branchloop %]
- [% IF ( branchloo.selected ) %]
- <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
- [% ELSE %]
- <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
- [% END %]
+ [% IF CAN_user_serials_superserials %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1 ) %]
+ [% ELSE %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
[% END %]
</select> (select a library)
</li>
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 395dd2c..79063c7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
@@ -409,8 +409,12 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
<fieldset class="rows"> <legend>Acquisition information</legend><ol>
<li><label for="branchcode">Library:</label>
<select name="branchcode" id="branchcode">
- <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
- [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %][% END %]
+ <option value="">Any</option>
+ [% IF branchfilter %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
+ [% ELSE %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
+ [% END %]
</select>
</li>
<li><label for="budgetid">Fund:</label>
@@ -763,9 +767,12 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
</select></li>
<li><label for="branchcode"> For:</label>
<select name="branchcode" id="branchcode">
- <option value="__ANY__">Any</option>[% FOREACH branchloo IN branchloop %]
- [% IF ( branchloo.selected ) %] <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %] <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
- [% END %]
+ <option value="__ANY__">Any</option>
+ [% IF branchfilter %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
+ [% ELSE %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
+ [% END %]
</select></li><li><input type="submit" value="Go" /></li></ol>
</fieldset>
</div>
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 83bc50a..c105cea 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
@@ -1,3 +1,4 @@
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Tools › MARC export</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -78,7 +79,7 @@ $(document).ready(function() {
<li>
<label>Library: </label>
[% INCLUDE 'branch-selector.inc'
- branches = branchloop %]
+ branches = libraries %]
</li>
<li>
<label for="startcn">From item call number: </label>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt
index 36fcb99..3851daf 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt
@@ -313,7 +313,6 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl
<!-- ***************************** Panel to deal with new holidays ********************** -->
<div class="panel" id="newHoliday">
<form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
- <input type="hidden" name="branchCodes" id="branchCodes" value="[% branchcodes %]" />
<fieldset class="brief">
<h3>Add new holiday</h3>
<ol>
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 5cf0453..45b4054 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt
@@ -139,7 +139,7 @@ $(document).ready(function(){
</li><li>
<label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
<option value="">All libraries</option>
- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
</select>
</li>
[% 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 21bec07..921c219 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
@@ -1,4 +1,5 @@
[% USE KohaDates %]
+[% USE Branches %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Tools › News</title>
[% INCLUDE 'doc-head-close.inc' %]
@@ -108,18 +109,12 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
<li>
<label for="branch">Library: </label>
<select id="branch" name="branch">
- [% IF ( new_detail.branchcode == '' ) %]
- <option value="" selected="selected">All libraries</option>
- [% ELSE %]
- <option value="" >All libraries</option>
- [% END %]
- [% FOREACH branch_item IN branch_list %]
- [% IF ( branch_item.value.branchcode == new_detail.branchcode ) %]
- <option value="[% branch_item.value.branchcode %]" selected="selected">[% branch_item.value.branchname %]</option>
- [% ELSE %]
- <option value="[% branch_item.value.branchcode %]">[% branch_item.value.branchname %]</option>
- [% END %]
- [% END %]
+ [% IF ( new_detail.branchcode == '' ) %]
+ <option value="" selected="selected">All libraries</option>
+ [% ELSE %]
+ <option value="" >All libraries</option>
+ [% END %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
</select>
</li>
<li>
@@ -187,17 +182,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
[% ELSE %]
<option value="" >All libraries</option>
[% END %]
- [% FOREACH branch_item IN branch_list %]
- [% IF ( branch_item.value.branchcode == branchcode ) %]
- <option value="[% branch_item.value.branchcode %]"
- selected="selected">[% branch_item.value.branchname %]
- </option>
- [% ELSE %]
- <option value="[% branch_item.value.branchcode %]"
- >[% branch_item.value.branchname %]
- </option>
- [% END %]
- [% END %]
+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
</select>
<input type="submit" class="button" value="Filter" />
</form>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
index 23b3a19..2b041c0 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
@@ -41,8 +41,8 @@ not use an API to fetch items that populates item.datedue.
[% IF ( item.transfertwhen ) %]
[% SET itemavailable = 0 %]
- <span class="item-status intransit">In transit from [% item.transfertfrom %]
- to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
+ <span class="item-status intransit">In transit from [% Branches.GetName( item.transfertfrom ) %]
+ to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
[% END %]
[% IF ( item.waiting ) %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
index ea8fcfa..17a57ed 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
@@ -321,8 +321,8 @@
<td class="barcode">[% itemLoo.barcode %]</td>
[% UNLESS ( singleBranchMode ) %]
- <td class="homebranch">[% itemLoo.homeBranchName %]</td>
- <td class="holdingbranch">[% itemLoo.holdingBranchName %]</td>
+ <td class="homebranch">[% Branches.GetName( itemLoo.homeBranchName ) %]</td>
+ <td class="holdingbranch">[% Branches.GetName( itemLoo.holdingBranchName ) %]</td>
[% END %]
<td class="call_no">[% itemLoo.callNumber %]</td>
[% IF ( itemdata_enumchron ) %]
@@ -332,7 +332,7 @@
[% IF ( itemLoo.dateDue ) %]
<span class="checkedout">Due [% itemLoo.dateDue %]</span>
[% ELSIF ( itemLoo.transfertwhen ) %]
- <span class="intransit">In transit from [% itemLoo.transfertfrom %] to [% itemLoo.transfertto %] since [% itemLoo.transfertwhen %]</span>
+ <span class="intransit">In transit from [% Branches.GetName( itemLoo.transfertfrom ) %] to [% Branches.GetName( itemLoo.transfertto ) %] since [% itemLoo.transfertwhen %]</span>
[% END %]
[% IF ( itemLoo.message ) %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
index d881264..17cf924 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
@@ -1,4 +1,5 @@
[% USE Koha %]
+[% USE Branches %]
[% USE AuthorisedValues %]
[% USE ItemTypes %]
[% INCLUDE 'doc-head-open.inc' %]
@@ -41,7 +42,7 @@
[% END %]
[% IF ( branch ) %]
at
- [% branch %]
+ [% Branches.GetName( branch ) %]
[% END %]
[% IF ( timeLimit != 999 ) %]
in the past [% timeLimitFinite %] months
diff --git a/members/deletemem.pl b/members/deletemem.pl
index 192eef3..a97d699 100755
--- a/members/deletemem.pl
+++ b/members/deletemem.pl
@@ -29,7 +29,6 @@ use C4::Context;
use C4::Output;
use C4::Auth;
use C4::Members;
-use C4::Branch; # GetBranches
use Module::Load;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
diff --git a/members/guarantor_search.pl b/members/guarantor_search.pl
index d34b828..352f124 100755
--- a/members/guarantor_search.pl
+++ b/members/guarantor_search.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch qw( GetBranches );
use C4::Output;
use C4::Members;
@@ -45,9 +44,6 @@ my $op = $input->param('op') || '';
my $referer = $input->referer();
-my $onlymine = C4::Branch::onlymine;
-my $branches = C4::Branch::GetBranches( $onlymine );
-
my $patron_categories = Koha::Patron::Categories->search_limited;
$template->param(
view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
@@ -56,7 +52,6 @@ $template->param(
selection_type => 'select',
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
- branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );
diff --git a/members/memberentry.pl b/members/memberentry.pl
index a6acf37..8b1253b 100755
--- a/members/memberentry.pl
+++ b/members/memberentry.pl
@@ -37,7 +37,6 @@ use C4::Members::AttributeTypes;
use C4::Koha;
use C4::Log;
use C4::Letters;
-use C4::Branch; # GetBranches
use C4::Form::MessagingPreferences;
use Koha::Borrower::Debarments;
use Koha::DateUtils;
diff --git a/members/pay.pl b/members/pay.pl
index 6632053..686a838 100755
--- a/members/pay.pl
+++ b/members/pay.pl
@@ -39,7 +39,6 @@ use C4::Accounts;
use C4::Stats;
use C4::Koha;
use C4::Overdues;
-use C4::Branch;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patron::Categories;
diff --git a/members/paycollect.pl b/members/paycollect.pl
index 72b435c..9b21f1a 100755
--- a/members/paycollect.pl
+++ b/members/paycollect.pl
@@ -28,7 +28,6 @@ use C4::Members;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Accounts;
use C4::Koha;
-use C4::Branch;
use Koha::Patron::Categories;
diff --git a/members/readingrec.pl b/members/readingrec.pl
index 82ca44f..ec1f122 100755
--- a/members/readingrec.pl
+++ b/members/readingrec.pl
@@ -28,7 +28,6 @@ use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
use C4::Members;
-use C4::Branch qw(GetBranches);
use List::MoreUtils qw/any uniq/;
use Koha::DateUtils;
use C4::Members::Attributes qw(GetBorrowerAttributes);
@@ -73,8 +72,6 @@ if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
$issues = GetAllIssues($borrowernumber,$order,$limit);
}
-my $branches = GetBranches();
-
# barcode export
if ( $op eq 'export_barcodes' ) {
if ( $data->{'privacy'} < 2) {
@@ -129,7 +126,6 @@ $template->param(
privacy => $data->{'privacy'},
categoryname => $data->{description},
is_child => ( $data->{category_type} eq 'C' ),
- branchname => $branches->{ $data->{branchcode} }->{branchname},
loop_reading => $issues,
activeBorrowerRelationship =>
( C4::Context->preference('borrowerRelationship') ne '' ),
diff --git a/members/routing-lists.pl b/members/routing-lists.pl
index af6d4bb..cec3462 100755
--- a/members/routing-lists.pl
+++ b/members/routing-lists.pl
@@ -22,7 +22,6 @@ use strict;
use CGI qw ( -utf8 );
use C4::Output;
use C4::Auth qw/:DEFAULT get_session/;
-use C4::Branch; # GetBranches
use C4::Members;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Context;
@@ -53,8 +52,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
}
);
-my $branches = GetBranches();
-
my $findborrower = $query->param('findborrower');
$findborrower =~ s|,| |g;
diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl
index d41b7a7..f87f8c6 100755
--- a/opac/opac-basket.pl
+++ b/opac/opac-basket.pl
@@ -21,7 +21,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Koha;
use C4::Biblio;
-use C4::Branch;
use C4::Items;
use C4::Circulation;
use C4::Auth;
@@ -91,7 +90,6 @@ foreach my $biblionumber ( @bibs ) {
$dat->{'even'} = 1;
}
-my $branches = GetBranches();
for my $itm (@items) {
if ($itm->{'location'}){
$itm->{'location_opac'} = $shelflocations->{$itm->{'location'} };
@@ -99,8 +97,8 @@ my $branches = GetBranches();
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
$itm->{transfertwhen} = $transfertwhen;
- $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
- $itm->{transfertto} = $branches->{$transfertto}{branchname};
+ $itm->{transfertfrom} = $transfertfrom;
+ $itm->{transfertto} = $transfertto;
}
}
$num++;
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 5db728b..7b82f47 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -188,7 +188,6 @@ if ($session->param('busc')) {
my ($arrParamsBusc, $offset, $results_per_page) = @_;
my $expanded_facet = $arrParamsBusc->{'expand'};
- my $branches = GetBranches();
my $itemtypes = GetItemTypes;
my @servers;
@servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
@@ -200,7 +199,7 @@ if ($session->param('busc')) {
$sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
my ($error, $results_hashref, $facets);
eval {
- ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
+ ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
};
my $hits;
my @newresults;
@@ -480,7 +479,6 @@ if ($hideitems) {
@items = @all_items;
}
-my $branches = GetBranches();
my $branch = '';
if (C4::Context->userenv){
$branch = C4::Context->userenv->{branch};
@@ -491,19 +489,19 @@ if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
||
C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
) {
- my $branchname;
+ my $branchcode;
if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
- $branchname = $branches->{$branch}->{'branchname'};
+ $branchcode = $branch;
}
elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
- $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
+ $branchcode = $ENV{'BRANCHCODE'};
}
my @our_items;
my @other_items;
foreach my $item ( @items ) {
- if ( $item->{'branchname'} eq $branchname ) {
+ if ( $item->{branchcode} eq $branchcode ) {
$item->{'this_branch'} = 1;
push( @our_items, $item );
} else {
@@ -669,8 +667,8 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
$itm->{transfertwhen} = $transfertwhen;
- $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
- $itm->{transfertto} = $branches->{$transfertto}{branchname};
+ $itm->{transfertfrom} = $transfertfrom;
+ $itm->{transfertto} = $transfertto;
}
if ( C4::Context->preference('OPACAcquisitionDetails')
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 0a4f945..e70ee89 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -30,7 +30,6 @@ use C4::Items;
use C4::Output;
use C4::Context;
use C4::Members;
-use C4::Branch; # GetBranches
use C4::Overdues;
use C4::Debug;
use Koha::DateUtils;
@@ -87,8 +86,7 @@ if ( $borr->{'BlockExpiredPatronOpacActions'} ) {
if ($borr->{reservefee} > 0){
$template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
}
-# get branches and itemtypes
-my $branches = GetBranches();
+
my $itemTypes = GetItemTypes();
# There are two ways of calling this script, with a single biblio num
@@ -123,7 +121,6 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
# pass the pickup branch along....
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
-($branches->{$branch}) or $branch = ""; # Confirm branch is real
$template->param( branch => $branch );
# Is the person allowed to choose their branch
@@ -432,7 +429,7 @@ foreach my $biblioNum (@biblionumbers) {
$itemLoopIter->{itemnumber} = $itemNum;
$itemLoopIter->{barcode} = $itemInfo->{barcode};
- $itemLoopIter->{homeBranchName} = $branches->{$itemInfo->{homebranch}}{branchname};
+ $itemLoopIter->{homeBranchName} = $itemInfo->{homebranch};
$itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
$itemLoopIter->{enumchron} = $itemInfo->{enumchron};
$itemLoopIter->{copynumber} = $itemInfo->{copynumber};
@@ -444,8 +441,7 @@ foreach my $biblioNum (@biblionumbers) {
# If the holdingbranch is different than the homebranch, we show the
# holdingbranch of the document too.
if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
- $itemLoopIter->{holdingBranchName} =
- $branches->{ $itemInfo->{holdingbranch} }{branchname};
+ $itemLoopIter->{holdingBranchName} = $itemInfo->{holdingbranch};
}
# If the item is currently on loan, we display its return date and
@@ -503,9 +499,8 @@ foreach my $biblioNum (@biblionumbers) {
GetTransfers($itemNum);
if ( $transfertwhen && ($transfertwhen ne '') ) {
$itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
- $itemLoopIter->{transfertfrom} =
- $branches->{$transfertfrom}{branchname};
- $itemLoopIter->{transfertto} = $branches->{$transfertto}{branchname};
+ $itemLoopIter->{transfertfrom} = $transfertfrom;
+ $itemLoopIter->{transfertto} = $transfertto;
$itemLoopIter->{nocancel} = 1;
}
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index 7120a51..e8a20df 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -38,7 +38,6 @@ use C4::Search::History;
use C4::Biblio; # GetBiblioData
use C4::Koha;
use C4::Tags qw(get_tags);
-use C4::Branch; # GetBranches
use C4::SocialData;
use C4::Ratings;
use C4::External::OverDrive;
@@ -202,7 +201,6 @@ if ($cgi->cookie("search_path_code")) {
}
}
-my $branches = GetBranches(); # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
$template->param( searchdomainloop => $library_categories );
@@ -597,7 +595,7 @@ if ($tag) {
# FIXME: No facets for tags search.
} elsif ($build_grouped_results) {
eval {
- ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
+ ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan);
};
} else {
$pasarParams .= '&query=' . uri_escape_utf8($query);
@@ -605,7 +603,7 @@ if ($tag) {
$pasarParams .= '&simple_query=' . uri_escape_utf8($simple_query);
$pasarParams .= '&query_type=' . uri_escape_utf8($query_type) if ($query_type);
eval {
- ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes_nocategory,$query_type,$scan,1);
+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes_nocategory,$query_type,$scan,1);
};
}
# This sorts the facets into alphabetical order
@@ -794,12 +792,12 @@ for (my $i=0;$i<@servers;$i++) {
||
C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
) {
- my $branchname;
+ my $branchcode;
if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
- $branchname = $branches->{$branch}->{'branchname'};
+ $branchcode = $branch;
}
elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
- $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
+ $branchcode = $ENV{'BRANCHCODE'};
}
foreach my $res ( @newresults ) {
@@ -807,7 +805,7 @@ for (my $i=0;$i<@servers;$i++) {
my @top_loop;
my @old_loop = @{$res->{'available_items_loop'}};
foreach my $item ( @old_loop ) {
- if ( $item->{'branchname'} eq $branchname ) {
+ if ( $item->{'branchcode'} eq $branchcode ) {
$item->{'this_branch'} = 1;
push( @top_loop, $item );
} else {
diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl
index 62aab0a..7d6dcca 100755
--- a/opac/opac-topissues.pl
+++ b/opac/opac-topissues.pl
@@ -49,7 +49,6 @@ if ( ! C4::Context->preference('OpacTopissue') ) {
exit;
}
-my $branches = GetBranches();
my $itemtypes = GetItemTypes();
my ($template, $borrowernumber, $cookie) = get_template_and_user(
@@ -95,7 +94,7 @@ my @results = GetTopIssues($params);
$template->param(
limit => $limit,
- branch => $branches->{$branch}->{branchname},
+ branch => $branch,
timeLimit => $timeLimit,
results => \@results,
);
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index a3975a6..398960d 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -33,7 +33,6 @@ use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Letters;
-use C4::Branch; # GetBranches
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Holds;
diff --git a/patroncards/add_user_search.pl b/patroncards/add_user_search.pl
index 67fa687..331ad31 100755
--- a/patroncards/add_user_search.pl
+++ b/patroncards/add_user_search.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch qw( GetBranches );
use C4::Output;
use C4::Members;
@@ -45,9 +44,6 @@ my $op = $input->param('op') || '';
my $referer = $input->referer();
-my $onlymine = C4::Branch::onlymine;
-my $branches = C4::Branch::GetBranches( $onlymine );
-
my $patron_categories = Koha::Patron::Categories->search_limited;
$template->param(
view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
@@ -56,7 +52,6 @@ $template->param(
selection_type => 'add',
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
- branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );
diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl
index 62895c6..e179e41 100755
--- a/reports/acquisitions_stats.pl
+++ b/reports/acquisitions_stats.pl
@@ -26,9 +26,9 @@ use C4::Reports;
use C4::Output;
use C4::Koha;
use C4::Circulation;
-use C4::Branch;
use C4::Biblio;
use Koha::DateUtils;
+use Koha::Libraries;
=head1 NAME
@@ -185,11 +185,7 @@ else {
my $CGIsepChoice = GetDelimiterChoices;
- my $branches = GetBranches;
- my @branches;
- foreach ( sort keys %$branches ) {
- push @branches, $branches->{$_};
- }
+ my @branches = Koha::Libraries->search({}, { order_by => 'branchname' });
my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', '');
my $ccode_label;
diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl
index c67a5d4..5202c18 100755
--- a/reports/borrowers_stats.pl
+++ b/reports/borrowers_stats.pl
@@ -23,7 +23,6 @@ use List::MoreUtils qw/uniq/;
use C4::Auth;
use C4::Context;
-use C4::Branch; # GetBranches
use C4::Koha;
use Koha::DateUtils;
use C4::Acquisition;
@@ -32,6 +31,7 @@ use C4::Reports;
use C4::Circulation;
use C4::Members::AttributeTypes;
+use Koha::Libraries;
use Koha::Patron::Categories;
use Date::Calc qw(
@@ -228,9 +228,10 @@ sub calculate {
}
}
+ my @branchcodes = map { $_->branchcode } Koha::Libraries->search;
($status ) and push @loopfilter,{crit=>"Status", filter=>$status };
($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity};
- push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort keys %$branches)};
+ push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort @branchcodes)};
push @loopfilter,{debug=>1, crit=>"(line, column)", filter=>"($line,$column)"};
# year of activity
my ( $period_year, $period_month, $period_day )=Add_Delta_YM( Today(),-$period, 0);
diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl
index ac50cd4..3dac58c 100755
--- a/reports/issues_avg_stats.pl
+++ b/reports/issues_avg_stats.pl
@@ -23,7 +23,6 @@ use strict;
use C4::Auth;
use CGI qw ( -utf8 );
use C4::Context;
-use C4::Branch; # GetBranches
use C4::Output;
use C4::Koha;
use C4::Circulation;
diff --git a/reports/issues_by_borrower_category.plugin b/reports/issues_by_borrower_category.plugin
index 27d837c..1c2d1d1 100755
--- a/reports/issues_by_borrower_category.plugin
+++ b/reports/issues_by_borrower_category.plugin
@@ -27,8 +27,6 @@ use C4::Output;
use C4::Koha;
use C4::Members;
-use C4::Branch; # GetBranches
-
use Koha::Patron::Categories;
=head1 NAME
diff --git a/reserve/request.pl b/reserve/request.pl
index 3828b8b..45d0854 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -28,7 +28,6 @@ script to place reserves/requests
use strict;
use warnings;
-use C4::Branch;
use CGI qw ( -utf8 );
use List::MoreUtils qw/uniq/;
use Date::Calc qw/Date_to_Days/;
@@ -64,8 +63,6 @@ my $multihold = $input->param('multi_hold');
$template->param(multi_hold => $multihold);
my $showallitems = $input->param('showallitems');
-# get Branches and Itemtypes
-my $branches = GetBranches();
my $itemtypes = GetItemTypes();
# Select borrowers infos
@@ -346,13 +343,12 @@ foreach my $biblionumber (@biblionumbers) {
$item->{itypename} = $itemtypes->{ $item->{itype} }{description};
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
- $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
+ $item->{homebranch} = $item->{homebranch};
# if the holdingbranch is different than the homebranch, we show the
# holdingbranch of the document too
if ( $item->{homebranch} ne $item->{holdingbranch} ) {
- $item->{holdingbranchname} =
- $branches->{ $item->{holdingbranch} }{branchname};
+ $item->{holdingbranch} = $item->{holdingbranch};
}
if($item->{biblionumber} ne $biblionumber){
@@ -378,7 +374,7 @@ foreach my $biblionumber (@biblionumbers) {
$item->{ReservedForBorrowernumber} = $reservedfor;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
- $item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
+ $item->{ExpectedAtLibrary} = $expectedAt;
$item->{waitingdate} = $wait;
}
@@ -410,9 +406,8 @@ foreach my $biblionumber (@biblionumbers) {
if ( defined $transfertwhen && $transfertwhen ne '' ) {
$item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
- $item->{transfertfrom} =
- $branches->{$transfertfrom}{branchname};
- $item->{transfertto} = $branches->{$transfertto}{branchname};
+ $item->{transfertfrom} = $transfertfrom;
+ $item->{transfertto} = $transfertto;
$item->{nocancel} = 1;
}
@@ -583,10 +578,7 @@ foreach my $biblionumber (@biblionumbers) {
C4::Search::enabled_staff_search_views,
);
if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
- $template->param(
- borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
- borrower_branchcode => $borrowerinfo->{'branchcode'},
- );
+ $template->param( borrower_branchcode => $borrowerinfo->{'branchcode'},);
}
$biblioloopiter{biblionumber} = $biblionumber;
diff --git a/rotating_collections/transferCollection.pl b/rotating_collections/transferCollection.pl
index fc29a4b..49b09b3 100755
--- a/rotating_collections/transferCollection.pl
+++ b/rotating_collections/transferCollection.pl
@@ -22,7 +22,6 @@ use C4::Output;
use C4::Auth;
use C4::Context;
use C4::RotatingCollections;
-use C4::Branch;
use CGI qw ( -utf8 );
@@ -60,17 +59,6 @@ if ($toBranch) {
}
}
-## Set up the toBranch select options
-my $branches = GetBranches();
-my @branchoptionloop;
-foreach my $br ( keys %$branches ) {
- my %branch;
- $branch{code} = $br;
- $branch{name} = $branches->{$br}->{'branchname'};
- push( @branchoptionloop, \%branch );
-}
-@branchoptionloop = sort {$a->{name} cmp $b->{name}} @branchoptionloop;
-
## Get data about collection
my ( $colTitle, $colDesc, $colBranchcode );
( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
@@ -79,7 +67,6 @@ $template->param(
colTitle => $colTitle,
colDesc => $colDesc,
colBranchcode => $colBranchcode,
- branchoptionloop => \@branchoptionloop
);
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/serials/add_user_search.pl b/serials/add_user_search.pl
index 6441a78..6cb177a 100755
--- a/serials/add_user_search.pl
+++ b/serials/add_user_search.pl
@@ -21,7 +21,6 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch qw( GetBranches );
use C4::Output;
use C4::Members;
@@ -45,10 +44,7 @@ my $op = $input->param('op') || '';
my $referer = $input->referer();
-my $onlymine = C4::Branch::onlymine;
-my $branches = C4::Branch::GetBranches( $onlymine );
my $patron_categories = Koha::Patron::Categories->search_limited;
-
$template->param(
view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
columns => ['cardnumber', 'name', 'branch', 'action'],
@@ -56,7 +52,6 @@ $template->param(
selection_type => 'add',
alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
categories => $patron_categories,
- branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
aaSorting => 1,
);
output_html_with_http_headers( $input, $cookie, $template->output );
diff --git a/serials/serials-search.pl b/serials/serials-search.pl
index 3e73c56..0afbada 100755
--- a/serials/serials-search.pl
+++ b/serials/serials-search.pl
@@ -31,7 +31,6 @@ this script is the search page for serials
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth;
-use C4::Branch;
use C4::Context;
use C4::Koha qw( GetAuthorisedValues );
use C4::Output;
@@ -131,19 +130,6 @@ for my $sub ( @subscriptions ) {
}
}
-my $branches = GetBranches();
-my @branches_loop;
-foreach (sort keys %$branches){
- my $selected = 0;
- $selected = 1 if( defined $branch and $branch eq $_ );
- push @branches_loop, {
- branchcode => $_,
- branchname => $branches->{$_}->{'branchname'},
- selected => $selected,
- };
-}
-
-
$template->param(
openedsubscriptions => \@openedsubscriptions,
closedsubscriptions => \@closedsubscriptions,
@@ -157,7 +143,6 @@ $template->param(
branch_filter => $branch,
locations => C4::Koha::GetAuthorisedValues('LOC', $location),
expiration_date_filter => $expiration_date_dt,
- branches_loop => \@branches_loop,
done_searched => $searched,
routing => $routing,
additional_field_filters => $additional_field_filters,
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index 31a1e35..a3eb860 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -26,7 +26,6 @@ use C4::Auth;
use C4::Acquisition;
use C4::Output;
use C4::Context;
-use C4::Branch; # GetBranches
use C4::Serials;
use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
@@ -126,29 +125,10 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
}
-my $onlymine =
- C4::Context->preference('IndependentBranches')
- && C4::Context->userenv
- && !C4::Context->IsSuperLibrarian
- && (
- not C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'superserials' } )
- )
- && C4::Context->userenv->{branch};
-my $branches = GetBranches($onlymine);
-my $branchloop;
-for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
- my $selected = 0;
- $selected = 1 if (defined($subs) && $thisbranch eq $subs->{'branchcode'});
- push @{$branchloop}, {
- value => $thisbranch,
- selected => $selected,
- branchname => $branches->{$thisbranch}->{'branchname'},
- };
-}
-
my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
-$template->param(branchloop => $branchloop,
+$template->param(
+ branchcode => $subs->{branchcode},
locations_loop=>$locations_loop,
);
diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl
index b40251e..ddc05fa 100755
--- a/suggestion/suggestion.pl
+++ b/suggestion/suggestion.pl
@@ -25,7 +25,6 @@ use C4::Auth; # get_template_and_user
use C4::Output;
use C4::Suggestions;
use C4::Koha; #GetItemTypes
-use C4::Branch;
use C4::Budgets;
use C4::Search;
use C4::Members;
@@ -60,7 +59,7 @@ sub GetCriteriumDesc{
}
return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
}
- return Koha::Libraries->find($criteriumvalue)->branchname;
+ return Koha::Libraries->find($criteriumvalue)->branchname
if $displayby =~ /branchcode/;
return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
@@ -298,31 +297,11 @@ if(defined($returnsuggested) and $returnsuggested ne "noone")
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions");
}
-####################
-## Initializing selection lists
-
-#branch display management
-my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
-my $onlymine =
- C4::Context->preference('IndependentBranches')
- && C4::Context->userenv
- && !C4::Context->IsSuperLibrarian()
- && C4::Context->userenv->{branch};
-my $branches = GetBranches($onlymine);
-my @branchloop;
-
-foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
- my %row = (
- value => $thisbranch,
- branchname => $branches->{$thisbranch}->{'branchname'},
- selected => ($branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter ) || ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} )
- );
- push @branchloop, \%row;
-}
-$branchfilter=C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
+my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : C4::Context->userenv->{'branch'};
-$template->param( branchloop => \@branchloop,
- branchfilter => $branchfilter);
+$template->param(
+ branchfilter => $branchfilter,
+);
$template->param( returnsuggestedby => $returnsuggestedby );
diff --git a/svc/cataloguing/framework b/svc/cataloguing/framework
index 49d341d..b0099e8 100755
--- a/svc/cataloguing/framework
+++ b/svc/cataloguing/framework
@@ -3,12 +3,12 @@
use Modern::Perl '2009';
use CGI;
-use C4::Branch;
use C4::ClassSource;
use C4::Context;
use C4::Biblio;
use C4::Service;
use Koha::Database;
+use Koha::Libraries;
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
@@ -29,12 +29,8 @@ foreach my $tag ( sort keys %$tagslib ) {
my $schema = Koha::Database->new->schema;
my $authorised_values = {};
+my $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search_filtered };
$authorised_values->{branches} = [];
-my $onlymine=C4::Context->preference('IndependentBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags} % 2 == 0 &&
- C4::Context->userenv->{branch};
-my $branches = GetBranches($onlymine);
foreach my $thisbranch ( sort keys %$branches ) {
push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch}->{'branchname'} };
}
diff --git a/t/db_dependent/Circulation/GetIssues.t b/t/db_dependent/Circulation/GetIssues.t
index b687045..3eee5df 100644
--- a/t/db_dependent/Circulation/GetIssues.t
+++ b/t/db_dependent/Circulation/GetIssues.t
@@ -7,9 +7,9 @@ use Test::MockModule;
use C4::Biblio;
use C4::Items;
use C4::Members;
-use C4::Branch;
use C4::Circulation;
use Koha::Library;
+use Koha::Libraries;
use Koha::Patron::Categories;
use MARC::Record;
@@ -21,9 +21,9 @@ $dbh->do(q|DELETE FROM issues|);
my $branchcode;
my $branch_created;
-my @branches = keys %{ GetBranches() };
-if (@branches) {
- $branchcode = $branches[0];
+my @libraries = Koha::Libraries->search;
+if (@libraries) {
+ $branchcode = $libraries[0]->branchcode;
} else {
$branchcode = 'B';
Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store;
diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t
index 7c53e97..bb5265f 100644
--- a/t/db_dependent/Overdues.t
+++ b/t/db_dependent/Overdues.t
@@ -4,7 +4,7 @@ use Modern::Perl;
use Test::More tests => 16;
use C4::Context;
-use C4::Branch;
+use Koha::Libraries;
use_ok('C4::Overdues');
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes');
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules');
@@ -83,8 +83,7 @@ $dbh->do(q|
( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 )
|);
-my $all_branches = C4::Branch::GetBranches;
-my @branchcodes = keys %$all_branches;
+my @branchcodes = map { $_->branchcode } Koha::Libraries->search;
my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules();
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' );
diff --git a/tools/export.pl b/tools/export.pl
index 2e8b044..38b9943 100755
--- a/tools/export.pl
+++ b/tools/export.pl
@@ -21,7 +21,6 @@ use CGI qw ( -utf8 );
use MARC::File::XML;
use List::MoreUtils qw(uniq);
use C4::Auth;
-use C4::Branch; # GetBranches
use C4::Csv;
use C4::Koha; # GetItemTypes
use C4::Output;
@@ -31,6 +30,7 @@ use Koha::Biblioitems;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Exporter::Record;
+use Koha::Libraries;
my $query = new CGI;
@@ -68,32 +68,26 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
);
my @branch = $query->param("branch");
-my $only_my_branch;
-# Limit to local branch if IndependentBranches and not superlibrarian
-if (
- (
- C4::Context->preference('IndependentBranches')
- && C4::Context->userenv
- && !C4::Context->IsSuperLibrarian()
- && C4::Context->userenv->{branch}
- )
- # Limit result to local branch strip_nonlocal_items
- or $query->param('strip_nonlocal_items')
-) {
- $only_my_branch = 1;
- @branch = ( C4::Context->userenv->{'branch'} );
-}
-
-my %branchmap = map { $_ => 1 } @branch; # for quick lookups
if ( $op eq "export" ) {
my $export_remove_fields = $query->param("export_remove_fields") || q||;
my @biblionumbers = $query->param("biblionumbers");
my @itemnumbers = $query->param("itemnumbers");
+ my $strip_nonlocal_items = $query->param('strip_nonlocal_items');
my @sql_params;
my $sql_query;
+ my $libraries = $strip_nonlocal_items
+ ? [ Koha::Libraries->find(C4::Context->userenv->{branch})->unblessed ]
+ : Koha::Libraries->search_filtered->unblessed;
+ my @branchcodes;
+ for my $branchcode ( @branch ) {
+ if ( grep { $_->{branchcode} eq $branchcode } @$libraries ) {
+ push @branchcodes, $branchcode;
+ }
+ }
+
if ( $record_type eq 'bibs' or $record_type eq 'auths' ) {
# No need to retrieve the record_ids if we already get them
unless ( @record_ids ) {
@@ -138,7 +132,7 @@ if ( $op eq "export" ) {
}
)
: (),
- ( @branch ? ( 'items.homebranch' => { in => \@branch } ) : () ),
+ ( @branchcodes ? ( 'items.homebranch' => { in => \@branchcodes } ) : () ),
( $itemtype
?
C4::Context->preference('item-level_itypes')
@@ -265,23 +259,14 @@ else {
);
push @itemtypesloop, \%row;
}
- my $branches = GetBranches($only_my_branch);
- my @branchloop;
- for my $thisbranch (
- sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
- keys %{$branches}
- )
- {
- push @branchloop,
- {
- value => $thisbranch,
- selected => %branchmap ? $branchmap{$thisbranch} : 1,
- branchname => $branches->{$thisbranch}->{'branchname'},
- };
- }
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
+ my $libraries = Koha::Libraries->search_filtered({}, { order_by => ['branchname'] })->unblessed;
+ for my $library ( @$libraries ) {
+ $library->{selected} = 1 if grep { $library->{branchcode} eq $_ } @branch;
+ }
+
if ( $flags->{superlibrarian}
&& C4::Context->config('backup_db_via_tools')
&& $backupdir
@@ -303,7 +288,7 @@ else {
}
$template->param(
- branchloop => \@branchloop,
+ libraries => $libraries,
itemtypeloop => \@itemtypesloop,
authority_types => $authority_types,
export_remove_fields => C4::Context->preference("ExportRemoveFields"),
diff --git a/tools/holidays.pl b/tools/holidays.pl
index 9ecf3ff..9602902 100755
--- a/tools/holidays.pl
+++ b/tools/holidays.pl
@@ -24,7 +24,6 @@ use CGI qw ( -utf8 );
use C4::Auth;
use C4::Output;
-use C4::Branch; # GetBranches
use C4::Calendar;
use Koha::DateUtils;
@@ -52,9 +51,6 @@ $keydate =~ s/-/\//g;
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
-# branches calculated - put branch codes in a single string so they can be passed in a form
-my $branchcodes = join '|', keys %{$branches};
-
# Get all the holidays
my $calendar = C4::Calendar->new(branchcode => $branch);
@@ -130,7 +126,6 @@ $template->param(
DAY_MONTH_HOLIDAYS_LOOP => \@day_month_holidays,
calendardate => $calendardate,
keydate => $keydate,
- branchcodes => $branchcodes,
branch => $branch,
);
diff --git a/tools/inventory.pl b/tools/inventory.pl
index f8dc852..4ca7863 100755
--- a/tools/inventory.pl
+++ b/tools/inventory.pl
@@ -32,7 +32,6 @@ use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Koha;
-use C4::Branch; # GetBranches
use C4::Circulation;
use C4::Reports::Guided; #_get_column_defs
use C4::Charset;
diff --git a/tools/koha-news.pl b/tools/koha-news.pl
index 9af1640..0faaa59 100755
--- a/tools/koha-news.pl
+++ b/tools/koha-news.pl
@@ -32,7 +32,6 @@ use C4::Output;
use C4::NewsChannels;
use C4::Languages qw(getTranslatedLanguages);
use Date::Calc qw/Date_to_Days Today/;
-use C4::Branch qw/GetBranches/;
use Koha::DateUtils;
my $cgi = new CGI;
@@ -81,10 +80,7 @@ foreach my $language ( @$tlangs ) {
}
}
-my $branches = GetBranches;
-
$template->param( lang_list => \@lang_list,
- branch_list => $branches,
branchcode => $branchcode );
my $op = $cgi->param('op') // '';
diff --git a/tools/letter.pl b/tools/letter.pl
index 3fc5036..79d418d 100755
--- a/tools/letter.pl
+++ b/tools/letter.pl
@@ -46,7 +46,6 @@ use CGI qw ( -utf8 );
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Branch; # GetBranches
use C4::Letters;
use C4::Members::Attributes;
diff --git a/tools/newHolidays.pl b/tools/newHolidays.pl
index eda4c1b..4776d65 100755
--- a/tools/newHolidays.pl
+++ b/tools/newHolidays.pl
@@ -57,13 +57,12 @@ if ($end_dt){
}
if($allbranches) {
- my $branch;
- my @branchcodes = split(/\|/, $input->param('branchCodes'));
- foreach $branch (@branchcodes) {
- add_holiday($newoperation, $branch, $weekday, $day, $month, $year, $title, $description);
- }
+ my $libraries = Koha::Libraries->search;
+ while ( my $library = $libraries->next ) {
+ add_holiday($newoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description);
+ }
} else {
- add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
+ add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
}
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
--
2.1.0