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

(-)a/C4/Members.pm (+1 lines)
Lines 173-178 The "message" field that comes from the DB is OK. Link Here
173
173
174
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
174
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
175
# FIXME rename this function.
175
# FIXME rename this function.
176
# DEPRECATED Do not use this subroutine!
176
sub patronflags {
177
sub patronflags {
177
    my %flags;
178
    my %flags;
178
    my ( $patroninformation) = @_;
179
    my ( $patroninformation) = @_;
(-)a/C4/SIP/ILS/Patron.pm (-7 / +11 lines)
Lines 32-49 sub new { Link Here
32
    my ($class, $patron_id) = @_;
32
    my ($class, $patron_id) = @_;
33
    my $type = ref($class) || $class;
33
    my $type = ref($class) || $class;
34
    my $self;
34
    my $self;
35
    $kp = Koha::Patrons->find( { cardnumber => $patron_id } )
35
    my $patron = Koha::Patrons->find( { cardnumber => $patron_id } )
36
      or Koha::Patrons->find( { userid => $patron_id } );
36
      or Koha::Patrons->find( { userid => $patron_id } );
37
    $debug and warn "new Patron: " . Dumper($kp->unblessed) if $kp;
37
    $debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron;
38
    unless ($kp) {
38
    unless ($patron) {
39
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
39
        syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
40
        return;
40
        return;
41
    }
41
    }
42
    $kp = $kp->unblessed;
42
    $kp = $patron->unblessed;
43
    my $pw        = $kp->{password};
43
    my $pw        = $kp->{password};
44
    my $flags     = C4::Members::patronflags( $kp );
44
    my $flags     = C4::Members::patronflags( $kp );
45
    my $debarred  = defined($flags->{DBARRED});
45
    my $debarred  = $patron->is_debarred;
46
    $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%$flags);
46
    $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here?
47
    my ($day, $month, $year) = (localtime)[3,4,5];
47
    my ($day, $month, $year) = (localtime)[3,4,5];
48
    my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
48
    my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
49
    my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
49
    my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
Lines 59-65 sub new { Link Here
59
    $dob and $dob =~ s/-//g;    # YYYYMMDD
59
    $dob and $dob =~ s/-//g;    # YYYYMMDD
60
    my $dexpiry     = $kp->{dateexpiry};
60
    my $dexpiry     = $kp->{dateexpiry};
61
    $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
61
    $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
62
    my $fines_amount = $flags->{CHARGES}->{amount};
62
    my $fines_amount = $patron->account->balance;
63
    $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
63
    $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
64
    my $fee_limit = _fee_limit();
64
    my $fee_limit = _fee_limit();
65
    my $fine_blocked = $fines_amount > $fee_limit;
65
    my $fine_blocked = $fines_amount > $fee_limit;
Lines 107-112 sub new { Link Here
107
    );
107
    );
108
    }
108
    }
109
    $debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
109
    $debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
110
111
    if ( $patron->is_debarred and $patron->debarredcomment ) {
112
        $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
113
    }
