@@ -, +, @@ - update fines/checkouts info - show/hide checkouts form and messages --- circ/circulation.pl | 27 -------- .../prog/en/includes/blocked-fines.inc | 14 ++-- .../prog/en/includes/checkouts-table.inc | 7 +- .../intranet-tmpl/prog/en/includes/checkouts.inc | 11 ++++ .../prog/en/modules/circ/circulation.tt | 74 ++++++++-------------- .../prog/en/modules/members/moremember.tt | 6 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 43 ++++++++++++- members/moremember.pl | 2 - svc/patron/fines | 45 +++++++++++++ 9 files changed, 133 insertions(+), 96 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.inc create mode 100755 svc/patron/fines --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -273,18 +273,12 @@ if ($findborrower) { } # get the borrower information..... -my $balance = 0; $patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber; if ($patron) { $template->param( borrowernumber => $patron->borrowernumber ); output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); - my $overdues = $patron->get_overdues; - my $issues = $patron->checkouts; - $balance = $patron->account->balance; - - # if the expiry date is before today ie they have expired if ( $patron->is_expired ) { #borrowercard expired, no issues @@ -303,11 +297,6 @@ if ($patron) { $template->param("returnbeforeexpiry" => 1); } } - $template->param( - overduecount => $overdues->count, - issuecount => $issues->count, - finetotal => $balance, - ); if ( $patron and $patron->is_debarred ) { $template->param( @@ -434,7 +423,6 @@ if (@$barcodes) { ); } - # 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; @@ -484,20 +472,6 @@ if ( $patron ) { $template->param( dbarred=> 1 ); $noissues = 1; } - my $account = $patron->account; - if( ( my $owing = $account->non_issues_charges ) > 0 ) { - my $noissuescharge = C4::Context->preference("noissuescharge") || 5; # FIXME If noissuescharge == 0 then 5, why?? - $noissues = ( not C4::Context->preference("AllowFineOverride") and ( $owing > $noissuescharge ) ); - $template->param( - charges => 1, - chargesamount => $owing, - ) - } elsif ( $balance < 0 ) { - $template->param( - credits => 1, - creditsamount => -$balance, - ); - } my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); @@ -617,7 +591,6 @@ $template->param( duedatespec => $duedatespec, restoreduedatespec => $restoreduedatespec, message => $message, - totaldue => sprintf('%.2f', $balance), # FIXME not used in template? inprocess => $inprocess, $view => 1, batch_allowed => $batch_allowed, --- 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,11 @@ -[% USE Price %] -[% SET NoIssuesCharge = Koha.Preference('noissuescharge') %] -[% IF fines and 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/includes/checkouts.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.inc @@ -0,0 +1,11 @@ +[% USE Koha %] + + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -16,6 +16,11 @@ [% INCLUDE 'doc-head-close.inc' %] +[% show_barcode_input = (Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce')) || !noissues || forceallow %] + @@ -288,9 +293,7 @@ [% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %] - [% UNLESS noissues %] - [% END %] [% END %] [% END %] @@ -494,7 +497,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') )%]
    @@ -531,7 +533,6 @@ No patron matched [% message | html %]
    - [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %] [% IF ( SpecifyDueDate ) %]
    Specify due date [% INCLUDE 'date-format.inc' %]:
    @@ -549,10 +550,8 @@ No patron matched [% message | html %]
    [% END %] - [% END %] - [% UNLESS ( noissues ) %] -
    +
    [% IF NEEDSCONFIRMATION %] [% ELSE %] @@ -579,19 +578,17 @@ No patron matched [% message | html %]
    [% END %] - [% END %] [% IF Koha.Preference('OnSiteCheckouts') %]
    - [% IF noissues %] -
    +
    - [% ELSE %] +
    - [% END %] +
    [% END %] @@ -612,35 +609,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 %] +

    +
      @@ -699,8 +681,8 @@ No patron matched [% message | html %] [% END %]
      View restrictions - [% IF (noissues && patron && CAN_user_circulate_force_checkout) %] - + [% IF (borrowernumber && CAN_user_circulate_force_checkout) %] + Override restriction temporarily [% END %] @@ -710,9 +692,7 @@ No patron matched [% message | html %] [% IF ( odues ) %]
    • Overdues: Patron has ITEMS OVERDUE. See highlighted items below
    • [% END %] - [% IF ( charges ) %] - [% INCLUDE 'blocked-fines.inc' fines = chargesamount %] - [% END %] + [% INCLUDE 'blocked-fines.inc' %] [% IF ( charges_guarantees ) %]
    • @@ -798,11 +778,7 @@ No patron matched [% message | html %]
      • - [% IF ( issuecount ) %] - [% issuecount %] Checkout(s) - [% ELSE %] - 0 Checkouts - [% END %] + 0 Checkout(s)
      • [% IF relatives_issues_count %] @@ -980,7 +956,7 @@ No patron matched [% message | html %] [% INCLUDE 'timepicker.inc' %] - + [% INCLUDE 'checkouts.inc' %] - + [% INCLUDE 'checkouts.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,6 +1,43 @@ +if ( KOHA === undefined ) var KOHA = {}; +KOHA.Checkouts = { + BorrowerNumber: null, + NoIssuesCharge: null, + AllowFineOverride: false, + DisallowIssue: false, + ForceOnSiteCheckouts: false, + ToggleInput: function( allow_issue ) { + if (KOHA.Checkouts.AllowFineOverride) allow_issue = true; + if (KOHA.Checkouts.DisallowIssue) allow_issue = false; + + $(".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() { + $.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); + + 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; @@ -76,7 +113,7 @@ $(document).ready(function() { content = ""; if ( data.returned ) { content = CIRCULATION_RETURNED; - $(id).parent().parent().addClass('ok'); + $(id).parent().parent().addClass('ok').find('.renew-td').text(''); $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED); if ( data.patronnote != null ) { $('.patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote); @@ -110,6 +147,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 ); @@ -429,7 +467,8 @@ $(document).ready(function() { content += ""; return content; - } + }, + "sClass": "renew-td" }, { "bSortable": false, --- a/members/moremember.pl +++ a/members/moremember.pl @@ -129,10 +129,8 @@ if ( $userenv and $userenv->{number} ) { # Allow DB user to create a superlibrar } my $issues = $patron->checkouts; -my $balance = $patron->account->balance; $template->param( issuecount => $issues->count, - fines => $balance, ); my $category_type = $patron->category->category_type; --- 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 ); --