# Patron's card was reported lost
}
-Each flag has a C<message> key, giving a human-readable explanation of
-the flag. If the state of a flag means that the patron should not be
+If the state of a flag means that the patron should not be
allowed to borrow any more books, then it will have a C<noissues> key
with a true value.
-The possible flags are:
-
-=head3 CHARGES
-
-=over 4
-
-=item Shows the patron's credit or debt, if any.
-
-=back
-
-=head3 GNA
-
-=over 4
-
-=item (Gone, no address.) Set if the patron has left without giving a
-forwarding address.
-
-=back
-
-=head3 LOST
-
-=over 4
-
-=item Set if the patron's card has been reported as lost.
-
-=back
-
-=head3 DBARRED
-
-=over 4
-
-=item Set if the patron has been debarred.
-
-=back
-
-=head3 NOTES
-
-=over 4
-
-=item Any additional notes about the patron.
-
-=back
-
-=head3 ODUES
-
-=over 4
-
-=item Set if the patron has overdue items. This flag has several keys:
-
-C<$flags-E<gt>{ODUES}{itemlist}> is a reference-to-array listing the
-overdue items. Its elements are references-to-hash, each describing an
-overdue item. The keys are selected fields from the issues, biblio,
-biblioitems, and items tables of the Koha database.
-
-C<$flags-E<gt>{ODUES}{itemlist}> is a string giving a text listing of
-the overdue items, one per line.
-
-=back
-
-=head3 WAITING
-
-=over 4
-
-=item Set if any items that the patron has reserved are available.
-
-C<$flags-E<gt>{WAITING}{itemlist}> is a reference-to-array listing the
-available items. Each element is a reference-to-hash whose keys are
-fields from the reserves table of the Koha database.
-
-=back
+See patronflags for more details.
C<$borrower-E<gt>{authflags}> is a hash giving more detailed information
about the top-level permissions flags set for the borrower. For example,
=head2 patronflags
- Not exported
+ $flags = &patronflags($patron);
- NOTE!: If you change this function, be sure to update the POD for
- &GetMemberDetails.
+ This function is not exported.
- $flags = &patronflags($patron);
+ The following will be set where applicable:
+ $flags->{CHARGES}->{amount} Amount of debt
+ $flags->{CHARGES}->{noissues} Set if debt amount >$5.00 (or syspref noissuescharge)
+ $flags->{CHARGES}->{message} Message -- deprecated
+
+ $flags->{CREDITS}->{amount} Amount of credit
+ $flags->{CREDITS}->{message} Message -- deprecated
+
+ $flags->{ GNA } Patron has no valid address
+ $flags->{ GNA }->{noissues} Set for each GNA
+ $flags->{ GNA }->{message} "Borrower has no valid address" -- deprecated
+
+ $flags->{ LOST } Patron's card reported lost
+ $flags->{ LOST }->{noissues} Set for each LOST
+ $flags->{ LOST }->{message} Message -- deprecated
+
+ $flags->{DBARRED} Set if patron debarred, no access
+ $flags->{DBARRED}->{noissues} Set for each DBARRED
+ $flags->{DBARRED}->{message} Message -- deprecated
- $flags->{CHARGES}
- {message} Message showing patron's credit or debt
- {noissues} Set if patron owes >$5.00
- {GNA} Set if patron gone w/o address
- {message} "Borrower has no valid address"
- {noissues} Set.
- {LOST} Set if patron's card reported lost
- {message} Message to this effect
- {noissues} Set.
- {DBARRED} Set is patron is debarred
- {message} Message to this effect
- {noissues} Set.
- {NOTES} Set if patron has notes
- {message} Notes about patron
- {ODUES} Set if patron has overdue books
- {message} "Yes"
- {itemlist} ref-to-array: list of overdue books
- {itemlisttext} Text list of overdue items
- {WAITING} Set if there are items available that the
- patron reserved
- {message} Message to this effect
- {itemlist} ref-to-array: list of available items
+ $flags->{ NOTES }
+ $flags->{ NOTES }->{message} The note itself. NOT deprecated
+
+ $flags->{ ODUES } Set if patron has overdue books.
+ $flags->{ ODUES }->{message} "Yes" -- deprecated
+ $flags->{ ODUES }->{itemlist} ref-to-array: list of overdue books
+ $flags->{ ODUES }->{itemlisttext} Text list of overdue items -- deprecated
+
+ $flags->{WAITING} Set if any of patron's reserves are available
+ $flags->{WAITING}->{message} Message -- deprecated
+ $flags->{WAITING}->{itemlist} ref-to-array: list of available items
+
+=over 4
+
+C<$flags-E<gt>{ODUES}-E<gt>{itemlist}> is a reference-to-array listing the
+overdue items. Its elements are references-to-hash, each describing an
+overdue item. The keys are selected fields from the issues, biblio,
+biblioitems, and items tables of the Koha database.
+
+C<$flags-E<gt>{ODUES}-E<gt>{itemlisttext}> is a string giving a text listing of
+the overdue items, one per line. Deprecated.
+
+C<$flags-E<gt>{WAITING}-E<gt>{itemlist}> is a reference-to-array listing the
+available items. Each element is a reference-to-hash whose keys are
+fields from the reserves table of the Koha database.
+
+=back
+
+All the "message" fields that include language generated in this function are deprecated,
+because such strings belong properly in the display layer.
+
+The "message" field that comes from the DB is OK.
=cut
+
+# TODO: use {anonymous => hashes} instead of a dozen %flaginfo
# FIXME rename this function.
sub patronflags {
my %flags;
my ($amount) = GetMemberAccountRecords( $patroninformation->{'borrowernumber'});
if ( $amount > 0 ) {
my %flaginfo;
- my $noissuescharge = C4::Context->preference("noissuescharge");
+ my $noissuescharge = C4::Context->preference("noissuescharge") || 5;
$flaginfo{'message'} = sprintf "Patron owes \$%.02f", $amount;
- $flaginfo{'amount'} = sprintf "%.02f",$amount;
+ $flaginfo{'amount'} = sprintf "%.02f", $amount;
if ( $amount > $noissuescharge ) {
$flaginfo{'noissues'} = 1;
}
elsif ( $amount < 0 ) {
my %flaginfo;
$flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$amount;
+ $flaginfo{'amount'} = sprintf "%.02f", $amount;
$flags{'CREDITS'} = \%flaginfo;
}
if ( $patroninformation->{'gonenoaddress'}
&& $patroninformation->{'borrowernotes'} )
{
my %flaginfo;
- $flaginfo{'message'} = "$patroninformation->{'borrowernotes'}";
+ $flaginfo{'message'} = $patroninformation->{'borrowernotes'};
$flags{'NOTES'} = \%flaginfo;
}
- my ( $odues, $itemsoverdue ) =
- checkoverdues( $patroninformation->{'borrowernumber'}, $dbh );
+ my ( $odues, $itemsoverdue ) = checkoverdues($patroninformation->{'borrowernumber'});
if ( $odues > 0 ) {
my %flaginfo;
$flaginfo{'message'} = "Yes";
@$itemsoverdue )
{
$flaginfo{'itemlisttext'} .=
- "$_->{'date_due'} $_->{'barcode'} $_->{'title'} \n";
+ "$_->{'date_due'} $_->{'barcode'} $_->{'title'} \n"; # newline is display layer
}
$flags{'ODUES'} = \%flaginfo;
}
. ",address=" . $dbh->quote( $data{'address'} )
. ",address2=" . $dbh->quote( $data{'address2'} )
. ",zipcode=" . $dbh->quote( $data{'zipcode'} )
+ . ",country=" . $dbh->quote( $data{'country'} )
. ",city=" . $dbh->quote( $data{'city'} )
. ",phone=" . $dbh->quote( $data{'phone'} )
. ",email=" . $dbh->quote( $data{'email'} )
. ",dateexpiry=" . $dbh->quote( $data{'dateexpiry'} )
. ",contactnote=" . $dbh->quote( $data{'contactnote'} )
. ",B_address=" . $dbh->quote( $data{'B_address'} )
+ . ",B_address2=" . $dbh->quote( $data{'B_address2'} )
. ",B_zipcode=" . $dbh->quote( $data{'B_zipcode'} )
+ . ",B_country=" . $dbh->quote( $data{'B_country'} )
. ",B_city=" . $dbh->quote( $data{'B_city'} )
. ",B_phone=" . $dbh->quote( $data{'B_phone'} )
. ",B_email=" . $dbh->quote( $data{'B_email'} )
. ",altcontactaddress2=" . $dbh->quote( $data{'altcontactaddress2'} )
. ",altcontactaddress3=" . $dbh->quote( $data{'altcontactaddress3'} )
. ",altcontactzipcode=" . $dbh->quote( $data{'altcontactzipcode'} )
+ . ",altcontactcountry=" . $dbh->quote( $data{'altcontactcountry'} )
. ",altcontactphone=" . $dbh->quote( $data{'altcontactphone'} ) ;
$debug and print STDERR "AddMember SQL: ($query)\n";
my $sth = $dbh->prepare($query);
$data->{title} = $biblio->{title};
$acctlines[$numlines] = $data;
$numlines++;
- $total += int(100 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
+ $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
}
- $total /= 100;
+ $total /= 1000;
$sth->finish;
return ( $total, \@acctlines,$numlines);
}