C4::Members - Perl Module containing convenience functions for member handling
use C4::Members;
This module contains routines for adding, modifying and deleting members/patrons/borrowers
$flags = &patronflags($patron);
This function is not exported.
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->{ 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
$flags->{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.$flags->{ODUES}->{itemlisttext}
is a string giving a text listing of the overdue items, one per line. Deprecated.$flags->{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.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.
$borrower = &GetMember(%information);
Retrieve the first patron record meeting on criteria listed in the %information
hash, which should contain one or more pairs of borrowers column names and values, e.g.,
$borrower = GetMember(borrowernumber => id);
&GetBorrower
returns a reference-to-hash whose keys are the fields of the borrowers
table in the Koha database.
FIXME: GetMember() is used throughout the code as a lookup on a unique key such as the borrowernumber, but this meaning is not enforced in the routine itself.
my $success = ModMember(borrowernumber => $borrowernumber, [ field => value ]... );
Modify borrower's data. All date fields should ALREADY be in ISO format.
return : true on success, or false on failure
$borrowernumber = &AddMember(%borrower);
insert new borrower into table
(%borrower keys are database columns. Database columns could be different in different versions. Please look into database for correct column names.)
Returns the borrowernumber upon success
Returns as undef upon any db error without further processing
my $uniqueness = Check_Userid($userid,$borrowernumber); $borrowernumber is optional (i.e. it can contain a blank value). If $userid is passed with a blank $borrowernumber variable, the database will be checked for all instances of that userid (i.e. userid=? AND borrowernumber != ''). If $borrowernumber is provided, the database will be checked for every instance of that userid coupled with a different borrower(number) than the one provided. return : 0 for not unique (i.e. this $userid already exists) 1 for unique (i.e. this $userid does not exist, or this $userid/$borrowernumber combination already exists)
my $newuid = Generate_Userid($borrowernumber, $firstname, $surname); Generate a userid using the $surname and the $firstname (if there is a value in $firstname). $borrowernumber is optional (i.e. it can contain a blank value). A value is passed when generating a new userid for an existing borrower. When a new userid is created for a new borrower, a blank value is passed to this sub. return : new userid ($firstname.$surname if there is a $firstname, or $surname if there is no value in $firstname) plus offset (0 if the $newuid is unique, or a higher numeric value if Check_Userid finds an existing match for the $newuid in the database).
Warning: The caller is responsible for locking the members table in write mode, to avoid database corruption.
my $issues = &GetPendingIssues(@borrowernumber);
Looks up what the patron with the given borrowernumber has borrowed.
&GetPendingIssues
returns a reference-to-array where each element is a reference-to-hash; the keys are the fields from the issues
, biblio
, and items
tables. The keys include biblioitems
fields.
$issues = &GetAllIssues($borrowernumber, $sortkey, $limit);
Looks up what the patron with the given borrowernumber has borrowed, and sorts the results.
$sortkey
is the name of a field on which to sort the results. This should be the name of a field in the issues
, biblio
, biblioitems
, or items
table in the Koha database.
$limit
is the maximum number of results to return.
&GetAllIssues
an arrayref, $issues
, of hashrefs, the keys of which are the fields from the issues
, biblio
, biblioitems
, and items
tables of the Koha database.
($total, $acctlines, $count) = &GetMemberAccountRecords($borrowernumber);
Looks up accounting data for the patron with the given borrowernumber.
&GetMemberAccountRecords
returns a three-element array. $acctlines
is a reference-to-array, where each element is a reference-to-hash; the keys are the fields of the accountlines
table in the Koha database. $count
is the number of elements in $acctlines
. $total
is the total amount outstanding for all of the account lines.
($total_balance, $non_issue_balance, $other_charges) = &GetMemberAccountBalance($borrowernumber);
Calculates amount immediately owing by the patron - non-issue charges. Based on GetMemberAccountRecords. Charges exempt from non-issue are: * Res (reserves) * Rent (rental) if RentalsInNoissuesCharge syspref is set to false * Manual invoices if ManInvInNoissuesCharge syspref is set to false
($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid);
Looks up accounting data for the patron with the given borrowernumber per file number.
&GetBorNotifyAcctRecord
returns a three-element array. $acctlines
is a reference-to-array, where each element is a reference-to-hash; the keys are the fields of the accountlines
table in the Koha database. $count
is the number of elements in $acctlines
. $total
is the total amount outstanding for all of the account lines.
my ($min, $max) = C4::Members::get_cardnumber_length()
Returns the minimum and maximum length for patron cardnumbers as determined by the CardnumberLength system preference, the BorrowerMandatoryField system preference, and the width of the database column.
$email = GetFirstValidEmailAddress($borrowernumber);
Return the first valid email address for a borrower, given the borrowernumber. For now, the order is defined as email, emailpro, B_email. Returns the empty string if the borrower has no email addresses.
$email = GetNoticeEmailAddress($borrowernumber);
Return the email address of borrower used for notices, given the borrowernumber. Returns the empty string if no email address.
$borrowers = &GetBorrowersToExpunge( not_borrowed_since => $not_borrowed_since, expired_before => $expired_before, category_code => $category_code, patron_list_id => $patron_list_id, branchcode => $branchcode ); This function get all borrowers based on the given criteria.
IssueSlip($branchcode, $borrowernumber, $quickslip) Returns letter hash ( see C4::Letters::GetPreparedLetter ) $quickslip is boolean, to indicate whether we want a quick slip IssueSlip populates ISSUESLIP and ISSUEQSLIP, and will make the following expansions: Both slips: <<branches.*>> <<borrowers.*>> ISSUESLIP: <checkedout> <<biblio.*>> <<items.*>> <<biblioitems.*>> <<issues.*>> </checkedout> <overdue> <<biblio.*>> <<items.*>> <<biblioitems.*>> <<issues.*>> </overdue> <news> <<opac_news.*>> </news> ISSUEQSLIP: <checkedout> <<biblio.*>> <<items.*>> <<biblioitems.*>> <<issues.*>> </checkedout> NOTE: Not all table fields are available, pleasee see GetPendingIssues for a list of available fields.
([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
This gets a list of users and their basic details from their email address. As it's possible for multiple user to have the same email address, it provides you with all of them. If there is no userid for the user, there will be an undef
there. An empty list will be returned if there are no matches.
Delete accounts that haven't been upgraded from the 'temporary' category Returns the number of removed patrons
Delete all unverified self registrations in borrower_modifications, older than the specified number of days.
Koha Team