From 9b9803b69c8bde879768ccfa3cc4688ef46b7799 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 3 Feb 2016 15:58:08 +0000 Subject: [PATCH] Bug 15758: Koha::Libraries - Remove GetBranchesLoop Signed-off-by: Owen Leonard Signed-off-by: Kyle M Hall --- C4/Auth.pm | 9 +-- C4/Branch.pm | 19 ------ C4/Search.pm | 3 + Koha/Template/Plugin/Branches.pm | 21 ++++--- acqui/basketgroup.pl | 7 +-- acqui/basketheader.pl | 10 +-- acqui/neworderempty.pl | 18 ------ admin/aqbudgetperiods.pl | 3 - admin/aqbudgets.pl | 6 +- admin/aqplan.pl | 2 - admin/clone-rules.pl | 4 -- admin/smart-rules.pl | 13 +--- catalogue/search.pl | 20 +----- cataloguing/additem.pl | 22 +++---- circ/bookcount.pl | 12 ++-- circ/branchtransfers.pl | 1 - circ/overdue.pl | 3 - circ/selectbranchprinter.pl | 4 +- circ/view_holdsqueue.pl | 2 - course_reserves/add_items.pl | 2 - .../prog/en/includes/budgets-admin-search.inc | 9 +-- .../prog/en/includes/doc-head-close.inc | 1 + .../prog/en/includes/html_helpers.inc | 9 +++ .../prog/en/modules/acqui/basketgroup.tt | 24 ++----- .../prog/en/modules/acqui/basketheader.tt | 21 +------ .../prog/en/modules/admin/aqbudgets.tt | 12 +--- .../prog/en/modules/admin/clone-rules.tt | 63 ++++++++----------- .../prog/en/modules/admin/smart-rules.tt | 30 +++++---- .../en/modules/admin/transport-cost-matrix.tt | 5 +- .../intranet-tmpl/prog/en/modules/auth.tt | 4 +- .../prog/en/modules/catalogue/advsearch.tt | 8 +-- .../prog/en/modules/circ/bookcount.tt | 12 ++-- .../prog/en/modules/circ/branchtransfers.tt | 11 +--- .../prog/en/modules/circ/overdue.tt | 25 +++----- .../en/modules/circ/selectbranchprinter.tt | 9 +-- .../prog/en/modules/circ/view_holdsqueue.tt | 14 ++--- .../course_reserves/add_items-step2.tt | 8 +-- .../prog/en/modules/members/member.tt | 8 +-- .../prog/en/modules/members/memberentrygen.tt | 13 ++-- .../prog/en/modules/reports/bor_issues_top.tt | 4 +- .../en/modules/reports/borrowers_stats.tt | 13 ++-- .../prog/en/modules/reports/cat_issues_top.tt | 13 ++-- .../prog/en/modules/reports/catalogue_out.tt | 8 +-- .../en/modules/reports/catalogue_stats.tt | 9 ++- .../en/modules/reports/issues_avg_stats.tt | 5 +- .../reports/issues_by_borrower_category.tt | 5 +- .../prog/en/modules/reports/issues_stats.tt | 15 ++--- .../prog/en/modules/reports/itemslost.tt | 7 +-- .../prog/en/modules/reports/itemtypes.tt | 8 +-- .../prog/en/modules/reports/reserves_stats.tt | 15 ++--- .../prog/en/modules/reports/serials_stats.tt | 8 +-- .../prog/en/modules/reserve/request.tt | 22 ++----- .../en/modules/serials/checkexpiration.tt | 17 ++--- .../prog/en/modules/tools/holidays.tt | 12 +--- .../prog/en/modules/tools/import_borrowers.tt | 7 ++- .../prog/en/modules/tools/inventory.tt | 8 +-- .../prog/en/modules/tools/letter.tt | 12 ++-- .../prog/en/modules/tools/overduerules.tt | 8 +-- .../bootstrap/en/includes/doc-head-close.inc | 1 + .../bootstrap/en/includes/html_helpers.inc | 9 +++ .../bootstrap/en/includes/masthead.inc | 10 ++- .../bootstrap/en/includes/opac-topissues.inc | 11 +--- .../bootstrap/en/modules/opac-advsearch.tt | 9 +-- .../bootstrap/en/modules/opac-memberentry.tt | 9 +-- .../bootstrap/en/modules/opac-reserve.tt | 17 +---- .../bootstrap/en/modules/opac-suggestions.tt | 11 +--- members/memberentry.pl | 11 ++-- members/members-home.pl | 30 +-------- opac/opac-memberentry.pl | 2 - opac/opac-reserve.pl | 5 +- opac/opac-suggestions.pl | 5 +- opac/opac-topissues.pl | 2 - opac/opac-user.pl | 18 ------ reports/bor_issues_top.pl | 12 ---- reports/borrowers_stats.pl | 10 --- reports/cat_issues_top.pl | 2 - reports/catalogue_out.pl | 2 - reports/catalogue_stats.pl | 2 - reports/guided_reports.pl | 10 +-- reports/issues_avg_stats.pl | 1 - reports/issues_by_borrower_category.plugin | 2 - reports/issues_stats.pl | 2 - reports/itemslost.pl | 7 +-- reports/itemtypes.plugin | 6 -- reports/reserves_stats.pl | 2 - reports/serials_stats.pl | 3 +- reserve/request.pl | 15 +---- serials/checkexpiration.pl | 8 +-- serials/claims.pl | 3 - t/db_dependent/Branch.t | 5 -- t/db_dependent/Holds/LocalHoldsPriority.t | 3 - t/db_dependent/Holds/RevertWaitingStatus.t | 7 ++- t/db_dependent/Reserves.t | 5 +- tools/batchMod.pl | 18 +++--- tools/holidays.pl | 21 ------- tools/import_borrowers.pl | 4 -- tools/inventory.pl | 11 ---- tools/letter.pl | 20 +----- tools/modborrowers.pl | 4 +- tools/overduerules.pl | 3 - 100 files changed, 284 insertions(+), 717 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc diff --git a/C4/Auth.pm b/C4/Auth.pm index f0822a61a6..0bcad666df 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -29,7 +29,6 @@ require Exporter; use C4::Context; use C4::Templates; # to get the template use C4::Languages; -use C4::Branch; # GetBranches use C4::Search::History; use Koha; use Koha::Caches; @@ -514,7 +513,6 @@ sub get_template_and_user { $template->param( OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"), AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), - BranchesLoop => GetBranchesLoop($opac_name), BranchCategoriesLoop => $library_categories, opac_name => $opac_name, LibraryName => "" . C4::Context->preference("LibraryName"), @@ -1080,7 +1078,7 @@ sub checkauth { $branchcode = $query->param('branch'); $branchname = Koha::Libraries->find($branchcode)->branchname; } - my $branches = GetBranches(); + my $branches = C4::Branch::GetBranches(); if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) { # we have to check they are coming from the right ip range @@ -1091,7 +1089,6 @@ sub checkauth { } } - my @branchesloop; foreach my $br ( keys %$branches ) { # now we work with the treatment of ip @@ -1208,7 +1205,6 @@ sub checkauth { my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt'; my $template = C4::Templates::gettemplate( $template_name, $type, $query ); $template->param( - branchloop => GetBranchesLoop(), OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"), opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"), login => 1, @@ -1532,8 +1528,7 @@ sub check_api_auth { $branchcode = $query->param('branch'); $branchname = Koha::Libraries->find($branchcode)->branchname; } - my $branches = GetBranches(); - my @branchesloop; + my $branches = C4::Branch::GetBranches(); foreach my $br ( keys %$branches ) { # now we work with the treatment of ip diff --git a/C4/Branch.pm b/C4/Branch.pm index 7b9b85d7f1..f2d7bf1d03 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -29,7 +29,6 @@ BEGIN { @EXPORT = qw( &GetBranch &GetBranches - &GetBranchesLoop &mybranch ); @EXPORT_OK = qw( &onlymine &mybranch ); @@ -83,8 +82,6 @@ Create a branch selector with the following code. [% END %] -=head4 Note that you often will want to just use GetBranchesLoop, for exactly the example above. - =cut sub GetBranches { @@ -135,22 +132,6 @@ sub mybranch { return C4::Context->userenv->{branch} || ''; } -sub GetBranchesLoop { # since this is what most pages want anyway - my $branch = @_ ? shift : mybranch(); # optional first argument is branchcode of "my branch", if preselection is wanted. - my $onlymine = @_ ? shift : onlymine(); - my $branches = GetBranches($onlymine); - my @loop; - foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) { - push @loop, { - value => $branchcode, - branchcode => $branchcode, - selected => ($branchcode eq $branch) ? 1 : 0, - branchname => $branches->{$branchcode}->{branchname}, - }; - } - return \@loop; -} - =head2 GetBranch $branch = GetBranch( $query, $branches ); diff --git a/C4/Search.pm b/C4/Search.pm index 29e606239f..ab84087b0b 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -337,6 +337,9 @@ sub getRecords { my @results; my $results_hashref = (); + # TODO simplify this structure ( { branchcode => $branchname } is enought) and remove this parameter + $branches ||= { map { $_->branchcode => { branchname => $_->branchname } } Koha::Libraries->search }; + # Initialize variables for the faceted results objects my $facets_counter = {}; my $facets_info = {}; diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 0b95e4284a..8b959a2e33 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -67,24 +67,25 @@ sub all { SELECT branchcode, branchname FROM branches |; - if ( C4::Branch::onlymine + 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}; } - $query .= q| ORDER BY branchname|; - my $branches = $dbh->selectall_arrayref( $query, { Slice => {} }, @params ); - - if ( $selected ) { - for my $branch ( @$branches ) { - if ( $branch->{branchcode} eq $selected ) { - $branch->{selected} = 1; - } + my $libraries = $dbh->selectall_arrayref( $query, { Slice => {} }, @params ); + + for my $l ( @$libraries ) { + if ( $selected and $l->{branchcode} eq $selected + or not $selected and C4::Context->userenv and $l->{branchcode} eq C4::Context->userenv->{branch} + ) { + $l->{selected} = 1; } } - return $branches; + + return $libraries; } 1; diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl index 85422cbcdc..ddc2ec279e 100755 --- a/acqui/basketgroup.pl +++ b/acqui/basketgroup.pl @@ -52,7 +52,6 @@ use C4::Output; use CGI qw ( -utf8 ); use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/; -use C4::Branch qw/GetBranches/; use C4::Members qw/GetMember/; use Koha::EDI qw/create_edi_order get_edifact_ean/; @@ -272,10 +271,8 @@ if ( $op eq "add" ) { $billingplace = $billingplace || $borrower->{'branchcode'}; $deliveryplace = $deliveryplace || $borrower->{'branchcode'}; - my $branches = C4::Branch::GetBranchesLoop( $billingplace ); - $template->param( billingplaceloop => $branches ); - $branches = C4::Branch::GetBranchesLoop( $deliveryplace ); - $template->param( deliveryplaceloop => $branches ); + $template->param( billingplace => $billingplace ); + $template->param( deliveryplace => $deliveryplace ); $template->param( booksellerid => $booksellerid ); # the template will display a unique basketgroup diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index c59ea87ba6..cdef0dfaa9 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -121,20 +121,14 @@ if ( $op eq 'add_form' ) { booksellerid => $booksellerid, basketno => $basketno, booksellers => \@booksellers, - deliveryplace => $basket->{deliveryplace}, - billingplace => $basket->{billingplace}, is_standing => $basket->{is_standing}, ); my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"}; my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"}; - # Build the combobox to select the billing place - - my $branches = C4::Branch::GetBranchesLoop( $billingplace ); - $template->param( billingplaceloop => $branches ); - $branches = C4::Branch::GetBranchesLoop( $deliveryplace ); - $template->param( deliveryplaceloop => $branches ); + $template->param( billingplace => $billingplace ); + $template->param( deliveryplace => $deliveryplace ); #End Edit } elsif ( $op eq 'add_validate' ) { diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index da5acd5cdd..72cab5aa6b 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -210,24 +210,6 @@ $suggestion = GetSuggestionInfo($suggestionid) if $suggestionid; my @currencies = Koha::Acquisition::Currencies->search; my $active_currency = Koha::Acquisition::Currencies->get_active; -# build branches list -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'}, - ); - $row{'selected'} = 1 if( $thisbranch && $data->{branchcode} && $thisbranch eq $data->{branchcode}) ; - push @branchloop, \%row; -} -$template->param( branchloop => \@branchloop ); - # build bookfund list my $borrower= GetMember('borrowernumber' => $loggedinuser); my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'}); diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index f7d8a46dec..7ce57835b8 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -281,14 +281,11 @@ foreach my $result ( @{$results} ) { push( @period_inactive_loop, $budgetperiod ); } -my $branchloop = C4::Branch::GetBranchesLoop(); - my $tab = $input->param('tab') ? $input->param('tab') - 1 : 0; $template->param( period_active_loop => \@period_active_loop, period_inactive_loop => \@period_inactive_loop, tab => $tab, - branchloop => $branchloop, ); $template->param($op=>1); diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 0e6b744251..c9baad7b53 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -96,12 +96,11 @@ my $user_branchcode = $user->{'branchcode'}; $template->param( show_mine => $show_mine, op => $op, + selected_branchcode => $filter_budgetbranch, ); my $budget; -my $branchloop = C4::Branch::GetBranchesLoop($filter_budgetbranch); - $template->param(auth_cats_loop => GetBudgetAuthCats( $budget_period_id )) if $budget_period_id; @@ -153,7 +152,7 @@ if ($op eq 'add_form') { $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 = (); @@ -343,7 +342,6 @@ if ( $op eq 'list' ) { spent_total => $spent_total, ordered_total => $ordered_total, available_total => $available_total, - branchloop => $branchloop, filter_budgetname => $filter_budgetname, ); diff --git a/admin/aqplan.pl b/admin/aqplan.pl index c6946d6c2e..a27fb0a4ca 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -394,7 +394,6 @@ if ( $output eq "file" ) { exit(1); } -my $branchloop = C4::Branch::GetBranchesLoop(); $template->param( authvals_row => \@authvals_row, budget_lines => \@budget_lines, @@ -411,7 +410,6 @@ $template->param( authvals => \@authvals_row, hide_cols_loop => \@hide_cols, - branchloop => $branchloop, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/admin/clone-rules.pl b/admin/clone-rules.pl index d2412ae15d..9fd330fa71 100755 --- a/admin/clone-rules.pl +++ b/admin/clone-rules.pl @@ -33,7 +33,6 @@ use C4::Output; use C4::Auth; use C4::Koha; use C4::Debug; -use C4::Branch; # GetBranchesLoop my $input = new CGI; my $dbh = C4::Context->dbh; @@ -49,13 +48,10 @@ my ($template, $loggedinuser, $cookie) my $frombranch = $input->param("frombranch"); my $tobranch = $input->param("tobranch"); -my $branchloop = GetBranchesLoop; $template->param(frombranch => $frombranch) if ($frombranch); $template->param(tobranch => $tobranch) if ($tobranch); -$template->param(branchloop => $branchloop); - if ($frombranch && $tobranch) { my $error; diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 4f5185dc04..6019214ef8 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -461,16 +461,6 @@ $template->param( defaultRefundRule => Koha::RefundLostItemFeeRules->_default_rule ); -my $branches = GetBranches(); -my @branchloop; -for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - push @branchloop, { - value => $thisbranch, - selected => $thisbranch eq $branch, - branchname => $branches->{$thisbranch}->{'branchname'}, - }; -} - my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] }); my @row_loop; @@ -624,8 +614,7 @@ $template->param( patron_categories => $patron_categories, itemtypeloop => \@itemtypes, rules => \@sorted_row_loop, - branchloop => \@branchloop, - humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), + humanbranch => ($branch ne '*' ? $branch : ''), current_branch => $branch, definedbranch => scalar(@sorted_row_loop)>0 ); diff --git a/catalogue/search.pl b/catalogue/search.pl index 3fa25c02d3..5428edeb08 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -214,25 +214,9 @@ if($cgi->cookie("intranet_bib_list")){ } # load the branches -my $branches = GetBranches(); - -# Populate branch_loop with all branches sorted by their name. If -# IndependentBranches is activated, set the default branch to the borrower -# branch, except for superlibrarian who need to search all libraries. -my $user = C4::Context->userenv; -my @branch_loop = map { - { - value => $_, - branchname => $branches->{$_}->{branchname}, - selected => $user->{branch} eq $_ && C4::Branch::onlymine(), - } -} sort { - $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} -} keys %$branches; - my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } ); -$template->param(branchloop => \@branch_loop, searchdomainloop => $categories); +$template->param(searchdomainloop => $categories); # load the Type stuff my $itemtypes = GetItemTypes; @@ -537,7 +521,7 @@ eval { my $itemtypes = GetItemTypes; ( $error, $results_hashref, $facets ) = $searcher->search_compat( $query, $simple_query, \@sort_by, \@servers, - $results_per_page, $offset, $expanded_facet, $branches, + $results_per_page, $offset, $expanded_facet, undef, $itemtypes, $query_type, $scan ); }; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 86abc5709d..9f0f146b48 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -29,9 +29,9 @@ use C4::Items; use C4::Context; use C4::Circulation; use C4::Koha; -use C4::Branch; use C4::ClassSource; use Koha::DateUtils; +use Koha::Libraries; use List::MoreUtils qw/any/; use C4::Search; use Storable qw(thaw freeze); @@ -175,9 +175,9 @@ sub generate_subfield_form { # builds list, depending on authorised value... if ( $subfieldlib->{authorised_value} eq "branches" ) { foreach my $thisbranch (@$branches) { - push @authorised_values, $thisbranch->{value}; - $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname}; - $value = $thisbranch->{value} if $thisbranch->{selected} && !$value; + push @authorised_values, $thisbranch->{branchcode}; + $authorised_lib{$thisbranch->{branchcode}} = $thisbranch->{branchname}; + $value = $thisbranch->{branchcode} if $thisbranch->{selected} && !$value; } } elsif ( $subfieldlib->{authorised_value} eq "itemtypes" ) { @@ -863,13 +863,11 @@ my $i=0; my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); -my $onlymine = - C4::Context->preference('IndependentBranches') - && C4::Context->userenv - && !C4::Context->IsSuperLibrarian() - && C4::Context->userenv->{branch}; my $branch = $input->param('branch') || C4::Context->userenv->{branch}; -my $branches = GetBranchesLoop($branch,$onlymine); # build once ahead of time, instead of multiple times later. +my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. +for my $library ( @$libraries ) { + $library->{selected} = 1 if $library->{branchcode} eq $branch +} # We generate form, from actuel record @fields = (); @@ -884,7 +882,7 @@ if($itemrecord){ next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); - my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $biblionumber, $temp, \@loop_data, $i, $restrictededition); + my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition); push @fields, "$tag$subfieldtag"; push (@loop_data, $subfield_data); $i++; @@ -908,7 +906,7 @@ foreach my $tag ( keys %{$tagslib}){ my @values = (undef); @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag))); for my $value (@values){ - my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $biblionumber, $temp, \@loop_data, $i, $restrictededition); + my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $libraries, $biblionumber, $temp, \@loop_data, $i, $restrictededition); push (@loop_data, $subfield_data); $i++; } diff --git a/circ/bookcount.pl b/circ/bookcount.pl index 09dc6fcbf0..d4d3e54ed0 100755 --- a/circ/bookcount.pl +++ b/circ/bookcount.pl @@ -32,6 +32,7 @@ use C4::Auth; use C4::Branch; # GetBranches use C4::Biblio; # GetBiblioItemData use Koha::DateUtils; +use Koha::Libraries; my $input = new CGI; my $itm = $input->param('itm'); @@ -69,10 +70,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $branchloop = GetBranchesLoop(C4::Context->userenv->{branch}); -foreach (@$branchloop) { - $_->{issues} = issuesat($itm, $_->{value}); - $_->{seen} = lastseenat( $itm, $_->{value} ) || undef; +my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; +for my $library ( @$libraries ) { + $library->{selected} = 1 if $library->{branchcode} eq C4::Context->userenv->{branch}; + $library->{issues} = issuesat($itm, $library->{branchcode}); + $library->{seen} = lastseenat( $itm, $library->{branchcode} ) || undef; } $template->param( @@ -85,7 +87,7 @@ $template->param( holdingbranch => $holdingbranch, lastdate => $lastdate ? $lastdate : 0, count => $count, - branchloop => $branchloop, + libraries => $libraries, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index a826289b65..8b7bddd69f 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -236,7 +236,6 @@ $template->param( cancelled => $cancelled, setwaiting => $setwaiting, trsfitemloop => \@trsfitemloop, - branchoptionloop => GetBranchesLoop($tobranchcd), errmsgloop => \@errmsgloop, CircAutocompl => C4::Context->preference("CircAutocompl") ); diff --git a/circ/overdue.pl b/circ/overdue.pl index 047e073f8b..c76b52991a 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -214,9 +214,6 @@ if (@patron_attr_filter_loop) { $template->param( patron_attr_header_loop => [ map { { header => $_->{description} } } grep { ! $_->{isclone} } @patron_attr_filter_loop ], - branchloop => GetBranchesLoop($branchfilter, $onlymine), - homebranchloop => GetBranchesLoop( $homebranchfilter, $onlymine ), - holdingbranchloop => GetBranchesLoop( $holdingbranchfilter, $onlymine ), branchfilter => $branchfilter, homebranchfilter => $homebranchfilter, holdingbranchfilter => $homebranchfilter, diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl index 42e8b05993..d87261d027 100755 --- a/circ/selectbranchprinter.pl +++ b/circ/selectbranchprinter.pl @@ -26,7 +26,7 @@ use C4::Output; use C4::Auth qw/:DEFAULT get_session/; use C4::Print; # GetPrinters use C4::Koha; -use C4::Branch; # GetBranches GetBranchesLoop +use C4::Branch; # GetBranches use Koha::Libraries; @@ -136,7 +136,7 @@ if (scalar @updated and not scalar @recycle_loop) { $template->param( referer => $referer, printerloop => \@printerloop, - branchloop => GetBranchesLoop($branch), + branch => $branch, recycle_loop=> \@recycle_loop, ); diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl index d21d3e7581..ce632e6d92 100755 --- a/circ/view_holdsqueue.pl +++ b/circ/view_holdsqueue.pl @@ -30,7 +30,6 @@ use C4::Output; use C4::Biblio; use C4::Items; use C4::Koha; # GetItemTypes -use C4::Branch; # GetBranches use C4::HoldsQueue qw(GetHoldsQueueItems); my $query = new CGI; @@ -72,7 +71,6 @@ foreach my $thisitemtype ( sort keys %$itemtypes ) { } $template->param( - branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), itemtypeloop => \@itemtypesloop, ); diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl index 24ea732201..bcfadc7f0d 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -26,7 +26,6 @@ use C4::Auth; use C4::Output; use C4::Koha; use C4::Biblio; -use C4::Branch; use C4::CourseReserves qw(GetCourse GetCourseItem GetCourseReserve ModCourseItem ModCourseReserve); @@ -73,7 +72,6 @@ if ( $action eq 'lookup' ) { ccodes => GetAuthorisedValues('CCODE'), locations => GetAuthorisedValues('LOC'), itypes => GetItemTypes( style => 'array' ), - branches => GetBranchesLoop(), return => $return, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc index c2babc2002..3399ce9405 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %]

