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

(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 262-268 if ($patron) { Link Here
262
    $template->param(
262
    $template->param(
263
        overduecount => $overdues->count,
263
        overduecount => $overdues->count,
264
        issuecount   => $issues->count,
264
        issuecount   => $issues->count,
265
        finetotal    => $balance,
265
        fines    => $balance,
266
    );
266
    );
267
267
268
    if ( $patron and $patron->is_debarred ) {
268
    if ( $patron and $patron->is_debarred ) {
(-)a/circ/renew.pl (-2 / +18 lines)
Lines 27-32 use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate Ad Link Here
27
use Koha::DateUtils qw( dt_from_string );
27
use Koha::DateUtils qw( dt_from_string );
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::BiblioFrameworks;
29
use Koha::BiblioFrameworks;
30
use Koha::Patrons;
30
31
31
my $cgi = CGI->new;
32
my $cgi = CGI->new;
32
33
Lines 47-56 $barcode = barcodedecode($barcode) if $barcode; Link Here
47
my $override_limit = $cgi->param('override_limit');
48
my $override_limit = $cgi->param('override_limit');
48
my $override_holds = $cgi->param('override_holds');
49
my $override_holds = $cgi->param('override_holds');
49
my $hard_due_date  = $cgi->param('hard_due_date');
50
my $hard_due_date  = $cgi->param('hard_due_date');
51
my $override_debt = $cgi->param('override_debt');
50
52
51
my ( $item, $issue, $borrower );
53
my ( $item, $issue, $borrower );
52
my $error = q{};
54
my $error = q{};
53
my ( $soonest_renew_date, $latest_auto_renew_date );
55
my ( $soonest_renew_date, $latest_auto_renew_date, $balance );
54
56
55
if ($barcode) {
57
if ($barcode) {
56
    $barcode = barcodedecode($barcode) if $barcode;
58
    $barcode = barcodedecode($barcode) if $barcode;
Lines 63-69 if ($barcode) { Link Here
63
        if ($issue) {
65
        if ($issue) {
64
66
65
            $borrower = $issue->patron();
67
            $borrower = $issue->patron();
66
            
68
            my $patron = Koha::Patrons->find($borrower->borrowernumber);
69
            $balance = $patron->account->balance;
70
            my $amountlimit = C4::Context->preference("noissuescharge");
71
67
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
72
            if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
68
                my $can_renew;
73
                my $can_renew;
69
                my $info;
74
                my $info;
Lines 90-95 if ($barcode) { Link Here
90
                        $item->itemnumber(),
95
                        $item->itemnumber(),
91
                    );
96
                    );
92
                }
97
                }
98
99
                if ( $balance > $amountlimit ) {
100
                    $error = "too_much_debt";
101
                    $can_renew = 0;
102
                    if($override_debt){
103
                        $can_renew = 1;
104
                        $error = undef;
105
                    }
106
                }
107
93
                if ($can_renew) {
108
                if ($can_renew) {
94
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
109
                    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
95
                    my $date_due =
110
                    my $date_due =
Lines 129-134 if ($barcode) { Link Here
129
        error    => $error,
144
        error    => $error,
130
        soonestrenewdate => $soonest_renew_date,
145
        soonestrenewdate => $soonest_renew_date,
131
        latestautorenewdate => $latest_auto_renew_date,
146
        latestautorenewdate => $latest_auto_renew_date,
147
        balance => $balance,
132
    );
148
    );
133
}
149
}
134
150
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 1090-1095 Link Here
1090
1090
1091
        [% UNLESS ( patron.borrowernumber ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %]
1091
        [% UNLESS ( patron.borrowernumber ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %]
1092
1092
1093
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
1094
        var fines = "[% fines %]";
1095
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
1096
1093
        // On-site checkout
1097
        // On-site checkout
1094
        function toggle_onsite_checkout(){
1098
        function toggle_onsite_checkout(){
1095
            if ( $("#onsite_checkout").prop('checked') ) {
1099
            if ( $("#onsite_checkout").prop('checked') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (+9 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 170-175 Link Here
170
                            [% ELSIF error == 'recalled' %]
171
                            [% ELSIF error == 'recalled' %]
171
                                <p>This item has been recalled.</p>
172
                                <p>This item has been recalled.</p>
172
173
174
                            [% ELSIF error == "too_much_debt" %]
175
176
                                <li>The patron has a debt of [% balance | $Price %].</li>
177
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
178
                                    <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
179
                                    <input type="hidden" name="override_debt" value="1" />
180
                                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
181
                                </form>
173
                            [% ELSE %]
182
                            [% ELSE %]
174
183
175
                                [% error | html %]
184
                                [% error | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+4 lines)
Lines 893-898 Link Here
893
        table_settings_issues_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
893
        table_settings_issues_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'issues-table', 'json' ) | $raw %]
894
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'relatives-issues-table', 'json' ) | $raw %]
894
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'relatives-issues-table', 'json' ) | $raw %]
895
895
896
        var amountlimit = "[% Koha.Preference('noissuescharge') %]";
897
        var fines = "[% fines %]";
898
        var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines);
899
896
        $(document).ready(function() {
900
        $(document).ready(function() {
897
            $("#info_digests").tooltip();
901
            $("#info_digests").tooltip();
898
902
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-38 / +53 lines)
Lines 150-156 $(document).ready(function() { Link Here
150
150
151
            var itemnumber = $(this).val();
151
            var itemnumber = $(this).val();
152
152
153
            $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
153
            var can_renew = true;
154
155
            if( parseFloat(fines) > parseFloat(amountlimit) ) {
156
                var result = confirm(MSG_CONFRIM_RENEW);
157
                if(result){
158
                    can_renew = true;
159
                }else{
160
                    can_renew = false;
161
                }
162
            }
154
163
155
            var params = {
164
            var params = {
156
                itemnumber:      itemnumber,
165
                itemnumber:      itemnumber,
Lines 174-215 $(document).ready(function() { Link Here
174
                params.date_due = dueDate
183
                params.date_due = dueDate
175
            }
184
            }
176
185
177
            $.post({
186
            if(can_renew) {
178
                url: "/cgi-bin/koha/svc/renew",
187
                $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
179
                data: params,
188
                renew(params);
180
                success: function( data ) {
189
            }
181
                    var id = "#renew_" + data.itemnumber;
182
183
                    var content = "";
184
                    if ( data.renew_okay ) {
185
                        content = __("Renewed, due:") + " " + data.date_due;
186
                        $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
187
                    } else {
188
                        content = __("Renew failed:") + " ";
189
                        if ( data.error == "no_checkout" ) {
190
                            content += __("not checked out");
191
                        } else if ( data.error == "too_many" ) {
192
                            content += __("too many renewals");
193
                        } else if ( data.error == "too_unseen" ) {
194
                            content += __("too many consecutive renewals without being seen by the library");
195
                        } else if ( data.error == "on_reserve" ) {
196
                            content += __("on hold");
197
                        } else if ( data.error == "restriction" ) {
198
                            content += __("Not allowed: patron restricted");
199
                        } else if ( data.error == "overdue" ) {
200
                            content += __("Not allowed: overdue");
201
                        } else if ( data.error ) {
202
                            content += data.error;
203
                        } else {
204
                            content += __("reason unknown");
205
                        }
206
                    }
207
208
                    $(id).replaceWith( content );
209
            },
210
            dataType: "json",
211
            async: false,
212
            });
213
        });
190
        });
214
191
215
        // Refocus on barcode field if it exists
192
        // Refocus on barcode field if it exists
Lines 221-226 $(document).ready(function() { Link Here
221
        return false;
198
        return false;
222
    });
199
    });
223
200
201
    function renew(params){
202
        $.post({
203
            url: "/cgi-bin/koha/svc/renew",
204
            data: params,
205
            success: function( data ) {
206
                var id = "#renew_" + data.itemnumber;
207
208
                var content = "";
209
                if ( data.renew_okay ) {
210
                    content = __("Renewed, due:") + " " + data.date_due;
211
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
212
                } else {
213
                    content = __("Renew failed:") + " ";
214
                    if ( data.error == "no_checkout" ) {
215
                        content += __("not checked out");
216
                    } else if ( data.error == "too_many" ) {
217
                        content += __("too many renewals");
218
                    } else if ( data.error == "too_unseen" ) {
219
                        content += __("too many consecutive renewals without being seen by the library");
220
                    } else if ( data.error == "on_reserve" ) {
221
                        content += __("on hold");
222
                    } else if ( data.error == "restriction" ) {
223
                        content += __("Not allowed: patron restricted");
224
                    } else if ( data.error == "overdue" ) {
225
                        content += __("Not allowed: overdue");
226
                    } else if ( data.error ) {
227
                        content += data.error;
228
                    } else {
229
                        content += __("reason unknown");
230
                    }
231
                }
232
233
                $(id).replaceWith( content );
234
        },
235
        dataType: "json",
236
        async: false,
237
        });
238
    }
239
224
    $("#RenewAll").on("click",function(){
240
    $("#RenewAll").on("click",function(){
225
        $("#CheckAllRenewals").click();
241
        $("#CheckAllRenewals").click();
226
        $("#UncheckAllCheckins").click();
242
        $("#UncheckAllCheckins").click();
227
- 

Return to bug 23415