110
    for (qw(EXPIRED CHARGES CREDITS GNA LOST DBARRED NOTES)) {
114
    for (qw(EXPIRED CHARGES CREDITS GNA LOST DBARRED NOTES)) {
111
        ($flags->{$_}) or next;
115
        ($flags->{$_}) or next;
112
        if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
116
        if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
(-)a/circ/circulation.pl (-77 / +60 lines)
Lines 29-34 use warnings; Link Here
29
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
30
use DateTime;
30
use DateTime;
31
use DateTime::Duration;
31
use DateTime::Duration;
32
use Scalar::Util qw( looks_like_number );
32
use C4::Output;
33
use C4::Output;
33
use C4::Print;
34
use C4::Print;
34
use C4::Auth qw/:DEFAULT get_session haspermission/;
35
use C4::Auth qw/:DEFAULT get_session haspermission/;
Lines 261-271 if ($findborrower) { Link Here
261
}
262
}
262
263
263
# get the borrower information.....
264
# get the borrower information.....
265
my $balance = 0;
264
$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
266
$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
265
if ($patron) {
267
if ($patron) {
266
    my $overdues = $patron->get_overdues;
268
    my $overdues = $patron->get_overdues;
267
    my $issues = $patron->checkouts;
269
    my $issues = $patron->checkouts;
268
    my $balance = $patron->account->balance;
270
    $balance = $patron->account->balance;
269
271
270
272
271
    # if the expiry date is before today ie they have expired
273
    # if the expiry date is before today ie they have expired
Lines 456-546 if ($patron) { Link Here
456
    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
458
    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
457
}
459
}
458
460
459
#title
461
if ( $patron ) {
460
my $flags = $patron ? C4::Members::patronflags( $patron->unblessed ) : {};
462
    my $noissues;
461
foreach my $flag ( sort keys %$flags ) {
463
    if ( $patron->gonenoaddress ) {
462
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
464
        $template->param( gna => 1 );
463
    if ( $flags->{$flag}->{'noissues'} ) {
465
        $noissues = 1;
466
    }
467
    if ( $patron->lost ) {
468
        $template->param( lost=> 1 );
469
        $noissues = 1;
470
    }
471
    if ( $patron->is_debarred ) {
472
        $template->param( dbarred=> 1 );
473
        $noissues = 1;
474
    }
475
    my $account = $patron->account;
476
    if( ( my $owing = $account->non_issues_charges ) > 0 ) {
477
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5; # FIXME If noissuescharge == 0 then 5, why??
478
        $noissues = ( not C4::Context->preference("AllowFineOverride") and ( $owing > $noissuescharge ) );
464
        $template->param(
479
        $template->param(
465
            noissues => ($force_allow_issue) ? 0 : 'true',
480
            charges => 1,
466
            forceallow => $force_allow_issue,
481
            chargesamount => $owing,
482
        )
483
    } elsif ( $balance < 0 ) {
484
        $template->param(
485
            credits => 1,
486
            creditsamount => -$balance,
467
        );
487
        );
468
        if ( $flag eq 'GNA' ) {
469
            $template->param( gna => 'true' );
470
        }
471
        elsif ( $flag eq 'LOST' ) {
472
            $template->param( lost => 'true' );
473
        }
474
        elsif ( $flag eq 'DBARRED' ) {
475
            $template->param( dbarred => 'true' );
476
        }
477
        elsif ( $flag eq 'CHARGES' ) {
478
            $template->param(
479
                charges    => 'true',
480
                chargesmsg => $flags->{'CHARGES'}->{'message'},
481
                chargesamount => $flags->{'CHARGES'}->{'amount'},
482
                charges_is_blocker => 1
483
            );
484
        }
485
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
486
            $template->param(
487
                charges_guarantees    => 'true',
488
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
489
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
490
                charges_guarantees_is_blocker => 1
491
            );
492
        }
493
        elsif ( $flag eq 'CREDITS' ) {
494
            $template->param(
495
                credits    => 'true',
496
                creditsmsg => $flags->{'CREDITS'}->{'message'},
497
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
498
            );
499
        }
500
    }
488
    }
501
    else {
502
        if ( $flag eq 'CHARGES' ) {
503
            $template->param(
504
                charges    => 'true',
505
                chargesmsg => $flags->{'CHARGES'}->{'message'},
506
                chargesamount => $flags->{'CHARGES'}->{'amount'},
507
            );
508
        }
509
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
510
            $template->param(
511
                charges_guarantees    => 'true',
512
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
513
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
514
            );
515
        }
516
        elsif ( $flag eq 'CREDITS' ) {
517
            $template->param(
518
                credits    => 'true',
519
                creditsmsg => $flags->{'CREDITS'}->{'message'},
520
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
521
            );
522
        }
523
        elsif ( $flag eq 'ODUES' ) {
524
            $template->param(
525
                odues    => 'true',
526
                oduesmsg => $flags->{'ODUES'}->{'message'}
527
            );
528
489
529
            my $items = $flags->{$flag}->{'itemlist'};
490
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
530
            if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
491
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
531
                $template->param( nonreturns => 'true' );
492
    if ( defined $no_issues_charge_guarantees ) {
532
            }
493
        my $guarantees_non_issues_charges = 0;
494
        my $guarantees = $patron->guarantees;
495
        while ( my $g = $guarantees->next ) {
496
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
533
        }
497
        }
534
        elsif ( $flag eq 'NOTES' ) {
498
        if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees ) {
535
            $template->param(
499
            $template->param(
536
                notes    => 'true',
500
                charges_guarantees    => 1,
537
                notesmsg => $flags->{'NOTES'}->{'message'}
501
                chargesamount_guarantees => $guarantees_non_issues_charges,
538
            );
502
            );
503
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
539
        }
504
        }
540
    }
505
    }
