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

(-)a/Koha/Account.pm (-11 / +8 lines)
Lines 758-773 and, if the syspref is set, renew them Link Here
758
sub _maybe_renew {
758
sub _maybe_renew {
759
    my ($items, $patron_id) = @_;
759
    my ($items, $patron_id) = @_;
760
760
761
    my $results = {
761
    my @results = ();
762
        ok     => [],
763
        not_ok => []
764
    };
765
762
766
    if (
763
    if (
767
        C4::Context->preference('RenewAccruingItemWhenPaid') &&
764
        C4::Context->preference('RenewAccruingItemWhenPaid') &&
768
        keys %{$items}
765
        keys %{$items}
769
    ) {
766
    ) {
770
771
        foreach my $itemnumber (keys %{$items}) {
767
        foreach my $itemnumber (keys %{$items}) {
772
            # Only do something if this item has no fines left on it
768
            # Only do something if this item has no fines left on it
773
            my $fine = C4::Overdues::GetFine( $itemnumber, $patron_id );
769
            my $fine = C4::Overdues::GetFine( $itemnumber, $patron_id );
Lines 784-803 sub _maybe_renew { Link Here
784
                    undef,
780
                    undef,
785
                    1
781
                    1
786
                );
782
                );
787
                push @{$results->{ok}}, {
783
                push @results, {
788
                    itemnumber => $itemnumber,
784
                    itemnumber => $itemnumber,
789
                    due_date   => $due_date
785
                    due_date   => $due_date,
786
                    success    => 1
790
                };
787
                };
791
            } else {
788
            } else {
792
                push @{$results->{not_ok}}, {
789
                push @results, {
793
                    itemnumber => $itemnumber,
790
                    itemnumber => $itemnumber,
794
                    error   => $error
791
                    error      => $error,
792
                    success    => 0
795
                };
793
                };
796
            }
794
            }
797
        }
795
        }
798
        return $results;
799
    }
796
    }
800
    return $results;
797
    return \@results;
801
}
798
}
802
799
803
1;
800
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/renew_results.inc (+12 lines)
Line 0 Link Here
1
[% IF renew_results && renew_results.size > 0 %]
2
    <div class="alert">
3
		The fines on the following items were paid off, renewal results are displayed below:
4
		[% FOREACH result IN renew_results %]
5
			[% IF result.success %]
6
				<p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Renewed - due [% result.info | html %]</p>
7
			[% ELSE %]
8
				<p>[% INCLUDE 'biblio-title.inc' biblio=result.item.biblio %] ( [% result.item.barcode | html %] ): Not renewed - [% INCLUDE 'renew_strings.inc' error=result.info %]</p>
9
			[% END %]
10
		[% END %]
11
    </div>
12
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-9 / +2 lines)
Lines 38-52 Link Here
38
    <li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a></li>
38
    <li><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a></li>
39
    <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
39
    <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
40
</ul>
40
</ul>
41
<div class="tabs-container">
41
<div class="tabs-container"> 
42
[% IF renew_errors.size > 0 %]
42
[% INCLUDE 'renew_results.inc' renew_results=renew_results %]
43
    <div class="alert">
44
        The fines on the following items were paid off, but the items could not be renewed:
45
        [% FOREACH problem IN renew_errors %]
46
            <p>[% INCLUDE 'biblio-title.inc' biblio=problem.item.biblio %] ( [% problem.item.barcode | html %] ): [% INCLUDE 'renew_error_strings.inc' error=problem.error %]</p>
47
        [% END %]
48
    </div>
49
[% END %]
50
<!-- The table with the account items -->
43
<!-- The table with the account items -->
51
<table id="table_account_fines">
44
<table id="table_account_fines">
52
    <thead>
45
    <thead>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt (-8 / +1 lines)
Lines 40-53 Link Here
40
    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
40
    <form action="/cgi-bin/koha/members/pay.pl" method="post" id="pay-fines-form">
41
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
41
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
42
<p><span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></span></p>
42
<p><span class="checkall"><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a></span> | <span class="clearall"><a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></span></p>
43
[% IF renew_errors.size > 0 %]
43
[% INCLUDE 'renew_results.inc' renew_results=renew_results %]
44
    <div class="alert">
45
        The fines on the following items were paid off, but the items could not be renewed:
46
        [% FOREACH problem IN renew_errors %]
