From a93d256c29182b61c739d482349641a09b57e533 Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Mon, 29 Sep 2025 16:43:05 +0000 Subject: [PATCH] Bug 7132: Acq: Check for duplicates when ordering from empty record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test using a new empty record: 1. Ensure you have a vendor and a new basket available for ordering. Click on “+Add to basket” and select “From a new (empty) record” 2. Choose an existing record to test with for example “CSS : the definitive guide” (http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=12&searchid=scs_1759160315801) 3. Copy over the main details from the existing record in order to fill out the required details of the new order. I.e Title, and Koha item type. Click add item and then select a fund. It’s not necessary to fill anything else out. 4. Click save and notice that the duplicate record is not found. 5. Apply the patch and restart_all. Clear cache in your browser if necessary. 6. Repeat steps 2 - 4. This time a duplicate warning will appear. Ensure that all options of the duplicate warning work as expected. 7. Sign off and have a great day! --- acqui/addorder.pl | 38 +++++++++++++++ .../modules/acqui/neworderempty_duplicate.tt | 48 +++++++++++++------ 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index d8aa9e781f..9d04c06564 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -128,6 +128,7 @@ use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalcu use C4::Items qw( AddItemFromMarc ); use C4::Log qw( logaction ); use C4::Output qw( output_html_with_http_headers ); +use C4::Search qw( FindDuplicate ); use C4::Suggestions qw( ModSuggestion ); use Koha::Acquisition::Baskets; use Koha::Acquisition::Currencies qw( get_active ); @@ -147,6 +148,8 @@ my $op = $input->param('op') // q{}; if ( $op eq 'cud-order' ) { my $use_ACQ_framework = $input->param('use_ACQ_framework'); + my $confirm_not_duplicate = $input->param('confirm_not_duplicate') || 0; + # Check if order total amount exceed allowed budget my $confirm_budget_exceeding = $input->param('confirm_budget_exceeding'); unless ($confirm_budget_exceeding) { @@ -328,6 +331,41 @@ if ( $op eq 'cud-order' ) { } C4::Acquisition::FillWithDefaultValues($record); + if ( !$confirm_not_duplicate ) { + my ( $dupe_biblionumber, $dupe_title ) = FindDuplicate($record); + + if ($dupe_biblionumber) { + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/neworderempty_duplicate.tt", + query => $input, + type => "intranet", + flagsrequired => { acquisition => 'order_manage' }, + } + ); + + my $vars = $input->Vars; + my @vars_loop; + foreach ( keys %$vars ) { + push @vars_loop, { name => $_, values => [ $input->multi_param($_) ] }; + } + + my $booksellerid = $input->param('booksellerid') // ''; + my $basketno = $input->param('basketno') // ''; + + $template->param( + biblionumber => $dupe_biblionumber, + duplicatetitle => $dupe_title, + booksellerid => $booksellerid, + basketno => $basketno, + vars_loop => \@vars_loop, + ); + + output_html_with_http_headers $input, $cookie, $template->output; + exit; + } + } + # create the record in catalogue, with framework '' my ( $biblionumber, $bibitemnum ) = AddBiblio( $record, '' ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tt index 78cb23489d..744a921957 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tt @@ -33,10 +33,12 @@ [% WRAPPER 'main-container.inc' aside='acquisitions-menu' %]

Duplicate warning

-

You selected a record from an external source that matches an existing record in your catalog: - [% duplicatetitle | html %]

+ [% IF breedingid %] +

You selected a record from an external source that matches an existing record in your catalog:

+ [% ELSE %] +

The details you entered match an existing record in your catalog:

+ [% END %] + [% duplicatetitle | html %]
@@ -66,16 +68,34 @@
-
- [% INCLUDE 'csrf-token.inc' %] -

Create new record

-

Create a new record by importing the external (duplicate) record.

- - - - - -
+ [% IF breedingid %] +
+ [% INCLUDE 'csrf-token.inc' %] +

Create new record

+

Create a new record by importing the external (duplicate) record.

+ + + + + +
+ [% ELSE %] +
+ [% INCLUDE 'csrf-token.inc' %] +

Create new record

+

Create a new record with the details you entered.

+ + + [% FOREACH var IN vars_loop %] + [% FOREACH val IN var.values %] + [% IF var.name != 'confirm_not_duplicate' %] + + [% END %] + [% END %] + [% END %] + +
+ [% END %]
-- 2.39.5