From f650b1c24be7480dde7b24c2d2df24ca2c7d474b Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Thu, 23 Aug 2012 16:02:52 +0200 Subject: [PATCH] Bug 7684: multiple fixes for inventory * when a file was uploaded and the comparison with catalogue range requested, the comparison was wrong: the logic was wrong * items that were not supposed to be scanned (ie: supposed to be on another shelf) didn't had the author and title, it was hard to retrieve them on the shelved * some useful fields were missing, like homebranch, location, status * the CSV export contained all the item information. It should contain the same informations as the screen Behaviour now: * scan a list of barcode & select a range of location * if a barcode has been scanned and should not be (mis placed item), the information is displayed * if you choose "compare barcodes list to result option", the resulting list contains all items that have been scanned and those that were supposed to be. Any item not in both list appears with a specific message on the last column Signed-off-by: Leila --- C4/Items.pm | 41 ++- C4/Templates.pm | 2 +- koha-tmpl/intranet-tmpl/prog/en/columns.def | 1 + .../prog/en/modules/tools/inventory.tt | 186 ++++++++------ tools/ajax-inventory.pl | 43 ++++ tools/inventory.pl | 271 ++++++++++++++------ 6 files changed, 374 insertions(+), 170 deletions(-) create mode 100755 tools/ajax-inventory.pl diff --git a/C4/Items.pm b/C4/Items.pm index 89b092b..3a052db 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -970,9 +970,11 @@ sub GetLostItems { =head2 GetItemsForInventory - $itemlist = GetItemsForInventory($minlocation, $maxlocation, - $location, $itemtype $datelastseen, $branch, - $offset, $size, $statushash); +=over 4 + +($itemlist, $iTotalRecords) = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype, $ignoreissued, $datelastseen, $branchcode, $offset, $size, $statushash); + +=back Retrieve a list of title/authors/barcode/callnumber, for biblio inventory. @@ -985,6 +987,8 @@ the datelastseen can be used to specify that you want to see items not seen sinc offset & size can be used to retrieve only a part of the whole listing (defaut behaviour) $statushash requires a hashref that has the authorized values fieldname (intems.notforloan, etc...) as keys, and an arrayref of statuscodes we are searching for as values. +$iTotalRecords is the number of rows that would have been returned without the $offset, $size limit clause + =cut sub GetItemsForInventory { @@ -993,7 +997,7 @@ sub GetItemsForInventory { my ( @bind_params, @where_strings ); my $query = <<'END_SQL'; -SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen +SELECT SQL_CALC_FOUND_ROWS items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, biblio.frameworkcode, datelastseen, homebranch, location, notforloan, damaged, itemlost, stocknumber FROM items LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber @@ -1052,20 +1056,33 @@ END_SQL $query .= join ' AND ', @where_strings; } $query .= ' ORDER BY items.cn_sort, itemcallnumber, title'; + $query .= " LIMIT $offset, $size" if ($offset and $size); my $sth = $dbh->prepare($query); $sth->execute( @bind_params ); my @results; - $size--; - while ( my $row = $sth->fetchrow_hashref ) { - $offset-- if ($offset); - $row->{datelastseen}=format_date($row->{datelastseen}); - if ( ( !$offset ) && $size ) { - push @results, $row; - $size--; + my $tmpresults = $sth->fetchall_arrayref({}); + $sth = $dbh->prepare("SELECT FOUND_ROWS()"); + $sth->execute(); + my ($iTotalRecords) = $sth->fetchrow_array(); + + foreach my $row (@$tmpresults) { + $row->{datelastseen} = format_date( $row->{datelastseen} ); + + # Auth values + foreach (keys %$row) { + # If the koha field is mapped to a marc field + my ($f, $sf) = GetMarcFromKohaField("items.$_", $row->{'frameworkcode'}); + if ($f and $sf) { + # We replace the code with it's description + my $authvals = C4::Koha::GetKohaAuthorisedValuesFromField($f, $sf, $row->{'frameworkcode'}); + $row->{$_} = $authvals->{$row->{$_}} if defined $authvals->{$row->{$_}}; + } } + push @results, $row; } - return \@results; + + return (\@results, $iTotalRecords); } =head2 GetItemsCount diff --git a/C4/Templates.pm b/C4/Templates.pm index 7f50143..26cef26 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -288,7 +288,7 @@ sub getlanguage { my $lang; # cookie - if ( $query->cookie('KohaOpacLanguage') ) { + if ($query and $query->cookie('KohaOpacLanguage') ) { $lang = $query->cookie('KohaOpacLanguage'); $lang =~ s/[^a-zA-Z_-]*//; # sanitize cookie } diff --git a/koha-tmpl/intranet-tmpl/prog/en/columns.def b/koha-tmpl/intranet-tmpl/prog/en/columns.def index 726ecc6..e487e80 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/columns.def +++ b/koha-tmpl/intranet-tmpl/prog/en/columns.def @@ -138,3 +138,4 @@ biblioitems.place Place of publication biblioitems.lccn LCCN biblioitems.marcxml MARC blob biblioitems.url URL +biblioitems.title Title 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 424928f..156db88 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -1,11 +1,53 @@ [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Inventory [% INCLUDE 'doc-head-close.inc' %] + + + [% INCLUDE 'calendar.inc' %]