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

(-)a/C4/ILSDI/Services.pm (-2 / +2 lines)
Lines 356-367 sub GetPatronInfo { Link Here
356
    # Get Member details
356
    # Get Member details
357
    my $borrowernumber = $cgi->param('patron_id');
357
    my $borrowernumber = $cgi->param('patron_id');
358
    my $borrower = GetMemberDetails( $borrowernumber );
358
    my $borrower = GetMemberDetails( $borrowernumber );
359
    my $flags = GetMemberFlags($borrower);
359
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
360
    return { code => 'PatronNotFound' } unless $$borrower{borrowernumber};
360
361
361
    # Cleaning the borrower hashref
362
    # Cleaning the borrower hashref
362
    $borrower->{'charges'}    = $borrower->{'flags'}->{'CHARGES'}->{'amount'};
363
    $borrower->{'charges'}    = $flags->{'CHARGES'}->{'amount'};
363
    $borrower->{'branchname'} = GetBranchName( $borrower->{'branchcode'} );
364
    $borrower->{'branchname'} = GetBranchName( $borrower->{'branchcode'} );
364
    delete $borrower->{'flags'};
365
    delete $borrower->{'userid'};
365
    delete $borrower->{'userid'};
366
    delete $borrower->{'password'};
366
    delete $borrower->{'password'};
367
367
(-)a/C4/Members.pm (-36 / +22 lines)
Lines 27-36 use C4::Dates qw(format_date_in_iso); Link Here
27
use Digest::MD5 qw(md5_base64);
27
use Digest::MD5 qw(md5_base64);
28
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
28
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
29
use C4::Log; # logaction
29
use C4::Log; # logaction
30
use C4::Overdues;
31
use C4::Reserves;
32
use C4::Accounts;
33
use C4::Biblio;
34
use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
30
use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
35
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
31
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
36
32
Lines 45-50 BEGIN { Link Here
45
	push @EXPORT, qw(
41
	push @EXPORT, qw(
46
		&Search
42
		&Search
47
		&GetMemberDetails
43
		&GetMemberDetails
44
        &GetMemberFlags
48
        &GetMemberRelatives
45
        &GetMemberRelatives
49
		&GetMember
46
		&GetMember
50
47
Lines 285-303 up the borrower by number; otherwise, it looks up the borrower by card Link Here
285
number.
282
number.
286
283
287
C<$borrower> is a reference-to-hash whose keys are the fields of the
284
C<$borrower> is a reference-to-hash whose keys are the fields of the
288
borrowers table in the Koha database. In addition,
285
borrowers table in the Koha database.
289
C<$borrower-E<gt>{flags}> is a hash giving more detailed information
290
about the patron. Its keys act as flags :
291
292
    if $borrower->{flags}->{LOST} {
293
        # Patron's card was reported lost
294
    }
295
296
If the state of a flag means that the patron should not be
297
allowed to borrow any more books, then it will have a C<noissues> key
298
with a true value.
299
300
See patronflags for more details.
301
286
302
C<$borrower-E<gt>{authflags}> is a hash giving more detailed information
287
C<$borrower-E<gt>{authflags}> is a hash giving more detailed information
303
about the top-level permissions flags set for the borrower.  For example,
288
about the top-level permissions flags set for the borrower.  For example,
Lines 313-323 sub GetMemberDetails { Link Here
313
    my $query;
298
    my $query;
314
    my $sth;
299
    my $sth;
315
    if ($borrowernumber) {
300
    if ($borrowernumber) {
316
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE  borrowernumber=?");
301
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee, enrolmentperiod
302
                                FROM borrowers
303
                                LEFT JOIN categories ON borrowers.categorycode=categories.categorycode, enrolmentperiod
304
                                WHERE  borrowernumber=?");
317
        $sth->execute($borrowernumber);
305
        $sth->execute($borrowernumber);
318
    }
306
    }
319
    elsif ($cardnumber) {
307
    elsif ($cardnumber) {
320
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?");
308
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee, enrolmentperiod
309
                                FROM borrowers
310
                                LEFT JOIN categories ON borrowers.categorycode=categories.categorycode
311
                                WHERE cardnumber=?");
321
        $sth->execute($cardnumber);
312
        $sth->execute($cardnumber);
322
    }
313
    }
323
    else {
314
    else {
Lines 326-333 sub GetMemberDetails { Link Here
326
    my $borrower = $sth->fetchrow_hashref;
317
    my $borrower = $sth->fetchrow_hashref;
327
    my ($amount) = GetMemberAccountRecords( $borrowernumber);
318
    my ($amount) = GetMemberAccountRecords( $borrowernumber);
328
    $borrower->{'amountoutstanding'} = $amount;
319
    $borrower->{'amountoutstanding'} = $amount;
329
    # FIXME - patronflags calls GetMemberAccountRecords... just have patronflags return $amount
330
    my $flags = patronflags( $borrower);
331
    my $accessflagshash;
320
    my $accessflagshash;
332
321
333
    $sth = $dbh->prepare("select bit,flag from userflags");
322
    $sth = $dbh->prepare("select bit,flag from userflags");
Lines 337-343 sub GetMemberDetails { Link Here
337
            $accessflagshash->{$flag} = 1;
326
            $accessflagshash->{$flag} = 1;
338
        }
327
        }
339
    }
328
    }
340
    $borrower->{'flags'}     = $flags;
341
    $borrower->{'authflags'} = $accessflagshash;
329
    $borrower->{'authflags'} = $accessflagshash;
342
330
343
    # For the purposes of making templates easier, we'll define a
331
    # For the purposes of making templates easier, we'll define a
Lines 353-363 sub GetMemberDetails { Link Here
353
    return ($borrower);    #, $flags, $accessflagshash);
341
    return ($borrower);    #, $flags, $accessflagshash);
354
}
342
}
355
343
356
=head2 patronflags
344
=head2 GetMemberFlags
357
358
 $flags = &patronflags($patron);
359
345
360
This function is not exported.
346
 $flags = &GetMemberFlags($patron);
361
347
362
The following will be set where applicable:
348
The following will be set where applicable:
363
 $flags->{CHARGES}->{amount}        Amount of debt
349
 $flags->{CHARGES}->{amount}        Amount of debt
Lines 415-422 The "message" field that comes from the DB is OK. Link Here
415
=cut
401
=cut
416
402
417
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
403
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
418
# FIXME rename this function.
404
sub GetMemberFlags {
419
sub patronflags {
405
    require C4::Reserves;
406
    require C4::Overdues;
420
    my %flags;
407
    my %flags;
421
    my ( $patroninformation) = @_;
408
    my ( $patroninformation) = @_;
422
    my $dbh=C4::Context->dbh;
409
    my $dbh=C4::Context->dbh;
Lines 759-765 sub AddMember { Link Here
759
    }
746
    }
760
    if ($enrolmentfee && $enrolmentfee > 0) {
747
    if ($enrolmentfee && $enrolmentfee > 0) {
761
        # insert fee in patron debts
748
        # insert fee in patron debts
762
        manualinvoice($data{'borrowernumber'}, '', '', 'A', $enrolmentfee);
749
        require C4::Accounts;
750
        C4::Accounts::manualinvoice($data{'borrowernumber'}, '', '', 'A', $enrolmentfee);
763
    }
751
    }
764
752
765
    return $data{'borrowernumber'};
753
    return $data{'borrowernumber'};
Lines 1113-1120 sub GetMemberAccountRecords { Link Here
1113
    my @acctlines;
1101
    my @acctlines;
1114
    my $numlines = 0;
1102
    my $numlines = 0;
1115
    my $strsth      = qq(
1103
    my $strsth      = qq(
1116
                        SELECT * 
1104
                        SELECT accountlines.*,biblio.biblionumber,biblio.title
1117
                        FROM accountlines 
1105
                        FROM accountlines 
1106
                        LEFT JOIN items USING(itemnumber)
1107
                        LEFT JOIN biblio USING (biblionumber)
1118
                        WHERE borrowernumber=?);
1108
                        WHERE borrowernumber=?);
1119
    my @bind = ($borrowernumber);
1109
    my @bind = ($borrowernumber);
1120
    if ($date && $date ne ''){
1110
    if ($date && $date ne ''){
Lines 1126-1136 sub GetMemberAccountRecords { Link Here
1126
    $sth->execute( @bind );
1116
    $sth->execute( @bind );
1127
    my $total = 0;
1117
    my $total = 0;
1128
    while ( my $data = $sth->fetchrow_hashref ) {
1118
    while ( my $data = $sth->fetchrow_hashref ) {
1129
        if ( $data->{itemnumber} ) {
1130
            my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} );
1131
            $data->{biblionumber} = $biblio->{biblionumber};
1132
            $data->{title}        = $biblio->{title};
1133
        }
1134
        $acctlines[$numlines] = $data;
1119
        $acctlines[$numlines] = $data;
1135
        $numlines++;
1120
        $numlines++;
1136
        $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
1121
        $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
Lines 1703-1709 EOF Link Here
1703
    my ($enrolmentfee) = $sth->fetchrow;
1688
    my ($enrolmentfee) = $sth->fetchrow;
1704
    if ($enrolmentfee && $enrolmentfee > 0) {
1689
    if ($enrolmentfee && $enrolmentfee > 0) {
1705
        # insert fee in patron debts
1690
        # insert fee in patron debts
1706
        manualinvoice($borrower->{'borrowernumber'}, '', '', 'A', $enrolmentfee);
1691
        require C4::Accounts;
1692
        C4::Accounts::manualinvoice($borrower->{'borrowernumber'}, '', '', 'A', $enrolmentfee);
1707
    }
1693
    }
1708
     logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog");
1694
     logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog");
1709
    return $date if ($sth);
1695
    return $date if ($sth);
(-)a/C4/SIP/ILS/Patron.pm (-1 / +1 lines)
Lines 47-53 sub new { Link Here
47
	$kp = GetMemberDetails(undef,$patron_id);
47
	$kp = GetMemberDetails(undef,$patron_id);
48
	$debug and warn "new Patron (GetMemberDetails): " . Dumper($kp);
48
	$debug and warn "new Patron (GetMemberDetails): " . Dumper($kp);
49
	my $pw        = $kp->{password};  ### FIXME - md5hash -- deal with . 
49
	my $pw        = $kp->{password};  ### FIXME - md5hash -- deal with . 
50
	my $flags     = $kp->{flags};     # or warn "Warning: No flags from patron object for '$patron_id'"; 
50
	my $flags     = GetMemberFlags($kp);
51
	my $debarred  = $kp->{debarred};  # 1 if ($kp->{flags}->{DBARRED}->{noissues});
51
	my $debarred  = $kp->{debarred};  # 1 if ($kp->{flags}->{DBARRED}->{noissues});
52
	$debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%{$kp->{flags}});
52
	$debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')) . Dumper(%{$kp->{flags}});
53
    my ($day, $month, $year) = (localtime)[3,4,5];
53
    my ($day, $month, $year) = (localtime)[3,4,5];
(-)a/circ/circulation.pl (-2 / +2 lines)
Lines 527-533 if ($borrowerslist) { Link Here
527
}
527
}
528
528
529
#title
529
#title
530
my $flags = $borrower->{'flags'};
530
my $flags = GetMemberFlags($borrower);
531
foreach my $flag ( sort keys %$flags ) {
531
foreach my $flag ( sort keys %$flags ) {
532
    $template->param( flagged=> 1);
532
    $template->param( flagged=> 1);
533
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
533
    $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
Lines 599-605 foreach my $flag ( sort keys %$flags ) { Link Here
599
    }
599
    }
600
}
600
}
601
601
602
my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
602
my $amountold = $flags->{'CHARGES'}->{'message'} || 0;
603
$amountold =~ s/^.*\$//;    # remove upto the $, if any
603
$amountold =~ s/^.*\$//;    # remove upto the $, if any
604
604
605
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
605
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
(-)a/circ/returns.pl (-1 / +1 lines)
Lines 479-485 $template->param( errmsgloop => \@errmsgloop ); Link Here
479
479
480
# patrontable ....
480
# patrontable ....
481
if ($borrower) {
481
if ($borrower) {
482
    my $flags = $borrower->{'flags'};
482
    my $flags = GetMemberFlags($borrower);
483
    my @flagloop;
483
    my @flagloop;
484
    my $flagset;
484
    my $flagset;
485
    foreach my $flag ( sort keys %$flags ) {
485
    foreach my $flag ( sort keys %$flags ) {
(-)a/members/deletemem.pl (-1 / +1 lines)
Lines 48-54 my $issues = GetPendingIssues($member); # FIXME: wasteful call when really, Link Here
48
my $countissues = scalar(@$issues);
48
my $countissues = scalar(@$issues);
49
49
50
my ($bor)=GetMemberDetails($member,'');
50
my ($bor)=GetMemberDetails($member,'');
51
my $flags=$bor->{flags};
51
my $flags=GetMemberFlags($bor);
52
my $userenv = C4::Context->userenv;
52
my $userenv = C4::Context->userenv;
53
53
54
 
54
 
(-)a/opac/sco/sco-main.pl (+2 lines)
Lines 113-118 if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { Link Here
113
    ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw);
113
    ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw);
114
}
114
}
115
my $borrower = GetMemberDetails(undef,$patronid);
115
my $borrower = GetMemberDetails(undef,$patronid);
116
# retrieve flags, they're needed by canbookbeissued sub
117
$borrower->{flags} = GetMemberFlags($borrower);
116
118
117
119
118
my $branch = $issuer->{branchcode};
120
my $branch = $issuer->{branchcode};
(-)a/t/db_dependent/lib/KohaTest/Members.pm (-2 / +1 lines)
Lines 14-20 sub methods : Test( 1 ) { Link Here
14
    my $self = shift;
14
    my $self = shift;
15
    my @methods = qw( Search
15
    my @methods = qw( Search
16
                      GetMemberDetails 
16
                      GetMemberDetails 
17
                      patronflags 
17
                      GetMemberFlags
18
                      GetMember 
18
                      GetMember 
19
                      GetMemberIssuesAndFines 
19
                      GetMemberIssuesAndFines 
20
                      ModMember 
20
                      ModMember 
21
- 

Return to bug 6875