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
($count, $borrowers) = &SearchMember($searchstring, $type,$category_type,$filter,$showallbranches);
Looks up patrons (borrowers) by name.
BUGFIX 499: $type
is now used to determine type of search. if $type is "simple", search is performed on the first letter of the surname only.
$category_type is used to get a specified type of user. (mainly adults when creating a child.)
$searchstring
is a space-separated list of search terms. Each term must match the beginning a borrower's surname, first name, or other name.
$filter
is assumed to be a list of elements to filter results on
$showallbranches
is used in IndependantBranches Context to display all branches results.
&SearchMember
returns a two-element list. $borrowers
is a reference-to-array; each element is a reference-to-hash, whose keys are the fields of the borrowers
table in the Koha database. $count
is the number of elements in $borrowers
.
($borrower, $flags) = &GetMemberDetails($borrowernumber, $cardnumber);
Looks up a patron and returns information about him or her. If $borrowernumber
is true (nonzero), &GetMemberDetails
looks up the borrower by number; otherwise, it looks up the borrower by card number.
$borrower
is a reference-to-hash whose keys are the fields of the borrowers table in the Koha database. In addition, $borrower->{flags}
is a hash giving more detailed information about the patron. Its keys act as flags :
if $borrower->{flags}->{LOST} { # Patron's card was reported lost }
Each flag has a message
key, giving a human-readable explanation of the flag. If the state of a flag means that the patron should not be allowed to borrow any more books, then it will have a noissues
key with a true value.
The possible flags are:
$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}{itemlist}
is a string giving a text listing of the overdue items, one per line.
$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.
Not exported NOTE!: If you change this function, be sure to update the POD for &GetMemberDetails. $flags = &patronflags($patron); $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
$borrower = &GetMember($information, $type);
Looks up information about a patron (borrower) by either card number ,firstname, or borrower number, depending on $type value. If $type
== 'cardnumber', &GetBorrower
searches by cardnumber then by firstname if not found in cardnumber; otherwise, it searches by borrowernumber.
&GetBorrower
returns a reference-to-hash whose keys are the fields of the borrowers
table in the Koha database.
($overdue_count, $issue_count, $total_fines) = &GetMemberIssuesAndFines($borrowernumber);
Returns aggregate data about items borrowed by the patron with the given borrowernumber.
&GetMemberIssuesAndFines
returns a three-element array. $overdue_count
is the number of overdue items the patron currently has borrowed. $issue_count
is the number of books the patron currently has borrowed. $total_fines
is the total fine currently due by the borrower.
&ModMember($borrowernumber);
Modify borrower's data. All date fields should ALREADY be in ISO format.
$borrowernumber = &AddMember(%borrower);
insert new borrower into table Returns the borrowernumber
Warning: The caller is responsible for locking the members table in write mode, to avoid database corruption.
($num_children, $children_arrayref) = &GetGuarantees($parent_borrno); $child0_cardno = $children_arrayref->[0]{"cardnumber"}; $child0_borrno = $children_arrayref->[0]{"borrowernumber"};
&GetGuarantees
takes a borrower number (e.g., that of a patron with children) and looks up the borrowers who are guaranteed by that borrower (i.e., the patron's children).
&GetGuarantees
returns two values: an integer giving the number of borrowers guaranteed by $parent_borrno
, and a reference to an array of references to hash, which gives the actual results.
&UpdateGuarantees($parent_borrno);
&UpdateGuarantees
borrower data for an adulte and updates all the guarantees with the modified information
($count, $issues) = &GetPendingIssues($borrowernumber);
Looks up what the patron with the given borrowernumber has borrowed.
&GetPendingIssues
returns a two-element array. $issues
is a reference-to-array, where each element is a reference-to-hash; the keys are the fields from the issues
, biblio
, and items
tables in the Koha database. $count
is the number of elements in $issues
.
($count, $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
returns a two-element array. $issues
is a reference-to-array, where each element is a reference-to-hash; the keys are the fields from the issues
, biblio
, biblioitems
, and items
tables of the Koha database. $count
is the number of elements in $issues
($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.
($count, $acctlines, $total) = &GetBorNotifyAcctRecord($params,$notifyid);
Looks up accounting data for the patron with the given borrowernumber per file number.
(FIXME - I'm not at all sure what this is about.)
&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.
($result,$categorycode) = &checkuniquemember($collectivity,$surname,$firstname,$dateofbirth);
Checks that a member exists or not in the database.
&result
is nonzero (=exist) or 0 (=does not exist) &categorycode
is from categorycode table &collectivity
is 1 (= we add a collectivity) or 0 (= we add a physical member) &surname
is the surname &firstname
is the firstname (only if collectivity=0) &dateofbirth
is the date of birth in ISO format (only if collectivity=0)
take all info from table city for the fields city and zip check for the name and the zip code of the city selected
recover cityid with city_name condition
$expirydate = GetExpiryDate($categorycode, $dateenrolled);
Calculate expiry date given a categorycode and starting date. Date argument must be in ISO format. Return date is also in ISO format.
check for the password and login are not used return the number of record 0=> NOT USED 1=> USED
($codes_arrayref, $labels_hashref) = &GetborCatFromCatType();
Looks up the different types of borrowers in the database. Returns two elements: a reference-to-array, which lists the borrower category codes, and a reference-to-hash, which maps the borrower category codes to category descriptions.
$hashref = &GetBorrowercategory($categorycode);
Given the borrower's category code, the function returns the corresponding data hashref for a comprehensive information display.
$arrayref_hashref = &GetBorrowercategory; If no category code provided, the function returns all the categories.
$arrayref_hashref = &GetBorrowercategoryList; If no category code provided, the function returns all the categories.
($codes_arrayref, $labels_hashref) = ðnicitycategories();
Looks up the different ethnic types in the database. Returns two elements: a reference-to-array, which lists the ethnicity codes, and a reference-to-hash, which maps the ethnicity codes to ethnicity descriptions.
$ethn_name = &fixEthnicity($ethn_code);
Takes an ethnicity code (e.g., "european" or "pi") and returns the corresponding descriptive name from the ethnicity
table in the Koha database ("European" or "Pacific Islander").
$dateofbirth,$date = &GetAge($date);
this function return the borrowers age with the value of dateofbirth
Just returns a list of all the borrowers of type I, borrownumber and name
add_member_orgs($borrowernumber,$borrowernumbers);
Takes a borrowernumber and a list of other borrowernumbers and inserts them into the borrowers_to_borrowers table
($id_cityarrayref, $city_hashref) = &GetCities();
Looks up the different city and zip in the database. Returns two elements: a reference-to-array, which lists the zip city codes, and a reference-to-hash, which maps the name of the city. WHERE =>OUEST PROVENCE OR EXTERIEUR
($lib) = &GetSortDetails($category,$sortvalue);
Returns the authorized value details &$lib
return value of authorized value details &$sortvalue
this is the value of authorized value &$category
this is the value of authorized value category
() = &DeleteBorrower($member);
delete all data fo borrowers and add record to deletedborrowers table &$member
this is the borrowernumber
DelMember($borrowernumber);
This function remove directly a borrower whitout writing it on deleteborrower. + Deletes reserves for the borrower
$date = ExtendMemberSubscriptionTo($borrowerid, $date);
Extending the subscription to a given date or to the expiry date calculated on ISO date. Returns ISO date.
($idroadtypearrayref, $roadttype_hashref) = &GetRoadTypes();
Looks up the different road type . Returns two elements: a reference-to-array, which lists the id_roadtype codes, and a reference-to-hash, which maps the road type of the road .
($borrowertitle)= &GetTitles();
Looks up the different title . Returns array with all borrowers title
my ($imagedata, $dberror) = GetPatronImage($cardnumber);
Returns the mimetype and binary image data of the image for the patron with the supplied cardnumber.
PutPatronImage($cardnumber, $mimetype, $imgfile);
Stores patron binary image data and mimetype in database. NOTE: This function is good for updating images as well as inserting new images in the database.
my ($dberror) = RmPatronImage($cardnumber);
Removes the image for the patron with the supplied cardnumber.
($roadtype) = &GetRoadTypeDetails($roadtypeid);
Returns the description of roadtype &$roadtype
return description of road type &$roadtypeid
this is the value of roadtype s
&GetBorrowersWhoHaveNotBorrowedSince($date)
this function get all borrowers who haven't borrowed since the date given on input arg.
$results = &GetBorrowersWhoHaveNeverBorrowed
this function get all borrowers who have never borrowed.
$result is a ref to an array which all elements are a hasref.
$results = &GetBorrowersWithIssuesHistoryOlderThan($date)
this function get all borrowers who has an issue history older than $date given on input arg.
$result is a ref to an array which all elements are a hashref. This hashref is containt the number of time this borrowers has borrowed before $date and the borrowernumber.
$results = &GetBorrowersNamesAndLatestIssueList(@borrowernumbers)
this function get borrowers Names and surnames and Issue information.
@borrowernumbers is an array which all elements are borrowernumbers. This hashref is containt the number of time this borrowers has borrowed before $date and the borrowernumber.
Koha Team
Hey! The above document had some coding errors, which are explained below:
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
=back without =over