View | Details | Raw Unified | Return to bug 31095
Collapse All | Expand All

(-)a/tools/modborrowers.pl (-6 / +6 lines)
Lines 35-41 use Koha::DateUtils qw( dt_from_string ); Link Here
35
use Koha::List::Patron qw( GetPatronLists );
35
use Koha::List::Patron qw( GetPatronLists );
36
use Koha::Libraries;
36
use Koha::Libraries;
37
use Koha::Patron::Categories;
37
use Koha::Patron::Categories;
38
use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments );
38
use Koha::Patron::Debarments qw( AddDebarment DelDebarment );
39
use Koha::Patrons;
39
use Koha::Patrons;
40
use List::MoreUtils qw(uniq);
40
use List::MoreUtils qw(uniq);
41
41
Lines 364-369 if ( $op eq 'do' ) { Link Here
364
    my @borrowernumbers = $input->multi_param('borrowernumber');
364
    my @borrowernumbers = $input->multi_param('borrowernumber');
365
    # For each borrower selected
365
    # For each borrower selected
366
    for my $borrowernumber ( @borrowernumbers ) {
366
    for my $borrowernumber ( @borrowernumbers ) {
367
367
        # If at least one field are filled, we want to modify the borrower
368
        # If at least one field are filled, we want to modify the borrower
368
        if ( defined $infos ) {
369
        if ( defined $infos ) {
369
            # If a debarred date or debarred comment has been submitted make a new debarment
370
            # If a debarred date or debarred comment has been submitted make a new debarment
Lines 378-396 if ( $op eq 'do' ) { Link Here
378
            }
379
            }
379
380
380
            # If debarment date or debarment comment are disabled then remove all debarrments
381
            # If debarment date or debarment comment are disabled then remove all debarrments
382
            my $patron = Koha::Patrons->find( $borrowernumber );
381
            if ( grep { /debarred/ } @disabled ) {
383
            if ( grep { /debarred/ } @disabled ) {
382
                eval {
384
                eval {
383
                   my $debarrments = GetDebarments( { borrowernumber => $borrowernumber } );
385
                   my $debarrments = $patron->restrictions;
384
                   foreach my $debarment (@$debarrments) {
386
                   foreach my $debarment (@$debarrments) {
385
                      DelDebarment( $debarment->{'borrower_debarment_id'} );
387
                      DelDebarment( $debarment->borrower_debarment_id );
386
                   }
388
                   }
387
                };
389
                };
388
            }
390
            }
389
391
390
            $infos->{borrowernumber} = $borrowernumber;
392
            $infos->{borrowernumber} = $borrowernumber;
391
            eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; };
393
            eval { $patron->set($infos)->store; };
392
            if ( $@ ) { # FIXME We could provide better error handling here
394
            if ( $@ ) { # FIXME We could provide better error handling here
393
                my $patron = Koha::Patrons->find( $borrowernumber );
394
                $infos->{cardnumber} = $patron ? $patron->cardnumber || '' : '';
395
                $infos->{cardnumber} = $patron ? $patron->cardnumber || '' : '';
395
                push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
396
                push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
396
            }
397
            }
397
- 

Return to bug 31095