Commit 4f521731 authored by joubu's avatar joubu Committed by Brendan Gallagher

Bug 15629: Koha::Libraries - Remove GetBranchDetail

C4::Branch::GetBranchDetail retrieved library infos, it could be easily
replaced with Koha::Libraries->find

When this change needs other big changes, the unblessed method is
called, to manipulate a hashref (as before) instead of a Koha::Library
object (for instance when $library is sent to GetPreparedLetter).

Test plan:
1/ Print a basket group, the library names should be correctly
displayed.
2/ Enable emailLibrarianWhenHoldIsPlaced and place a hold, a HOLDPLACED
notice will be generated (focus on the library name)
3/ Edit a patron and change his/her library
4/ Generate the advanced notices (misc/cronjobs/advance_notices.pl) and
have a look at the generated notices
5/ Same of overdues notices
6/ Set IndependentBranches and use a non superlibrarian user to place a
hold. The "pickup at" should be correctly filled.
Signed-off-by: default avatarOwen Leonard <oleonard@myacpl.org>
Signed-off-by: default avatarKyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com 
parent f4d6c1cd
......@@ -31,6 +31,7 @@ use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Acquisition::Order;
use Koha::Acquisition::Bookseller;
use Koha::Number::Price;
use Koha::Libraries;
use C4::Koha qw( subfield_is_koha_internal_p );
......@@ -2949,14 +2950,14 @@ sub NotifyOrderUsers {
my $order = GetOrder( $ordernumber );
for my $borrowernumber (@borrowernumbers) {
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $branch = C4::Branch::GetBranchDetail( $borrower->{branchcode} );
my $library = Koha::Libraries->find( $borrower->{branchcode} )->unblessed;
my $biblio = C4::Biblio::GetBiblio( $order->{biblionumber} );
my $letter = C4::Letters::GetPreparedLetter(
module => 'acquisition',
letter_code => 'ACQ_NOTIF_ON_RECEIV',
branchcode => $branch->{branchcode},
branchcode => $library->branchcode,
tables => {
'branches' => $branch,
'branches' => $library,
'borrowers' => $borrower,
'biblio' => $biblio,
'aqorders' => $order,
......
......@@ -33,7 +33,6 @@ BEGIN {
&GetBranch
&GetBranches
&GetBranchesLoop
&GetBranchDetail
&ModBranch
&GetBranchInfo
&mybranch
......@@ -293,22 +292,6 @@ sub GetBranch {
return $branch;
}
=head2 GetBranchDetail
$branch = &GetBranchDetail($branchcode);
Given the branch code, the function returns a
hashref for the corresponding row in the branches table.
=cut
sub GetBranchDetail {
my ($branchcode) = shift or return;
my $sth = C4::Context->dbh->prepare("SELECT * FROM branches WHERE branchcode = ?");
$sth->execute($branchcode);
return $sth->fetchrow_hashref();
}
=head2 GetBranchInfo
$results = GetBranchInfo($branchcode);
......
......@@ -51,6 +51,7 @@ use Koha::Items;
use Koha::Borrowers;
use Koha::Borrower::Debarments;
use Koha::Database;
use Koha::Libraries;
use Carp;
use List::MoreUtils qw( uniq );
use Date::Calc qw(
......@@ -1798,7 +1799,7 @@ patron who last borrowed the book.
sub AddReturn {
my ( $barcode, $branch, $exemptfine, $dropbox, $return_date, $dropboxdate ) = @_;
if ($branch and not GetBranchDetail($branch)) {
if ($branch and not Koha::Libraries->find($branch)) {
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'};
undef $branch;
}
......
......@@ -420,7 +420,7 @@ sub SendAlerts {
# warn "sending issues...";
my $userenv = C4::Context->userenv;
my $branchdetails = GetBranchDetail($_->{'branchcode'});
my $library = Koha::Libraries->find( $_->{branchcode} );
my $letter = GetPreparedLetter (
module => 'serial',
letter_code => $letter_code,
......@@ -441,9 +441,9 @@ sub SendAlerts {
my %mail = $message->create_message_headers(
{
to => $email,
from => $branchdetails->{'branchemail'},
replyto => $branchdetails->{'branchreplyto'},
sender => $branchdetails->{'branchreturnpath'},
from => $library->branchemail,
replyto => $library->branchreplyto,
sender => $library->branchreturnpath,
subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
message => $letter->{'is_html'}
? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
......@@ -571,13 +571,13 @@ sub SendAlerts {
}
# send an "account details" notice to a newly created user
elsif ( $type eq 'members' ) {
my $branchdetails = GetBranchDetail($externalid->{'branchcode'});
my $library = Koha::Libraries->find( $externalid->{branchcode} )->unblessed;
my $letter = GetPreparedLetter (
module => 'members',
letter_code => $letter_code,
branchcode => $externalid->{'branchcode'},
tables => {
'branches' => $branchdetails,
'branches' => $library,
'borrowers' => $externalid->{'borrowernumber'},
},
substitute => { 'borrowers.password' => $externalid->{'password'} },
......@@ -588,9 +588,9 @@ sub SendAlerts {
my %mail = $email->create_message_headers(
{
to => $externalid->{'emailaddr'},
from => $branchdetails->{'branchemail'},
replyto => $branchdetails->{'branchreplyto'},
sender => $branchdetails->{'branchreturnpath'},
from => $library->{branchemail},
replyto => $library->{branchreplyto},
sender => $library->{branchreturnpath},
subject => Encode::encode( "UTF-8", "" . $letter->{'title'} ),
message => $letter->{'is_html'}
? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
......@@ -1206,11 +1206,11 @@ sub _send_message_by_email {
my $branch_email = undef;
my $branch_replyto = undef;
my $branch_returnpath = undef;
if ($member){
my $branchdetail = GetBranchDetail( $member->{'branchcode'} );
$branch_email = $branchdetail->{'branchemail'};
$branch_replyto = $branchdetail->{'branchreplyto'};
$branch_returnpath = $branchdetail->{'branchreturnpath'};
if ($member) {
my $library = Koha::Libraries->find( $member->{branchcode} );
$branch_email = $library->branchemail;
$branch_replyto = $library->branchreplyto;
$branch_returnpath = $library->branchreturnpath;
}
my $email = Koha::Email->new();
my %sendmail_params = $email->create_message_headers(
......
......@@ -34,13 +34,13 @@ use C4::Accounts;
use C4::Members::Messaging;
use C4::Members qw();
use C4::Letters;
use C4::Branch qw( GetBranchDetail );
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Database;
use Koha::Hold;
use Koha::Holds;
use Koha::Libraries;
use List::MoreUtils qw( firstidx any );
use Carp;
......@@ -219,13 +219,13 @@ sub AddReserve {
# Send e-mail to librarian if syspref is active
if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber);
my $branch_details = C4::Branch::GetBranchDetail($borrower->{branchcode});
my $library = Koha::Libraries->find($borrower->{branchcode})->unblessed;
if ( my $letter = C4::Letters::GetPreparedLetter (
module => 'reserves',
letter_code => 'HOLDPLACED',
branchcode => $branch,
tables => {
'branches' => $branch_details,
'branches' => $library,
'borrowers' => $borrower,
'biblio' => $biblionumber,
'biblioitems' => $biblionumber,
......@@ -233,7 +233,7 @@ sub AddReserve {
},
) ) {
my $admin_email_address =$branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
my $admin_email_address = $library->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
C4::Letters::EnqueueLetter(
{ letter => $letter,
......@@ -1969,15 +1969,15 @@ sub _koha_notify_reserve {
");
$sth->execute( $borrowernumber, $biblionumber );
my $reserve = $sth->fetchrow_hashref;
my $branch_details = GetBranchDetail( $reserve->{'branchcode'} );
my $library = Koha::Libraries->find( $reserve->{branchcode} )->unblessed;
my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress');
my $admin_email_address = $library->{branchemail} || C4::Context->preference('KohaAdminEmailAddress');
my %letter_params = (
module => 'reserves',
branchcode => $reserve->{branchcode},
tables => {
'branches' => $branch_details,
'branches' => $library,
'borrowers' => $borrower,
'biblio' => $biblionumber,
'biblioitems' => $biblionumber,
......
......@@ -210,7 +210,6 @@ if ($op eq ""){
}
# 3rd add order
my $patron = C4::Members::GetMember( borrowernumber => $loggedinuser );
my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
# get quantity in the MARC record (1 if none)
my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
my %orderinfo = (
......
......@@ -28,10 +28,9 @@ use strict;
use warnings;
use utf8;
use C4::Branch qw(GetBranchDetail);
use Koha::Number::Price;
use Koha::DateUtils;
use Koha::Libraries;
BEGIN {
use Exporter ();
......@@ -147,9 +146,8 @@ sub printhead {
# get library name
my $libraryname = C4::Context->preference("LibraryName");
# get branch details
my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} );
my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
my $billing_library = Koha::Libraries->find( $basketgroup->{billingplace} );
my $delivery_library = Koha::Libraries->find( $basketgroup->{deliveryplace} );
my $freedeliveryplace = $basketgroup->{freedeliveryplace};
# get the subject
my $subject;
......@@ -181,21 +179,21 @@ sub printhead {
$text->translate(100/mm, ($height-86)/mm);
$text->text($libraryname);
$text->translate(100/mm, ($height-97)/mm);
$text->text($billingdetails->{branchname});
$text->text($billing_library->branchname);
$text->translate(100/mm, ($height-108.5)/mm);
$text->text($billingdetails->{branchphone});
$text->text($billing_library->branchphone);
$text->translate(100/mm, ($height-115.5)/mm);
$text->text($billingdetails->{branchfax});
$text->text($billing_library->branchfax);
$text->translate(100/mm, ($height-122.5)/mm);
$text->text($billingdetails->{branchaddress1});
$text->text($billing_library->branchaddress1);
$text->translate(100/mm, ($height-127.5)/mm);
$text->text($billingdetails->{branchaddress2});
$text->text($billing_library->branchaddress2);
$text->translate(100/mm, ($height-132.5)/mm);
$text->text($billingdetails->{branchaddress3});
$text->text($billing_library->branchaddress3);
$text->translate(100/mm, ($height-137.5)/mm);
$text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry}));
$text->text(join(' ', $billing_library->branchzip, $billing_library->branchcity, $billing_library->branchcountry));
$text->translate(100/mm, ($height-147.5)/mm);
$text->text($billingdetails->{branchemail});
$text->text($billing_library->branchemail);
# print subject
$text->translate(100/mm, ($height-145.5)/mm);
......@@ -227,13 +225,13 @@ sub printhead {
$start += 5;
}
} else {
$text->text( $deliverydetails->{branchaddress1} );
$text->text( $delivery_library->branchaddress1 );
$text->translate( 50 / mm, ( $height - 242 ) / mm );
$text->text( $deliverydetails->{branchaddress2} );
$text->text( $delivery_library->branchaddress2 );
$text->translate( 50 / mm, ( $height - 247 ) / mm );
$text->text( $deliverydetails->{branchaddress3} );
$text->text( $delivery_library->branchaddress3 );
$text->translate( 50 / mm, ( $height - 252 ) / mm );
$text->text( join( ' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry} ) );
$text->text( join( ' ', $delivery_library->branchzip, $delivery_library->branchcity, $delivery_library->branchcountry ) );
}
$text->translate(50/mm, ($height-262)/mm);
$text->text($basketgroup->{deliverycomment});
......
......@@ -28,10 +28,9 @@ use strict;
use warnings;
use utf8;
use C4::Branch qw(GetBranchDetail);
use Koha::Number::Price;
use Koha::DateUtils;
use Koha::Libraries;
BEGIN {
use Exporter ();
......@@ -147,9 +146,8 @@ sub printhead {
# get library name
my $libraryname = C4::Context->preference("LibraryName");
# get branch details
my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} );
my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
my $billing_library = Koha::Libraries->find( $basketgroup->{billingplace} );
my $delivery_library = Koha::Libraries->find( $basketgroup->{deliveryplace} );
my $freedeliveryplace = $basketgroup->{freedeliveryplace};
# get the subject
my $subject;
......@@ -181,21 +179,21 @@ sub printhead {
$text->translate(100/mm, ($height-86)/mm);
$text->text($libraryname);
$text->translate(100/mm, ($height-97)/mm);
$text->text($billingdetails->{branchname});
$text->text($billing_library->branchname);
$text->translate(100/mm, ($height-108.5)/mm);
$text->text($billingdetails->{branchphone});
$text->text($billing_library->branchphone);
$text->translate(100/mm, ($height-115.5)/mm);
$text->text($billingdetails->{branchfax});
$text->text($billing_library->branchfax);
$text->translate(100/mm, ($height-122.5)/mm);
$text->text($billingdetails->{branchaddress1});
$text->text($billing_library->branchaddress1);
$text->translate(100/mm, ($height-127.5)/mm);
$text->text($billingdetails->{branchaddress2});
$text->text($billing_library->branchaddress2);
$text->translate(100/mm, ($height-132.5)/mm);
$text->text($billingdetails->{branchaddress3});
$text->text($billing_library->branchaddress3);
$text->translate(100/mm, ($height-137.5)/mm);
$text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry}));
$text->text(join(' ', $billing_library->branchzip, $billing_library->branchcity, $billing_library->branchcountry));
$text->translate(100/mm, ($height-147.5)/mm);
$text->text($billingdetails->{branchemail});
$text->text($billing_library->branchemail);
# print subject
$text->translate(100/mm, ($height-145.5)/mm);
......@@ -227,13 +225,13 @@ sub printhead {
$start += 5;
}
} else {
$text->text( $deliverydetails->{branchaddress1} );
$text->text( $delivery_library->branchaddress1 );
$text->translate( 50 / mm, ( $height - 242 ) / mm );
$text->text( $deliverydetails->{branchaddress2} );
$text->text( $delivery_library->branchaddress2 );
$text->translate( 50 / mm, ( $height - 247 ) / mm );
$text->text( $deliverydetails->{branchaddress3} );
$text->text( $delivery_library->branchaddress3 );
$text->translate( 50 / mm, ( $height - 252 ) / mm );
$text->text( join( ' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry} ) );
$text->text( join( ' ', $delivery_library->branchzip, $delivery_library->branchcity, $delivery_library->branchcountry ) );
}
$text->translate(50/mm, ($height-262)/mm);
$text->text($basketgroup->{deliverycomment});
......
......@@ -29,10 +29,11 @@ use strict;
use warnings;
use utf8;
use C4::Branch qw(GetBranchDetail GetBranchName);
use C4::Branch qw(GetBranchName);
use Koha::Number::Price;
use Koha::DateUtils;
use Koha::Libraries;
BEGIN {
use Exporter ();
......@@ -311,9 +312,8 @@ sub printhead {
# get library name
my $libraryname = C4::Context->preference("LibraryName");
# get branch details
my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} );
my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
my $billing_library = Koha::Libraries->find( $basketgroup->{billingplace} );
my $delivery_library = Koha::Libraries->find( $basketgroup->{deliveryplace} );
my $freedeliveryplace = $basketgroup->{freedeliveryplace};
# get the subject
my $subject;
......@@ -345,21 +345,21 @@ sub printhead {
$text->translate(100/mm, ($height-86)/mm);
$text->text($libraryname);
$text->translate(100/mm, ($height-97)/mm);
$text->text($billingdetails->{branchname});
$text->text($billing_library->branchname);
$text->translate(100/mm, ($height-108.5)/mm);
$text->text($billingdetails->{branchphone});
$text->text($billing_library->branchphone);
$text->translate(100/mm, ($height-115.5)/mm);
$text->text($billingdetails->{branchfax});
$text->text($billing_library->branchfax);
$text->translate(100/mm, ($height-122.5)/mm);
$text->text($billingdetails->{branchaddress1});
$text->text($billing_library->branchaddress1);
$text->translate(100/mm, ($height-127.5)/mm);
$text->text($billingdetails->{branchaddress2});
$text->text($billing_library->branchaddress2);
$text->translate(100/mm, ($height-132.5)/mm);
$text->text($billingdetails->{branchaddress3});
$text->text($billing_library->branchaddress3);
$text->translate(100/mm, ($height-137.5)/mm);
$text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry}));
$text->text(join(' ', $billing_library->branchzip, $billing_library->branchcity, $billing_library->branchcountry));
$text->translate(100/mm, ($height-147.5)/mm);
$text->text($billingdetails->{branchemail});
$text->text($billing_library->branchemail);
# print subject
$text->translate(100/mm, ($height-145.5)/mm);
......@@ -391,13 +391,13 @@ sub printhead {
$start += 5;
}
} else {
$text->text($deliverydetails->{branchaddress1});
$text->text($delivery_library->branchaddress1);
$text->translate(50/mm, ($height-242)/mm);
$text->text($deliverydetails->{branchaddress2});
$text->text($delivery_library->branchaddress2);
$text->translate(50/mm, ($height-247)/mm);
$text->text($deliverydetails->{branchaddress3});
$text->text($delivery_library->branchaddress3);
$text->translate(50/mm, ($height-252)/mm);
$text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry}));
$text->text(join(' ', $delivery_library->branchzip, $delivery_library->branchcity, $delivery_library->branchcountry));
}
$text->translate(50/mm, ($height-262)/mm);
$text->text($basketgroup->{deliverycomment});
......
......@@ -28,10 +28,11 @@ use strict;
use warnings;
use utf8;
use C4::Branch qw(GetBranchDetail GetBranchName);
use C4::Branch qw(GetBranchName);
use Koha::Number::Price;
use Koha::DateUtils;
use Koha::Libraries;
BEGIN {
use Exporter ();
......@@ -311,9 +312,8 @@ sub printhead {
# get library name
my $libraryname = C4::Context->preference("LibraryName");
# get branch details
my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} );
my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
my $billing_library = Koha::Libraries->find( $basketgroup->{billingplace} );
my $delivery_library = Koha::Libraries->find( $basketgroup->{deliveryplace} );
my $freedeliveryplace = $basketgroup->{freedeliveryplace};
# get the subject
my $subject;
......@@ -345,21 +345,21 @@ sub printhead {
$text->translate(100/mm, ($height-86)/mm);
$text->text($libraryname);
$text->translate(100/mm, ($height-97)/mm);
$text->text($billingdetails->{branchname});
$text->text($billing_library->branchname);
$text->translate(100/mm, ($height-108.5)/mm);
$text->text($billingdetails->{branchphone});
$text->text($billing_library->branchphone);
$text->translate(100/mm, ($height-115.5)/mm);
$text->text($billingdetails->{branchfax});
$text->text($billing_library->branchfax);
$text->translate(100/mm, ($height-122.5)/mm);
$text->text($billingdetails->{branchaddress1});
$text->text($billing_library->branchaddress1);
$text->translate(100/mm, ($height-127.5)/mm);
$text->text($billingdetails->{branchaddress2});
$text->text($billing_library->branchaddress2);
$text->translate(100/mm, ($height-132.5)/mm);
$text->text($billingdetails->{branchaddress3});
$text->text($billing_library->branchaddress3);
$text->translate(100/mm, ($height-137.5)/mm);
$text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry}));
$text->text(join(' ', $billing_library->branchzip, $billing_library->branchcity, $billing_library->branchcountry));
$text->translate(100/mm, ($height-147.5)/mm);
$text->text($billingdetails->{branchemail});
$text->text($billing_library->branchemail);
# print subject
$text->translate(100/mm, ($height-145.5)/mm);
......@@ -391,13 +391,13 @@ sub printhead {
$start += 5;
}
} else {
$text->text($deliverydetails->{branchaddress1});
$text->text($delivery_library->branchaddress1);
$text->translate(50/mm, ($height-242)/mm);
$text->text($deliverydetails->{branchaddress2});
$text->text($delivery_library->branchaddress2);
$text->translate(50/mm, ($height-247)/mm);
$text->text($deliverydetails->{branchaddress3});
$text->text($delivery_library->branchaddress3);
$text->translate(50/mm, ($height-252)/mm);
$text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry}));
$text->text(join(' ', $delivery_library->branchzip, $delivery_library->branchcity, $delivery_library->branchcountry));
}
$text->translate(50/mm, ($height-262)/mm);
$text->text($basketgroup->{deliverycomment});
......
......@@ -44,7 +44,6 @@ use C4::Koha;
use C4::Biblio;
use C4::Items;
use C4::Members; # to use GetMember
use C4::Branch; # GetBranchDetail
use C4::Serials; # CountSubscriptionFromBiblionumber
use C4::Search; # enabled_staff_search_views
use C4::Acquisition qw(GetOrdersByBiblionumber);
......
......@@ -27,6 +27,7 @@ use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Libraries;
use Koha::List::Patron;
my $query = new CGI;
......@@ -47,11 +48,11 @@ my $branches = GetBranches;
my @branchloop;
if ( C4::Branch::onlymine ) {
my $userenv = C4::Context->userenv;
my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
my $library = Koha::Libraries->find( $userenv->{'branch'} );
push @branchloop, {
value => $branch->{branchcode},
branchcode => $branch->{branchcode},
branchname => $branch->{branchname},
value => $library->branchcode,
branchcode => $library->branchcode,
branchname => $library->branchname,
selected => 1
}
} else {
......
......@@ -52,6 +52,7 @@ use C4::Form::MessagingPreferences;
use List::MoreUtils qw/uniq/;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Koha::Libraries;
use Module::Load;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
......@@ -215,8 +216,8 @@ if ( C4::Context->preference("IndependentBranches") ) {
else {
$samebranch = 1;
}
my $branchdetail = GetBranchDetail( $data->{'branchcode'});
@{$data}{keys %$branchdetail} = values %$branchdetail; # merge in all branch columns
my $library = Koha::Libraries->find( $data->{branchcode})->unblessed;
@{$data}{keys %$library} = values %$library; # merge in all branch columns
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
my $lib1 = &GetSortDetails( "Bsort1", $data->{'sort1'} );
......
......@@ -57,6 +57,7 @@ use C4::Members::Messaging;
use C4::Overdues;
use Koha::DateUtils;
use C4::Log;
use Koha::Libraries;
=head1 NAME
......@@ -507,7 +508,7 @@ sub get_branch_info {
## Get branch info for borrowers home library.
my $borrower_details = C4::Members::GetMember( borrowernumber => $borrowernumber );
my $borrower_branchcode = $borrower_details->{'branchcode'};
my $branch = C4::Branch::GetBranchDetail( $borrower_branchcode );
my $branch = Koha::Libraries->find( $borrower_branchcode )->unblessed;
my %branch_info;
foreach my $key( keys %$branch ) {
$branch_info{"branches.$key"} = $branch->{$key};
......
......@@ -8,6 +8,7 @@ use Getopt::Long;
use C4::Budgets qw( GetBudget );
use C4::Members qw( GetMember );
use C4::Suggestions qw( GetUnprocessedSuggestions );
use Koha::Libraries;
my ( $help, $verbose, $confirm, @days );
GetOptions(
......@@ -47,8 +48,8 @@ for my $number_of_days (@days) {
my $patron = C4::Members::GetMember( borrowernumber => $budget->{budget_owner_id} );
my $email_address =
C4::Members::GetNoticeEmailAddress( $budget->{budget_owner_id} );
my $library = C4::Branch::GetBranchDetail( $patron->{branchcode} );
my $admin_email_address = $library->{branchemail}
my $library = Koha::Libraries->find( $patron->{branchcode} );
my $admin_email_address = $library->branchemail
|| C4::Context->preference('KohaAdminEmailAddress');
if ($email_address) {
......
......@@ -41,6 +41,7 @@ use C4::Log;
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Libraries;
=head1 NAME
......@@ -438,8 +439,8 @@ foreach my $branchcode (@branches) {
}
}
my $branch_details = C4::Branch::GetBranchDetail($branchcode);
my $admin_email_address = $branch_details->{'branchemail'}
my $library = Koha::Libraries->find($branchcode);
my $admin_email_address = $library->branchemail
|| C4::Context->preference('KohaAdminEmailAddress');
my @output_chunks; # may be sent to mail or stdout or csv file.
......@@ -679,7 +680,7 @@ END_SQL
branchcode => $branchcode,
items => \@items,
substitute => { # this appears to be a hack to overcome incomplete features in this code.
bib => $branch_details->{'branchname'}, # maybe 'bib' is a typo for 'lib<rary>'?
bib => $library->branchname, # maybe 'bib' is a typo for 'lib<rary>'?
'items.content' => $titles,
'count' => $itemcount,
},
......@@ -713,7 +714,7 @@ END_SQL
city => $data->{'city'},
phone => $data->{'phone'},
cardnumber => $data->{'cardnumber'},
branchname => $branch_details->{'branchname'},
branchname => $library->branchname,
letternumber => $i,
postcode => $data->{'zipcode'},
country => $data->{'country'},
......
......@@ -46,6 +46,7 @@ use C4::Search; # enabled_staff_search_views
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Holds;
use Koha::Libraries;
my $dbh = C4::Context->dbh;
my $input = new CGI;
......@@ -562,7 +563,7 @@ foreach my $biblionumber (@biblionumbers) {
$reserve{'reserve_id'} = $res->reserve_id();
if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) {
$reserve{'branchloop'} = [ GetBranchDetail( $res->branchcode() ) ];
$reserve{'branchloop'} = [ Koha::Libraries->find( $res->branchcode() ) ];
}
else {
$reserve{'branchloop'} = GetBranchesLoop( $res->branchcode() );
......
......@@ -21,7 +21,7 @@ use Modern::Perl;
use C4::Context;
use Data::Dumper;
use Test::More tests => 21;
use Test::More tests => 19;
use C4::Branch;
use Koha::Libraries;
......@@ -38,7 +38,6 @@ can_ok(
GetBranch
GetBranches
GetBranchesLoop
GetBranchDetail
ModBranch
GetBranchInfo
mybranch
......@@ -80,7 +79,8 @@ my $b1 = {
branchip => 'ipA',
branchprinter => undef,
branchnotes => 'noteA',
opac_info => 'opacA'
opac_info => 'opacA',
issuing => undef,
};
my $b2 = {
branchcode => 'BRB',
......@@ -102,6 +102,7 @@ my $b2 = {
branchprinter => undef,
branchnotes => 'noteB',
opac_info => 'opacB',
issuing => undef,
};
ModBranch($b1);
is( ModBranch($b2), undef, 'the field add is missing' );
......@@ -117,12 +118,6 @@ is( Koha::Libraries->search->count, $count + 1, "branch BRB deleted"
is( GetBranchName( $b1->{branchcode} ),
$b1->{branchname}, "GetBranchName returns the right name" );
#Test GetBranchDetail
my $branchdetail = GetBranchDetail( $b1->{branchcode} );
$branchdetail->{add} = 1;
$b1->{issuing} = undef; # Not used in DB
is_deeply( $branchdetail, $b1, 'branchdetail is right' );
#Test Getbranches
my $branches = GetBranches();
is( scalar( keys %$branches ),
......@@ -149,15 +144,13 @@ $b1 = {
branchip => 'ipA modified',
branchprinter => undef,