@@ -, +, @@ --- C4/Items.pm | 12 +++++++-- .../prog/en/modules/tools/inventory.tt | 29 ++++++++++++++++++++++ t/db_dependent/Items/GetItemsForInventory.t | 7 +++++- tools/inventory.pl | 12 ++++++++- 4 files changed, 56 insertions(+), 4 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -477,7 +477,6 @@ lists of authorized values for certain item fields. minlocation => $minlocation, maxlocation => $maxlocation, location => $location, - itemtype => $itemtype, ignoreissued => $ignoreissued, datelastseen => $datelastseen, branchcode => $branchcode, @@ -485,6 +484,7 @@ lists of authorized values for certain item fields. offset => $offset, size => $size, statushash => $statushash, + itemtypes => @itemsarray, } ); Retrieve a list of title/authors/barcode/callnumber, for biblio inventory. @@ -517,6 +517,7 @@ sub GetItemsForInventory { my $size = $parameters->{'size'} // ''; my $statushash = $parameters->{'statushash'} // ''; my $ignore_waiting_holds = $parameters->{'ignore_waiting_holds'} // ''; + my $items = $parameters->{'itemtypes'} // ''; my $dbh = C4::Context->dbh; my ( @bind_params, @where_strings ); @@ -576,7 +577,6 @@ sub GetItemsForInventory { push @where_strings, 'biblioitems.itemtype = ?'; push @bind_params, $itemtype; } - if ( $ignoreissued) { $query .= "LEFT JOIN issues ON items.itemnumber = issues.itemnumber "; push @where_strings, 'issues.date_due IS NULL'; @@ -587,6 +587,14 @@ sub GetItemsForInventory { push( @where_strings, q{(reserves.found != 'W' OR reserves.found IS NULL)} ); } + if ( $items and @{$items} > 0 ){ + my $joinedvals; + for my $itemtype (@{$items}){ + $joinedvals = join(',', @{$items}); + } + push @where_strings, "( biblioitems.itemtype IN (" . $joinedvals . ") OR items.itype IN (" . $joinedvals . ") )"; + } + if ( @where_strings ) { $query .= 'WHERE '; $query .= join ' AND ', @where_strings; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -157,7 +157,27 @@ +
  • + +
    +

    Select all | Clear all

    +
    + [% FOREACH itemtype IN itemtypes %] +
    + + +
    + [% IF loop.count() % 4 == 0 && !loop.last() %] +
    +
    + [% END %] + [% END %] +
    +
    +
  • + +
    @@ -432,6 +452,15 @@ $("fieldset#optionalfilters").hide(); } }); + + $("#checkallitemtypes").on("click",function(e){ + e.preventDefault(); + $(".branch_select").prop("checked",1); + }); + $("#checknoneitemtypes").on("click",function(e){ + e.preventDefault(); + $(".branch_select").prop("checked",0); + }); }); [% END %] --- a/t/db_dependent/Items/GetItemsForInventory.t +++ a/t/db_dependent/Items/GetItemsForInventory.t @@ -46,7 +46,7 @@ my $builder = t::lib::TestBuilder->new; subtest 'Skip items with waiting holds' => sub { - plan tests => 7; + plan tests => 8; $schema->storage->txn_begin; @@ -99,6 +99,11 @@ subtest 'Skip items with waiting holds' => sub { is( scalar @{$items_2}, $second_items_count, 'Results and count match' ); is( $first_items_count + 2, $second_items_count, 'Two items added, count makes sense' ); + my $real_itemtype_count = Koha::Items->search({ itype => $itemtype->itemtype })->count; + my $itype_str = "'" . $itemtype->itemtype . "'"; # manipulate string for db query + my ( $items_3, $itemtype_count ) = GetItemsForInventory({ itemtypes => [ $itype_str ] }); + is( $itemtype_count, $real_itemtype_count, 'Itemtype filter gets correct number of inventory items' ); + # Add 2 waiting holds C4::Reserves::AddReserve( { --- a/tools/inventory.pl +++ a/tools/inventory.pl @@ -126,6 +126,13 @@ for my $authvfield (@$statuses) { my @class_sources = Koha::ClassSources->search({ used => 1 }); my $pref_class = C4::Context->preference("DefaultClassificationSource"); +my @itemtypes = Koha::ItemTypes->search; +my @selected_itemtypes; +foreach my $itemtype ( @itemtypes ) { + if ( defined $input->param('itemtype-' . $itemtype->itemtype) ) { + push @selected_itemtypes, "'" . $itemtype->itemtype . "'"; + } +} $template->param( authorised_values => \@authorised_value_list, @@ -141,7 +148,8 @@ $template->param( uploadedbarcodesflag => ($uploadbarcodes || $barcodelist) ? 1 : 0, ignore_waiting_holds => $ignore_waiting_holds, class_sources => \@class_sources, - pref_class => $pref_class + pref_class => $pref_class, + itemtypes => \@itemtypes, ); # Walk through uploaded barcodes, report errors, mark as seen, check in @@ -251,6 +259,7 @@ if ( $op && ( !$uploadbarcodes || $compareinv2barcd )) { offset => 0, statushash => $staton, ignore_waiting_holds => $ignore_waiting_holds, + itemtypes => \@selected_itemtypes, }); } # Build rightplacelist used to check if a scanned item is in the right place. @@ -267,6 +276,7 @@ if( @scanned_items ) { offset => 0, statushash => undef, ignore_waiting_holds => $ignore_waiting_holds, + itemtypes => \@selected_itemtypes, }); # Convert the structure to a hash on barcode $rightplacelist = { --