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

(-)a/Koha/Patron.pm (-1 / +45 lines)
Lines 1910-1915 sub queue_notice { Link Here
1910
    return \%return;
1910
    return \%return;
1911
}
1911
}
1912
1912
1913
=head3 safe_to_delete
1914
1915
    my $result = $patron->safe_to_delete;
1916
    if ( $result eq 'has_guarantees' ) { ... }
1917
    elsif ( $result ) { ... }
1918
    else { # cannot delete }
1919
1920
This method tells if the Koha:Patron object can be deleted. Possible return values
1921
1922
=over 4
1923
1924
=item 'ok'
1925
1926
=item 'has_checkouts'
1927
1928
=item 'has_debt'
1929
1930
=item 'has_guarantees'
1931
1932
=item 'is_anonymous_patron'
1933
1934
=back
1935
1936
=cut
1937
1938
sub safe_to_delete {
1939
    my ($self) = @_;
1940
1941
    my $anonymous_patron = C4::Context->preference('AnonymousPatron');
1942
1943
    return 'is_anonymous_patron'
1944
        if $anonymous_patron && $self->id eq $anonymous_patron;
1945
1946
    return 'has_checkouts'
1947
        if $self->checkouts->count;
1948
1949
    return 'has_debt'
1950
        if $self->account->outstanding_debits->total_outstanding > 0;
1951
1952
    return 'has_guarantees'
1953
        if $self->guarantee_relationships->count;
1954
1955
    return 'ok';
1956
}
1957
1913
=head2 Internal methods
1958
=head2 Internal methods
1914
1959
1915
=head3 _type
1960
=head3 _type
1916
- 

Return to bug 29741