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

(-)a/C4/Members.pm (+1 lines)
Lines 172-177 The "message" field that comes from the DB is OK. Link Here
172
172
173
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
173
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
174
# FIXME rename this function.
174
# FIXME rename this function.
175
# DEPRECATED Do not use this subroutine!
175
sub patronflags {
176
sub patronflags {
176
    my %flags;
177
    my %flags;
177
    my ( $patroninformation) = @_;
178
    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 28-33 use Modern::Perl; Link Here
28
use CGI qw ( -utf8 );
28
use CGI qw ( -utf8 );
29
use DateTime;
29
use DateTime;
30
use DateTime::Duration;
30
use DateTime::Duration;
31
use Scalar::Util qw( looks_like_number );
31
use C4::Output;
32
use C4::Output;
32
use C4::Print;
33
use C4::Print;
33
use C4::Auth qw/:DEFAULT get_session haspermission/;
34
use C4::Auth qw/:DEFAULT get_session haspermission/;
Lines 272-277 if ($findborrower) { Link Here
272
}
273
}
273
274
274
# get the borrower information.....
275
# get the borrower information.....
276
my $balance = 0;
275
$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
277
$patron ||= Koha::Patrons->find( $borrowernumber ) if $borrowernumber;
276
if ($patron) {
278
if ($patron) {
277
279
Lines 280-286 if ($patron) { Link Here
280
282
281
    my $overdues = $patron->get_overdues;
283
    my $overdues = $patron->get_overdues;
282
    my $issues = $patron->checkouts;
284
    my $issues = $patron->checkouts;
283
    my $balance = $patron->account->balance;
285
    $balance = $patron->account->balance;
284
286
285
287
286
    # if the expiry date is before today ie they have expired
288
    # if the expiry date is before today ie they have expired
Lines 471-561 if ($patron) { Link Here
471
    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
473
    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
472
}
474
}
473
475
474
#title
476
if ( $patron ) {
475
my $flags = $patron ? C4::Members::patronflags( $patron->unblessed ) : {};
477
    my $noissues;
476
foreach my $flag ( sort keys %$flags ) {
478
    if ( $patron->gonenoaddress ) {
477
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
479
        $template->param( gna => 1 );
478
    if ( $flags->{$flag}->{'noissues'} ) {
480
        $noissues = 1;
481
    }
482
    if ( $patron->lost ) {
483
        $template->param( lost=> 1 );
484
        $noissues = 1;
485
    }
486
    if ( $patron->is_debarred ) {
487
        $template->param( dbarred=> 1 );
488
        $noissues = 1;
489
    }
490
    my $account = $patron->account;
491
    if( ( my $owing = $account->non_issues_charges ) > 0 ) {
492
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5; # FIXME If noissuescharge == 0 then 5, why??
493
        $noissues = ( not C4::Context->preference("AllowFineOverride") and ( $owing > $noissuescharge ) );
479
        $template->param(
494
        $template->param(
480
            noissues => ($force_allow_issue) ? 0 : 'true',
495
            charges => 1,
481
            forceallow => $force_allow_issue,
496
            chargesamount => $owing,
497
        )
498
    } elsif ( $balance < 0 ) {
499
        $template->param(
500
            credits => 1,
501
            creditsamount => -$balance,
482
        );
502
        );
483
        if ( $flag eq 'GNA' ) {
484
            $template->param( gna => 'true' );
485
        }
486
        elsif ( $flag eq 'LOST' ) {
487
            $template->param( lost => 'true' );
488
        }
489
        elsif ( $flag eq 'DBARRED' ) {
490
            $template->param( dbarred => 'true' );
491
        }
492
        elsif ( $flag eq 'CHARGES' ) {
493
            $template->param(
494
                charges    => 'true',
495
                chargesmsg => $flags->{'CHARGES'}->{'message'},
496
                chargesamount => $flags->{'CHARGES'}->{'amount'},
497
                charges_is_blocker => 1
498
            );
499
        }
500
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
501
            $template->param(
502
                charges_guarantees    => 'true',
503
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
504
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
505
                charges_guarantees_is_blocker => 1
506
            );
507
        }
508
        elsif ( $flag eq 'CREDITS' ) {
509
            $template->param(
510
                credits    => 'true',
511
                creditsmsg => $flags->{'CREDITS'}->{'message'},
512
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
513
            );
514
        }
515
    }
503
    }
516
    else {
517
        if ( $flag eq 'CHARGES' ) {
518
            $template->param(
519
                charges    => 'true',
520
                chargesmsg => $flags->{'CHARGES'}->{'message'},
521
                chargesamount => $flags->{'CHARGES'}->{'amount'},
522
            );
523
        }
524
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
525
            $template->param(
526
                charges_guarantees    => 'true',
527
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
528
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
529
            );
530
        }
531
        elsif ( $flag eq 'CREDITS' ) {
532
            $template->param(
533
                credits    => 'true',
534
                creditsmsg => $flags->{'CREDITS'}->{'message'},
535
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
536
            );
537
        }
538
        elsif ( $flag eq 'ODUES' ) {
539
            $template->param(
540
                odues    => 'true',
541
                oduesmsg => $flags->{'ODUES'}->{'message'}
542
            );
543
504
544
            my $items = $flags->{$flag}->{'itemlist'};
505
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
545
            if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
506
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
546
                $template->param( nonreturns => 'true' );
507
    if ( defined $no_issues_charge_guarantees ) {
547
            }
508
        my $guarantees_non_issues_charges = 0;
509
        my $guarantees = $patron->guarantees;
510
        while ( my $g = $guarantees->next ) {
511
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
548
        }
512
        }
549
        elsif ( $flag eq 'NOTES' ) {
513
        if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees ) {
550
            $template->param(
514
            $template->param(
551
                notes    => 'true',
515
                charges_guarantees    => 1,
552
                notesmsg => $flags->{'NOTES'}->{'message'}
516
                chargesamount_guarantees => $guarantees_non_issues_charges,
553
            );
517
            );
518
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
554
        }
519
        }
555
    }
520
    }
556
}
557
521
558
my $total = $patron ? $patron->account->balance : 0;
522
    if ( $patron->has_overdues ) {
523
        $template->param( odues => 1 );
524
    }
