Browse Source

Bug 15758: Koha::Libraries - Remove GetBranches

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
16.11.x
Jonathan Druart 8 years ago
committed by Kyle M Hall
parent
commit
df97814f30
  1. 4
      C4/Auth.pm
  2. 69
      C4/Branch.pm
  3. 13
      C4/Circulation.pm
  4. 6
      C4/Context.pm
  5. 7
      C4/ILSDI/Services.pm
  6. 1
      C4/Items.pm
  7. 4
      C4/Overdues.pm
  8. 13
      C4/Search.pm
  9. 5
      C4/ShelfBrowser.pm
  10. 7
      C4/XSLT.pm
  11. 21
      Koha/Libraries.pm
  12. 21
      Koha/Template/Plugin/Branches.pm
  13. 5
      acqui/add_user_search.pl
  14. 1
      acqui/addorderiso2709.pl
  15. 18
      acqui/basket.pl
  16. 2
      acqui/basketheader.pl
  17. 21
      acqui/invoices.pl
  18. 1
      acqui/lateorders.pl
  19. 1
      acqui/neworderempty.pl
  20. 14
      acqui/newordersubscription.pl
  21. 1
      acqui/orderreceive.pl
  22. 5
      admin/add_user_search.pl
  23. 15
      admin/aqbudgets.pl
  24. 15
      admin/authorised_values.pl
  25. 14
      admin/branch_transfer_limits.pl
  26. 12
      admin/categories.pl
  27. 16
      admin/item_circulation_alerts.pl
  28. 14
      admin/patron-attr-types.pl
  29. 2
      admin/smart-rules.pl
  30. 9
      admin/transport-cost-matrix.pl
  31. 8
      catalogue/detail.pl
  32. 11
      catalogue/itemsearch.pl
  33. 6
      catalogue/search.pl
  34. 18
      cataloguing/addbiblio.pl
  35. 1
      cataloguing/value_builder/unimarc_field_4XX.pl
  36. 9
      circ/bookcount.pl
  37. 15
      circ/branchtransfers.pl
  38. 1
      circ/circulation.pl
  39. 22
      circ/returns.pl
  40. 10
      circ/selectbranchprinter.pl
  41. 12
      circ/transferstoreceive.pl
  42. 6
      koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc
  43. 9
      koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc
  44. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
  45. 5
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt
  46. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt
  47. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt
  48. 6
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
  49. 3
      koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt
  50. 4
      koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
  51. 6
      koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
  52. 7
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt
  53. 6
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt
  54. 18
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
  55. 8
      koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
  56. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt
  57. 14
      koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
  58. 11
      koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt
  59. 18
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
  60. 10
      koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
  61. 17
      koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
  62. 3
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt
  63. 1
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt
  64. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt
  65. 31
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
  66. 4
      koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
  67. 6
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
  68. 3
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt
  69. 1
      members/deletemem.pl
  70. 5
      members/guarantor_search.pl
  71. 1
      members/memberentry.pl
  72. 1
      members/pay.pl
  73. 1
      members/paycollect.pl
  74. 4
      members/readingrec.pl
  75. 3
      members/routing-lists.pl
  76. 6
      opac/opac-basket.pl
  77. 16
      opac/opac-detail.pl
  78. 15
      opac/opac-reserve.pl
  79. 14
      opac/opac-search.pl
  80. 3
      opac/opac-topissues.pl
  81. 1
      opac/opac-user.pl
  82. 5
      patroncards/add_user_search.pl
  83. 8
      reports/acquisitions_stats.pl
  84. 5
      reports/borrowers_stats.pl
  85. 1
      reports/issues_avg_stats.pl
  86. 2
      reports/issues_by_borrower_category.plugin
  87. 20
      reserve/request.pl
  88. 13
      rotating_collections/transferCollection.pl
  89. 5
      serials/add_user_search.pl
  90. 15
      serials/serials-search.pl
  91. 24
      serials/subscription-add.pl
  92. 31
      suggestion/suggestion.pl
  93. 8
      svc/cataloguing/framework
  94. 8
      t/db_dependent/Circulation/GetIssues.t
  95. 5
      t/db_dependent/Overdues.t
  96. 53
      tools/export.pl
  97. 5
      tools/holidays.pl
  98. 1
      tools/inventory.pl
  99. 4
      tools/koha-news.pl
  100. 1
      tools/letter.pl

4
C4/Auth.pm

@ -1078,7 +1078,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
@ -1528,7 +1528,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

69
C4/Branch.pm

@ -28,7 +28,6 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&GetBranch
&GetBranches
);
@EXPORT_OK = qw( &onlymine );
}
@ -47,76 +46,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')

13
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
@ -310,7 +309,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);
@ -339,7 +337,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;
}
@ -1899,8 +1900,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

6
C4/Context.pm

