From 621b1c3b7f18ff8de84dbafc5aeecb6167abffd0 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 17 Jun 2015 14:50:14 +1000 Subject: [PATCH] Bug 14393: Add collection code filter to inventory This patch adds the ability to do inventory by collection. _TEST PLAN_ Before applying: 1) Go to "Tools > Inventory/stocktaking" 2) Note that there is no "Collection code:" option Optionally: 2b) You can create a Barcode file with a single barcode 2c) Don't select anything from "Select items you want to check" (or filter if you know how to filter to make it faster... doesn't matter) 2d) Click "Submit" at the bottom of the screen 2e) Note that there is no "Collection code" column in the screen output or CSV output (ie with/without the "Export to CSV file" box ticked before submitting) Apply the patch. After applying: 3) Note that there is a "Collection code" filter on the main inventory screen 4) Create a Barcode file with a single barcode for an item with a collection and upload it using the "Choose file" button. 5) Select that item's collection code from the "Collection code" filter 6) Click "Submit" 7) Note that the screen output and the CSV output contains a "Collection code" column (ie with/without the "Export to CSV file" box ticked before submitting) Signed-off-by: kelly mcelligott Signed-off-by: Fridolin Somers --- C4/Items.pm | 9 +++++++- .../prog/en/modules/tools/inventory.tt | 22 +++++++++++++++++++ tools/inventory.pl | 13 +++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 4d25a6ad49..a7f06dd876 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -536,6 +536,7 @@ sub GetItemsForInventory { my $statushash = $parameters->{'statushash'} // ''; my $ignore_waiting_holds = $parameters->{'ignore_waiting_holds'} // ''; my $itemtypes = $parameters->{'itemtypes'} || []; + my $ccode = $parameters->{'ccode'} // ''; my $dbh = C4::Context->dbh; my ( @bind_params, @where_strings ); @@ -544,7 +545,8 @@ sub GetItemsForInventory { my $max_cnsort = GetClassSort($class_source,undef,$maxlocation); my $select_columns = q{ - SELECT DISTINCT(items.itemnumber), barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, withdrawn, stocknumber, items.cn_sort + SELECT DISTINCT(items.itemnumber), barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, withdrawn, stocknumber, items.cn_sort, ccode + }; my $select_count = q{SELECT COUNT(DISTINCT(items.itemnumber))}; my $query = q{ @@ -561,6 +563,11 @@ sub GetItemsForInventory { } } + if ($ccode){ + push @where_strings, 'ccode = ?'; + push @bind_params, $ccode; + } + if ($minlocation) { push @where_strings, 'items.cn_sort >= ?'; push @bind_params, $min_cnsort; 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 782907355a..f68adcf372 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -1,5 +1,6 @@ [% USE raw %] [% USE Asset %] +[% USE AuthorisedValues %] [% USE KohaDates %] [% USE Branches %] [% SET footerjs = 1 %] @@ -116,6 +117,22 @@ [% END %] [% END %] + [% SET ccodes = AuthorisedValues.GetAuthValueDropbox('CCODE') %] + [% IF ( ccodes.count > 0 ) %] +
  • + + +
  • + [% END %]
  • (items.itemcallnumber)
  • @@ -229,6 +246,7 @@ + [% UNLESS uploadedbarcodesflag %]
    Select all Clear all
    @@ -241,6 +259,7 @@ Barcode Call number Library + Collection code Title Not for loan Lost @@ -268,6 +287,9 @@ [% Branches.GetName( result.homebranch ) | html %] [% result.location | html %] + + [% result.ccode | html %] + [% result.title | html %] [% IF ( result.author ) %] diff --git a/tools/inventory.pl b/tools/inventory.pl index 3400c70d11..5be7d7fd67 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -58,6 +58,7 @@ my $op = $input->param('op'); my $compareinv2barcd = $input->param('compareinv2barcd'); my $dont_checkin = $input->param('dont_checkin'); my $out_of_order = $input->param('out_of_order'); +my $ccode = $input->param('ccode'); my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "tools/inventory.tt", @@ -73,6 +74,9 @@ my $authorisedvalue_categories = ''; my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] })->unblessed; unshift @$frameworks, { frameworkcode => '' }; +my @collections = (); +my @collection_codes = (); + for my $fwk ( @$frameworks ){ my $fwkcode = $fwk->{frameworkcode}; my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); @@ -149,6 +153,7 @@ $template->param( class_sources => \@class_sources, pref_class => $pref_class, itemtypes => \@itemtypes, + ccode => $ccode, ); # Walk through uploaded barcodes, report errors, mark as seen, check in @@ -260,12 +265,14 @@ if ( $op && ( !$uploadbarcodes || $compareinv2barcd )) { branch => $branch, offset => 0, statushash => $staton, + ccode => $ccode, ignore_waiting_holds => $ignore_waiting_holds, itemtypes => \@selected_itemtypes, }); } # Build rightplacelist used to check if a scanned item is in the right place. if( @scanned_items ) { + # For the items that may be marked as "wrong place", we only check the location (callnumbers, location, ccode and branch) ( $rightplacelist ) = GetItemsForInventory({ minlocation => $minlocation, maxlocation => $maxlocation, @@ -279,11 +286,13 @@ if( @scanned_items ) { statushash => undef, ignore_waiting_holds => $ignore_waiting_holds, itemtypes => \@selected_itemtypes, + ccode => $ccode, }); # Convert the structure to a hash on barcode $rightplacelist = { map { $_->{barcode} ? ( $_->{barcode}, $_ ) : (); } @$rightplacelist }; + } # Report scanned items that are on the wrong place, or have a wrong notforloan @@ -394,7 +403,7 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ my @translated_keys; for my $key (qw / biblioitems.title biblio.author items.barcode items.itemnumber - items.homebranch items.location + items.homebranch items.location items.ccode items.itemcallnumber items.notforloan items.itemlost items.damaged items.withdrawn items.stocknumber @@ -406,7 +415,7 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ $csv->combine(@translated_keys); print $csv->string, "\n"; - my @keys = qw/ title author barcode itemnumber homebranch location itemcallnumber notforloan itemlost damaged withdrawn stocknumber /; + my @keys = qw/ title author barcode itemnumber homebranch location ccode itemcallnumber notforloan itemlost damaged withdrawn stocknumber /; for my $item ( @$loop ) { my @line; for my $key (@keys) { -- 2.39.5