Bugzilla – Attachment 129701 Details for
Bug 15157
Cronjob to automatically restrict patrons with pending/unpaid charges
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15157: Cronjob to debar Patrons with unpaid accountlines
Bug-15157-Cronjob-to-debar-Patrons-with-unpaid-acc.patch (text/plain), 3.37 KB, created by
Martin Renvoize
on 2022-01-21 16:28:24 UTC
(
hide
)
Description:
Bug 15157: Cronjob to debar Patrons with unpaid accountlines
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2022-01-21 16:28:24 UTC
Size:
3.37 KB
patch
obsolete
>From 15330c6102c0f6d73680d0d74db38328342d5941 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Mon, 9 Nov 2015 13:19:07 +0200 >Subject: [PATCH] Bug 15157: Cronjob to debar Patrons with unpaid 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 :) > >You can give the message from a file if the cronjob runner >doesn't deal with quotes, or as a command-line parameter. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > misc/debarrBorrowersWithFines.pl | 90 ++++++++++++++++++++++++++++++++ > 1 file changed, 90 insertions(+) > create mode 100644 misc/debarrBorrowersWithFines.pl > >diff --git a/misc/debarrBorrowersWithFines.pl b/misc/debarrBorrowersWithFines.pl >new file mode 100644 >index 0000000000..5192bc06b7 >--- /dev/null >+++ b/misc/debarrBorrowersWithFines.pl >@@ -0,0 +1,90 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use Getopt::Long; >+ >+use C4::Accounts; >+use Koha::Borrower::Debarments; >+ >+my ($help, $confirm, $message, $expiration, $file); >+GetOptions( >+ 'h|help' => \$help, >+ 'c|confirm:s' => \$confirm, >+ 'm|message:s' => \$message, >+ 'f|file:s' => \$file, >+ 'e|expiration:s' => \$expiration, >+); >+ >+my $HELP = <<HELP; >+ >+debarrBorrowersWithFines.pl >+ >+Creates a debarment for all Borrowers who have fines. >+ >+ -h --help This friendly reminder! >+ >+ -c --confirm Confirm that you want to make your Patrons MAD by barring >+ them from your library because they have ANY unpaid fines. >+ >+ -m --message MANDATORY. The description of the debarment visible to the end-user. >+ or >+ -f --messagefile MANDATORY. The file from which to read the message content. >+ >+ -e --expiration OPTIONAL. When does the debarment expire? >+ As ISO8601 date, eg '2015-12-31' >+ >+ >+EXAMPLE: >+ >+ debarrBorrowersWithFines.pl --confirm -m "This is a description of you bad deeds" >+That did almost work. >+ >+ debarrBorrowersWithFines.pl -c MAD -m "You didn't play by our rules!" -e '2015-12-31' >+ debarrBorrowersWithFines.pl -c MAD -f "/home/koha/kohaclone/messagefile" >+This works. Always RTFM. >+ >+HELP >+ >+if ($help) { >+ print $HELP; >+ exit 0; >+} >+elsif (not($confirm) || $confirm ne 'MAD' || (not($message || $file) )) { >+ print $HELP; >+ exit 1; >+} >+elsif (not($file) && not(length($message) > 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(); >+$message = getMessageContent(); >+ >+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"; >+ } >+} >+ >+=head getMessageContent >+Gets either the textual message or slurps a file. >+=cut >+ >+sub getMessageContent { >+ return $message if ($message); >+ open(my $FH, "<:encoding(UTF-8)", $file) or die "$!\n"; >+ my @msg = <$FH>; >+ close $FH; >+ return join("",@msg); >+} >\ No newline at end of file >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15157
:
44643
|
44645
|
44646
|
109220
|
124894
|
124895
|
124896
|
129701
|
129702
|
129703
|
129704
|
130103
|
158288
|
158289
|
158290
|
158291
|
158292
|
158315
|
158316
|
158317
|
158318