[Koha] Exclude users from search (check out)

Paul Hoffman paul at flo.org
Wed Sep 26 02:11:40 NZST 2018


On Tue, Sep 25, 2018 at 06:48:41PM +0700, zefanja wrote:
> we use Koha in our school and therefor many students get enrolled each
> year, but also many students leave the school every year. Every year we
> have more and more users, that are not at school anymore, but they still
> exist in Koha. If we want to checkout books and search for the right
> user we have many similar names over the years, sometimes the same
> firstname and lastname.
> 
> Is it possible to deactivate users so they are excluded from the search
> result (checkout)? I don't want to delete them because we will loose the
> circulation data.

I think you'd have to modify the source code, but if you want to go down 
that path then look for the call to 
C4::Utils::DataTables::Members::search in the file 
intranet/cgi-bin/circ/circulation.pl (lines 242-248 in our install).  
Immediately after the following line, which sets the variable 
$borrowers, add some code that discards elements in @$borrowers (i.e., 
that discards patrons) with an expiration date (too far) in the past.  
Something like this (totally untested!):

    my $borrowers = $results->{patrons};
    # ------------------------ Add these lines ------------------------
    use POSIX qw(strftime);
    # Omit if expired more than 30 days ago (not taking possible
    # daylight saving time transitions into account!)
    my $cutoff = strftime('%Y-%m-%d', localtime(time - 30*86400));
    #                     ^^^^^^^^^^ Or maybe '%Y%m%d'?
    @$borrowers = grep { $_->{dateexpiry} gt $cutoff } @$borrowers;
    # -----------------------------------------------------------------

However, what circulation data exactly do you want to preserve -- data 
on fines that you're still hoping will be paid?  I assume when purging 
patron you can skip anyone with outstanding fees, so you'd get rid of 
the vast majority(?) of old, crufty patrons but leave the ones you care 
about.

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