@@ -, +, @@ requested, the comparison was wrong: the logic was wrong didn't had the author and title, it was hard to retrieve them on the shelved informations as the screen * 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 --- 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 --- a/C4/Items.pm +++ a/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 --- a/C4/Templates.pm +++ a/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 } --- a/koha-tmpl/intranet-tmpl/prog/en/columns.def +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ a/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' %]