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 468-558 if ($patron) { Link Here
468
    );
470
    );
469
}
471
}
470
472
471
#title
473
if ( $patron ) {
472
my $flags = $patron ? C4::Members::patronflags( $patron->unblessed ) : {};
474
    my $noissues;
473
foreach my $flag ( sort keys %$flags ) {
475
    if ( $patron->gonenoaddress ) {
474
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
476
        $template->param( gna => 1 );
475
    if ( $flags->{$flag}->{'noissues'} ) {
477
        $noissues = 1;
478
    }
479
    if ( $patron->lost ) {
480
        $template->param( lost=> 1 );
481
        $noissues = 1;
482
    }
483
    if ( $patron->is_debarred ) {
484
        $template->param( dbarred=> 1 );
485
        $noissues = 1;
486
    }
487
    my $account = $patron->account;
488
    if( ( my $owing = $account->non_issues_charges ) > 0 ) {
489
        my $noissuescharge = C4::Context->preference("noissuescharge") || 5; # FIXME If noissuescharge == 0 then 5, why??
490
        $noissues = ( not C4::Context->preference("AllowFineOverride") and ( $owing > $noissuescharge ) );
476
        $template->param(
491
        $template->param(
477
            noissues => ($force_allow_issue) ? 0 : 'true',
492
            charges => 1,
478
            forceallow => $force_allow_issue,
493
            chargesamount => $owing,
494
        )
495
    } elsif ( $balance < 0 ) {
496
        $template->param(
497
            credits => 1,
498
            creditsamount => -$balance,
479
        );
499
        );
480
        if ( $flag eq 'GNA' ) {
481
            $template->param( gna => 'true' );
482
        }
483
        elsif ( $flag eq 'LOST' ) {
484
            $template->param( lost => 'true' );
485
        }
486
        elsif ( $flag eq 'DBARRED' ) {
487
            $template->param( dbarred => 'true' );
488
        }
489
        elsif ( $flag eq 'CHARGES' ) {
490
            $template->param(
491
                charges    => 'true',
492
                chargesmsg => $flags->{'CHARGES'}->{'message'},
493
                chargesamount => $flags->{'CHARGES'}->{'amount'},
494
                charges_is_blocker => 1
495
            );
496
        }
497
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
498
            $template->param(
499
                charges_guarantees    => 'true',
500
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
501
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
502
                charges_guarantees_is_blocker => 1
503
            );
504
        }
505
        elsif ( $flag eq 'CREDITS' ) {
506
            $template->param(
507
                credits    => 'true',
508
                creditsmsg => $flags->{'CREDITS'}->{'message'},
509
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
510
            );
511
        }
512
    }
500
    }
513
    else {
514
        if ( $flag eq 'CHARGES' ) {
515
            $template->param(
516
                charges    => 'true',
517
                chargesmsg => $flags->{'CHARGES'}->{'message'},
518
                chargesamount => $flags->{'CHARGES'}->{'amount'},
519
            );
520
        }
521
        elsif ( $flag eq 'CHARGES_GUARANTEES' ) {
522
            $template->param(
523
                charges_guarantees    => 'true',
524
                chargesmsg_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'message'},
525
                chargesamount_guarantees => $flags->{'CHARGES_GUARANTEES'}->{'amount'},
526
            );
527
        }
528
        elsif ( $flag eq 'CREDITS' ) {
529
            $template->param(
530
                credits    => 'true',
531
                creditsmsg => $flags->{'CREDITS'}->{'message'},
532
                creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
533
            );
534
        }
535
        elsif ( $flag eq 'ODUES' ) {
536
            $template->param(
537
                odues    => 'true',
538
                oduesmsg => $flags->{'ODUES'}->{'message'}
539
            );
540
501
541
            my $items = $flags->{$flag}->{'itemlist'};
502
    my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees");
542
            if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
503
    $no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees );
543
                $template->param( nonreturns => 'true' );
504
    if ( defined $no_issues_charge_guarantees ) {
544
            }
505
        my $guarantees_non_issues_charges = 0;
506
        my $guarantees = $patron->guarantees;
507
        while ( my $g = $guarantees->next ) {
508
            $guarantees_non_issues_charges += $g->account->non_issues_charges;
545
        }
509
        }
546
        elsif ( $flag eq 'NOTES' ) {
510
        if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees ) {
547
            $template->param(
511
            $template->param(
548
                notes    => 'true',
512
                charges_guarantees    => 1,
549
                notesmsg => $flags->{'NOTES'}->{'message'}
513
                chargesamount_guarantees => $guarantees_non_issues_charges,
550
            );
514
            );
515
            $noissues = 1 unless C4::Context->preference("allowfineoverride");
551
        }
516
        }
552
    }
517
    }
553
}
554
518
555
my $total = $patron ? $patron->account->balance : 0;
519
    if ( $patron->has_overdues ) {
520
        $template->param( odues => 1 );
521
    }
522
523
    if ( $patron->borrowernotes ) {
524
        my $borrowernotes = $patron->borrowernotes;
525
        $borrowernotes =~ s#\n#<br />#g;
526
        $template->param(
527
            notes =>1,
528
            notesmsg => $borrowernotes,
529
        )
530
    }
531
532
    if ( $noissues ) {
533
        $template->param(
534
            noissues => ($force_allow_issue) ? 0 : 'true',
535
            forceallow => $force_allow_issue,
536
        );
537
    }
538
}
556
539
557
if ( $patron && $patron->is_child) {
540
if ( $patron && $patron->is_child) {
558
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
541
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
Lines 634-640 $template->param( Link Here
634
    duedatespec       => $duedatespec,
617
    duedatespec       => $duedatespec,
635
    restoreduedatespec => $restoreduedatespec,
618
    restoreduedatespec => $restoreduedatespec,
636
    message           => $message,
619
    message           => $message,
637
    totaldue          => sprintf('%.2f', $total),
620
    totaldue          => sprintf('%.2f', $balance), # FIXME not used in template?
638
    inprocess         => $inprocess,
621
    inprocess         => $inprocess,
639
    $view             => 1,
622
    $view             => 1,
640
    batch_allowed     => $batch_allowed,
623
    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 patron and noissues and not checkout_infos %]
43
[% ELSIF patron 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