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

(-)a/circ/circulation.pl (-14 lines)
Lines 261-270 my $patron; Link Here
261
if ($borrowernumber) {
261
if ($borrowernumber) {
262
    $patron = Koha::Patrons->find( $borrowernumber );
262
    $patron = Koha::Patrons->find( $borrowernumber );
263
    $borrower = GetMember( borrowernumber => $borrowernumber );
263
    $borrower = GetMember( borrowernumber => $borrowernumber );
264
    my $overdues = $patron->get_overdues;
265
    my $issues = $patron->checkouts;
266
    my $balance = $patron->account->balance;
267
268
264
269
    # if the expiry date is before today ie they have expired
265
    # if the expiry date is before today ie they have expired
270
    if ( $patron->is_expired ) {
266
    if ( $patron->is_expired ) {
Lines 284-294 if ($borrowernumber) { Link Here
284
            $template->param("returnbeforeexpiry" => 1);
280
            $template->param("returnbeforeexpiry" => 1);
285
        }
281
        }
286
    }
282
    }
287
    $template->param(
288
        overduecount => $overdues->count,
289
        issuecount   => $issues->count,
290
        finetotal    => $balance,
291
    );
292
283
293
    if ( $patron and $patron->is_debarred ) {
284
    if ( $patron and $patron->is_debarred ) {
294
        $template->param(
285
        $template->param(
Lines 415-425 if (@$barcodes) { Link Here
415
        itembiblionumber => $getmessageiteminfo->{'biblionumber'}
406
        itembiblionumber => $getmessageiteminfo->{'biblionumber'}
416
    );
407
    );
417
408
418
419
    # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue
420
    $patron = Koha::Patrons->find( $borrowernumber );
421
    $template_params->{issuecount} = $patron->checkouts->count;
422
423
    if ( $iteminfo ) {
409
    if ( $iteminfo ) {
424
        $iteminfo->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($iteminfo->{biblionumber}), GetFrameworkCode($iteminfo->{biblionumber}));
410
        $iteminfo->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($iteminfo->{biblionumber}), GetFrameworkCode($iteminfo->{biblionumber}));
425
        $template_params->{item} = $iteminfo;
411
        $template_params->{item} = $iteminfo;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc (-8 / +10 lines)
Lines 1-13 Link Here
1
[% USE Price %]
1
<script type="text/javascript">
2
[% SET NoIssuesCharge = Koha.Preference('noissuescharge') %]
2
KOHA.Checkouts.BorrowerNumber = [% borrowernumber %];
3
[% IF fines > 0 %]
3
KOHA.Checkouts.NoIssuesCharge = [% Koha.Preference('noissuescharge') || "null" %];
4
    <li>
4
</script>
5
    <li id="outstanding-fees" style="display: none;">
5
        <span class="circ-hlt">Fees &amp; Charges:</span>
6
        <span class="circ-hlt">Fees &amp; Charges:</span>
6
        Patron has outstanding fees &amp; charges of [% fines | $Price %].
7
        Patron has outstanding fees &amp; charges of <span id="outstanding-fees-amount"></span>
7
        [% IF !Koha.Preference('AllowFineOverride') && NoIssuesCharge && fines > NoIssuesCharge %]
8
        </a>.
8
           <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
9
10
        [% IF !Koha.Preference('AllowFineOverride') %]
11
            <span class="circ-hlt" id="outstanding-fees-over-limit" style="display: none;">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
9
        [% END %]
12
        [% END %]
10
        <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]" class="btn btn-default btn-xs" >Make payment</a>
13
        <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% borrowernumber %]" class="btn btn-default btn-xs" >Make payment</a>
11
        <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]" class="btn btn-default btn-xs" >Pay all fines</a></li>
14
        <a href="/cgi-bin/koha/members/paycollect.pl?borrowernumber=[% borrowernumber %]" class="btn btn-default btn-xs" >Pay all fines</a></li>
12
    </li>
15
    </li>
13
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc (-4 / +3 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
<div id="checkouts">
2
<div id="checkouts">
3
    [% IF ( issuecount ) %]
3
    <div class="has-checkouts" style="display: none;">
4
        <div id="issues-table-loading-message">
4
        <div id="issues-table-loading-message">
5
            <p>
5
            <p>
6
                <a id="issues-table-load-now-button" href="#" class="btn btn-default"><i class="fa fa-book"></i> Show checkouts</a>
6
                <a id="issues-table-load-now-button" href="#" class="btn btn-default"><i class="fa fa-book"></i> Show checkouts</a>
Lines 70-76 Link Here
70
                [% END %]
70
                [% END %]
71
            </div>
71
            </div>
72
        </form>
72
        </form>
73
    [% ELSE %]
73
    </div>
74
        <p>Patron has nothing checked out.</p>
74
    <p class="no-checkouts" style="display: none;">Patron has nothing checked out.</p>
75
    [% END %]
76
</div>
75
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-46 / +26 lines)
Lines 23-28 Link Here
23
[% INCLUDE 'strings.inc' %]
23
[% INCLUDE 'strings.inc' %]
24
[% INCLUDE 'datatables.inc' %]
24
[% INCLUDE 'datatables.inc' %]
25
[% INCLUDE 'columns_settings.inc' %]
25
[% INCLUDE 'columns_settings.inc' %]
26
<style>
27
.issue-allow, .issue-disallow, #mainform {display: none;}
28
</style>
26
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
29
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
27
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
30
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery-ui-timepicker-addon.min.js"></script>
28
[% INCLUDE 'timepicker.inc' %]
31
[% INCLUDE 'timepicker.inc' %]
Lines 87-92 function toggle_onsite_checkout(){ Link Here
87
function Dopop(link) {
90
function Dopop(link) {
88
    var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
91
    var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
89
}
92
}
93
94
KOHA.Checkouts.DisallowIssue = [% noissues ? "true" : "false" %];
95
KOHA.Checkouts.ForceAllowIssue = [% forceallow ? "true" : "false" %];
96
KOHA.Checkouts.ForceOnSiteCheckouts = [% Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ? "true" : "false" %];
90
$(document).ready(function() {
97
$(document).ready(function() {
91
    $('#mainform').on('submit',function() {
98
    $('#mainform').on('submit',function() {
92
        if ($("#barcode") && $("#barcode").val()) {
99
        if ($("#barcode") && $("#barcode").val()) {
Lines 408-416 $(document).ready(function() { Link Here
408
</form>
415
</form>
409
416
410
[% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %]
417
[% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %]
411
    [% UNLESS noissues %]
418
        <button class="issue-allow" type="submit" onclick="window.location.href='/cgi-bin/koha/reserve/request.pl?biblionumber=[% itembiblionumber %]&borrowernumber=[% borrowernumber %]'"><i class="fa fa-sticky-note-o"></i> Cancel checkout and place a hold for [% INCLUDE 'patron-title.inc' %]</button>
412
        <button type="submit" onclick="window.location.href='/cgi-bin/koha/reserve/request.pl?biblionumber=[% itembiblionumber %]&borrowernumber=[% borrowernumber %]'"><i class="fa fa-sticky-note-o"></i> Cancel checkout and place a hold for [% INCLUDE 'patron-title.inc' %]</button>
413
    [% END %]
414
[% END %]
419
[% END %]
415
</div></div>
420
</div></div>
416
[% END %] <!-- NEEDSCONFIRMATION -->
421
[% END %] <!-- NEEDSCONFIRMATION -->
Lines 577-583 No patron matched <span class="ex">[% message | html %]</span> Link Here
577
    <div class="dialog alert"><strong>Error:</strong> This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.</div>
582
    <div class="dialog alert"><strong>Error:</strong> This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.</div>
578
[% END %]
583
[% END %]
579
584
580
[% IF ( !noissues ) || ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') )%]
581
<div class="yui-u first">
585
<div class="yui-u first">
582
586
583
<form method="post" action="/cgi-bin/koha/circ/circulation.pl" id="mainform" name="mainform" autocomplete="off">
587
<form method="post" action="/cgi-bin/koha/circ/circulation.pl" id="mainform" name="mainform" autocomplete="off">
Lines 614-620 No patron matched <span class="ex">[% message | html %]</span> Link Here
614
618
615
    <div class="checkout-settings">
619
    <div class="checkout-settings">
616
620
617
        [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %]
618
            [% IF ( SpecifyDueDate ) %]
621
            [% IF ( SpecifyDueDate ) %]
619
                <div id="specify-due-date" class="checkout-setting">
622
                <div id="specify-due-date" class="checkout-setting">
620
                    <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
623
                    <div class="hint">Specify due date [% INCLUDE 'date-format.inc' %]: </div>
Lines 632-641 No patron matched <span class="ex">[% message | html %]</span> Link Here
632
                    <button class="btn btn-default btn-sm action" id="cleardate" name="cleardate" onclick="this.checked = false; this.form.duedatespec.value = ''; this.form.stickyduedate.checked = false; this.form.barcode.focus(); return false;" >Clear</button>
635
                    <button class="btn btn-default btn-sm action" id="cleardate" name="cleardate" onclick="this.checked = false; this.form.duedatespec.value = ''; this.form.stickyduedate.checked = false; this.form.barcode.focus(); return false;" >Clear</button>
633
                </div>
636
                </div>
634
            [% END %]
637
            [% END %]
635
        [% END %]
636
638
637
        [% UNLESS ( noissues ) %]
639
            <div id="set-automatic-renewal" class="checkout-setting issue-allow">
638
            <div id="set-automatic-renewal" class="checkout-setting">
639
                [% IF NEEDSCONFIRMATION %]
640
                [% IF NEEDSCONFIRMATION %]
640
                    <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" />
641
                    <input type="checkbox" name="auto_renew" id="auto_renew" value="auto_renew" disabled="disabled" />
641
                [% ELSE %]
642
                [% ELSE %]
Lines 662-680 No patron matched <span class="ex">[% message | html %]</span> Link Here
662
                    <label for="override_high_holds">Don't decrease checkout length based on holds</label>
663
                    <label for="override_high_holds">Don't decrease checkout length based on holds</label>
663
                </div>
664
                </div>
664
            [% END %]
665
            [% END %]
665
        [% END %]
666
666
667
        [% IF Koha.Preference('OnSiteCheckouts') %]
667
        [% IF Koha.Preference('OnSiteCheckouts') %]
668
            <div id="onsite_checkout-select" class="checkout-setting">
668
            <div id="onsite_checkout-select" class="checkout-setting">
669
                [% IF noissues %]
669
                    <div class="onsite-checkout-only issue-disallow">
670
                    <div class="onsite-checkout-only">
671
                        <input type="checkbox" id="onsite_checkout" name="onsite_checkout_forced" checked="checked" disabled="disabled" /> <label for="onsite_checkout">On-site checkouts only. Automatic due date: </label>
670
                        <input type="checkbox" id="onsite_checkout" name="onsite_checkout_forced" checked="checked" disabled="disabled" /> <label for="onsite_checkout">On-site checkouts only. Automatic due date: </label>
672
                        <input type="text" name="duedatespec" id="duedatespec" />
671
                        <input type="text" name="duedatespec" id="duedatespec" />
673
                        <input type="hidden" name="onsite_checkout" checked="checked" value="1" />
672
                        <input type="hidden" name="onsite_checkout" checked="checked" value="1" />
674
                    </div>
673
                    </div>
675
                [% ELSE %]
674
                    <div class="issue-allow">
676
                    <input type="checkbox" id="onsite_checkout" name="onsite_checkout" /> <label for="onsite_checkout">On-site checkout</label>
675
                    <input type="checkbox" id="onsite_checkout" name="onsite_checkout" /> <label for="onsite_checkout">On-site checkout</label>
677
                [% END %]
676
                    </div>
678
            </div>
677
            </div>
679
        [% END %]
678
        [% END %]
680
679
Lines 696-730 No patron matched <span class="ex">[% message | html %]</span> Link Here
696
[% END %]
695
[% END %]
697
</form></div>
696
</form></div>
698
697
699
[% END %]<!-- /unless noissues -->
700
701
[% IF ( noissues ) %]
702
    [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]
703
        <div class="yui-u">
704
    [% ELSE %]
705
        <div>
706
    [% END %]
707
[% ELSE %]
708
    <div class="yui-u">
698
    <div class="yui-u">
709
[% END %]
699
        <div id="circmessages" class="circmessage attention">
710
700
            <h3>Attention:</h3>
711
        [% IF ( noissues ) %]
701
            <div class="issue-disallow">
712
            [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]
702
            [% IF !( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]
713
                <div id="circmessages" class="circmessage attention">
714
            [% ELSE %]
715
                <h4>Checking out to [% INCLUDE 'patron-title.inc' %]</h4>
703
                <h4>Checking out to [% INCLUDE 'patron-title.inc' %]</h4>
716
                <div id="circmessages" class="circmessage warning">
717
            [% END %]
704
            [% END %]
718
            <h3>
705
                <h3>
719
                Cannot check out!
706
                    Cannot check out!
720
                [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]
707
                    [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]
721
                    <span class="circ-hlt">Only on-site checkouts are allowed</span>
708
                        <span class="circ-hlt">Only on-site checkouts are allowed</span>
722
                [% END %]
709
                    [% END %]
723
            </h3>
710
                </h3>
724
        [% ELSE %]
711
            </div>
725
            <div id="circmessages" class="circmessage attention">
726
                <h3>Attention:</h3>
727
        [% END %]
728
712
729
		<ul>
713
		<ul>
730
714
Lines 783-790 No patron matched <span class="ex">[% message | html %]</span> Link Here
783
                   [% END %]
767
                   [% END %]
784
                   <br/>
768
                   <br/>
785
                   <a class="btn btn-default btn-sm" href="#reldebarments" onclick="$('#debarments-tab-link').click()"><i class="fa fa-ban"></i> View restrictions</a>
769
                   <a class="btn btn-default btn-sm" href="#reldebarments" onclick="$('#debarments-tab-link').click()"><i class="fa fa-ban"></i> View restrictions</a>
786
                    [% IF (noissues && borrowernumber && CAN_user_circulate_force_checkout) %]
770
                    [% IF (borrowernumber && CAN_user_circulate_force_checkout) %]
787
                        <span class="override_debarment">
771
                        <span class="override_debarment issue-disallow">
788
                            <a href="/cgi-bin/koha/circ/circulation.pl?forceallow=1&amp;borrowernumber=[% borrowernumber %]" class="btn btn-default btn-sm">Override restriction temporarily</a>
772
                            <a href="/cgi-bin/koha/circ/circulation.pl?forceallow=1&amp;borrowernumber=[% borrowernumber %]" class="btn btn-default btn-sm">Override restriction temporarily</a>
789
                        </span>
773
                        </span>
790
                    [% END %]
774
                    [% END %]
Lines 884-894 No patron matched <span class="ex">[% message | html %]</span> Link Here
884
868
885
<ul>
869
<ul>
886
    <li>
870
    <li>
887
        [% IF ( issuecount ) %]
871
            <a href="#checkouts"><span id="issuecount">0</span> Checkout(s)</a>
888
            <a href="#checkouts">[% issuecount %] Checkout(s)</a>
889
        [% ELSE %]
890
            <a href="#checkouts">0 Checkouts</a>
891
        [% END %]
892
    </li>
872
    </li>
893
873
894
    [% IF relatives_issues_count %]
874
    [% IF relatives_issues_count %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-3 / +1 lines)
Lines 179-191 function validate1(date) { Link Here
179
[% ELSE %]
179
[% ELSE %]
180
    [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry | $KohaDates %]</div>[% END %]
180
    [% IF ( was_renewed ) %]<div class="dialog message">Patron's account has been renewed until [% dateexpiry | $KohaDates %]</div>[% END %]
181
181
182
    [% IF fines %]
183
    <div id="circmessages" class="circmessage attention">
182
    <div id="circmessages" class="circmessage attention">
184
      <ul>
183
      <ul>
185
        [% INCLUDE 'blocked-fines.inc' %]
184
        [% INCLUDE 'blocked-fines.inc' %]
186
      </ul>
185
      </ul>
187
    </div>
186
    </div>
188
    [% END %]
189
187
190
    [% IF ( flagged ) %]
188
    [% IF ( flagged ) %]
191
    <div id="circmessages" class="circmessage attention">
189
    <div id="circmessages" class="circmessage attention">
Lines 501-507 function validate1(date) { Link Here
501
499
502
<div id="finesholdsissues" class="toptabs">
500
<div id="finesholdsissues" class="toptabs">
503
    <ul>
501
    <ul>
504
        <li><a href="#checkouts">[% issuecount %] Checkout(s)</a></li>
502
        <li><a href="#checkouts"><span id="issuecount">0</span> Checkout(s)</a></li>
505
        [% IF relatives_issues_count %]
503
        [% IF relatives_issues_count %]
506
            <li><a href="#relatives-issues" id="relatives-issues-tab">Relatives' checkouts</a></li>
504
            <li><a href="#relatives-issues" id="relatives-issues-tab">Relatives' checkouts</a></li>
507
        [% END %]
505
        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (+40 lines)
Lines 1-6 Link Here
1
if ( KOHA === undefined ) var KOHA = {};
2
KOHA.Checkouts = {
3
    NoIssuesCharge: null,
4
    BorrowerNumber: null,
5
    DisallowIssue: false,
6
    ForceAllowIssue: false,
7
    ForceOnSiteCheckouts: false,
8
    ToggleInput: function( allow_issue ) {
9
        if (KOHA.Checkouts.DisallowIssue) allow_issue = false;
10
        if (KOHA.Checkouts.ForceAllowIssue) allow_issue = true;
11
12
        $(".issue-allow").toggle(allow_issue);
13
        $(".issue-disallow").toggle(!allow_issue);
14
        $("#mainform").toggle(allow_issue || KOHA.Checkouts.ForceOnSiteCheckouts);
15
16
        if (!allow_issue) {
17
            $(".circmessage.attention").removeClass("attention").addClass("warning");
18
        }
19
    },
20
    UpdateCheckoutsAndFees: function(checkouts_only=false) {
21
        $.get( "/cgi-bin/koha/svc/patron/fines", {borrowernumber: KOHA.Checkouts.BorrowerNumber}, function( data ) {
22
            $("#issuecount").text(data.issuecount);
23
            var has_checkouts = data.issuecount > 0;
24
            $(".has-checkouts").toggle(has_checkouts);
25
            $(".no-checkouts").toggle(!has_checkouts);
26
            if (checkouts_only) return;
27
28
            var noissue = KOHA.Checkouts.NoIssuesCharge !== null && data.owing >= KOHA.Checkouts.NoIssuesCharge;
29
            $("#outstanding-fees").toggle(data.owing > 0);
30
            $("#outstanding-fees-amount").text(data.owing_formatted);
31
            $("#outstanding-fees-over-limit").toggle(noissue);
32
            KOHA.Checkouts.ToggleInput(!noissue);
33
        } );
34
    }
35
}
36
1
$(document).ready(function() {
37
$(document).ready(function() {
2
    $.ajaxSetup ({ cache: false });
38
    $.ajaxSetup ({ cache: false });
3
39
40
    KOHA.Checkouts.UpdateCheckoutsAndFees();
41
4
    var barcodefield = $("#barcode");
42
    var barcodefield = $("#barcode");
5
    var issuesTable;
43
    var issuesTable;
6
44
Lines 65-70 $(document).ready(function() { Link Here
65
103
66
                content = "";
104
                content = "";
67
                if ( data.returned ) {
105
                if ( data.returned ) {
106
                    KOHA.Checkouts.UpdateCheckoutsAndFees(true);
68
                    content = CIRCULATION_RETURNED;
107
                    content = CIRCULATION_RETURNED;
69
                    $(id).parent().parent().addClass('ok');
108
                    $(id).parent().parent().addClass('ok');
70
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
109
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
Lines 97-102 $(document).ready(function() { Link Here
97
136
98
                var content = "";
137
                var content = "";
99
                if ( data.renew_okay ) {
138
                if ( data.renew_okay ) {
139
                    KOHA.Checkouts.UpdateCheckoutsAndFees();
100
                    issuesTable.api().ajax.reload();
140
                    issuesTable.api().ajax.reload();
101
                    content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
141
                    content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
102
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
142
                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
(-)a/members/moremember.pl (-8 lines)
Lines 120-133 my $error = $input->param('error'); Link Here
120
$template->param( error => $error ) if ( $error );
120
$template->param( error => $error ) if ( $error );
121
121
122
my $patron        = Koha::Patrons->find($borrowernumber);
122
my $patron        = Koha::Patrons->find($borrowernumber);
123
my $issues        = $patron->checkouts;
124
my $balance       = $patron->account->balance;
125
$template->param(
126
    issuecount => $issues->count,
127
    fines      => $balance,
128
);
129
130
131
my $data = GetMember( 'borrowernumber' => $borrowernumber );
123
my $data = GetMember( 'borrowernumber' => $borrowernumber );
132
124
133
if ( not defined $data ) {
125
if ( not defined $data ) {
(-)a/svc/patron/fines (-1 / +45 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2016 CatalystIT
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
23
use C4::Service;
24
use Koha::Patrons;
25
use Koha::Number::Price;
26
27
my ( $query, $response ) = C4::Service->init( borrowers => '*' );
28
29
my $borrowernumber = $query->param('borrowernumber')
30
  or return C4::Service->return_error('input', "No 'borrowernumber'");
31
my $patron = Koha::Patrons->find( $borrowernumber )
32
  or return C4::Service->return_error('input', "Invalid 'borrowernumber'", borrowernumber => $borrowernumber);
33
34
my $od     = $patron->get_overdues->count;
35
my $issues = $patron->checkouts->count;
36
my $owing  = $patron->account->balance;
37
38
$response->param(
39
    overduecount    => $od,
40
    issuecount      => $issues,
41
    owing           => $owing || 0.00,
42
    owing_formatted => Koha::Number::Price->new( $owing )->format,
43
);
44
45
C4::Service->return_success( $response );

Return to bug 14803