47
            <p>[% INCLUDE 'biblio-title.inc' biblio=problem.item.biblio %] ( [% problem.item.barcode | html %] ): [% INCLUDE 'renew_error_strings.inc' error=problem.error %]</p>
48
        [% END %]
49
    </div>
50
[% END %]
51
<table id="finest">
44
<table id="finest">
52
<thead>
45
<thead>
53
<tr>
46
<tr>
(-)a/members/boraccount.pl (-6 / +14 lines)
Lines 23-28 Link Here
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
# along with Koha; if not, see <http://www.gnu.org/licenses>.
24
24
25
use Modern::Perl;
25
use Modern::Perl;
26
use URI::Escape;
26
27
27
use C4::Auth;
28
use C4::Auth;
28
use C4::Output;
29
use C4::Output;
Lines 52-58 my $borrowernumber = $input->param('borrowernumber'); Link Here
52
my $payment_id     = $input->param('payment_id');
53
my $payment_id     = $input->param('payment_id');
53
my $change_given   = $input->param('change_given');
54
my $change_given   = $input->param('change_given');
54
my $action         = $input->param('action') || '';
55
my $action         = $input->param('action') || '';
55
my @renew_errors   = $input->param('renew_error');
56
my @renew_results  = $input->param('renew_result');
56
57
57
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
58
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
58
my $patron = Koha::Patrons->find( $borrowernumber );
59
my $patron = Koha::Patrons->find( $borrowernumber );
Lines 84-94 if($total <= 0){ Link Here
84
85
85
# Populate an arrayref with everything we need to display any
86
# Populate an arrayref with everything we need to display any
86
# renew errors that occurred based on what we were passed
87
# renew errors that occurred based on what we were passed
87
my $renew_errors_display = [];
88
my $renew_results_display = [];
88
foreach my $renew_error(@renew_errors) {
89
foreach my $renew_result(@renew_results) {
89
    my ($itemnumber, $error) = split(/,/, $renew_error);
90
    my ($itemnumber, $success, $info) = split(/,/, $renew_result);
90
    my $item = Koha::Items->find($itemnumber);
91
    my $item = Koha::Items->find($itemnumber);
91
    push @{$renew_errors_display}, { item => $item, error => $error };
92
    if ($success) {
93
        $info = uri_unescape($info);
94
    }
95
    push @{$renew_results_display}, {
96
        item    => $item,
97
        success => $success,
98
        info    => $info
99
    };
92
}
100
}
93
101
94
$template->param(
102
$template->param(
Lines 99-105 $template->param( Link Here
99
    accounts            => \@accountlines,
107
    accounts            => \@accountlines,
100
    payment_id          => $payment_id,
108
    payment_id          => $payment_id,
101
    change_given        => $change_given,
109
    change_given        => $change_given,
102
    renew_errors        => $renew_errors_display,
110
    renew_results       => $renew_results_display,
103
);
111
);
104
112
105
output_html_with_http_headers $input, $cookie, $template->output;
113
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/pay.pl (-7 / +14 lines)
Lines 66-72 if ( !$borrowernumber ) { Link Here
66
66
67
my $payment_id = $input->param('payment_id');
67
my $payment_id = $input->param('payment_id');
68
our $change_given = $input->param('change_given');
68
our $change_given = $input->param('change_given');
69
our @renew_errors = $input->param('renew_error');
69
our @renew_results = $input->param('renew_result');
70
70
71
# get borrower details
71
# get borrower details
72
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
72
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
Lines 138-156 for (@names) { Link Here
138
}
138
}
139
139
140
# Populate an arrayref with everything we need to display any
140
# Populate an arrayref with everything we need to display any
141
# renew errors that occurred based on what we were passed
141
# renew results that occurred based on what we were passed
142
my $renew_errors_display = [];
142
my $renew_results_display = [];
143
foreach my $renew_error(@renew_errors) {
143
foreach my $renew_result(@renew_results) {
144
    my ($itemnumber, $error) = split(/,/, $renew_error);
144
    my ($itemnumber, $success, $info) = split(/,/, $renew_result);
145
    my $item = Koha::Items->find($itemnumber);
145
    my $item = Koha::Items->find($itemnumber);
146
    push @{$renew_errors_display}, { item => $item, error => $error };
146
    if ($success) {
147
        $info = uri_unescape($info);
148
    }
149
    push @{$renew_results_display}, {
150
        item => $item,
151
        success => $success,
152
        info => $info
153
    };
147
}
154
}
148
155
149
$template->param(
156
$template->param(
150
    finesview  => 1,
157
    finesview  => 1,
151
    payment_id => $payment_id,
158
    payment_id => $payment_id,
152
    change_given => $change_given,
159
    change_given => $change_given,
153
    renew_errors => $renew_errors_display
160
    renew_results => $renew_results_display
154
);
161
);
155
162
156
add_accounts_to_template();
163
add_accounts_to_template();
(-)a/members/paycollect.pl (-20 / +24 lines)
Lines 34-39 use Koha::Patron::Categories; Link Here
34
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
35
use Koha::Account;
35
use Koha::Account;
36
use Koha::Token;
36
use Koha::Token;
37
use Koha::DateUtils;
37
38
38
my $input = CGI->new();
39
my $input = CGI->new();
39
40
Lines 150-158 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
150
                token  => scalar $input->param('csrf_token'),
151
                token  => scalar $input->param('csrf_token'),
151
            });
