From fc858796b5a8e0392807695ae353d1b3aa8d5dc7 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 24 Apr 2025 15:04:04 +0100 Subject: [PATCH] Bug 39711: Update call to ModContract and improve error handling --- admin/aqcontract.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index c2d830a7c05..5009a022cf3 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -27,7 +27,6 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Contract qw( DelContract - ModContract ); use Koha::DateUtils qw( dt_from_string ); @@ -103,16 +102,22 @@ elsif ( $op eq 'cud-add_validate' ) { } if ($is_a_modif) { - ModContract( + my $contractnumber = $input->param('contractnumber'); + my $contract = Koha::Acquisition::Contracts->find($contractnumber); + if ( !$contract ) { + $template->param( blocking_error => "Contract $contractnumber not found" ); + output_html_with_http_headers $input, $cookie, $template->output; + } + + $contract->set( { contractstartdate => $contractstart_dt, contractenddate => $contractend_dt, contractname => scalar $input->param('contractname'), contractdescription => scalar $input->param('contractdescription'), booksellerid => scalar $input->param('booksellerid'), - contractnumber => scalar $input->param('contractnumber'), } - ); + )->store; } else { my $contract = Koha::Acquisition::Contract->new( { @@ -124,7 +129,6 @@ elsif ( $op eq 'cud-add_validate' ) { } )->store; } - print $input->redirect("/cgi-bin/koha/acquisition/vendors/$booksellerid"); exit; -- 2.48.1