|
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/; |
28 |
use Date::Calc qw/Today Add_Delta_YM/; |
| 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 46-51
BEGIN {
Link Here
|
| 46 |
&Search |
42 |
&Search |
| 47 |
&SearchMember |
43 |
&SearchMember |
| 48 |
&GetMemberDetails |
44 |
&GetMemberDetails |
|
|
45 |
&GetMemberFlags |
| 49 |
&GetMemberRelatives |
46 |
&GetMemberRelatives |
| 50 |
&GetMember |
47 |
&GetMember |
| 51 |
|
48 |
|
|
Lines 325-343
up the borrower by number; otherwise, it looks up the borrower by card
Link Here
|
| 325 |
number. |
322 |
number. |
| 326 |
|
323 |
|
| 327 |
C<$borrower> is a reference-to-hash whose keys are the fields of the |
324 |
C<$borrower> is a reference-to-hash whose keys are the fields of the |
| 328 |
borrowers table in the Koha database. In addition, |
325 |
borrowers table in the Koha database. |
| 329 |
C<$borrower-E<gt>{flags}> is a hash giving more detailed information |
|
|
| 330 |
about the patron. Its keys act as flags : |
| 331 |
|
| 332 |
if $borrower->{flags}->{LOST} { |
| 333 |
# Patron's card was reported lost |
| 334 |
} |
| 335 |
|
| 336 |
If the state of a flag means that the patron should not be |
| 337 |
allowed to borrow any more books, then it will have a C<noissues> key |
| 338 |
with a true value. |
| 339 |
|
| 340 |
See patronflags for more details. |
| 341 |
|
326 |
|
| 342 |
C<$borrower-E<gt>{authflags}> is a hash giving more detailed information |
327 |
C<$borrower-E<gt>{authflags}> is a hash giving more detailed information |
| 343 |
about the top-level permissions flags set for the borrower. For example, |
328 |
about the top-level permissions flags set for the borrower. For example, |
|
Lines 353-363
sub GetMemberDetails {
Link Here
|
| 353 |
my $query; |
338 |
my $query; |
| 354 |
my $sth; |
339 |
my $sth; |
| 355 |
if ($borrowernumber) { |
340 |
if ($borrowernumber) { |
| 356 |
$sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowernumber=?"); |
341 |
$sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee, enrolmentperiod |
|
|
342 |
FROM borrowers |
| 343 |
LEFT JOIN categories ON borrowers.categorycode=categories.categorycode, enrolmentperiod |
| 344 |
WHERE borrowernumber=?"); |
| 357 |
$sth->execute($borrowernumber); |
345 |
$sth->execute($borrowernumber); |
| 358 |
} |
346 |
} |
| 359 |
elsif ($cardnumber) { |
347 |
elsif ($cardnumber) { |
| 360 |
$sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?"); |
348 |
$sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee, enrolmentperiod |
|
|
349 |
FROM borrowers |
| 350 |
LEFT JOIN categories ON borrowers.categorycode=categories.categorycode |
| 351 |
WHERE cardnumber=?"); |
| 361 |
$sth->execute($cardnumber); |
352 |
$sth->execute($cardnumber); |
| 362 |
} |
353 |
} |
| 363 |
else { |
354 |
else { |
|
Lines 366-373
sub GetMemberDetails {
Link Here
|
| 366 |
my $borrower = $sth->fetchrow_hashref; |
357 |
my $borrower = $sth->fetchrow_hashref; |
| 367 |
my ($amount) = GetMemberAccountRecords( $borrowernumber); |
358 |
my ($amount) = GetMemberAccountRecords( $borrowernumber); |
| 368 |
$borrower->{'amountoutstanding'} = $amount; |
359 |
$borrower->{'amountoutstanding'} = $amount; |
| 369 |
# FIXME - patronflags calls GetMemberAccountRecords... just have patronflags return $amount |
|
|
| 370 |
my $flags = patronflags( $borrower); |
| 371 |
my $accessflagshash; |
360 |
my $accessflagshash; |
| 372 |
|
361 |
|
| 373 |
$sth = $dbh->prepare("select bit,flag from userflags"); |
362 |
$sth = $dbh->prepare("select bit,flag from userflags"); |
|
Lines 377-401
sub GetMemberDetails {
Link Here
|
| 377 |
$accessflagshash->{$flag} = 1; |
366 |
$accessflagshash->{$flag} = 1; |
| 378 |
} |
367 |
} |
| 379 |
} |
368 |
} |
| 380 |
$borrower->{'flags'} = $flags; |
|
|
| 381 |
$borrower->{'authflags'} = $accessflagshash; |
369 |
$borrower->{'authflags'} = $accessflagshash; |
| 382 |
|
|
|
| 383 |
# find out how long the membership lasts |
| 384 |
$sth = |
| 385 |
$dbh->prepare( |
| 386 |
"select enrolmentperiod from categories where categorycode = ?"); |
| 387 |
$sth->execute( $borrower->{'categorycode'} ); |
| 388 |
my $enrolment = $sth->fetchrow; |
| 389 |
$borrower->{'enrolmentperiod'} = $enrolment; |
| 390 |
|
370 |
|
| 391 |
return ($borrower); #, $flags, $accessflagshash); |
371 |
return ($borrower); #, $flags, $accessflagshash); |
| 392 |
} |
372 |
} |
| 393 |
|
373 |
|
| 394 |
=head2 patronflags |
374 |
=head2 GetMemberFlags |
| 395 |
|
375 |
|
| 396 |
$flags = &patronflags($patron); |
376 |
$flags = &GetMemberFlags($patron); |
| 397 |
|
|
|
| 398 |
This function is not exported. |
| 399 |
|
377 |
|
| 400 |
The following will be set where applicable: |
378 |
The following will be set where applicable: |
| 401 |
$flags->{CHARGES}->{amount} Amount of debt |
379 |
$flags->{CHARGES}->{amount} Amount of debt |
|
Lines 453-460
The "message" field that comes from the DB is OK.
Link Here
|
| 453 |
=cut |
431 |
=cut |
| 454 |
|
432 |
|
| 455 |
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo |
433 |
# TODO: use {anonymous => hashes} instead of a dozen %flaginfo |
| 456 |
# FIXME rename this function. |
434 |
sub GetMemberFlags { |
| 457 |
sub patronflags { |
435 |
require C4::Reserves; |
|
|
436 |
require C4::Overdues; |
| 458 |
my %flags; |
437 |
my %flags; |
| 459 |
my ( $patroninformation) = @_; |
438 |
my ( $patroninformation) = @_; |
| 460 |
my $dbh=C4::Context->dbh; |
439 |
my $dbh=C4::Context->dbh; |
|
Lines 822-828
sub AddMember {
Link Here
|
| 822 |
} |
801 |
} |
| 823 |
if ($enrolmentfee && $enrolmentfee > 0) { |
802 |
if ($enrolmentfee && $enrolmentfee > 0) { |
| 824 |
# insert fee in patron debts |
803 |
# insert fee in patron debts |
| 825 |
manualinvoice($data{'borrowernumber'}, '', '', 'A', $enrolmentfee); |
804 |
require C4::Accounts; |
|
|
805 |
C4::Accounts::manualinvoice($data{'borrowernumber'}, '', '', 'A', $enrolmentfee); |
| 826 |
} |
806 |
} |
| 827 |
|
807 |
|
| 828 |
return $data{'borrowernumber'}; |
808 |
return $data{'borrowernumber'}; |
|
Lines 1172-1179
sub GetMemberAccountRecords {
Link Here
|
| 1172 |
my @acctlines; |
1152 |
my @acctlines; |
| 1173 |
my $numlines = 0; |
1153 |
my $numlines = 0; |
| 1174 |
my $strsth = qq( |
1154 |
my $strsth = qq( |
| 1175 |
SELECT * |
1155 |
SELECT accountlines.*,biblio.biblionumber,biblio.title |
| 1176 |
FROM accountlines |
1156 |
FROM accountlines |
|
|
1157 |
LEFT JOIN items USING(itemnumber) |
| 1158 |
LEFT JOIN biblio USING (biblionumber) |
| 1177 |
WHERE borrowernumber=?); |
1159 |
WHERE borrowernumber=?); |
| 1178 |
my @bind = ($borrowernumber); |
1160 |
my @bind = ($borrowernumber); |
| 1179 |
if ($date && $date ne ''){ |
1161 |
if ($date && $date ne ''){ |
|
Lines 1185-1195
sub GetMemberAccountRecords {
Link Here
|
| 1185 |
$sth->execute( @bind ); |
1167 |
$sth->execute( @bind ); |
| 1186 |
my $total = 0; |
1168 |
my $total = 0; |
| 1187 |
while ( my $data = $sth->fetchrow_hashref ) { |
1169 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 1188 |
if ( $data->{itemnumber} ) { |
|
|
| 1189 |
my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} ); |
| 1190 |
$data->{biblionumber} = $biblio->{biblionumber}; |
| 1191 |
$data->{title} = $biblio->{title}; |
| 1192 |
} |
| 1193 |
$acctlines[$numlines] = $data; |
1170 |
$acctlines[$numlines] = $data; |
| 1194 |
$numlines++; |
1171 |
$numlines++; |
| 1195 |
$total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors |
1172 |
$total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors |
|
Lines 1763-1769
EOF
Link Here
|
| 1763 |
my ($enrolmentfee) = $sth->fetchrow; |
1740 |
my ($enrolmentfee) = $sth->fetchrow; |
| 1764 |
if ($enrolmentfee && $enrolmentfee > 0) { |
1741 |
if ($enrolmentfee && $enrolmentfee > 0) { |
| 1765 |
# insert fee in patron debts |
1742 |
# insert fee in patron debts |
| 1766 |
manualinvoice($borrower->{'borrowernumber'}, '', '', 'A', $enrolmentfee); |
1743 |
require C4::Accounts; |
|
|
1744 |
C4::Accounts::manualinvoice($borrower->{'borrowernumber'}, '', '', 'A', $enrolmentfee); |
| 1767 |
} |
1745 |
} |
| 1768 |
return $date if ($sth); |
1746 |
return $date if ($sth); |
| 1769 |
return 0; |
1747 |
return 0; |