@ -1030,6 +1030,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__

7
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);
@ -630,8 +629,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};
}
@ -708,8 +706,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};
}

1
C4/Items.pm

@ -1337,6 +1337,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

4
C4/Overdues.pm

@ -36,6 +36,7 @@ use C4::Debug;
use Koha::DateUtils;
use Koha::Account::Line;
use Koha::Account::Lines;
use Koha::Libraries;
use vars qw(@ISA @EXPORT);
@ -788,8 +789,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;
}

13
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;
@ -857,6 +856,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);
@ -1843,14 +1844,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.

5
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(@ISA @EXPORT @EXPORT_OK);
@ -117,7 +117,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);
@ -129,7 +128,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'})) {

7
C4/XSLT.pm

@ -276,7 +276,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 = "";
@ -317,8 +318,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}}):'';
my $holdingbranch = $item->{holdingbranch}? xml_escape($branches{$item->{holdingbranch}}):'';
$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});

21
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

21
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 ) = @_;
@ -61,21 +62,11 @@ sub OnlyMine {
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

5
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 );

1
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;

18
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/;
use Koha::Database;
use Koha::EDI qw( create_edi_order get_edifact_ean );
@ -236,6 +236,7 @@ elsif ( $op eq 'ediorder' ) {
exit 1;
}
}
if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
push @branches_loop, {
branchcode => $userenv->{branch},
@ -245,20 +246,17 @@ elsif ( $op eq 'ediorder' ) {
}
} else {
# get branches
my $branches = C4::Branch::GetBranches;
my @branchcodes = sort {
$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
} keys %$branches;
foreach my $branch (@branchcodes) {
my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
foreach my $branch (@$branches) {
my $selected = 0;
if (defined $basket->{branch}) {
$selected = 1 if $branch eq $basket->{branch};
$selected = 1 if $branch->{branchcode} eq $basket->{branch};
} else {
$selected = 1 if $branch eq C4::Context->userenv->{branch};
$selected = 1 if $branch->{branchcode} eq C4::Context->userenv->{branch};
}
push @branches_loop, {
branchcode => $branch,
branchname => $branches->{$branch}->{branchname},
branchcode => $branch->{branchcode},
branchname => $branch->{branchname},
selected => $selected
};
}

2
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');

21
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;
@ -107,24 +106,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) {
@ -149,9 +130,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;

1
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;

1
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/;

14
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,

1
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;

5
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 );

15
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;
@ -141,18 +140,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 = ();
@ -200,7 +187,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,
);
@ -258,7 +244,6 @@ if ($op eq 'add_form') {
}
if ( $op eq 'list' ) {
my $branches = GetBranches();
$template->param(
budget_id => $budget_id,
%$period,

15
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,15 +56,14 @@ if ($op eq 'add_form') {
$category = $input->param('category');
}
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 {$_ eq $branch->{branchcode}} @$selected_branches ) ? 1 : 0;
push @branches_loop, {
branchcode => $branchcode,
branchname => $branches->{$branchcode}->{branchname},
selected => $selected,
branchcode => $branch->{branchcode},
branchname => $branch->{branchname},
selected => $selected,
};
}

14
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,

12
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::Patrons;
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 { $_ eq $branch->{branchcode} } @$selected_branches ) ? 1 : 0;
push @branches_loop,
{ branchcode => $branchcode,
branchname => $branches->{$branchcode}->{branchname},
{ branchcode => $branch->{branchcode},
branchname => $branch->{branchname},
selected => $selected,
};
}

16
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);

14
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, {
@ -252,14 +252,14 @@ sub edit_attribute_type_form {
$template->param(classes_val_loop => GetAuthorisedValues( 'PA_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->{branchcode}} @$selected_branches ) ? 1 : 0;
push @branches_loop, {
branchcode => $branches->{$branch}{branchcode},
branchname => $branches->{$branch}{branchname},
branchcode => $branch->{branchcode},
branchname => $branch->{branchname},
selected => $selected,
};
}

2
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;

9
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};

8
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;
@ -127,7 +126,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;
@ -258,7 +256,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;
@ -269,8 +267,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;
}

11
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, {

6
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;
@ -216,7 +215,10 @@ if($cgi->cookie("intranet_bib_list")){
# load the branches
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;

18
cataloguing/addbiblio.pl

@ -31,13 +31,14 @@ use C4::Context;
use MARC::Record;
use C4::Log;
use C4::Koha;
use C4::Branch;
use C4::ClassSource;
use C4::ImportBatch;
use C4::Charset;
use Koha::BiblioFrameworks;
use Koha::DateUtils;
use Koha::Libraries;
use Date::Calc qw(Today);
use MARC::File::USMARC;
use MARC::File::XML;
@ -173,18 +174,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, ""

1
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;

9
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,

15
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;

1
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::Memb