@@ -, +, @@ - update fines/checkouts info - show/hide checkouts form and messages --- circ/circulation.pl | 14 ----- .../prog/en/includes/blocked-fines.inc | 18 +++--- .../prog/en/includes/checkouts-table.inc | 7 +-- .../prog/en/modules/circ/circulation.tt | 72 ++++++++-------------- .../prog/en/modules/members/moremember.tt | 4 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 40 ++++++++++++ members/moremember.pl | 8 --- svc/patron/fines | 45 ++++++++++++++ 8 files changed, 125 insertions(+), 83 deletions(-) create mode 100755 svc/patron/fines --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -261,10 +261,6 @@ my $patron; if ($borrowernumber) { $patron = Koha::Patrons->find( $borrowernumber ); $borrower = GetMember( borrowernumber => $borrowernumber ); - my $overdues = $patron->get_overdues; - my $issues = $patron->checkouts; - my $balance = $patron->account->balance; - # if the expiry date is before today ie they have expired if ( $patron->is_expired ) { @@ -284,11 +280,6 @@ if ($borrowernumber) { $template->param("returnbeforeexpiry" => 1); } } - $template->param( - overduecount => $overdues->count, - issuecount => $issues->count, - finetotal => $balance, - ); if ( $patron and $patron->is_debarred ) { $template->param( @@ -415,11 +406,6 @@ if (@$barcodes) { itembiblionumber => $getmessageiteminfo->{'biblionumber'} ); - - # FIXME If the issue is confirmed, we launch another time checkouts->count, now display the issue count after issue - $patron = Koha::Patrons->find( $borrowernumber ); - $template_params->{issuecount} = $patron->checkouts->count; - if ( $iteminfo ) { $iteminfo->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($iteminfo->{biblionumber}), GetFrameworkCode($iteminfo->{biblionumber})); $template_params->{item} = $iteminfo; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc @@ -1,13 +1,15 @@ -[% USE Price %] -[% SET NoIssuesCharge = Koha.Preference('noissuescharge') %] -[% IF fines > 0 %] -
  • + +
  • -[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -1,6 +1,6 @@ [% USE Koha %]
    - [% IF ( issuecount ) %] + +
    --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -23,6 +23,9 @@ [% INCLUDE 'strings.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] + [% INCLUDE 'timepicker.inc' %] @@ -87,6 +90,10 @@ function toggle_onsite_checkout(){ function Dopop(link) { var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); } + +KOHA.Checkouts.DisallowIssue = [% noissues ? "true" : "false" %]; +KOHA.Checkouts.ForceAllowIssue = [% forceallow ? "true" : "false" %]; +KOHA.Checkouts.ForceOnSiteCheckouts = [% Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ? "true" : "false" %]; $(document).ready(function() { $('#mainform').on('submit',function() { if ($("#barcode") && $("#barcode").val()) { @@ -408,9 +415,7 @@ $(document).ready(function() { [% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %] - [% UNLESS noissues %] - - [% END %] + [% END %] [% END %] @@ -577,7 +582,6 @@ No patron matched [% message | html %]
    Error: This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.
    [% END %] -[% IF ( !noissues ) || ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') )%]
    @@ -614,7 +618,6 @@ No patron matched [% message | html %]
    - [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %] [% IF ( SpecifyDueDate ) %]
    Specify due date [% INCLUDE 'date-format.inc' %]:
    @@ -632,10 +635,8 @@ No patron matched [% message | html %]
    [% END %] - [% END %] - [% UNLESS ( noissues ) %] -
    +
    [% IF NEEDSCONFIRMATION %] [% ELSE %] @@ -662,19 +663,17 @@ No patron matched [% message | html %]
    [% END %] - [% END %] [% IF Koha.Preference('OnSiteCheckouts') %]
    - [% IF noissues %] -
    +
    - [% ELSE %] +
    - [% END %] +
    [% END %] @@ -696,35 +695,20 @@ No patron matched [% message | html %] [% END %]
    -[% END %] - -[% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
    - [% ELSE %] -
    - [% END %] -[% ELSE %]
    -[% END %] - - [% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
    - [% ELSE %] +
    +

    Attention:

    +
    + [% IF !( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]

    Checking out to [% INCLUDE 'patron-title.inc' %]

    -
    [% END %] -

    - Cannot check out! - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] - Only on-site checkouts are allowed - [% END %] -

    - [% ELSE %] -
    -

    Attention:

    - [% END %] +

    + Cannot check out! + [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] + Only on-site checkouts are allowed + [% END %] +

    +
      @@ -783,8 +767,8 @@ No patron matched [% message | html %] [% END %]
      View restrictions - [% IF (noissues && borrowernumber && CAN_user_circulate_force_checkout) %] - + [% IF (borrowernumber && CAN_user_circulate_force_checkout) %] + Override restriction temporarily [% END %] @@ -884,11 +868,7 @@ No patron matched [% message | html %]
      • - [% IF ( issuecount ) %] - [% issuecount %] Checkout(s) - [% ELSE %] - 0 Checkouts - [% END %] + 0 Checkout(s)
      • [% IF relatives_issues_count %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -179,13 +179,11 @@ function validate1(date) { [% ELSE %] [% IF ( was_renewed ) %]
        Patron's account has been renewed until [% dateexpiry | $KohaDates %]
        [% END %] - [% IF fines %]
          [% INCLUDE 'blocked-fines.inc' %]
        - [% END %] [% IF ( flagged ) %]
        @@ -501,7 +499,7 @@ function validate1(date) {
          -
        • [% issuecount %] Checkout(s)
        • +
        • 0 Checkout(s)
        • [% IF relatives_issues_count %]
        • Relatives' checkouts
        • [% END %] --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,6 +1,44 @@ +if ( KOHA === undefined ) var KOHA = {}; +KOHA.Checkouts = { + NoIssuesCharge: null, + BorrowerNumber: null, + DisallowIssue: false, + ForceAllowIssue: false, + ForceOnSiteCheckouts: false, + ToggleInput: function( allow_issue ) { + if (KOHA.Checkouts.DisallowIssue) allow_issue = false; + if (KOHA.Checkouts.ForceAllowIssue) allow_issue = true; + + $(".issue-allow").toggle(allow_issue); + $(".issue-disallow").toggle(!allow_issue); + $("#mainform").toggle(allow_issue || KOHA.Checkouts.ForceOnSiteCheckouts); + + if (!allow_issue) { + $(".circmessage.attention").removeClass("attention").addClass("warning"); + } + }, + UpdateCheckoutsAndFees: function(checkouts_only=false) { + $.get( "/cgi-bin/koha/svc/patron/fines", {borrowernumber: KOHA.Checkouts.BorrowerNumber}, function( data ) { + $("#issuecount").text(data.issuecount); + var has_checkouts = data.issuecount > 0; + $(".has-checkouts").toggle(has_checkouts); + $(".no-checkouts").toggle(!has_checkouts); + if (checkouts_only) return; + + var noissue = KOHA.Checkouts.NoIssuesCharge !== null && data.owing >= KOHA.Checkouts.NoIssuesCharge; + $("#outstanding-fees").toggle(data.owing > 0); + $("#outstanding-fees-amount").text(data.owing_formatted); + $("#outstanding-fees-over-limit").toggle(noissue); + KOHA.Checkouts.ToggleInput(!noissue); + } ); + } +} + $(document).ready(function() { $.ajaxSetup ({ cache: false }); + KOHA.Checkouts.UpdateCheckoutsAndFees(); + var barcodefield = $("#barcode"); var issuesTable; @@ -65,6 +103,7 @@ $(document).ready(function() { content = ""; if ( data.returned ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(true); content = CIRCULATION_RETURNED; $(id).parent().parent().addClass('ok'); $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED); @@ -97,6 +136,7 @@ $(document).ready(function() { var content = ""; if ( data.renew_okay ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(); issuesTable.api().ajax.reload(); content = CIRCULATION_RENEWED_DUE + " " + data.date_due; $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); --- a/members/moremember.pl +++ a/members/moremember.pl @@ -120,14 +120,6 @@ my $error = $input->param('error'); $template->param( error => $error ) if ( $error ); my $patron = Koha::Patrons->find($borrowernumber); -my $issues = $patron->checkouts; -my $balance = $patron->account->balance; -$template->param( - issuecount => $issues->count, - fines => $balance, -); - - my $data = GetMember( 'borrowernumber' => $borrowernumber ); if ( not defined $data ) { --- a/svc/patron/fines +++ a/svc/patron/fines @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# Copyright 2016 CatalystIT +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +use C4::Service; +use Koha::Patrons; +use Koha::Number::Price; + +my ( $query, $response ) = C4::Service->init( borrowers => '*' ); + +my $borrowernumber = $query->param('borrowernumber') + or return C4::Service->return_error('input', "No 'borrowernumber'"); +my $patron = Koha::Patrons->find( $borrowernumber ) + or return C4::Service->return_error('input', "Invalid 'borrowernumber'", borrowernumber => $borrowernumber); + +my $od = $patron->get_overdues->count; +my $issues = $patron->checkouts->count; +my $owing = $patron->account->balance; + +$response->param( + overduecount => $od, + issuecount => $issues, + owing => $owing || 0.00, + owing_formatted => Koha::Number::Price->new( $owing )->format, +); + +C4::Service->return_success( $response ); --