525
526
    if ( $patron->borrowernotes ) {
527
        my $borrowernotes = $patron->borrowernotes;
528
        $borrowernotes =~ s#\n#<br />#g;
529
        $template->param(
530
            notes =>1,
531
            notesmsg => $borrowernotes,
532
        )
533
    }
534
535
    if ( $noissues ) {
536
        $template->param(
537
            noissues => ($force_allow_issue) ? 0 : 'true',
538
            forceallow => $force_allow_issue,
539
        );
540
    }
541
}
559
542
560
if ( $patron && $patron->category->category_type eq 'C') {
543
if ( $patron && $patron->category->category_type eq 'C') {
561
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
544
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
Lines 641-647 $template->param( Link Here
641
    duedatespec       => $duedatespec,
624
    duedatespec       => $duedatespec,
642
    restoreduedatespec => $restoreduedatespec,
625
    restoreduedatespec => $restoreduedatespec,
643
    message           => $message,
626
    message           => $message,
644
    totaldue          => sprintf('%.2f', $total),
627
    totaldue          => sprintf('%.2f', $balance), # FIXME not used in template?
645
    inprocess         => $inprocess,
628
    inprocess         => $inprocess,
646
    $view             => 1,
629
    $view             => 1,
647
    batch_allowed     => $batch_allowed,
630
    batch_allowed     => $batch_allowed,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-3 / +3 lines)
Lines 707-713 No patron matched <span class="ex">[% message | html %]</span> Link Here
707
               </li>
707
               </li>
708
            [% END %]
708
            [% END %]
709
709
710
                [% 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>
710
                [% IF ( odues ) %]<li><span class="circ-hlt">Overdues: Patron has ITEMS OVERDUE.</span> <a href="#checkouts">See highlighted items below</a></li>
711
            [% END %]
711
            [% END %]
712
712
713
            [% IF ( charges ) %]
713
            [% IF ( charges ) %]
Lines 717-723 No patron matched <span class="ex">[% message | html %]</span> Link Here
717
            [% IF ( charges_guarantees ) %]
717
            [% IF ( charges_guarantees ) %]
718
                <li>
718
                <li>
719
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
719
                    <span class="circ-hlt">Fees &amp; Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
720
                        [% IF ( charges_guarantees_is_blocker ) %]
720
                        [% IF noissues %]
721
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
721
                            <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
722
                        [% END %]
722
                        [% END %]
723
                </li>
723
                </li>
Lines 726-732 No patron matched <span class="ex">[% message | html %]</span> Link Here
726
726
727
            [% IF ( credits ) %]
727
            [% IF ( credits ) %]
728
                <li>
728
                <li>
729
                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount %][% END %]
729
                    <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of [% creditsamount | $Price %][% END %]
730
                </li>
730
                </li>
731
            [% END %]
731
            [% END %]
732
732
(-)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