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

(-)a/C4/Circulation.pm (-4 / +6 lines)
Lines 719-732 sub CanBookBeIssued { Link Here
719
        ModDateLastSeen( $item->{'itemnumber'} );
719
        ModDateLastSeen( $item->{'itemnumber'} );
720
        return( { STATS => 1 }, {});
720
        return( { STATS => 1 }, {});
721
    }
721
    }
722
    if ( ref $borrower->{flags} ) {
722
723
        if ( $borrower->{flags}->{GNA} ) {
723
    my $flags = C4::Members::patronflags( $borrower );
724
    if ( ref $flags ) {
725
        if ( $flags->{GNA} ) {
724
            $issuingimpossible{GNA} = 1;
726
            $issuingimpossible{GNA} = 1;
725
        }
727
        }
726
        if ( $borrower->{flags}->{'LOST'} ) {
728
        if ( $flags->{'LOST'} ) {
727
            $issuingimpossible{CARD_LOST} = 1;
729
            $issuingimpossible{CARD_LOST} = 1;
728
        }
730
        }
729
        if ( $borrower->{flags}->{'DBARRED'} ) {
731
        if ( $flags->{'DBARRED'} ) {
730
            $issuingimpossible{DEBARRED} = 1;
732
            $issuingimpossible{DEBARRED} = 1;
731
        }
733
        }
732
    }
734
    }
