@@ -, +, @@
modification
---
.../prog/en/modules/tools/modborrowers.tt | 8 ++++----
tools/modborrowers.pl | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
@@ -149,8 +149,8 @@
Expiry date |
Circulation note |
Opac Note |
- Debarred till |
- Debarred comment |
+ Restriction expiration |
+ Restriction comment |
[% FOREACH attrh IN attributes_header %]
[% attrh.attribute | html %] |
[% END %]
@@ -234,9 +234,9 @@
[% CASE 'opacnote' %]
OPAC note:
[% CASE 'debarred' %]
- Debarred till:
+ Restriction expiration:
[% CASE 'debarredcomment' %]
- Debarred comment:
+ Restriction comment:
[% END %]
[% IF ( field.type == 'text' ) %]
--- a/tools/modborrowers.pl
+++ a/tools/modborrowers.pl
@@ -38,6 +38,7 @@ use Koha::DateUtils qw( dt_from_string );
use Koha::List::Patron;
use Koha::Libraries;
use Koha::Patron::Categories;
+use Koha::Patron::Debarments;
use Koha::Patrons;
my $input = new CGI;
@@ -306,6 +307,27 @@ if ( $op eq 'do' ) {
for my $borrowernumber ( @borrowernumbers ) {
# If at least one field are filled, we want to modify the borrower
if ( defined $infos ) {
+ # If a debarred date or debarred comment has been submitted make a new debarment
+ if ( $infos->{debarred} || $infos->{debarredcomment} ) {
+ AddDebarment(
+ {
+ borrowernumber => $borrowernumber,
+ type => 'MANUAL',
+ comment => $infos->{debarredcomment},
+ expiration => $infos->{debarred},
+ });
+ }
+
+ # If debarment date or debarment comment are disabled then remove all debarrments
+ if ( grep { /debarred/ } @disabled ) {
+ eval {
+ my $debarrments = GetDebarments( { borrowernumber => $borrowernumber } );
+ foreach my $debarment (@$debarrments) {
+ DelDebarment( $debarment->{'borrower_debarment_id'} );
+ }
+ };
+ }
+
$infos->{borrowernumber} = $borrowernumber;
eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
if ( $@ ) { # FIXME We could provide better error handling here
--