From 51d513d13029d6958b3907d0f6433ce4e92b4db3 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 24 Apr 2025 14:11:46 +0100 Subject: [PATCH] Bug 39711: Update all calls to GetContracts --- Koha/Acquisition/Bookseller.pm | 12 ++++-------- acqui/basketheader.pl | 28 ++++++++-------------------- admin/aqcontract.pl | 3 +-- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm index 3745e506739..84b459a96ce 100644 --- a/Koha/Acquisition/Bookseller.pm +++ b/Koha/Acquisition/Bookseller.pm @@ -21,10 +21,9 @@ use Koha::Acquisition::Bookseller::Aliases; use Koha::Acquisition::Bookseller::Contacts; use Koha::Acquisition::Bookseller::Interfaces; use Koha::Acquisition::Bookseller::Issues; +use Koha::Acquisition::Contracts; use Koha::Subscriptions; -use C4::Contract qw( GetContracts ); - use base qw( Koha::Object ); =head1 NAME @@ -86,7 +85,7 @@ sub contacts { =head3 contracts my $vendor = Koha::Acquisition::Booksellers->find( $id ); - my @contracts = $vendor->contracts(); + my $contracts = $vendor->contracts(); Returns the list of contracts for the vendor @@ -94,11 +93,8 @@ Returns the list of contracts for the vendor sub contracts { my ($self) = @_; - return GetContracts( - { - booksellerid => $self->id, - } - ); + my $contracts_rs = $self->_result->aqcontracts; + return Koha::Acquisition::Contracts->_new_from_dbic($contracts_rs); } =head3 subscriptions diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index 4ab854258d4..5a36b88b82f 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -51,10 +51,11 @@ use C4::Context; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); -use C4::Contract qw( GetContracts GetContract ); +use C4::Contract qw( GetContract ); use Koha::Acquisition::Booksellers; use Koha::Acquisition::Baskets; +use Koha::Acquisition::Contracts; use Koha::AdditionalFields; my $input = CGI->new; @@ -77,7 +78,12 @@ my $is_an_edit = $input->param('is_an_edit'); $template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) ); if ( $op eq 'add_form' ) { + my @contracts = Koha::Acquisition::Contracts->search( + { booksellerid => $booksellerid, contractenddate => { '>=' => \'now()' } } )->as_list; my @contractloop; + foreach my $contract (@contracts) { + push( @contractloop, $contract->unblessed ); + } if ($basketno) { #this is an edit @@ -85,33 +91,15 @@ if ( $op eq 'add_form' ) { if ( !$booksellerid ) { $booksellerid = $basket->{'booksellerid'}; } - my $contracts = GetContracts( - { - booksellerid => $booksellerid, - activeonly => 1, - } - ); - @contractloop = @$contracts; for (@contractloop) { if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) { - $_->{'selected'} = 1; + $_->{selected} = 1; } } $template->param( is_an_edit => 1 ); $template->param( additional_field_values => Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template ); - } else { - - #new basket - my $basket; - my $contracts = GetContracts( - { - booksellerid => $booksellerid, - activeonly => 1, - } - ); - push( @contractloop, @$contracts ); } my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); my $count = scalar @contractloop; diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 00f1ea45a04..53f7bd45316 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -29,7 +29,6 @@ use C4::Contract qw( AddContract DelContract GetContract - GetContracts ModContract ); use Koha::DateUtils qw( dt_from_string ); @@ -169,7 +168,7 @@ if ( $op eq 'list' ) { $template->param( else => 1 ); # get contracts - my @contracts = @{ GetContracts( { booksellerid => $booksellerid } ) }; + my @contracts = Koha::Acquisition::Contracts->search( { booksellerid => $booksellerid } )->as_list; $template->param( loop => \@contracts ); -- 2.48.1