541
}
542
506
543
my $total = $patron ? $patron->account->balance : 0;
507
    if ( $patron->has_overdues ) {
508
        $template->param( odues => 1 );
509
    }
510
511
    if ( $patron->borrowernotes ) {
512
        my $borrowernotes = $patron->borrowernotes;
513
        $borrowernotes =~ s#\n#<br />#g;
514
        $template->param(
515
            notes =>1,
516
            notesmsg => $borrowernotes,
517
        )
518
    }
519
520
    if ( $noissues ) {
521
        $template->param(
522
            noissues => ($force_allow_issue) ? 0 : 'true',
523
            forceallow => $force_allow_issue,
524
        );
525
    }
526
}
544
527
545
if ( $patron && $patron->category->category_type eq 'C') {
528
if ( $patron && $patron->category->category_type eq 'C') {
546
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
529
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
Lines 626-632 $template->param( Link Here
626
    duedatespec       => $duedatespec,
609
    duedatespec       => $duedatespec,
627
    restoreduedatespec => $restoreduedatespec,
610
    restoreduedatespec => $restoreduedatespec,
628
    message           => $message,
611
    message           => $message,
629
    totaldue          => sprintf('%.2f', $total),
612
    totaldue          => sprintf('%.2f', $balance), # FIXME not used in template?
630
    inprocess         => $inprocess,
613
    inprocess         => $inprocess,
631
    $view             => 1,
614
    $view             => 1,
632
    batch_allowed     => $batch_allowed,
615
    batch_allowed     => $batch_allowed,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-3 / +3 lines)
Lines 832-838 No patron matched <span class="ex">[% message | html %]</span> Link Here
832
               </li>
832
               </li>
833
            [% END %]
833
            [% END %]
834
834
835
                [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE.</span> <a href="#checkouts">See highlighted items below</a>[% END %]</li>
835
                [% IF ( odues ) %]<li><span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE.</span> <a href="#checkouts">See highlighted items below</a></li>
836
            [% END %]
836
            [% END %]
837
837
838
            [% IF ( charges ) %]
838
            [% IF ( charges ) %]
Lines 842-848 No patron matched <span class="ex">[% message | html %]</span> Link Here
842
            [% IF ( charges_guarantees ) %]
842
            [% IF ( charges_guarantees ) %]
843
                <li>
843
                <li>
844
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
844
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
845
                        [% IF ( charges_guarantees_is_blocker ) %]
845
                        [% IF noissues %]
846
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
846
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
847
                        [% END %]
847
                        [% END %]
848
                </li>
848
                </li>
Lines 851-857 No patron matched <span class="ex">[% message | html %]</span> Link Here
851
851
852
            [% IF ( credits ) %]
852
            [% IF ( credits ) %]
853
                <li>
853
                <li>
854
                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %]
854
                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount | $Price %][% END %]
855
                </li>
855
                </li>
856
            [% END %]
856
            [% END %]
857
857
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt (-3 / +2 lines)
Lines 43-52 Link Here
43
[% ELSIF borrower and noissues and not checkout_infos %]
43
[% ELSIF borrower and noissues and not checkout_infos %]
44
  <div class="dialog alert">
44
  <div class="dialog alert">
45
    Cannot check out!
45
    Cannot check out!
46
    [% IF charges_is_blocker %]
46
    [% IF charges %]
47
      <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
47
      <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
48
    [% END %]
48
    [% END %]
49
    [% IF charges_guarantees_is_blocker %]
49
    [% IF charges_guarantees %]
50
        <li>
50
        <li>
51
            <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
51
            <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
52
        </li>
52
        </li>
53
- 

Return to bug 19933