Bugzilla – Attachment 47521 Details for
Bug 15629
Move the C4::Branch related code to Koha::Libraries - part 3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 15629: Koha::Libraries - Remove GetBranchDetail
SIGNED-OFF-Bug-15629-KohaLibraries---Remove-GetBra.patch (text/plain), 39.66 KB, created by
Owen Leonard
on 2016-02-01 16:47:39 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 15629: Koha::Libraries - Remove GetBranchDetail
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-02-01 16:47:39 UTC
Size:
39.66 KB
patch
obsolete
>From 963b01f93718647301fae57c04f1cf78f361464d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 20 Jan 2016 12:17:43 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 15629: Koha::Libraries - Remove > GetBranchDetail >Content-Type: text/plain; charset="utf-8" > >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: Owen Leonard <oleonard@myacpl.org> >--- > C4/Acquisition.pm | 7 +++--- > C4/Branch.pm | 17 ------------- > C4/Circulation.pm | 3 ++- > C4/Letters.pm | 28 +++++++++++----------- > C4/Reserves.pm | 14 +++++------ > acqui/addorderiso2709.pl | 1 - > acqui/pdfformat/layout2pages.pm | 32 ++++++++++++------------- > acqui/pdfformat/layout2pagesde.pm | 32 ++++++++++++------------- > acqui/pdfformat/layout3pages.pm | 32 ++++++++++++------------- > acqui/pdfformat/layout3pagesfr.pm | 32 ++++++++++++------------- > catalogue/ISBDdetail.pl | 1 - > members/members-home.pl | 9 +++---- > members/moremember.pl | 5 ++-- > misc/cronjobs/advance_notices.pl | 3 ++- > misc/cronjobs/notice_unprocessed_suggestions.pl | 5 ++-- > misc/cronjobs/overdue_notices.pl | 9 +++---- > reserve/request.pl | 3 ++- > t/db_dependent/Branch.t | 21 ++++++---------- > t/db_dependent/ILSDI_Services.t | 6 ++--- > t/db_dependent/Items.t | 12 +++++----- > t/db_dependent/Letters.t | 12 +++++----- > t/db_dependent/Suggestions.t | 3 ++- > 22 files changed, 133 insertions(+), 154 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 4044556..512924b 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -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, >diff --git a/C4/Branch.pm b/C4/Branch.pm >index 057a043..465a0e4 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -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); >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index ae53366..fe891e4 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -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( >@@ -1796,7 +1797,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; > } >diff --git a/C4/Letters.pm b/C4/Letters.pm >index dc9574f..576b7ec 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -418,7 +418,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, >@@ -439,9 +439,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'} ), >@@ -569,13 +569,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'} }, >@@ -586,9 +586,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'} ), >@@ -1197,11 +1197,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( >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index f981be1..e0d616b 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -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, >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index 8ce2ce1..5656d77 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -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 = ( >diff --git a/acqui/pdfformat/layout2pages.pm b/acqui/pdfformat/layout2pages.pm >index a06d1b8..55213aa 100644 >--- a/acqui/pdfformat/layout2pages.pm >+++ b/acqui/pdfformat/layout2pages.pm >@@ -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}); >diff --git a/acqui/pdfformat/layout2pagesde.pm b/acqui/pdfformat/layout2pagesde.pm >index 5df84d3..a514eec 100644 >--- a/acqui/pdfformat/layout2pagesde.pm >+++ b/acqui/pdfformat/layout2pagesde.pm >@@ -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}); >diff --git a/acqui/pdfformat/layout3pages.pm b/acqui/pdfformat/layout3pages.pm >index 9b9c47f..ffec723 100644 >--- a/acqui/pdfformat/layout3pages.pm >+++ b/acqui/pdfformat/layout3pages.pm >@@ -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}); >diff --git a/acqui/pdfformat/layout3pagesfr.pm b/acqui/pdfformat/layout3pagesfr.pm >index a3d509f..66ba608 100644 >--- a/acqui/pdfformat/layout3pagesfr.pm >+++ b/acqui/pdfformat/layout3pagesfr.pm >@@ -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}); >diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl >index 8c02f42..6aa2cee 100755 >--- a/catalogue/ISBDdetail.pl >+++ b/catalogue/ISBDdetail.pl >@@ -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); >diff --git a/members/members-home.pl b/members/members-home.pl >index b9368f6..f4e0cea 100755 >--- a/members/members-home.pl >+++ b/members/members-home.pl >@@ -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 { >diff --git a/members/moremember.pl b/members/moremember.pl >index 796e19a..cf1dcb6 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -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'} ); >diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl >index 6eda48c..855492e 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -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}; >diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl >index 3a31ed4..4c370e8 100755 >--- a/misc/cronjobs/notice_unprocessed_suggestions.pl >+++ b/misc/cronjobs/notice_unprocessed_suggestions.pl >@@ -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) { >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 9be7e4d..1774b29 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -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'}, >diff --git a/reserve/request.pl b/reserve/request.pl >index dfdd6e1..14c3d56 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -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; >@@ -564,7 +565,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() ); >diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t >index 72a59d4..73e7ec7 100644 >--- a/t/db_dependent/Branch.t >+++ b/t/db_dependent/Branch.t >@@ -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, > branchnotes => 'notesA modified', >- opac_info => 'opacA modified' >+ opac_info => 'opacA modified', >+ issuing => undef, > }; > > ModBranch($b1); > is( Koha::Libraries->search->count, $count + 1, > "A branch has been modified, no new branch added" ); >-$branchdetail = GetBranchDetail( $b1->{branchcode} ); >-$b1->{issuing} = undef; >-is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA"); > > #Test categories > my $count_cat = Koha::LibraryCategories->search->count; >@@ -236,6 +229,7 @@ $b2 = { > branchprinter => undef, > branchnotes => 'noteB', > opac_info => 'opacB', >+ issuing => undef, > CAT1 => 1, > CAT2 => 1 > }; >@@ -244,7 +238,6 @@ $b2info = GetBranchInfo( $b2->{branchcode} ); > push( @cat, $cat2->{categorycode} ); > delete $b2->{CAT1}; > delete $b2->{CAT2}; >-$b2->{issuing} = undef; > $b2->{categories} = \@cat; > is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1 and CAT2' ); > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 9aee73e..34712c2 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -3,7 +3,7 @@ > use Modern::Perl; > > use C4::Members qw/AddMember GetMember GetBorrowercategory/; >-use C4::Branch; >+use Koha::Libraries; > use CGI qw ( -utf8 ); > > use Test::More tests => 15; >@@ -37,8 +37,8 @@ unless ( GetBorrowercategory('UT') ) { > ('UT','Unit tester',99,99,0.000000,1,0.000000,'C','default');"); > } > >-# Create branch >-unless ( GetBranchDetail('UT') ) { >+# Create library >+unless ( Koha::Libraries->find('UT') ) { > $dbh->do("INSERT INTO branches (branchcode,branchname) VALUES ('UT','Unit test library');"); > } > >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index c0603b9..e3a1e02 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -202,13 +202,13 @@ subtest 'GetItemsInfo tests' => sub { > holdingbranch => $library2->{branchcode}, > }, $biblionumber ); > >- my $branch = GetBranchDetail( $library1->{branchcode} ); >- $branch->{ opac_info } = "homebranch OPAC info"; >- ModBranch($branch); >+ my $library = Koha::Libraries->find( $library1->{branchcode} )->unblessed; >+ $library->{ opac_info }= "homebranch OPAC info"; >+ ModBranch($library); > >- $branch = GetBranchDetail( $library2->{branchcode} ); >- $branch->{ opac_info } = "holdingbranch OPAC info"; >- ModBranch($branch); >+ $library = Koha::Libraries->find( $library2->{branchcode} )->unblessed; >+ $library->{ opac_info } = "holdingbranch OPAC info"; >+ ModBranch($library); > > my @results = GetItemsInfo( $biblionumber ); > ok( @results, 'GetItemsInfo returns results'); >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 03d474a..dd3e07a 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 69; >+use Test::More tests => 68; > use Test::MockModule; > use Test::Warn; > >@@ -36,7 +36,6 @@ $module->mock( > > use_ok('C4::Context'); > use_ok('C4::Members'); >-use_ok('C4::Branch'); > use_ok('C4::Acquisition'); > use_ok('C4::Biblio'); > use_ok('C4::Bookseller'); >@@ -47,6 +46,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Order; > use Koha::Acquisition::Bookseller; >+use Koha::Libraries; > my $schema = Koha::Database->schema; > $schema->storage->txn_begin(); > >@@ -263,13 +263,13 @@ my $prepared_letter = GetPreparedLetter(( > substitute => $substitute, > repeat => $repeat, > )); >-my $branch = GetBranchDetail($library->{branchcode}); >-my $my_title_letter = qq|$branch->{branchname} - $substitute->{status}|; >+my $retrieved_library = Koha::Libraries->find($library->{branchcode}); >+my $my_title_letter = $retrieved_library->branchname . qq| - $substitute->{status}|; > my $my_content_letter = qq|Dear Jane Smith, > According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible. > >-$branch->{branchname} >-$branch->{branchaddress1} >+|.$retrieved_library->branchname.qq| >+|.$retrieved_library->branchaddress1.qq| > URL: http://thisisatest.com > > The following item(s) is/are currently $substitute->{status}: >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 29e59bb..ddd7f00 100644 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -24,6 +24,7 @@ use C4::Branch; > use C4::Budgets qw( AddBudgetPeriod AddBudget ); > > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Libraries; > > use DateTime::Duration; > use Test::More tests => 105; >@@ -62,7 +63,7 @@ $dbh->do(q|DELETE FROM message_queue|); > $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'CHECKED', 'my content')|); > > # Add CPL if missing. >-if (not defined GetBranchDetail('CPL')) { >+if (not defined Koha::Libraries->find('CPL')) { > ModBranch({add => 1, branchcode => 'CPL', branchname => 'Centerville'}); > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15629
:
46997
|
46998
|
46999
|
47000
|
47001
|
47002
|
47518
|
47519
|
47520
|
47521
|
47522
|
47523
|
47553
|
47701
|
47706
|
47707
|
47708
|
47709
|
47710
|
47711
|
47712
|
47713