[Koha] Batch checkin in 18.05 koha

Paul Hoffman paul at flo.org
Thu Nov 1 05:50:41 NZDT 2018


On Wed, Oct 31, 2018 at 08:27:08PM +0500, Arshad Iqbal wrote:
> This feature can be added in koha coming version..
> On Oct 31, 2018 4:58 PM, "Owen Leonard" <oleonard at myacpl.org> wrote:
> >
> > > Without offline plugin not possible
> >
> > Koha has no built-in tool for batch checkins like there is for batch
> checkouts.
> >
> > There is an open bug report for this feature, but as far as I know no
> > one is working on it:
> >
> > https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19814

If you're feeling adventurous, you might try doing this from the command line
using a simple script; something like this (totally untested!):

# -----------------------------------------------------------------------
#!/usr/bin/perl

use strict;
use warnings;

use C4::Context;
use C4::Circulation;

while (<STDIN>) {
    chomp;
    s/\r$//;
    my $result = ProcessOfflineReturn({ 'barcode' => $_ });
    if ($result =~ /success/i) {
        print STDERR "OK $_\n";
    }
    else {
        print STDERR "ERR $_ $result\n";
    }
}
# -----------------------------------------------------------------------

Save it as /foo/bar/checkin.pl (just for the sake of example), make it
executable (chmod a+x /foo/bar/checkin.pl) and invoke it like this:

koha-shell -c /foo/bar/checkin.pl < /foo/my/file.txt

Where /foo/my/file.txt is just a bunch of item barcodes, one per line.

The ProcessOfflineReturn() function takes care of everything for you -- look up
the item given its barcode, find the patron who checked it out, mark it
returned, etc.  It's defined in the file /usr/share/koha/lib/C4/Circulation.pm
around line 3726 if you want to see exactly what it does.  (I find the Koha
source code remarkably easy to read and generally have no trouble figuring out
how to use it from a Perl script, though it helps that I've been programming in
Perl for a long, long time.)

Paul.

-- 
Paul Hoffman <paul at flo.org>
Software Services Manager
Fenway Library Organization
550 Huntington Ave.
Boston, MA 02115
(617) 442-2384


More information about the Koha mailing list