View | Details | Raw Unified | Return to bug 35641
Collapse All | Expand All

(-)a/tools/inventory.pl (-29 / +24 lines)
Lines 167-177 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
167
    my $date = $input->param('setdate');
167
    my $date = $input->param('setdate');
168
    my $date_dt = dt_from_string($date);
168
    my $date_dt = dt_from_string($date);
169
169
170
    my $strsth  = "select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?";
171
    my $qonloan = $dbh->prepare($strsth);
172
    $strsth="select * from items where items.barcode =? and items.withdrawn = 1";
173
    my $qwithdrawn = $dbh->prepare($strsth);
174
175
    my @barcodes;
170
    my @barcodes;
176
    my @uploadedbarcodes;
171
    my @uploadedbarcodes;
177
172
Lines 218-250 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
218
        $template->param( err_length => $err_length,
213
        $template->param( err_length => $err_length,
219
                          err_data   => $err_data );
214
                          err_data   => $err_data );
220
    }
215
    }
216
    my @items = Koha::Items->search( { barcode => { -in => \@barcodes } } )->as_list;
217
    my %items = map { $_->barcode => $_ } @items;
221
    foreach my $barcode (@barcodes) {
218
    foreach my $barcode (@barcodes) {
222
        if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) {
219
        my $item = $items{ $barcode };
223
            push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 };
220
        if ( $item ) {
224
        } else {
221
            if ( $item->withdrawn ) {
225
            my $item = Koha::Items->find({barcode => $barcode});
222
                push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 };
226
            if ( $item ) {
223
                next;
227
                # Modify date last seen for scanned items, remove lost status
224
            }
228
                $item->set({ itemlost => 0, datelastseen => $date_dt })->store;
225
            # Modify date last seen for scanned items, remove lost status
229
                my $item_unblessed = $item->unblessed;
226
            $item->set({ itemlost => 0, datelastseen => $date_dt })->store;
230
                $moddatecount++;
227
            my $item_unblessed = $item->unblessed;
231
                unless ( $dont_checkin ) {
228
            $moddatecount++;
232
                    $qonloan->execute($barcode);
229
            unless ( $dont_checkin ) {
233
                    if ($qonloan->rows){
230
                if ( $item->onloan ){
234
                        my $data = $qonloan->fetchrow_hashref;
231
                    #FIXME Is this correct? Shouldn't the item be checked in at the branch we are signed in at?
235
                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
232
                    my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $item->homebranch);
236
                        if( $doreturn ) {
233
                    if( $doreturn ) {
237
                            $item_unblessed->{onloan} = undef;
234
                        $item_unblessed->{onloan} = undef;
238
                            $item_unblessed->{datelastseen} = dt_from_string;
235
                        $item_unblessed->{datelastseen} = dt_from_string;
239
                        } else {
236
                    } else {
240
                            push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
237
                        push @errorloop, { barcode => $barcode, ERR_ONLOAN_NOT_RET => 1 };
241
                        }
242
                    }
238
                    }
243
                }
239
                }
244
                push @scanned_items, $item_unblessed;
245
            } else {
246
                push @errorloop, { barcode => $barcode, ERR_BARCODE => 1 };
247
            }
240
            }
241
            push @scanned_items, $item_unblessed;
242
        } else {
243
            push @errorloop, { barcode => $barcode, ERR_BARCODE => 1 };
248
        }
244
        }
249
    }
245
    }
250
    $template->param( date => $date );
246
    $template->param( date => $date );
251
- 

Return to bug 35641