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); |