152
            });
152
153
154
        my $url;
155
        my $pay_result;
153
        if ($pay_individual) {
156
        if ($pay_individual) {
154
            my $line = Koha::Account::Lines->find($accountlines_id);
157
            my $line = Koha::Account::Lines->find($accountlines_id);
155
            my $pay_result = $account->pay(
158
            $pay_result = $account->pay(
156
                {
159
                {
157
                    lines        => [$line],
160
                    lines        => [$line],
158
                    amount       => $total_paid,
161
                    amount       => $total_paid,
Lines 164-180 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
164
                }
167
                }
165
            );
168
            );
166
            $payment_id = $pay_result->{payment_id};
169
            $payment_id = $pay_result->{payment_id};
167
            # It's possible renewals took place, parse any renew results
170
168
            # and pass errors on
171
            $url = "/cgi-bin/koha/members/pay.pl";
169
            my @renew_errors = map { "renew_error=$_->{itemnumber},$_->{error}" }
170
                @{$pay_result->{renew_result}->{not_ok}};
171
            my $renew_result = $pay_result->{renew_result};
172
            my $append = scalar @renew_errors ? '&' . join('&', @renew_errors) : '';
173
174
            print $input->redirect(
175
                "/cgi-bin/koha/members/pay.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=${change_given}${append}");
176
        } else {
172
        } else {
177
            my $pay_result;
178
            if ($select) {
173
            if ($select) {
179
                if ( $select =~ /^([\d,]*).*/ ) {
174
                if ( $select =~ /^([\d,]*).*/ ) {
180
                    $select = $1;    # ensure passing no junk
175
                    $select = $1;    # ensure passing no junk
Lines 220-234 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
220
                );
215
                );
221
            }
216
            }
222
            $payment_id = $pay_result->{payment_id};
217
            $payment_id = $pay_result->{payment_id};
223
            # It's possible renewals took place, parse any renew results
218
224
            # and pass errors on
219
            $url = "/cgi-bin/koha/members/boraccount.pl";
225
            my @renew_errors = map { "renew_error=$_->{itemnumber},$_->{error}" }
220
        }
226
                @{$pay_result->{renew_result}->{not_ok}};
221
        # It's possible renewals took place, parse any renew results
227
            my $renew_result = $pay_result->{renew_result};
222
        # and pass on
228
            my $append = scalar @renew_errors ? '&' . join('&', @renew_errors) : '';
223
        my @renew_result = ();
229
224
        foreach my $ren( @{$pay_result->{renew_result}} ) {
230
            print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=${change_given}${append}");
225
            my $str = "renew_result=$ren->{itemnumber},$ren->{success},";
226
            my $app = $ren->{success} ?
227
                uri_escape(
228
                    output_pref({ dt => $ren->{due_date}, as_due_date => 1 })
229
                ) : $ren->{error};
230
                push @renew_result, "${str}${app}";
231
        }
231
        }
232
        my $append = scalar @renew_result ? '&' . join('&', @renew_result) : '';
233
234
        $url .= "?borrowernumber=$borrowernumber&payment_id=$payment_id&change_given=${change_given}${append}";
235
236
        print $input->redirect($url);
232
    }
237
    }
233
} else {
238
} else {
234
    $total_paid = '0.00';    #TODO not right with pay_individual
239
    $total_paid = '0.00';    #TODO not right with pay_individual
235
- 

Return to bug 23051