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

(-)a/Koha/Patron/Debarments.pm (-9 / +14 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use C4::Context;
22
use C4::Context;
23
use C4::Log qw( logaction );
23
use C4::Log qw( logaction );
24
24
25
use Koha::Database;
25
use Koha::Patron::Restriction::Types;
26
use Koha::Patron::Restriction::Types;
26
use Koha::Patron::Restrictions;
27
use Koha::Patron::Restrictions;
27
28
Lines 102-121 Deletes a debarment. Link Here
102
=cut
103
=cut
103
104
104
sub DelDebarment {
105
sub DelDebarment {
105
    my ($id) = @_;
106
    my ($borrower_debarment_id) = @_;
106
107
    my $borrowernumber = _GetBorrowernumberByDebarmentId($id);
108
107
109
    my $sql = "DELETE FROM borrower_debarments WHERE borrower_debarment_id = ?";
108
    my $restriction = Koha::Patron::Restrictions->find($borrower_debarment_id);
110
109
111
    my $r = C4::Context->dbh->do( $sql, {}, ($id) );
110
    return unless $restriction;
112
111
113
    UpdateBorrowerDebarmentFlags($borrowernumber);
112
    Koha::Database->new->schema->txn_do(
113
        sub {
114
            my $borrowernumber = $restriction->borrowernumber;
115
            logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, $restriction )
116
                if C4::Context->preference("BorrowersLog");
114
117
115
    logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, q{} )
118
            $restriction->delete;
116
        if C4::Context->preference("BorrowersLog");
119
            UpdateBorrowerDebarmentFlags($borrowernumber);
120
        }
121
    );
117
122
118
    return $r;
123
    return 1;
119
}
124
}
120
125
121
=head2 ModDebarment
126
=head2 ModDebarment
(-)a/t/db_dependent/Patron/Borrower_Debarments.t (-3 / +2 lines)
Lines 405-412 subtest 'BorrowersLog tests' => sub { Link Here
405
    is( $mod_logs->count, 1, 'Restriction modification logged' );
405
    is( $mod_logs->count, 1, 'Restriction modification logged' );
406
    like( $mod_logs->next->info, qr/$mod_comment/ );
406
    like( $mod_logs->next->info, qr/$mod_comment/ );
407
407
408
    is( $del_logs->count,      1,   'Restriction deletion logged' );
408
    is( $del_logs->count, 1, 'Restriction deletion logged' );
409
    is( $del_logs->next->info, q{}, 'Empty info field on deletion' );
409
    like( $del_logs->next->info, qr/$mod_comment/, 'Deleted restriction contains last known comment' );
410
410
411
    $schema->storage->txn_rollback;
411
    $schema->storage->txn_rollback;
412
};
412
};
413
- 

Return to bug 25996