@@ -, +, @@ with pending/unpaid fines/accountlines --- misc/debarrBorrowersWithFines.pl | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 misc/debarrBorrowersWithFines.pl --- a/misc/debarrBorrowersWithFines.pl +++ a/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"; + } +} --