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

(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 311-317 if ($patron) { Link Here
311
    $template->param(
311
    $template->param(
312
        overduecount => $overdues->count,
312
        overduecount => $overdues->count,
313
        issuecount   => $issues->count,
313
        issuecount   => $issues->count,
314
        finetotal    => $balance,
314
        fines    => $balance,
315
    );
315
    );
316
316
317
    if ( $patron and $patron->is_debarred ) {
317
    if ( $patron and $patron->is_debarred ) {
(-)a/circ/renew.pl (-2 / +18 lines)
Lines 28-33 use C4::Koha; Link Here
28
use Koha::DateUtils;
28
use Koha::DateUtils;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::BiblioFrameworks;
30
use Koha::BiblioFrameworks;
31
use Koha::Patrons;
31
32
32
my $cgi = new CGI;
33
my $cgi = new CGI;
33
34
Lines 48-57 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae Link Here
48
$barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
49
$barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
49
my $override_limit = $cgi->param('override_limit');
50
my $override_limit = $cgi->param('override_limit');
50
my $override_holds = $cgi->param('override_holds');
51
my $override_holds = $cgi->param('override_holds');
52
my $override_debt = $cgi->param('override_debt');
51
53
52
my ( $item, $issue, $borrower );
54
my ( $item, $issue, $borrower );
53
my $error = q{};
55
my $error = q{};
54
my ( $soonest_renew_date, $latest_auto_renew_date );
56
my ( $soonest_renew_date, $latest_auto_renew_date, $balance );
55
57
56
if ($barcode) {
58
if ($barcode) {
57
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
59
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
Lines 64-70 if ($barcode) { Link Here
64
        if ($issue) {
66
        if ($issue) {
65
67
66
            $borrower = $issue->borrower();
68
            $borrower = $issue->borrower();
67
            
69
            my $patron = Koha::Patrons->find($borrower->borrowernumber);
70
            $balance = $patron->account->balance;
71
            my $amountlimit = C4::Context->preference("noissuescharge");
72
68
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
73
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
69
                my $can_renew;
74
                my $can_renew;
70
                ( $can_renew, $error ) =
75
                ( $can_renew, $error ) =
Lines 93-98 if ($barcode) { Link Here
93
                        $item->itemnumber(),
98
                        $item->itemnumber(),
94
                    );
99
                    );
95
                }
100
                }
101
102
                if ( $balance > $amountlimit ) {
103
                    $error = "too_much_debt";
104
                    $can_renew = 0;
105
                    if($override_debt){
106
                        $can_renew = 1;
107
                        $error = undef;
108
                    }
109
                }
110
96
                if ($can_renew) {
111
                if ($can_renew) {
97
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
112
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
98
                    my $date_due;
113
                    my $date_due;
Lines 122-127 if ($barcode) { Link Here
122
        error    => $error,
137
        error    => $error,
123
        soonestrenewdate => $soonest_renew_date,
138
        soonestrenewdate => $soonest_renew_date,
124
        latestautorenewdate => $latest_auto_renew_date,
139
        latestautorenewdate => $latest_auto_renew_date,
140
        balance => $balance,
125
    );
141
    );
126
}
142
}
127
143
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 1068-1073 Link Here
1068
1068
1069
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1069
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1070
1070
1071
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
1072
        var fines = "[% fines %]";
1073
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
1074
1071
        // On-site checkout
1075
        // On-site checkout
1072
        function toggle_onsite_checkout(){
1076
        function toggle_onsite_checkout(){
1073
            if ( $("#onsite_checkout").prop('checked') ) {
1077
            if ( $("#onsite_checkout").prop('checked') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (+10 lines)
Lines 2-7 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% USE Price %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
8
Lines 135-142 Link Here
135
                                <p>Item is not allowed renewal.</p>
136
                                <p>Item is not allowed renewal.</p>
136
137
137
                            [% ELSIF error == "onsite_checkout" %]
138
                            [% ELSIF error == "onsite_checkout" %]
139
138
                                <p>Item cannot be renewed because it's an onsite checkout</p>
140
                                <p>Item cannot be renewed because it's an onsite checkout</p>
139
141
142
                            [% ELSIF error == "too_much_debt" %]
143
144
                                <li>The patron has a debt of [% balance | $Price %].</li>
145
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
146
                                    <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
147
                                    <input type="hidden" name="override_debt" value="1" />
148
                                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
149
                                </form>
140
                            [% ELSE %]
150
                            [% ELSE %]
141
151
142
                                [% error | html %]
152
                                [% error | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+4 lines)
Lines 887-892 Link Here
887
887
888
        columns_settings_issues_table = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
888
        columns_settings_issues_table = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
889
889
890
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
891
        var fines = "[% fines %]";
892
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
893
890
        $(document).ready(function() {
894
        $(document).ready(function() {
891
            if ( $('#clubs-tab').length ) {
895
            if ( $('#clubs-tab').length ) {
892
                $('#clubs-tab-link').on('click', function() {
896
                $('#clubs-tab-link').on('click', function() {
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-30 / +45 lines)
Lines 137-143 $(document).ready(function() { Link Here
137
137
138
            var itemnumber = $(this).val();
138
            var itemnumber = $(this).val();
139
139
140
            $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
140
            var can_renew = true;
141
142
            if( parseFloat(fines) > parseFloat(amountlimit) ) {
143
                var result = confirm(MSG_CONFRIM_RENEW);
144
                if(result){
145
                    can_renew = true;
146
                }else{
147
                    can_renew = false;
148
                }
149
            }
141
150
142
            var params = {
151
            var params = {
143
                itemnumber:      itemnumber,
152
                itemnumber:      itemnumber,
Lines 155-188 $(document).ready(function() { Link Here
155
                params.date_due = dueDate
164
                params.date_due = dueDate
156
            }
165
            }
157
166
158
            $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
167
            if(can_renew) {
159
                var id = "#renew_" + data.itemnumber;
168
                $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
160
169
                renew(params);
161
                var content = "";
170
            }
162
                if ( data.renew_okay ) {
163
                    content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
164
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
165
                } else {
166
                    content = CIRCULATION_RENEW_FAILED + " ";
167
                    if ( data.error == "no_checkout" ) {
168
                        content += NOT_CHECKED_OUT;
169
                    } else if ( data.error == "too_many" ) {
170
                        content += TOO_MANY_RENEWALS;
171
                    } else if ( data.error == "on_reserve" ) {
172
                        content += ON_RESERVE;
173
                    } else if ( data.error == "restriction" ) {
174
                        content += NOT_RENEWABLE_RESTRICTION;
175
                    } else if ( data.error == "overdue" ) {
176
                        content += NOT_RENEWABLE_OVERDUE;
177
                    } else if ( data.error ) {
178
                        content += data.error;
179
                    } else {
180
                        content += REASON_UNKNOWN;
181
                    }
182
                }
183
184
                $(id).replaceWith( content );
185
            }, "json")
186
        });
171
        });
187
172
188
        // Refocus on barcode field if it exists
173
        // Refocus on barcode field if it exists
Lines 194-199 $(document).ready(function() { Link Here
194
        return false;
179
        return false;
195
    });
180
    });
196
181
182
    function renew(params){
183
        $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
184
            var id = "#renew_" + data.itemnumber;
185
186
            var content = "";
187
            if ( data.renew_okay ) {
188
                content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
189
                $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
190
            } else {
191
                content = CIRCULATION_RENEW_FAILED + " ";
192
                if ( data.error == "no_checkout" ) {
193
                    content += NOT_CHECKED_OUT;
194
                } else if ( data.error == "too_many" ) {
195
                    content += TOO_MANY_RENEWALS;
196
                } else if ( data.error == "on_reserve" ) {
197
                    content += ON_RESERVE;
198
                } else if ( data.error == "restriction" ) {
199
                    content += NOT_RENEWABLE_RESTRICTION;
200
                } else if ( data.error == "overdue" ) {
201
                    content += NOT_RENEWABLE_OVERDUE;
202
                } else if ( data.error ) {
203
                    content += data.error;
204
                } else {
205
                    content += REASON_UNKNOWN;
206
                }
207
            }
208
209
            $(id).replaceWith( content );
210
        }, "json")
211
    }
212
197
    $("#RenewAll").on("click",function(){
213
    $("#RenewAll").on("click",function(){
198
        $("#CheckAllRenewals").click();
214
        $("#CheckAllRenewals").click();
199
        $("#UncheckAllCheckins").click();
215
        $("#UncheckAllCheckins").click();
200
- 

Return to bug 23415