From bf75ddacbe2deaafa7e56f54e1e85a2cc4353370 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 23 Sep 2021 15:51:06 +0100 Subject: [PATCH] Bug 29099: Add bundle support to inventory tool --- C4/Items.pm | 6 ++++++ .../prog/en/modules/tools/inventory.tt | 20 ++++++++++++++++++- tools/inventory.pl | 13 ++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/C4/Items.pm b/C4/Items.pm index c0375939d63..54dc0bb9e72 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -583,6 +583,7 @@ sub GetItemsForInventory { my $minlocation = $parameters->{'minlocation'} // ''; my $maxlocation = $parameters->{'maxlocation'} // ''; my $class_source = $parameters->{'class_source'} // C4::Context->preference('DefaultClassificationSource'); + my $items_bundle = $parameters->{'items_bundle'} // ''; my $location = $parameters->{'location'} // ''; my $itemtype = $parameters->{'itemtype'} // ''; my $ignoreissued = $parameters->{'ignoreissued'} // ''; @@ -636,6 +637,11 @@ sub GetItemsForInventory { push @bind_params, $max_cnsort; } + if ($items_bundle) { + push @where_strings, 'items.itemnumber IN (SELECT itemnumber FROM items_bundle_item WHERE items_bundle_id = ?)'; + push @bind_params, $items_bundle; + } + if ($datelastseen) { push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)'; push @bind_params, $datelastseen; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 081435fba55..b7203b08469 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -181,6 +181,17 @@ [% END %] + [% IF items_bundles.size > 0 %] +
  • + + +
  • + [% END %] @@ -420,7 +431,8 @@ $('#locationloop').val() || $('#minlocation').val() || $('#maxlocation').val() || - $('#statuses input:checked').length + $('#statuses input:checked').length || + $('#items_bundle').val() ) ) { return confirm( _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" + @@ -561,6 +573,12 @@ }); }); + [% INCLUDE 'select2.inc' %] + [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/tools/inventory.pl b/tools/inventory.pl index 8e735d40e44..a0128b23aa3 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -49,6 +49,7 @@ my $minlocation = $input->param('minlocation') || ''; my $maxlocation = $input->param('maxlocation'); my $class_source = $input->param('class_source'); $maxlocation = $minlocation . 'Z' unless ( $maxlocation || !$minlocation ); +my $items_bundle = $input->param('items_bundle'); my $location = $input->param('location') || ''; my $ignoreissued = $input->param('ignoreissued'); my $ignore_waiting_holds = $input->param('ignore_waiting_holds'); @@ -70,6 +71,15 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +my $schema = Koha::Database->new()->schema(); +my $items_bundle_rs = $schema->resultset('ItemsBundle'); +my @items_bundles = $items_bundle_rs->search( + undef, + { + order_by => { -asc => ['biblionumber.title'] }, + join => ['biblionumber'], + } +); my @authorised_value_list; my $authorisedvalue_categories = ''; @@ -166,6 +176,7 @@ foreach my $itemtype (@itemtypes) { $template->param( authorised_values => \@authorised_value_list, + items_bundles => \@items_bundles, today => dt_from_string, minlocation => $minlocation, maxlocation => $maxlocation, @@ -291,6 +302,7 @@ if ( $op eq 'cud-inventory' && ( !$uploadbarcodes || $compareinv2barcd ) ) { minlocation => $minlocation, maxlocation => $maxlocation, class_source => $class_source, + items_bundle => $items_bundle, location => $location, ignoreissued => $ignoreissued, datelastseen => $datelastseen, @@ -315,6 +327,7 @@ if (@scanned_items) { maxlocation => $maxlocation, class_source => $class_source, location => $location, + items_bundle => $items_bundle, ignoreissued => undef, datelastseen => undef, branchcode => $branchcode, -- 2.48.1