Bugzilla – Attachment 9412 Details for
Bug 7684
inventory : datatable fix actions etc.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7684: multiple fixes for inventory
0001-Bug-7684-multiple-fixes-for-inventory.patch (text/plain), 11.24 KB, created by
Jonathan Druart
on 2012-05-04 10:20:02 UTC
(
hide
)
Description:
Bug 7684: multiple fixes for inventory
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2012-05-04 10:20:02 UTC
Size:
11.24 KB
patch
obsolete
>From 0eccfae941b78a1c6a6616296d98f3333e318648 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 4 May 2012 12:14:43 +0200 >Subject: [PATCH 1/1] 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 >--- > C4/Items.pm | 2 +- > .../prog/en/modules/tools/inventory.tt | 28 +++++-- > tools/inventory.pl | 94 ++++++++++++-------- > 3 files changed, 79 insertions(+), 45 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 52423a2..b128110 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -963,7 +963,7 @@ sub GetItemsForInventory { > my ( @bind_params, @where_strings ); > > my $query = <<'END_SQL'; >-SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen >+SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen, homebranch, location > FROM items > LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber > LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber >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 d8eb82f..e3fdae6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >@@ -127,7 +127,7 @@ $(document).ready(function(){ > <label for="[% value.id %]"> > [% value.lib %] > </label> >- <input type="checkbox" name="status-[% value.fieldname %]-[% value.id %]" id="[% value.id %]" /> >+ <input type="checkbox" name="status-[% value.fieldname %]-[% value.authorised_value %]" id="[% value.authorised_value %]" /> > </li>[% END %] > [% END %] > </ul> >@@ -196,7 +196,11 @@ $(document).ready(function(){ > <tr> > <th>Seen</th> > <th>Barcode</th> >+ <th>Location</th> > <th>Title</th> >+ <th>Status</th> >+ <th>Lost</th> >+ <th>Damaged</th> > <th>Unseen since</th> > <th>Problems</th> > </tr> >@@ -209,17 +213,29 @@ $(document).ready(function(){ > [% loo.barcode %] > </td> > <td> >- <p><b>[% loo.itemcallnumber %]</b> - <a href="#" onclick="window.open('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% loo.biblionumber %]','marcview','width=800,height=600,toolbar=0,scrollbars=1');">[% loo.title |html %]</a></p> >+ [% loo.homebranch %] [% loo.location %] [[% loo.itemcallnumber %]] >+ </td> >+ <td> >+ <p><a href="#" onclick="window.open('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% loo.biblionumber %]','marcview','width=800,height=600,toolbar=0,scrollbars=1');">[% loo.title |html %]</a></p> > <p>[% loo.author %]</p> > </td> > <td> >+ [% loo.notforloan %] >+ </td> >+ <td> >+ [% loo.itemlost %] >+ </td> >+ <td> >+ [% loo.damaged %] >+ </td> >+ <td> > <p>[% loo.datelastseen %]</p> > </td> > <td> >- [% IF ( loo.notfoundbarcode ) %] >- <p style="background: red;">Not found among barcodes in barcodes file.</p> >- [% ELSIF ( loo.notfoundkoha ) %] >- <p style="background: red;">Not found in Koha.</p> >+ [% IF ( loo.wrongplace ) %] >+ <p style="background: red;">Item should not have been scanned.</p> >+ [% ELSIF ( loo.missingitem ) %] >+ <p style="background: red;">Item missing.</p> > [% ELSE %] > <p style="background: green;">None</p> > [% END %] >diff --git a/tools/inventory.pl b/tools/inventory.pl >index 5e7b198..ba484f9 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -18,11 +18,12 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; >+use Modern::Perl; > > #need to open cgi and get the fh before anything else opens a new cgi context (see C4::Auth) > use CGI; >+use List::MoreUtils qw /none/; >+ > my $input = CGI->new; > my $uploadbarcodes = $input->param('uploadbarcodes'); > >@@ -104,12 +105,12 @@ for my $statfield (qw/items.notforloan items.itemlost items.wthdrawn items.damag > } > } > $template->param( statuses => $statuses ); >-my $staton = {}; #authorized values that are ticked >+my $staton = {}; #authorized values that are ticked > for my $authvfield (@$statuses) { > $staton->{$authvfield->{fieldname}} = []; > for my $authval (@{$authvfield->{values}}){ >- if ( defined $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{id}) && $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{id}) eq 'on' ){ >- push @{$staton->{$authvfield->{fieldname}}}, $authval->{id}; >+ if ( defined $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{authorised_value}) && $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{authorised_value}) eq 'on' ){ >+ push @{$staton->{$authvfield->{fieldname}}}, $authval->{authorised_value}; > } > } > } >@@ -179,40 +180,40 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){ > # $template->param(errorfile=>$errorfile) if ($errorfile); > $template->param(errorloop=>\@errorloop) if (@errorloop); > } >-#if we want to compare the results to a list of barcodes, or we have no barcode file >-if ( ! ($uploadbarcodes && length($uploadbarcodes)>0 ) || ( $input->param('compareinv2barcd') eq 'on' && length($uploadbarcodes)>0) ) { >- if ($markseen) { >- foreach ($input->param) { >- /SEEN-(.+)/ and &ModDateLastSeen($1); >- } >- } >- if ($markseen or $op) { >- $res = GetItemsForInventory( $minlocation, $maxlocation, $location, $itemtype, $ignoreissued, $datelastseen, $branchcode, $branch, $offset, $pagesize, $staton ); >- $template->param(loop =>$res, >- nextoffset => ($offset+$pagesize), >- prevoffset => ($offset?$offset-$pagesize:0), >- ); >+ >+# mark seen if applicable (ie: coming form mark seen checkboxes) >+if ($markseen) { >+ foreach ( $input->param ) { >+ /SEEN-(.+)/ and &ModDateLastSeen($1); > } >- if ( defined $input->param('compareinv2barcd') && ( ( $input->param('compareinv2barcd') eq 'on' ) && ( scalar @brcditems != scalar @$res ) ) && length($uploadbarcodes) > 0 ){ >- if ( scalar @brcditems > scalar @$res ){ >- for my $brcditem (@brcditems) { >- if (! grep( $_->{barcode} =~ /$brcditem->{barcode}/ , @$res) ){ >- $brcditem->{notfoundkoha} = 1; >- push @$res, $brcditem; >- } >- } >- } else { >- my @notfound; >- for my $item (@$res) { >- if ( ! grep( $_->{barcode} =~ /$item->{barcode}/ , @brcditems) ){ >- $item->{notfoundbarcode} = 1; >- push @notfound, $item; >- } >- } >- $res = [@$res, @notfound]; >- } >+} >+# now build the result list: inventoried items if requested, and mis-placed items -always- >+my $inventorylist; >+if ( $markseen or $op ) { >+ # retrieve all items in this range. >+ $inventorylist = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype, $ignoreissued, '', $branchcode, $branch, $offset, $pagesize, $staton); >+ # if comparison is requested, then display all the result (otherwise, we'll use the inventorylist to find missplaced items, later >+ $res = $inventorylist if $input->param('compareinv2barcd'); >+} >+# set "missing" flags for all items with a datelastseen before the choosen datelastseen >+foreach (@$res) {$_->{missingitem}=1 if C4::Dates->new($_->{datelastseen})->output('iso') lt C4::Dates->new($datelastseen)->output('iso')} >+# insert "wrongplace" to all scanned items that are not supposed to be in this range >+# note this list is always displayed, whatever the librarian has choosen for comparison >+foreach my $temp (@brcditems) { >+ next if $temp->{onloan}; # skip checked out items >+ if (none { defined $_->{barcode} and $temp->{barcode} eq $_->{barcode} and !$_->{onloan} } @$inventorylist) { >+ $temp->{wrongplace}=1; >+ my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber}); >+ $temp->{title} = $biblio->{title}; >+ $temp->{author} = $biblio->{author}; >+ push @$res, $temp; > } > } >+$template->param( >+ loop => $res, >+ nextoffset => ( $offset + $pagesize ), >+ prevoffset => ( $offset ? $offset - $pagesize : 0 ), >+); > > if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ > eval {use Text::CSV}; >@@ -222,11 +223,28 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ > -type => 'text/csv', > -attachment => 'inventory.csv', > ); >+ $csv->combine(qw / title author barcode itemnumber homebranch location itemcallnumber notforloan lost damaged /); >+ print $csv->string, "\n"; > for my $re (@$res){ > my @line; >- for my $key (keys %$re) { >- push @line, $re->{$key}; >+ for my $key ( qw / title author barcode itemnumber homebranch location itemcallnumber notforloan itemlost damaged / ) { >+ given ( $key ) { >+ when ( /notforloan/ ) { >+ push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'NOT_LOAN', ''); >+ } >+ when ( /itemlost/ ) { >+ push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'LOST', ''); >+ } >+ when ( /damaged/ ) { >+ push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'DAMAGED', ''); >+ } >+ default { >+ push @line, $re->{$key}; >+ } >+ } > } >+ push @line, "wrong place" if $re->{wrongplace}; >+ push @line, "missing item" if $re->{missingitem}; > $csv->combine(@line); > print $csv->string, "\n"; > } >-- >1.7.7.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7684
:
9412
|
10413
|
11793
|
11843
|
12387
|
13097
|
16212
|
16483
|
16484
|
16524
|
16541
|
16594
|
16598
|
17841
|
17844
|
18705
|
18706
|
19215
|
20467
|
20468
|
21112
|
21113
|
21206
|
21331
|
21332
|
21440
|
21441
|
21968
|
21970
|
21971
|
21972
|
22208
|
22209
|
22210