(-)a/C4/ILSDI/Services.pm (-3 / +3 lines)
Lines 361-374 sub GetPatronInfo { Link Here
361
361
362
    # Get Member details
362
    # Get Member details
363
    my $borrowernumber = $cgi->param('patron_id');
363
    my $borrowernumber = $cgi->param('patron_id');
364
    my $borrower = GetMemberDetails( $borrowernumber );
364
    my $borrower = GetMember( borrowernumber => $borrowernumber );
365
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
365
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
366
366
367
    # Cleaning the borrower hashref
367
    # Cleaning the borrower hashref
368
    $borrower->{'charges'}    = $borrower->{'flags'}->{'CHARGES'}->{'amount'};
368
    my $flags = C4::Members::patronflags( $borrower );
369
    $borrower->{'charges'}    = $flags>{'CHARGES'}->{'amount'};
369
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
370
    my $library = Koha::Libraries->find( $borrower->{branchcode} );
370
    $borrower->{'branchname'} = $library ? $library->branchname : '';
371
    $borrower->{'branchname'} = $library ? $library->branchname : '';
371
    delete $borrower->{'flags'};
372
    delete $borrower->{'userid'};
372
    delete $borrower->{'userid'};
373
    delete $borrower->{'password'};
373
    delete $borrower->{'password'};
374
374
(-)a/C4/Members.pm (-16 lines)
Lines 136-153 number. Link Here
136
136
137
C<$borrower> is a reference-to-hash whose keys are the fields of the
137
C<$borrower> is a reference-to-hash whose keys are the fields of the
138
borrowers table in the Koha database. In addition,
138
borrowers table in the Koha database. In addition,
139
C<$borrower-E<gt>{flags}> is a hash giving more detailed information
140
about the patron. Its keys act as flags :
141
142
    if $borrower->{flags}->{LOST} {
143
        # Patron's card was reported lost
144
    }
145
146
If the state of a flag means that the patron should not be
147
allowed to borrow any more books, then it will have a C<noissues> key
148
with a true value.
149
150
See patronflags for more details.
151
139
152
=cut
140
=cut
153
141
Lines 188-196 sub GetMemberDetails { Link Here
188
    my $borrower = $sth->fetchrow_hashref;
176
    my $borrower = $sth->fetchrow_hashref;
189
    return unless $borrower;
177
    return unless $borrower;
190
178
191
    my $flags = patronflags( $borrower);
192
    $borrower->{'flags'}     = $flags;
193
194
    $borrower->{'is_expired'} = 0;
179
    $borrower->{'is_expired'} = 0;
195
    $borrower->{'is_expired'} = 1 if
180
    $borrower->{'is_expired'} = 1 if
196
      defined($borrower->{dateexpiry}) &&
181
      defined($borrower->{dateexpiry}) &&
Lines 499-505 sub ModMember { Link Here
499
    my $schema = Koha::Database->new()->schema;
484
    my $schema = Koha::Database->new()->schema;
500
    my @columns = $schema->source('Borrower')->columns;
485
    my @columns = $schema->source('Borrower')->columns;
501
    my $new_borrower = { map { join(' ', @columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) };
486
    my $new_borrower = { map { join(' ', @columns) =~ /$_/ ? ( $_ => $data{$_} ) : () } keys(%data) };
502
    delete $new_borrower->{flags};
503
487
504
    $new_borrower->{dateofbirth}     ||= undef if exists $new_borrower->{dateofbirth};
488
    $new_borrower->{dateofbirth}     ||= undef if exists $new_borrower->{dateofbirth};
505
    $new_borrower->{dateenrolled}    ||= undef if exists $new_borrower->{dateenrolled};
489
    $new_borrower->{dateenrolled}    ||= undef if exists $new_borrower->{dateenrolled};
(-)a/C4/SIP/ILS/Patron.pm (-3 / +3 lines)
Lines 40-48 sub new { Link Here
40
    $kp = GetMemberDetails($kp->{borrowernumber});
40
    $kp = GetMemberDetails($kp->{borrowernumber});
41
    $debug and warn "new Patron (GetMemberDetails): " . Dumper($kp);
41
    $debug and warn "new Patron (GetMemberDetails): " . Dumper($kp);
42
    my $pw        = $kp->{password};
42
    my $pw        = $kp->{password};
43
    my $flags     = $kp->{flags};     # or warn "Warning: No flags from patron object for '$patron_id'";
43
    my $flags     = C4::Members::patronflags( $kp );
44
    my $debarred  = defined($kp->{flags}->{DBARRED});
44
    my $debarred  = defined($flags->{DBARRED});
45
    $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%{$kp->{flags}});
45
    $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%$flags);
46
    my ($day, $month, $year) = (localtime)[3,4,5];
46
    my ($day, $month, $year) = (localtime)[3,4,5];
47
    my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
47
    my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
48
    my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
48
    my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
(-)a/circ/circulation.pl (-2 / +2 lines)
Lines 472-478 if ($borrowernumber) { Link Here
472
}
472
}
473
473
474
#title
474
#title
475
my $flags = $borrower->{'flags'};
475
my $flags = $borrower ? C4::Members::patronflags( $borrower ) : {};
476
foreach my $flag ( sort keys %$flags ) {
476
foreach my $flag ( sort keys %$flags ) {
477
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
477
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
478
    if ( $flags->{$flag}->{'noissues'} ) {
478
    if ( $flags->{$flag}->{'noissues'} ) {
Lines 555-561 foreach my $flag ( sort keys %$flags ) { Link Here
555
    }
555
    }
556
}
556
}
557
557
558
my $amountold = $borrower->{flags} ? $borrower->{flags}->{'CHARGES'}->{'message'} || 0 : 0;
558
my $amountold = $flags ? $flags->{'CHARGES'}->{'message'} || 0 : 0;
559
$amountold =~ s/^.*\$//;    # remove upto the $, if any
559
$amountold =~ s/^.*\$//;    # remove upto the $, if any
560
560
561
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
561
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
(-)a/members/deletemem.pl (-2 / +2 lines)
Lines 76-83 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preferen Link Here
76
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
76
my $issues = GetPendingIssues($member);     # FIXME: wasteful call when really, we only want the count
77
my $countissues = scalar(@$issues);
77
my $countissues = scalar(@$issues);
78
78
79
my ($bor)=GetMemberDetails($member,'');
79
my $bor = C4::Members::GetMember( borrowernumber => $member );
80
my $flags=$bor->{flags};
80
my $flags = C4::Members::patronflags( $bor );
81
my $userenv = C4::Context->userenv;
81
my $userenv = C4::Context->userenv;
82
82
83
 
83
 
(-)a/members/member-flags.pl (-2 / +1 lines)
Lines 86-92 if ($input->param('newflags')) { Link Here
86
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
86
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
87
} else {
87
} else {
88
88
89
    my $flags = $bor->{'flags'};
89
    my $flags = C4::Members::patronflags( $bor );
90
    my $accessflags;
90
    my $accessflags;
91
    my $dbh = C4::Context->dbh();
91
    my $dbh = C4::Context->dbh();
92
    # FIXME This needs to be improved to avoid doing the same query
92
    # FIXME This needs to be improved to avoid doing the same query
93
- 

Return to bug 17578