[% LibraryName %]

@@ -10,11 +11,11 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index f72425d470..078a6c38a0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -43,6 +43,7 @@ [% INCLUDE 'validator-strings.inc' %] +[% PROCESS 'html_helpers.inc' %] [% IF ( IntranetUserJS ) %] +[% PROCESS 'html_helpers.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc new file mode 100644 index 0000000000..1d383828b5 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc @@ -0,0 +1,9 @@ +[% BLOCK options_for_libraries %] + [% FOREACH l IN libraries %] + [% IF l.selected %] + + [% ELSE %] + + [% END%] + [% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index b2aceaa979..fdce32c583 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
@@ -228,9 +229,12 @@ - [% FOREACH branchloo IN branchloop %] - [% IF ( branchloo.selected ) %] - - [% END %] + [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %] [% AdvancedSearchTypes = Koha.Preference('AdvancedSearchTypes').split('\|') %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index c77742b13a..5b461f41d0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Advanced search [% INCLUDE 'doc-head-close.inc' %] @@ -214,11 +215,11 @@ diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 609ea452c9..e19d067fd3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -1,5 +1,6 @@ [% USE Categories %] [% USE Koha %] +[% USE Branches %] [% USE KohaDates %] [% SET userupdateview = 1 %] @@ -156,13 +157,7 @@ Home library: [% END %] 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 8decae4c15..bca3bffb4a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% USE KohaDates %] [% USE Price %] [% USE ItemTypes %] @@ -214,23 +215,11 @@ [% UNLESS ( bibitemloo.holdable ) %] [% ELSE %] [% END # / UNLESS bibitemloo.holdable %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 3f4234f394..2645905160 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% USE AuthorisedValues %] [% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] @@ -54,16 +55,10 @@
  • [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %]
  • - [% IF ( branchloop ) %] + [% IF branchcode %]
  • [% END %] diff --git a/members/memberentry.pl b/members/memberentry.pl index 7d36e2f97c..d77e339afa 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -42,6 +42,7 @@ use C4::Form::MessagingPreferences; use Koha::Patron::Debarments; use Koha::Cities; use Koha::DateUtils; +use Koha::Libraries; use Koha::Patron::Categories; use Koha::Token; use Email::Valid; @@ -595,8 +596,8 @@ foreach (keys(%flags)) { } # get Branch Loop -# in modify mod: userbranch value for GetBranchesLoop() comes from borrowers table -# in add mod: userbranch value come from branches table (ip correspondence) +# in modify mod: userbranch value comes from borrowers table +# in add mod: userbranch value comes from branches table (ip correspondence) my $userbranch = ''; if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { @@ -606,10 +607,9 @@ if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category_type eq 'C' ) )) { $userbranch = $data{'branchcode'}; } +$template->param( userbranch => $userbranch ); -my $branchloop = GetBranchesLoop( $userbranch ); - -if( !$branchloop ){ +if ( Koha::Libraries->search->count < 1 ){ $no_add = 1; $template->param(no_branches => 1); } @@ -681,7 +681,6 @@ $template->param( check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) "op$op" => 1); -$template->param( branchloop => $branchloop ) if ( $branchloop ); $template->param( nodouble => $nodouble, borrowernumber => $borrowernumber, #register number diff --git a/members/members-home.pl b/members/members-home.pl index 26d91ce17e..5e474bb9e9 100755 --- a/members/members-home.pl +++ b/members/members-home.pl @@ -24,7 +24,6 @@ use C4::Auth; use C4::Output; use C4::Context; use C4::Members; -use C4::Branch; use Koha::Patron::Modifications; use Koha::Libraries; use Koha::List::Patron; @@ -44,37 +43,10 @@ my ($template, $loggedinuser, $cookie) debug => 1, }); -my $branches = GetBranches; -my @branchloop; -if ( C4::Branch::onlymine ) { - my $userenv = C4::Context->userenv; - my $library = Koha::Libraries->find( $userenv->{'branch'} ); - push @branchloop, { - value => $library->id, - branchcode => $library->branchcode, - branchname => $library->branchname, - selected => 1 - } -} else { - foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) { - my $selected = 0; - $selected = 1 if $branch and $branch eq $_; - push @branchloop, { - value => $_, - branchcode => $_, - branchname => $branches->{$_}->{branchname}, - selected => $selected - }; - } -} - my $no_add = 0; -if(scalar(@branchloop) < 1){ +if( Koha::Libraries->search->count < 1){ $no_add = 1; $template->param(no_branches => 1); -} -else { - $template->param(branchloop=>\@branchloop); } my @categories = Koha::Patron::Categories->search_limited; diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 1a5bac49ef..8b5ade944f 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -29,7 +29,6 @@ use C4::Form::MessagingPreferences; use Koha::Patrons; use Koha::Patron::Modification; use Koha::Patron::Modifications; -use C4::Branch qw(GetBranchesLoop); use C4::Scrubber; use Email::Valid; use Koha::DateUtils; @@ -70,7 +69,6 @@ $template->param( action => $action, hidden => GetHiddenFields( $mandatory, 'registration' ), mandatory => $mandatory, - branches => GetBranchesLoop(), OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), ); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 1fd2f82a1d..9dd9e3dd85 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -127,9 +127,6 @@ my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->us ($branches->{$branch}) or $branch = ""; # Confirm branch is real $template->param( branch => $branch ); -# make branch selection options... -my $branchloop = GetBranchesLoop($branch); - # Is the person allowed to choose their branch my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0; @@ -383,7 +380,7 @@ foreach my $biblioNum (@biblionumbers) { my $record = GetMarcBiblio($biblioNum); # Init the bib item with the choices for branch pickup - my %biblioLoopIter = ( branchloop => $branchloop ); + my %biblioLoopIter; # Get relevant biblio data. my $biblioData = $biblioDataHash{$biblioNum}; diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index b183364343..388e04aa7e 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -22,7 +22,6 @@ use CGI qw ( -utf8 ); use Encode qw( encode ); use C4::Auth; # get_template_and_user use C4::Members; -use C4::Branch; use C4::Koha; use C4::Output; use C4::Suggestions; @@ -202,9 +201,7 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { } my $branchcode = $input->param('branchcode') || $borr->{'branchcode'} || $userbranch || '' ; -# make branch selection options... - my $branchloop = GetBranchesLoop($branchcode); - $template->param( branchloop => $branchloop ); + $template->param( branchcode => $branchcode ); } my $mandatoryfields = ''; diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl index 1bb4d2d3cd..9e2f613ca4 100755 --- a/opac/opac-topissues.pl +++ b/opac/opac-topissues.pl @@ -100,6 +100,4 @@ $template->param( results => \@results, ); -$template->param(branchloop => GetBranchesLoop($branch)); - output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 3eac79f656..95adbbc945 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -272,24 +272,6 @@ if ($show_barcode) { } $template->param( show_barcode => 1 ) if $show_barcode; -# load the branches -my $branches = GetBranches(); -my @branch_loop; -for my $branch_hash ( sort keys %{$branches} ) { - my $selected; - if ( C4::Context->preference('SearchMyLibraryFirst') ) { - $selected = - ( C4::Context->userenv - && ( $branch_hash eq C4::Context->userenv->{branch} ) ); - } - push @branch_loop, - { value => "branch: $branch_hash", - branchname => $branches->{$branch_hash}->{'branchname'}, - selected => $selected, - }; -} -$template->param( branchloop => \@branch_loop ); - # now the reserved items.... my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } ); diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl index 1e1dcfdf54..cd2964b9fd 100755 --- a/reports/bor_issues_top.pl +++ b/reports/bor_issues_top.pl @@ -23,7 +23,6 @@ use CGI qw ( -utf8 ); use C4::Auth; use C4::Output; use C4::Context; -use C4::Branch; # GetBranches use C4::Koha; use C4::Circulation; use C4::Members; @@ -110,16 +109,6 @@ my @values; # here each element returned by map is a hashref, get it? my @mime = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation my $delims = GetDelimiterChoices; -my $branches = GetBranches; -my @branchloop; -foreach (sort keys %$branches) { -# my $selected = 1 if $thisbranch eq $branch; - my %row = ( value => $_, -# selected => $selected, - branchname => $branches->{$_}->{branchname}, - ); - push @branchloop, \%row; -} my $itemtypes = GetItemTypes; my @itemtypeloop; @@ -135,7 +124,6 @@ my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by = $template->param( mimeloop => \@mime, CGIseplist => $delims, - branchloop => \@branchloop, itemtypeloop => \@itemtypeloop, patron_categories => $patron_categories, ); diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index a7e656fdd4..c4203b6f8c 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -65,9 +65,6 @@ my $output = $input->param("output"); my $basename = $input->param("basename"); our $sep = $input->param("sep"); $sep = "\t" if ($sep and $sep eq 'tabulation'); -my $selected_branch; # = $input->param("?"); - -our $branches = GetBranches; my ($template, $borrowernumber, $cookie) = get_template_and_user({template_name => $fullreportname, @@ -121,13 +118,6 @@ if ($do_it) { my $req; my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']}); $template->param( patron_categories => $patron_categories ); - my @branchloop; - foreach (sort {$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}} keys %$branches) { - my $line = {branchcode => $_, branchname => $branches->{$_}->{branchname} || 'UNKNOWN'}; - $line->{selected} = 'selected' if ($selected_branch and $selected_branch eq $_); - push @branchloop, $line; - } - $template->param(BRANCH_LOOP => \@branchloop); $req = $dbh->prepare("SELECT DISTINCTROW zipcode FROM borrowers WHERE zipcode IS NOT NULL AND zipcode <> '' ORDER BY zipcode"); $req->execute; $template->param( ZIP_LOOP => $req->fetchall_arrayref({})); diff --git a/reports/cat_issues_top.pl b/reports/cat_issues_top.pl index ce7eded258..dd3781132f 100755 --- a/reports/cat_issues_top.pl +++ b/reports/cat_issues_top.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; @@ -159,7 +158,6 @@ if ($do_it) { $template->param( CGIextChoice => $CGIextChoice, CGIsepChoice => $CGIsepChoice, - branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), itemtypeloop =>\@itemtypeloop, ccodeloop =>\@ccodeloop, shelvinglocloop =>\@shelvinglocloop, diff --git a/reports/catalogue_out.pl b/reports/catalogue_out.pl index 4ce9b3fcab..73595f4b08 100755 --- a/reports/catalogue_out.pl +++ b/reports/catalogue_out.pl @@ -24,7 +24,6 @@ use CGI qw ( -utf8 ); use C4::Auth; use C4::Context; use C4::Debug; -use C4::Branch; # GetBranchesLoop use C4::Output; use C4::Koha; # GetItemTypes # use Date::Manip; # TODO: add not borrowed since date X criteria @@ -78,7 +77,6 @@ foreach ( $template->param( itemtypeloop => \@itemtypeloop, - branchloop => GetBranchesLoop(), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/reports/catalogue_stats.pl b/reports/catalogue_stats.pl index c153947bc3..b0a72b0094 100755 --- a/reports/catalogue_stats.pl +++ b/reports/catalogue_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::Reports; @@ -156,7 +155,6 @@ if ($do_it) { $template->param( itemtypes => $itemtypes, - CGIBranch => GetBranchesLoop( C4::Context->userenv->{'branch'} ), locationloop => \@locations, authvals => \@authvals, CGIextChoice => \@mime, diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index c5ad623edb..3a122d21f9 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -29,13 +29,13 @@ use C4::Auth qw/:DEFAULT get_session/; use C4::Output; use C4::Debug; use C4::Koha qw/GetFrameworksLoop/; -use C4::Branch; use C4::Context; use Koha::Caches; use C4::Log; use Koha::DateUtils qw/dt_from_string output_pref/; use Koha::AuthorisedValue; use Koha::AuthorisedValues; +use Koha::Libraries; use Koha::Patron::Categories; =head1 NAME @@ -664,10 +664,10 @@ elsif ($phase eq 'Run this report'){ my %authorised_lib; # builds list, depending on authorised value... if ( $authorised_value eq "branches" ) { - my $branches = GetBranchesLoop(); - foreach my $thisbranch (@$branches) { - push @authorised_values, $thisbranch->{value}; - $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname}; + my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } ); + while ( my $library = $libraries->next ) { + push @authorised_values, $library->branchcode; + $authorised_lib{$library->branchcode} = $library->branchname; } } elsif ( $authorised_value eq "itemtypes" ) { diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl index 797d5f4b4c..cf2686aba9 100755 --- a/reports/issues_avg_stats.pl +++ b/reports/issues_avg_stats.pl @@ -154,7 +154,6 @@ if ($do_it) { $template->param( patron_categories => $patron_categories, itemtypes => $itemtypes, - branchloop => GetBranchesLoop(), hassort1 => $hassort1, hassort2 => $hassort2, HlghtSort2 => $hglghtsort2, diff --git a/reports/issues_by_borrower_category.plugin b/reports/issues_by_borrower_category.plugin index 060d34598a..27d837cc81 100755 --- a/reports/issues_by_borrower_category.plugin +++ b/reports/issues_by_borrower_category.plugin @@ -66,8 +66,6 @@ the hashes are then translated to hash / arrays to be returned to manager.pl & s sub set_parameters { my ($template) = @_; - $template->param( branchloop => GetBranchesLoop() ); - my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']}); $template->param( patron_categories => $patron_categories ); return $template; diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 48df561be5..665e02b886 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -26,7 +26,6 @@ use Date::Manip; use C4::Auth; use C4::Debug; use C4::Context; -use C4::Branch; # GetBranches use C4::Koha; use C4::Output; use C4::Circulation; @@ -156,7 +155,6 @@ $template->param( itemtypeloop => \@itemtypeloop, locationloop => \@locations, ccodeloop => \@ccodes, - branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), hassort1=> $hassort1, hassort2=> $hassort2, Bsort1 => $Bsort1, diff --git a/reports/itemslost.pl b/reports/itemslost.pl index f0f318ab1f..00f2b99d9d 100755 --- a/reports/itemslost.pl +++ b/reports/itemslost.pl @@ -34,7 +34,6 @@ use C4::Output; use C4::Biblio; use C4::Items; use C4::Koha; # GetItemTypes -use C4::Branch; # GetBranches use Koha::DateUtils; my $query = new CGI; @@ -80,10 +79,6 @@ if ( $get_items ) { ); } -# getting all branches. -#my $branches = GetBranches; -#my $branch = C4::Context->userenv->{"branchname"}; - # getting all itemtypes my $itemtypes = &GetItemTypes(); my @itemtypesloop; @@ -98,7 +93,7 @@ foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp # get lost statuses my $lost_status_loop = C4::Koha::GetAuthorisedValues( 'LOST' ); -$template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), +$template->param( itemtypeloop => \@itemtypesloop, loststatusloop => $lost_status_loop, ); diff --git a/reports/itemtypes.plugin b/reports/itemtypes.plugin index b1b7c3dab4..ffa6fb7a43 100755 --- a/reports/itemtypes.plugin +++ b/reports/itemtypes.plugin @@ -25,18 +25,12 @@ use C4::Context; use C4::Search; use C4::Output; use C4::Koha; -use C4::Branch; # GetBranches =head1 =cut sub set_parameters { my ($template) = @_; - my $userbranch = ''; - if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { - $userbranch = C4::Context->userenv->{'branch'}; - } - $template->param( branchloop => GetBranchesLoop($userbranch) ); return $template; } diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index 04d626838a..40a231db51 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -26,7 +26,6 @@ use CGI qw ( -utf8 ); use C4::Auth; use C4::Debug; use C4::Context; -use C4::Branch; # GetBranches use C4::Koha; use C4::Output; use C4::Reports; @@ -164,7 +163,6 @@ $template->param( itemtypeloop => \@itemtypeloop, locationloop => \@locations, ccodeloop => \@ccodes, - branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), hassort1=> $hassort1, hassort2=> $hassort2, Bsort1 => $Bsort1, diff --git a/reports/serials_stats.pl b/reports/serials_stats.pl index f6ba4c008c..614b95f4ca 100755 --- a/reports/serials_stats.pl +++ b/reports/serials_stats.pl @@ -22,7 +22,6 @@ use warnings; use C4::Auth; use CGI qw ( -utf8 ); use C4::Context; -use C4::Branch; # GetBranches use C4::Output; use C4::Koha; use C4::Reports; @@ -153,7 +152,7 @@ if($do_it){ CGIextChoice => $CGIextChoice, CGIsepChoice => $CGIsepChoice, booksellers => \@booksellers, - branches => GetBranchesLoop(C4::Context->userenv->{'branch'})); + ); } output_html_with_http_headers $input, $cookie, $template->output; diff --git a/reserve/request.pl b/reserve/request.pl index e656e0e520..f4d0279884 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -67,12 +67,6 @@ my $showallitems = $input->param('showallitems'); my $branches = GetBranches(); my $itemtypes = GetItemTypes(); -my $userbranch = ''; -if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { - $userbranch = C4::Context->userenv->{'branch'}; -} - - # Select borrowers infos my $findborrower = $input->param('findborrower'); $findborrower = '' unless defined $findborrower; @@ -588,13 +582,7 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'suspend_until'} = $res->suspend_until(); $reserve{'reserve_id'} = $res->reserve_id(); $reserve{itemtype} = $res->itemtype(); - - if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) { - $reserve{'branchloop'} = [ Koha::Libraries->find( $res->branchcode() ) ]; - } - else { - $reserve{'branchloop'} = GetBranchesLoop( $res->branchcode() ); - } + $reserve{branchcode} = $res->branchcode(); push( @reserveloop, \%reserve ); } @@ -603,7 +591,6 @@ foreach my $biblionumber (@biblionumbers) { my $time = time(); $template->param( - branchloop => GetBranchesLoop($userbranch), time => $time, fixedRank => $fixedRank, ); diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index e4fa9ce4ef..7e2eed483c 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -47,7 +47,6 @@ use warnings; use CGI qw ( -utf8 ); use C4::Auth; use C4::Serials; # GetExpirationDate -use C4::Branch; use C4::Output; use C4::Context; use Koha::DateUtils; @@ -113,18 +112,19 @@ if ($date) { ); } -my $branches_loop; +my $can_change_library;; if ( !C4::Context->preference("IndependentBranches") or C4::Context->IsSuperLibrarian() or ( ref $flags->{serials} and $flags->{serials}->{superserials} ) or ( !ref $flags->{serials} and $flags->{serials} == 1 ) ) { - $branches_loop = C4::Branch::GetBranchesLoop( $branch ); + $can_change_library = 1; } $template->param ( (uc(C4::Context->preference("marcflavour"))) => 1, - branches_loop => $branches_loop, + can_change_library => $can_change_library, + branch => $branch, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/serials/claims.pl b/serials/claims.pl index 97f52aecc8..b4bc94fbd1 100755 --- a/serials/claims.pl +++ b/serials/claims.pl @@ -25,7 +25,6 @@ use C4::Acquisition; use C4::Output; use C4::Context; use C4::Letters; -use C4::Branch; # GetBranches GetBranchesLoop use C4::Koha qw( GetAuthorisedValues ); use Koha::AdditionalField; @@ -65,7 +64,6 @@ for my $field ( @$additional_fields ) { } } -my $branchloop = GetBranchesLoop(); my @serialnums=$input->multi_param('serialid'); if (@serialnums) { # i.e. they have been flagged to generate claims @@ -105,7 +103,6 @@ $template->param( missingissues => \@missingissues, supplierid => $supplierid, claimletter => $claimletter, - branchloop => $branchloop, additional_fields_for_subscription => $additional_fields, csv_profiles => [ Koha::CsvProfiles->search({ type => 'sql' }) ], letters => $letters, diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index 51c629e6f2..348adb36f9 100644 --- a/t/db_dependent/Branch.t +++ b/t/db_dependent/Branch.t @@ -38,7 +38,6 @@ can_ok( 'C4::Branch', qw( GetBranch GetBranches - GetBranchesLoop mybranch ) ); @@ -198,8 +197,4 @@ is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories adde #TODO later: test mybranchine and onlymine # Actually we cannot mock C4::Context->userenv in unit tests -#Test GetBranchesLoop -my $loop = GetBranchesLoop; -is( scalar(@$loop), Koha::Libraries->search->count, 'There is the right number of branches' ); - $schema->storage->txn_rollback; diff --git a/t/db_dependent/Holds/LocalHoldsPriority.t b/t/db_dependent/Holds/LocalHoldsPriority.t index b58362bd76..241272caea 100755 --- a/t/db_dependent/Holds/LocalHoldsPriority.t +++ b/t/db_dependent/Holds/LocalHoldsPriority.t @@ -63,9 +63,6 @@ foreach ( 1 .. $borrowers_count ) { my $biblionumber = $bibnum; -my @branches = GetBranchesLoop(); -my $branch = $branches[0][0]{value}; - # Create five item level holds my $i = 1; foreach my $borrowernumber (@borrowernumbers) { diff --git a/t/db_dependent/Holds/RevertWaitingStatus.t b/t/db_dependent/Holds/RevertWaitingStatus.t index 513eb52345..90419df565 100755 --- a/t/db_dependent/Holds/RevertWaitingStatus.t +++ b/t/db_dependent/Holds/RevertWaitingStatus.t @@ -13,6 +13,8 @@ use C4::Items; use C4::Members; use C4::Reserves; +use Koha::Libraries; + use t::lib::TestBuilder; my $schema = Koha::Database->schema; @@ -61,13 +63,12 @@ foreach my $i ( 1 .. $borrowers_count ) { my $biblionumber = $bibnum; -my @branches = GetBranchesLoop(); -my $branch = $branches[0][0]{value}; +my $branchcode = Koha::Libraries->search->next->branchcode; # Create five item level holds foreach my $borrowernumber (@borrowernumbers) { AddReserve( - $branch, + $branchcode, $borrowernumber, $biblionumber, my $bibitems = q{}, diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 987ccc8d6f..e26e553f35 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -113,10 +113,9 @@ my $notes = ''; my $checkitem = undef; my $found = undef; -my @branches = GetBranchesLoop(); -my $branch = $branches[0][0]{value}; +my $branchcode = Koha::Libraries->search->next->branchcode; -AddReserve($branch, $borrowernumber, $biblionumber, +AddReserve($branchcode, $borrowernumber, $biblionumber, $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found); diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 0ef4248bb9..439e4243f7 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -292,11 +292,11 @@ $query .= qq{ AND ( branchcode = ? OR branchcode IS NULL ) } if $branch_limit; $query .= qq{ GROUP BY lib ORDER BY lib, lib_opac}; my $authorised_values_sth = $dbh->prepare( $query ); -my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later. +my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later. # Adding a default choice, in case the user does not want to modify the branch my $nochange_branch = { branchname => '', value => '', selected => 1 }; -unshift (@$branches, $nochange_branch); +unshift (@$libraries, $nochange_branch); my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); @@ -350,14 +350,14 @@ foreach my $tag (sort keys %{$tagslib}) { my @authorised_values; my %authorised_lib; # builds list, depending on authorised value... - - if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) { - foreach my $thisbranch (@$branches) { - push @authorised_values, $thisbranch->{value}; - $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname}; - } + + if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) { + foreach my $library (@$libraries) { + push @authorised_values, $library->{branchcode}; + $authorised_lib{$library->{branchcode}} = $library->{branchname}; + } $value = ""; - } + } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { push @authorised_values, ""; my $itemtypes = GetItemTypes( style => 'array' ); diff --git a/tools/holidays.pl b/tools/holidays.pl index 2aee9ba249..4de6886aea 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -51,26 +51,6 @@ my $keydate = output_pref( { dt => $calendarinput_dt, dateonly => 1, dateformat $keydate =~ s/-/\//g; my $branch= $input->param('branch') || C4::Context->userenv->{'branch'}; -# Set all the branches. -my $onlymine = - ( C4::Context->preference('IndependentBranches') - && C4::Context->userenv - && !C4::Context->IsSuperLibrarian() - && C4::Context->userenv->{branch} ? 1 : 0 ); -if ( $onlymine ) { - $branch = C4::Context->userenv->{'branch'}; -} -my $branches = GetBranches($onlymine); -my @branchloop; -for my $thisbranch ( - sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } - keys %{$branches} ) { - push @branchloop, - { value => $thisbranch, - selected => $thisbranch eq $branch, - branchname => $branches->{$thisbranch}->{'branchname'}, - }; -} # branches calculated - put branch codes in a single string so they can be passed in a form my $branchcodes = join '|', keys %{$branches}; @@ -145,7 +125,6 @@ foreach my $yearMonthDay (keys %$single_holidays) { $template->param( WEEK_DAYS_LOOP => \@week_days, - branchloop => \@branchloop, HOLIDAYS_LOOP => \@holidays, EXCEPTION_HOLIDAYS_LOOP => \@exception_holidays, DAY_MONTH_HOLIDAYS_LOOP => \@day_month_holidays, diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl index d4a5a9e0cc..ed5f7889b4 100755 --- a/tools/import_borrowers.pl +++ b/tools/import_borrowers.pl @@ -40,7 +40,6 @@ use warnings; use C4::Auth; use C4::Output; use C4::Context; -use C4::Branch qw/GetBranchesLoop/; use C4::Members; use C4::Members::Attributes qw(:all); use C4::Members::AttributeTypes; @@ -85,9 +84,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ debug => 1, }); -# get the branches and pass them to the template -my $branches = GetBranchesLoop(); -$template->param( branches => $branches ) if ( $branches ); # get the patron categories and pass them to the template my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']}); $template->param( categories => \@patron_categories ); diff --git a/tools/inventory.pl b/tools/inventory.pl index 990855f840..5e5a5e3682 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -64,16 +64,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); - -my $branches = GetBranches(); -my @branch_loop; -for my $branch_hash (keys %$branches) { - push @branch_loop, {value => "$branch_hash", - branchname => $branches->{$branch_hash}->{'branchname'}, - selected => ($branch_hash eq $branchcode?1:0)}; -} - -@branch_loop = sort {$a->{branchname} cmp $b->{branchname}} @branch_loop; my @authorised_value_list; my $authorisedvalue_categories = ''; @@ -128,7 +118,6 @@ for my $authvfield (@$statuses) { } $statussth =~ s, and $,,g; $template->param( - branchloop => \@branch_loop, authorised_values => \@authorised_value_list, today => dt_from_string, minlocation => $minlocation, diff --git a/tools/letter.pl b/tools/letter.pl index 9f8ac95429..0f72cd6296 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -104,7 +104,6 @@ if ($op eq 'copy_form') { $template->param( oldbranchcode => $oldbranchcode, branchcode => $branchcode, - branchloop => _branchloop($branchcode), copying => 1, modify => 0, ); @@ -240,7 +239,6 @@ sub add_form { $template->param( module => $module, - branchloop => _branchloop($branchcode), SQLfieldnames => $field_selection, branchcode => $branchcode, ); @@ -379,26 +377,10 @@ sub default_display { $template->param( letter => $loop_data, - branchloop => _branchloop($branchcode), + branchcode => $branchcode, ); } -sub _branchloop { - my ($branchcode) = @_; - - my $branches = GetBranches(); - my @branchloop; - for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - push @branchloop, { - value => $thisbranch, - selected => $branchcode && $thisbranch eq $branchcode, - branchname => $branches->{$thisbranch}->{'branchname'}, - }; - } - - return \@branchloop; -} - sub add_fields { my @tables = @_; my @fields = (); diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index db532a6d63..31e4ec1fa2 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -28,7 +28,6 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; -use C4::Branch; use C4::Koha; use C4::Members; use C4::Members::Attributes; @@ -37,6 +36,7 @@ use C4::Output; use List::MoreUtils qw /any uniq/; use Koha::DateUtils qw( dt_from_string ); use Koha::List::Patron; +use Koha::Libraries; use Koha::Patron::Categories; my $input = new CGI; @@ -145,7 +145,7 @@ if ( $op eq 'show' ) { if @notfoundcardnumbers; # Construct drop-down list values - my $branches = GetBranchesLoop; + my $branches = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed; my @branches_option; push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches; unshift @branches_option, { value => "", lib => "" }; diff --git a/tools/overduerules.pl b/tools/overduerules.pl index 8ce3f3c3af..f21092d411 100755 --- a/tools/overduerules.pl +++ b/tools/overduerules.pl @@ -24,7 +24,6 @@ use C4::Context; use C4::Output; use C4::Auth; use C4::Koha; -use C4::Branch; use C4::Letters; use C4::Members; use C4::Overdues; @@ -210,7 +209,6 @@ if ($op eq 'save') { $input_saved = 1; } } -my $branchloop = GetBranchesLoop($branch); my $letters = C4::Letters::GetLettersAvailableForALibrary( { @@ -310,7 +308,6 @@ my @tabs = ( $template->param( table => ( @first or @second or @third ? 1 : 0 ), - branchloop => $branchloop, branch => $branch, tabs => \@tabs, message_transport_types => $message_transport_types, -- 2.39.5