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

(-)a/C4/ILSDI/Services.pm (-2 / +1 lines)
Lines 376-383 sub GetPatronInfo { Link Here
376
376
377
    # Cleaning the borrower hashref
377
    # Cleaning the borrower hashref
378
    my $borrower = $patron->unblessed;
378
    my $borrower = $patron->unblessed;
379
    my $flags = C4::Members::patronflags( $borrower );
379
    $borrower->{charges} = sprintf "%.02f", $patron->account->non_issues_charges; # FIXME Formatting should not be done here
380
    $borrower->{'charges'} = $flags->{'CHARGES'}->{'amount'};
381
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
380
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
382
    $borrower->{'branchname'} = $library ? $library->branchname : '';
381
    $borrower->{'branchname'} = $library ? $library->branchname : '';
383
    delete $borrower->{'userid'};
382
    delete $borrower->{'userid'};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE Price %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Delete patron [% firstname %] [% surname %]</title>
3
<title>Koha &rsaquo; Delete patron [% firstname %] [% surname %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 21-27 Link Here
21
                <li>Patron has [% ItemsOnIssues %] item(s) checked out.</li>
22
                <li>Patron has [% ItemsOnIssues %] item(s) checked out.</li>
22
            [% END %]
23
            [% END %]
23
            [% IF ( charges ) %]
24
            [% IF ( charges ) %]
24
                <li>Patron has [% charges %] in fines.</li>
25
                <li>Patron has [% charges | $Prices %] in fines.</li>
25
            [% END %]
26
            [% END %]
26
            [% IF ( guarantees ) %]
27
            [% IF ( guarantees ) %]
27
                <li>Patron's record has guaranteed accounts attached.</li>
28
                <li>Patron's record has guaranteed accounts attached.</li>
(-)a/members/deletemem.pl (-5 / +5 lines)
Lines 79-85 unless ( $patron ) { Link Here
79
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member");
79
    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$member");
80
    exit;
80
    exit;
81
}
81
}
82
my $flags = C4::Members::patronflags( $patron->unblessed );
82
my $charges = $patron->account->non_issues_charges;
83
my $userenv = C4::Context->userenv;
83
my $userenv = C4::Context->userenv;
84
84
85
 
85
 
Lines 109-115 if (C4::Context->preference("IndependentBranches")) { Link Here
109
my $op = $input->param('op') || 'delete_confirm';
109
my $op = $input->param('op') || 'delete_confirm';
110
my $dbh = C4::Context->dbh;
110
my $dbh = C4::Context->dbh;
111
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
111
my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
112
if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'}  or $is_guarantor or $deletelocal == 0) {
112
if ( $op eq 'delete_confirm' or $countissues > 0 or $charges  or $is_guarantor or $deletelocal == 0) {
113
    $template->param( picture => 1 ) if $patron->image;
113
    $template->param( picture => 1 ) if $patron->image;
114
114
115
    $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
115
    $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
Lines 136-143 if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_ Link Here
136
    if ($countissues >0) {
136
    if ($countissues >0) {
137
        $template->param(ItemsOnIssues => $countissues);
137
        $template->param(ItemsOnIssues => $countissues);
138
    }
138
    }
139
    if ($flags->{'CHARGES'} ne '') {
139
    if ( $charges > 0 ) {
140
        $template->param(charges => $flags->{'CHARGES'}->{'amount'});
140
        $template->param(charges => $charges);
141
    }
141
    }
142
    if ($is_guarantor) {
142
    if ($is_guarantor) {
143
        $template->param(guarantees => 1);
143
        $template->param(guarantees => 1);
Lines 146-152 if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'} or $is_ Link Here
146
        $template->param(keeplocal => 1);
146
        $template->param(keeplocal => 1);
147
    }
147
    }
148
    # This is silly written but reflect the same conditions as above
148
    # This is silly written but reflect the same conditions as above
149
    if ( not $countissues > 0 and not $flags->{CHARGES} ne '' and not $is_guarantor and not $deletelocal == 0 ) {
149
    if ( not $countissues > 0 and not $charges and not $is_guarantor and not $deletelocal == 0 ) {
150
        $template->param(
150
        $template->param(
151
            op         => 'delete_confirm',
151
            op         => 'delete_confirm',
152
            csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
152
            csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
(-)a/members/member-flags.pl (-1 lines)
Lines 103-109 if ($input->param('newflags')) { Link Here
103
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
103
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
104
} else {
104
} else {
105
105
106
    my $flags = C4::Members::patronflags( $bor );
107
    my $accessflags;
106
    my $accessflags;
108
    my $dbh = C4::Context->dbh();
107
    my $dbh = C4::Context->dbh();
109
    # FIXME This needs to be improved to avoid doing the same query
108
    # FIXME This needs to be improved to avoid doing the same query
(-)a/misc/cronjobs/delete_patrons.pl (-3 / +6 lines)
Lines 66-79 for my $member (@$members) { Link Here
66
      if $verbose;
66
      if $verbose;
67
67
68
    my $borrowernumber = $member->{borrowernumber};
68
    my $borrowernumber = $member->{borrowernumber};
69
    my $flags = C4::Members::patronflags( $member );
69
    my $patron = Koha::Patrons->find( $borrowernumber );
70
    if ( my $charges = $flags->{CHARGES}{amount} ) {
70
    unless ( $patron ) {
71
        say "Patron with borrowernumber $borrowernumber does not exist";
72
        next;
73
    }
74
    if ( my $charges = $patron->account->non_issues_charges ) { # And what if we owe to this patron?
71
        say "Failed to delete patron $borrowernumber: patron has $charges in fines";
75
        say "Failed to delete patron $borrowernumber: patron has $charges in fines";
72
        next;
76
        next;
73
    }
77
    }
74
78
75
    if ( $confirm ) {
79
    if ( $confirm ) {
76
        my $patron = Koha::Patrons->find( $borrowernumber );
77
        my $deleted = eval { $patron->move_to_deleted; };
80
        my $deleted = eval { $patron->move_to_deleted; };
78
        if ($@ or not $deleted) {
81
        if ($@ or not $deleted) {
79
            say "Failed to delete patron $borrowernumber, cannot move it" . ( $@ ? ": ($@)" : "" );
82
            say "Failed to delete patron $borrowernumber, cannot move it" . ( $@ ? ": ($@)" : "" );
(-)a/t/db_dependent/Circulation/dateexpiry.t (-4 lines)
Lines 55-61 sub can_book_be_issued { Link Here
55
            }
55
            }
56
        }
56
        }
57
    );
57
    );
58
    $patron->{flags} = C4::Members::patronflags( $patron );
59
    my $duration = gettimeofday();
58
    my $duration = gettimeofday();
60
    my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
59
    my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
61
    $duration = gettimeofday() - $duration;
60
    $duration = gettimeofday() - $duration;
Lines 71-77 sub can_book_be_issued { Link Here
71
            }
70
            }
72
        }
71
        }
73
    );
72
    );
74
    $patron->{flags} = C4::Members::patronflags( $patron );
75
    ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
73
    ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
76
    is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' );
74
    is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' );
77
75
Lines 85-91 sub can_book_be_issued { Link Here
85
            },
83
            },
86
        }
84
        }
87
    );
85
    );
88
    $patron->{flags} = C4::Members::patronflags( $patron );
89
    ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
86
    ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} );
90
    is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' );
87
    is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' );
91
88
92
- 

Return to bug 19933