From 2e7ed6d39a7cc78f96cfa64adae52f421fe2e1d8 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Thu, 21 Jun 2012 17:20:53 +0200 Subject: [PATCH] [FOLLOW-UP] Bug 7684: multiple fixes for inventory - Adds not found barcodes list into csv report --- tools/inventory.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/inventory.pl b/tools/inventory.pl index ba484f9..0c2e92c 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -139,6 +139,7 @@ $template->param(branchloop => \@branch_loop, datelastseen => $datelastseen, ); my @brcditems; +my @errorloop; if ($uploadbarcodes && length($uploadbarcodes)>0){ my $dbh=C4::Context->dbh; my $date = format_date_in_iso($input->param('setdate')) || C4::Dates->today('iso'); @@ -147,7 +148,6 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){ my $qonloan = $dbh->prepare($strsth); $strsth="select * from items where items.barcode =? and items.wthdrawn = 1"; my $qwthdrawn = $dbh->prepare($strsth); - my @errorloop; my $count=0; while (my $barcode=<$uploadbarcodes>){ $barcode =~ s/\r?\n$//; @@ -225,9 +225,10 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ ); $csv->combine(qw / title author barcode itemnumber homebranch location itemcallnumber notforloan lost damaged /); print $csv->string, "\n"; + my @keys = qw / title author barcode itemnumber homebranch location itemcallnumber notforloan lost damaged /; for my $re (@$res){ my @line; - for my $key ( qw / title author barcode itemnumber homebranch location itemcallnumber notforloan itemlost damaged / ) { + for my $key (@keys) { given ( $key ) { when ( /notforloan/ ) { push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'NOT_LOAN', ''); @@ -248,6 +249,17 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ $csv->combine(@line); print $csv->string, "\n"; } + # Adding not found barcodes + foreach my $error (@errorloop) { + my @line; + if ($error->{'ERR_BARCODE'}) { + push @line, map { $_ eq 'barcode' ? $error->{'barcode'} : ''} @keys; + push @line, "barcode not found"; + $csv->combine(@line); + print $csv->string, "\n"; + } + } + exit; } -- 1.7.9.5