From 6445c9f34d65cd673a563e6b2fb2c0ae97d09df7 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Mon, 9 Nov 2015 13:19:07 +0200 Subject: [PATCH] Bug 15157 - Cronjob to automatically debar Borrowers/Patrons with pending/unpaid fines/accountlines If your library wants to debar all Borrower who haven't paid their fines by the end of the year, this script will do that trick :) --- misc/debarrBorrowersWithFines.pl | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 misc/debarrBorrowersWithFines.pl diff --git a/misc/debarrBorrowersWithFines.pl b/misc/debarrBorrowersWithFines.pl new file mode 100755 index 0000000..f481a86 --- /dev/null +++ b/misc/debarrBorrowersWithFines.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +use Modern::Perl; +use Getopt::Long; + +use C4::Accounts; +use Koha::Borrower::Debarments; + +my ($help, $confirm, $message, $expiration); +GetOptions( + 'h|help' => \$help, + 'c|confirm:s' => \$confirm, + 'm|message:s' => \$message, + 'e|expiration:s' => \$expiration, +); + +my $HELP = < 20)) { + print $HELP; + print "\nYour --message is too short. A proper message to your end-users must be longer than 20 characters.\n"; + exit 1; +} + +my $badBorrowers = C4::Accounts::GetAllBorrowersWithUnpaidFines(); + +foreach my $bb (@$badBorrowers) { + #Don't crash, but keep debarring as long as you can! + eval { + my $success = Koha::Borrower::Debarments::AddDebarment({ + borrowernumber => $bb->{borrowernumber}, + expiration => $expiration, + type => 'MANUAL', + comment => $message, + }); + }; + if ($@) { + print $@."\n"; + } +} \ No newline at end of file -- 1.9.1