Koha::Patron - Koha Patron Object class
Autogenerate next cardnumber from highest value found in database
trim whitespace from data which has some non-whitespace in it. Could be moved to Koha::Object if need to be reused
$patron->plain_text_password( $password );
stores a copy of the unencrypted password in the object for use in code before encrypting for db
Patron specific store method to cleanup record and do other necessary things before saving to db
$patron->delete
Delete patron's holds, lists and finally the patron.
Lists owned by the borrower are deleted, but entries from the borrower to other lists are kept.
my $patron_category = $patron->category
Return the patron category for this patron
Returns a Koha::Library object representing the patron's home library.
Returns a Koha::SMS::Provider object representing the patron's SMS provider.
Returns Koha::Patron::Relationships object for this patron's guarantors
Returns the set of relationships for the patrons that are guarantors for this patron.
This is returned instead of a Koha::Patron object because the guarantor may not exist as a patron in Koha. If this is true, the guarantors name exists in the Koha::Patron::Relationship object and will have no guarantor_id.
Returns Koha::Patron::Relationships object for this patron's guarantors
Returns the set of relationships for the patrons that are guarantees for this patron.
The method returns Koha::Patron::Relationship objects for the sake of consistency with the guantors method. A guarantee by definition must exist as a patron in Koha.
Returns the amount owed by the patron's guarantors *and* the other guarantees of those guarantors
Returns the HouseboundProfile associated with this patron.
Returns the HouseboundRole associated with this patron.
Returns the siblings of this patron.
my $patron = Koha::Patrons->find($id); $patron->merge_with( \@patron_ids ); This subroutine merges a list of patrons into the patron record. This is accomplished by finding all related patron ids for the patrons to be merged in other tables and changing the ids to be that of the keeper patron.
$wants_check = $patron->wants_check_for_previous_checkout;
Return 1 if Koha needs to perform PrevIssue checking, else 0.
$do_check = $patron->do_check_for_previous_checkout($item);
Return 1 if the bib associated with $ITEM has previously been checked out to $PATRON, 0 otherwise.
my $debarment_expiration = $patron->is_debarred;
Returns the date a patron debarment will expire, or undef if the patron is not debarred
my $is_expired = $patron->is_expired;
Returns 1 if the patron is expired or 0;
my $is_going_to_expire = $patron->is_going_to_expire;
Returns 1 if the patron is going to expired, depending on the NotifyBorrowerDeparture pref or 0
$patron->set_password({ password => $plain_text_password [, skip_validation => 1 ] });
Set the patron's password.
The passed string is validated against the current password enforcement policy. Validation can be skipped by passing the skip_validation parameter.
Exceptions are thrown if the password is not good enough.
my $new_expiry_date = $patron->renew_account
Extending the subscription to the expiry date.
my $has_overdues = $patron->has_overdues;
Returns the number of patron's overdues
$patron->track_login; $patron->track_login({ force => 1 }); Tracks a (successful) login attempt. The preference TrackLastPatronActivity must be enabled. Or you should pass the force parameter.
my $is_moved = $patron->move_to_deleted;
Move a patron to the deletedborrowers table. This can be done before deleting a patron, to make sure the data are not completely deleted.
my @requests = $borrower->article_requests(); my $requests = $borrower->article_requests();
Returns either a list of ArticleRequests objects, or an ArtitleRequests object, depending on the calling context.
my @requests = $patron->article_requests_current
Returns the article requests associated with this patron that are incomplete
my @requests = $biblio->article_requests_finished
Returns the article requests associated with this patron that are completed
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal);
Add enrolment fee for a patron if needed.
$renewal - boolean denoting whether this is an account renewal or not
my $checkouts = $patron->checkouts
my $pending_checkouts = $patron->pending_checkouts
This method will return the same as $self->checkouts, but with a prefetch on items, biblio and biblioitems.
It has been introduced to replaced the C4::Members::GetPendingIssues subroutine
It should not be used directly, prefer to access fields you need instead of retrieving all these fields in one go.
my $old_checkouts = $patron->old_checkouts
my $overdue_items = $patron->get_overdues
Return the overdue items
my @routinglists = $patron->get_routing_lists
Returns the routing lists a patron is subscribed to.
my $age = $patron->get_age
Return the age of the patron
my $is_valid = $patron->is_valid_age
Return 1 if patron's age is between allowed limits, returns 0 if it's not.
my $account = $patron->account
my $holds = $patron->holds
Return all the holds placed by this patron
my $old_holds = $patron->old_holds
Return all the historical holds for this patron
my $return_claims = $patron->return_claims
my $email = $patron->notice_email_address;
Return the email address of patron used for notices. Returns the empty string if no email address.
my $first_valid_email_address = $patron->first_valid_email_address
Return the first valid email address for a patron. For now, the order is defined as email, emailpro, B_email. Returns the empty string if the borrower has no email addresses.
my $is_locked = $patron->account_locked
Return true if the patron has reached the maximum number of login attempts (see pref FailedLoginAttempts). If login_attempts is < 0, this is interpreted as an administrative lockout (independent of FailedLoginAttempts; see also Koha::Patron->lock). Otherwise return false. If the pref is not set (empty string, null or 0), the feature is considered as disabled.
my $can_see = $patron->can_see_patron_infos( $patron );
Return true if the patron (usually the logged in user) can see the patron's infos for a given patron
my $can_see = $patron->can_see_patrons_from( $branchcode );
Return true if the patron (usually the logged in user) can see the patron's infos from a given library
my $libraries = $patron-libraries_where_can_see_patrons;
Return the list of branchcodes(!) of libraries the patron is allowed to see other patron's infos. The branchcodes are arbitrarily returned sorted. We are supposing here that the object is related to the logged in patron (use of C4::Context::only_my_library)
An empty array means no restriction, the patron can see patron's infos from any libraries.
my $permission = $patron->has_permission($required);
See C4::Auth::haspermission for details of syntax for $required
my $is_superlibrarian = $patron->is_superlibrarian;
Return true if the patron is a superlibrarian.
my $is_adult = $patron->is_adult
Return true if the patron has a category with a type Adult (A) or Organization (I)
my $is_child = $patron->is_child
Return true if the patron has a category with a type Child (C)
my $patron = Koha::Patrons->find(42); $patron->userid( $new_userid ); my $has_a_valid_userid = $patron->has_valid_userid
my $patron = Koha::Patron->new( $params ); my $has_a_valid_userid = $patron->has_valid_userid
Return true if the current userid of this patron is valid/unique, otherwise false.
Note that this should be done in $self->store instead and raise an exception if needed.
my $patron = Koha::Patron->new( $params ); $patron->generate_userid
Generate a userid using the $surname and the $firstname (if there is a value in $firstname).
Set a generated userid ($firstname.$surname if there is a $firstname, or $surname if there is no value in $firstname) plus offset (0 if the $userid is unique, or a higher numeric value if not unique).
Return object of Koha::Patron::Attributes type with all attributes set for this patron
Or setter FIXME
Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 }); Lock and optionally expire a patron account. Remove holds and article requests if remove flag set. In order to distinguish from locking by entering a wrong password, let's call this an administrative lockout.
Koha::Patrons->find($id)->anonymize; Anonymize or clear borrower fields. Fields in BorrowerMandatoryField are randomized, other personal data is cleared too. Patrons with issues are skipped.
my @relationships = $patron->add_guarantor( { borrowernumber => $borrowernumber, relationships => $relationship, } ); Adds a new guarantor to a patron.
my $attribute_value = $patron->get_extended_attribute( $code );
Return the attribute for the code passed in parameter.
It not exist it returns undef
Note that this will not work for repeatable attribute types.
Maybe you certainly not want to use this method, it is actually only used for SHOW_BARCODE (which should be a real patron's attribute (not extended)
my $json = $patron->to_api;
Overloaded method that returns a JSON representation of the Koha::Patron object, suitable for API output.
This method returns the mapping for representing a Koha::Patron object on the API.
Kyle M Hall <kyle@bywatersolutions.com> Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> Martin Renvoize <martin.renvoize@ptfs-europe.com>