From 0aabf1c4e69a3dd0c5986afcda8f252693af09e0 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Wed, 23 Jul 2025 15:04:39 +0000 Subject: [PATCH] Bug 27248: Add barcode list input to batch extend due dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a barcode list input to batch extend due dates Test plan: 1. Have some checkouts and copy the barcodes 2. Go to Tools > Batch extend due dates 3. Paste the barcodes in the new input one line at a time 4. Confirm you can extend the due dates for those items 5. Confirm the other limits still work For example if you enter a branchcode and a list of barcodes only items that were checked out from that branchcode and are on the list of items get an updated due date Signed-off-by: Anneli Österman --- .../modules/tools/batch_extend_due_dates.tt | 6 +++++ tools/batch_extend_due_dates.pl | 27 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt index 26787e4662..2ba3f7bfc0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt @@ -123,6 +123,12 @@ +
    +
  1. + + +
  2. +
New due date: diff --git a/tools/batch_extend_due_dates.pl b/tools/batch_extend_due_dates.pl index abc504288a..78a8034b44 100755 --- a/tools/batch_extend_due_dates.pl +++ b/tools/batch_extend_due_dates.pl @@ -22,11 +22,14 @@ use Modern::Perl; use CGI; -use C4::Auth qw( get_template_and_user ); -use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Circulation qw( barcodedecode ); +use C4::Context; use Koha::Checkouts; use Koha::DateUtils qw( dt_from_string ); use Koha::Items; +use List::MoreUtils qw( uniq ); my $input = CGI->new; my $op = $input->param('op') // q|form|; @@ -50,6 +53,7 @@ if ( $op eq 'form' ) { my @categorycodes = $input->multi_param('categorycodes'); my @itemtypecodes = $input->multi_param('itemtypecodes'); my @branchcodes = $input->multi_param('branchcodes'); + my $list = $input->param('barcodelist'); my $from_due_date = $input->param('from_due_date'); my $to_due_date = $input->param('to_due_date'); my $new_hard_due_date = $input->param('new_hard_due_date'); @@ -71,6 +75,25 @@ if ( $op eq 'form' ) { if (@branchcodes) { $search_params->{'me.branchcode'} = { -in => \@branchcodes }; } + if ($list) { + my $split_chars = C4::Context->preference('BarcodeSeparators'); + my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list ); + @barcodelist = uniq @barcodelist; + + @barcodelist = map { barcodedecode($_) } @barcodelist; + + # Note: adding lc for case insensitivity + my %itemdata = + map { lc( $_->{barcode} ) => $_->{itemnumber} } @{ Koha::Items->search( + { barcode => { -in => \@barcodelist } }, + { columns => [ 'itemnumber', 'barcode' ] } + )->unblessed + }; + my @itemnumbers = map { exists $itemdata{ lc $_ } ? $itemdata{ lc $_ } : () } @barcodelist; + my @notfoundbarcodes = grep { !exists $itemdata{ lc $_ } } @barcodelist; + + $search_params->{'itemnumber'} = { -in => \@itemnumbers }; + } if ( $from_due_date and $to_due_date ) { my $to_due_date_endday = dt_from_string($to_due_date); -- 2.39.5