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 1147-1152 Link Here
1147
1147
1148
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1148
        [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %]
1149
1149
1150
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
1151
        var fines = "[% fines %]";
1152
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
1153
1150
        // On-site checkout
1154
        // On-site checkout
1151
        function toggle_onsite_checkout(){
1155
        function toggle_onsite_checkout(){
1152
            if ( $("#onsite_checkout").prop('checked') ) {
1156
            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 161-168 Link Here
161
                                <p>Item is not allowed renewal.</p>
162
                                <p>Item is not allowed renewal.</p>
162
163
163
                            [% ELSIF error == "onsite_checkout" %]
164
                            [% ELSIF error == "onsite_checkout" %]
165
164
                                <p>Item cannot be renewed because it's an onsite checkout</p>
166
                                <p>Item cannot be renewed because it's an onsite checkout</p>
165
167
168
                            [% ELSIF error == "too_much_debt" %]
169
170
                                <li>The patron has a debt of [% balance | $Price %].</li>
171
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
172
                                    <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
173
                                    <input type="hidden" name="override_debt" value="1" />
174
                                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
175
                                </form>
166
                            [% ELSE %]
176
                            [% ELSE %]
167
177
168
                                [% error | html %]
178
                                [% error | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+4 lines)
Lines 965-970 Link Here
965
965
966
        columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
966
        columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
967
967
968
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
969
        var fines = "[% fines %]";
970
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
971
968
        $(document).ready(function() {
972
        $(document).ready(function() {
969
973
970
            if ( $('#clubs-tab').length ) {
974
            if ( $('#clubs-tab').length ) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-38 / +53 lines)
Lines 152-158 $(document).ready(function() { Link Here
152
152
153
            var itemnumber = $(this).val();
153
            var itemnumber = $(this).val();
154
154
155
            $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
155
            var can_renew = true;
156
157
            if( parseFloat(fines) > parseFloat(amountlimit) ) {
158
                var result = confirm(MSG_CONFRIM_RENEW);
159
                if(result){
160
                    can_renew = true;
161
                }else{
162
                    can_renew = false;
163
                }
164
            }
156
165
157
            var params = {
166
            var params = {
158
                itemnumber:      itemnumber,
167
                itemnumber:      itemnumber,
Lines 176-217 $(document).ready(function() { Link Here
176
                params.date_due = dueDate
185
                params.date_due = dueDate
177
            }
186
            }
178
187
179
            $.post({
188
            if(can_renew) {
180
                url: "/cgi-bin/koha/svc/renew",
189
                $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
181
                data: params,
190
                renew(params);
182
                success: function( data ) {
191
            }
183
                    var id = "#renew_" + data.itemnumber;
184
185
                    var content = "";
186
                    if ( data.renew_okay ) {
187
                        content = __("Renewed, due:") + " " + data.date_due;
188
                        $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
189
                    } else {
190
                        content = __("Renew failed:") + " ";
191
                        if ( data.error == "no_checkout" ) {
192
                            content += __("not checked out");
193
                        } else if ( data.error == "too_many" ) {
194
                            content += __("too many renewals");
195
                        } else if ( data.error == "too_unseen" ) {
196
                            content += __("too many consecutive renewals without being seen by the library");
197
                        } else if ( data.error == "on_reserve" ) {
198
                            content += __("on hold");
199
                        } else if ( data.error == "restriction" ) {
200
                            content += __("Not allowed: patron restricted");
201
                        } else if ( data.error == "overdue" ) {
202
                            content += __("Not allowed: overdue");
203
                        } else if ( data.error ) {
204
                            content += data.error;
205
                        } else {
206
                            content += __("reason unknown");
207
                        }
208
                    }
209
210
                    $(id).replaceWith( content );
211
            },
212
            dataType: "json",
213
            async: false,
214
            });
215
        });
192
        });
216
193
217
        // Refocus on barcode field if it exists
194
        // Refocus on barcode field if it exists
Lines 223-228 $(document).ready(function() { Link Here
223
        return false;
200
        return false;
224
    });
201
    });
225
202
203
    function renew(params){
204
        $.post({
205
            url: "/cgi-bin/koha/svc/renew",
206
            data: params,
207
            success: function( data ) {
208
                var id = "#renew_" + data.itemnumber;
209
210
                var content = "";
211
                if ( data.renew_okay ) {
212
                    content = __("Renewed, due:") + " " + data.date_due;
213
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
214
                } else {
215
                    content = __("Renew failed:") + " ";
216
                    if ( data.error == "no_checkout" ) {
217
                        content += __("not checked out");
218
                    } else if ( data.error == "too_many" ) {
219
                        content += __("too many renewals");
220
                    } else if ( data.error == "too_unseen" ) {
221
                        content += __("too many consecutive renewals without being seen by the library");
222
                    } else if ( data.error == "on_reserve" ) {
223
                        content += __("on hold");
224
                    } else if ( data.error == "restriction" ) {
225
                        content += __("Not allowed: patron restricted");
226
                    } else if ( data.error == "overdue" ) {
227
                        content += __("Not allowed: overdue");
228
                    } else if ( data.error ) {
229
                        content += data.error;
230
                    } else {
231
                        content += __("reason unknown");
232
                    }
233
                }
234
235
                $(id).replaceWith( content );
236
        },
237
        dataType: "json",
238
        async: false,
239
        });
240
    }
241
226
    $("#RenewAll").on("click",function(){
242
    $("#RenewAll").on("click",function(){
227
        $("#CheckAllRenewals").click();
243
        $("#CheckAllRenewals").click();
228
        $("#UncheckAllCheckins").click();
244
        $("#UncheckAllCheckins").click();
229
- 

Return to bug 23415