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

(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 286-292 if ($patron) { Link Here
286
    $template->param(
286
    $template->param(
287
        overduecount => $overdues->count,
287
        overduecount => $overdues->count,
288
        issuecount   => $issues->count,
288
        issuecount   => $issues->count,
289
        finetotal    => $balance,
289
        fines    => $balance,
290
    );
290
    );
291
291
292
    if ( $patron and $patron->is_debarred ) {
292
    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 = CGI->new;
33
my $cgi = CGI->new;
33
34
Lines 49-58 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('item Link Here
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');
51
my $hard_due_date  = $cgi->param('hard_due_date');
52
my $hard_due_date  = $cgi->param('hard_due_date');
53
my $override_debt = $cgi->param('override_debt');
52
54
53
my ( $item, $issue, $borrower );
55
my ( $item, $issue, $borrower );
54
my $error = q{};
56
my $error = q{};
55
my ( $soonest_renew_date, $latest_auto_renew_date );
57
my ( $soonest_renew_date, $latest_auto_renew_date, $balance );
56
58
57
if ($barcode) {
59
if ($barcode) {
58
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
60
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
Lines 65-71 if ($barcode) { Link Here
65
        if ($issue) {
67
        if ($issue) {
66
68
67
            $borrower = $issue->borrower();
69
            $borrower = $issue->borrower();
68
            
70
            my $patron = Koha::Patrons->find($borrower->borrowernumber);
71
            $balance = $patron->account->balance;
72
            my $amountlimit = C4::Context->preference("noissuescharge");
73
69
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
74
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
70
                my $can_renew;
75
                my $can_renew;
71
                ( $can_renew, $error ) =
76
                ( $can_renew, $error ) =
Lines 94-99 if ($barcode) { Link Here
94
                        $item->itemnumber(),
99
                        $item->itemnumber(),
95
                    );
100
                    );
96
                }
101
                }
102
103
                if ( $balance > $amountlimit ) {
104
                    $error = "too_much_debt";
105
                    $can_renew = 0;
106
                    if($override_debt){
107
                        $can_renew = 1;
108
                        $error = undef;
109
                    }
110
                }
111
97
                if ($can_renew) {
112
                if ($can_renew) {
98
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
113
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
99
                    my $date_due;
114
                    my $date_due;
Lines 134-139 if ($barcode) { Link Here
134
        error    => $error,
149
        error    => $error,
135
        soonestrenewdate => $soonest_renew_date,
150
        soonestrenewdate => $soonest_renew_date,
136
        latestautorenewdate => $latest_auto_renew_date,
151
        latestautorenewdate => $latest_auto_renew_date,
152
        balance => $balance,
137
    );
153
    );
138
}
154
}
139
155
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 1113-1118 Link Here
1113
1113
1114
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1114
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1115
1115
1116
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
1117
        var fines = "[% fines %]";
1118
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
1119
1116
        // On-site checkout
1120
        // On-site checkout
1117
        function toggle_onsite_checkout(){
1121
        function toggle_onsite_checkout(){
1118
            if ( $("#onsite_checkout").prop('checked') ) {
1122
            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 147-154 Link Here
147
                                <p>Item is not allowed renewal.</p>
148
                                <p>Item is not allowed renewal.</p>
148
149
149
                            [% ELSIF error == "onsite_checkout" %]
150
                            [% ELSIF error == "onsite_checkout" %]
151
150
                                <p>Item cannot be renewed because it's an onsite checkout</p>
152
                                <p>Item cannot be renewed because it's an onsite checkout</p>
151
153
154
                            [% ELSIF error == "too_much_debt" %]
155
156
                                <li>The patron has a debt of [% balance | $Price %].</li>
157
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
158
                                    <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
159
                                    <input type="hidden" name="override_debt" value="1" />
160
                                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
161
                                </form>
152
                            [% ELSE %]
162
                            [% ELSE %]
153
163
154
                                [% error | html %]
164
                                [% error | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+4 lines)
Lines 946-951 Link Here
946
946
947
        columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
947
        columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
948
948
949
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
950
        var fines = "[% fines %]";
951
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
952
949
        $(document).ready(function() {
953
        $(document).ready(function() {
950
954
951
            if ( $('#clubs-tab').length ) {
955
            if ( $('#clubs-tab').length ) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-32 / +47 lines)
Lines 146-152 $(document).ready(function() { Link Here
146
146
147
            var itemnumber = $(this).val();
147
            var itemnumber = $(this).val();
148
148
149
            $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
149
            var can_renew = true;
150
151
            if( parseFloat(fines) > parseFloat(amountlimit) ) {
152
                var result = confirm(MSG_CONFRIM_RENEW);
153
                if(result){
154
                    can_renew = true;
155
                }else{
156
                    can_renew = false;
157
                }
158
            }
150
159
151
            var params = {
160
            var params = {
152
                itemnumber:      itemnumber,
161
                itemnumber:      itemnumber,
Lines 170-205 $(document).ready(function() { Link Here
170
                params.date_due = dueDate
179
                params.date_due = dueDate
171
            }
180
            }
172
181
173
            $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
182
            if(can_renew) {
174
                var id = "#renew_" + data.itemnumber;
183
                $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
175
184
                renew(params);
176
                var content = "";
185
            }
177
                if ( data.renew_okay ) {
178
                    content = __("Renewed, due:") + " " + data.date_due;
179
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
180
                } else {
181
                    content = __("Renew failed:") + " ";
182
                    if ( data.error == "no_checkout" ) {
183
                        content += __("not checked out");
184
                    } else if ( data.error == "too_many" ) {
185
                        content += __("too many renewals");
186
                    } else if ( data.error == "too_unseen" ) {
187
                        content += __("too many consecutive renewals without being seen by the library");
188
                    } else if ( data.error == "on_reserve" ) {
189
                        content += __("on hold");
190
                    } else if ( data.error == "restriction" ) {
191
                        content += __("Not allowed: patron restricted");
192
                    } else if ( data.error == "overdue" ) {
193
                        content += __("Not allowed: overdue");
194
                    } else if ( data.error ) {
195
                        content += data.error;
196
                    } else {
197
                        content += __("reason unknown");
198
                    }
199
                }
200
201
                $(id).replaceWith( content );
202
            }, "json")
203
        });
186
        });
204
187
205
        // Refocus on barcode field if it exists
188
        // Refocus on barcode field if it exists
Lines 211-216 $(document).ready(function() { Link Here
211
        return false;
194
        return false;
212
    });
195
    });
213
196
197
    function renew(params){
198
        $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
199
            var id = "#renew_" + data.itemnumber;
200
201
            var content = "";
202
            if ( data.renew_okay ) {
203
                content = __("Renewed, due:") + " " + data.date_due;
204
                $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
205
            } else {
206
                content = __("Renew failed:") + " ";
207
                if ( data.error == "no_checkout" ) {
208
                    content += __("not checked out");
209
                } else if ( data.error == "too_many" ) {
210
                    content += __("too many renewals");
211
                } else if ( data.error == "too_unseen" ) {
212
                    content += __("too many consecutive renewals without being seen by the library");
213
                } else if ( data.error == "on_reserve" ) {
214
                    content += __("on hold");
215
                } else if ( data.error == "restriction" ) {
216
                    content += __("Not allowed: patron restricted");
217
                } else if ( data.error == "overdue" ) {
218
                    content += __("Not allowed: overdue");
219
                } else if ( data.error ) {
220
                    content += data.error;
221
                } else {
222
                    content += __("reason unknown");
223
                }
224
            }
225
226
            $(id).replaceWith( content );
227
        }, "json")
228
    }
229
214
    $("#RenewAll").on("click",function(){
230
    $("#RenewAll").on("click",function(){
215
        $("#CheckAllRenewals").click();
231
        $("#CheckAllRenewals").click();
216
        $("#UncheckAllCheckins").click();
232
        $("#UncheckAllCheckins").click();
217
- 

Return to bug 23415