Koha::Item - Koha Item object class
$item->store;
$params can take an optional 'skip_record_index' parameter. If set, the reindexation process will not happen (index_records not called) You should not turn it on if you do not understand what it is doing exactly.
returns 1 if the item is safe to delete,
"book_on_loan" if the item is checked out,
"not_same_branch" if the item is blocked by independent branches,
"book_reserved" if the there are holds aganst the item, or
"linked_analytics" if the item has linked analytic records.
"last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed
my $is_moved = $item->move_to_deleted;
Move an item to the deleteditems table. This can be done before deleting an item, to make sure the data are not completely deleted.
Returns the itemtype for the item based on whether item level itemtypes are set or not.
my $library = $item->home_library
Return the Koha::Library object representing the home library
my $library = $item->holding_library
Return the Koha::Library object representing the holding library
my $biblio = $item->biblio;
Return the bibliographic record of this item
my $biblioitem = $item->biblioitem;
Return the biblioitem record of this item
my $checkout = $item->checkout;
Return the checkout for this item
my $item_group = $item->item_group;
Return the item group for this item
my $item_group_item = $item->item_group_item;
Return the item group for this item
my $return_claims = $item->return_claims;
Return any return_claims associated with this item
my $return_claim = $item->return_claim;
Returns the most recent unresolved return_claims associated with this item
my $holds = $item->holds(); my $holds = $item->holds($params); my $holds = $item->holds({ found => 'W'});
Return holds attached to an item, optionally accept a hashref of params to pass to search
my $bookings = $item->bookings();
Returns the bookings attached to this item.
my $booking = $item->find_booking( { checkout_date => $now, due_date => $future_date } );
Find the first booking that would conflict with the passed checkout dates for this item. If a booking lead period is configured for the itemtype we will also take that into account here, counting bookings that fall in that lead period as conflicts too.
FIXME: This can be simplified, it was originally intended to iterate all biblio level bookings to catch cases where this item may be the last available to satisfy a biblio level only booking. However, we dropped the biblio level functionality prior to push as bugs were found in it's implementation.
my $bookable = $item->check_booking( { start_date => $datetime, end_date => $datetime, [ booking_id => $booking_id ] } );
Returns a boolean denoting whether the passed booking can be made without clashing.
Optionally, you may pass a booking id to exclude from the checks; This is helpful when you are updating an existing booking.
my $transfer = $item->request_transfer( { to => $to_library, reason => $reason, [ ignore_limits => 0, enqueue => 1, replace => 'reason' ] } );
Add a transfer request for this item to the given branch for the given reason.
An exception will be thrown if the BranchTransferLimits would prevent the requested transfer, unless 'ignore_limits' is passed to override the limits.
An exception will be thrown if an active transfer (i.e pending arrival date) is found; The caller should catch such cases and retry the transfer request as appropriate passing an appropriate override.
Overrides * enqueue - Used to queue up the transfer when the existing transfer is found to be in transit. * replace - Used to replace the existing transfer request with your own.
my $transfer = $item->get_transfer;
Return the active transfer request or undef
Note: Transfers are retrieved in a Modified FIFO (First In First Out) order whereby the most recently sent, but not received, transfer will be returned if it exists, otherwise the oldest unsatisfied transfer will be returned.
This allows for transfers to queue, which is the case for stock rotation and rotating collections where a manual transfer may need to take precedence but we still expect the item to end up at a final location eventually.
my $transfer = $item->transfer;
Returns the active transfer request. Returns undef if no active transfer is found.
Note: Transfers are retrieved in a Modified FIFO (First In First Out) order whereby the most recently sent, but not received, transfer will be returned if it exists, otherwise the oldest unsatisfied transfer will be returned.
This allows for transfers to queue, which is the case for stock rotation and rotating collections where a manual transfer may need to take precedence but we still expect the item to end up at a final location eventually.
my $transfer = $item->get_transfers;
Return the list of outstanding transfers (i.e requested but not yet cancelled or received).
Note: Transfers are retrieved in a Modified FIFO (First In First Out) order whereby the most recently sent, but not received, transfer will be returned first if it exists, otherwise requests are in oldest to newest request order.
This allows for transfers to queue, which is the case for stock rotation and rotating collections where a manual transfer may need to take precedence but we still expect the item to end up at a final location eventually.
Gets and sets the last patron to return an item.
Accepts a patron's id (borrowernumber) and returns Koha::Patron objects
$item->last_returned_by( $borrowernumber );
my $patron = $item->last_returned_by();
my $bool = $item->can_article_request( $borrower )
Returns true if item can be specifically requested
$borrower must be a Koha::Patron object
my $bool = $item->hidden_in_opac({ [ rules => $rules ] })
Returns true if item fields match the hidding criteria defined in $rules. Returns false otherwise.
Takes HASHref that can have the following parameters: OPTIONAL PARAMETERS: $rules : { <field> => [ value_1, ... ], ... }
Note: $rules inherits its structure from the parsed YAML from reading the OpacHiddenItems system preference.
$item->can_be_transferred({ to => $to_library, from => $from_library }) Checks if an item can be transferred to given library.
This feature is controlled by two system preferences: UseBranchTransferLimits to enable / disable the feature BranchTransferLimitsType to use either an itemnumber or ccode as an identifier for setting the limitations
Takes HASHref that can have the following parameters: MANDATORY PARAMETERS: $to : Koha::Library OPTIONAL PARAMETERS: $from : Koha::Library # if not given, item holdingbranch # will be used instead
Returns 1 if item can be transferred to $to_library, otherwise 0.
To find out whether at least one item of a Koha::Biblio can be transferred, please see Koha::Biblio->can_be_transferred() instead of using this method for multiple items of the same biblio.
my $pickup_locations = $item->pickup_locations({ patron => $patron })
Returns possible pickup locations for this item, according to patron's home library and if item can be transferred to each pickup location.
Throws a Koha::Exceptions::MissingParameter exception if the mandatory parameter patron is not passed.
my $type = $item->article_request_type( $borrower )
returns 'yes', 'no', 'bib_only', or 'item_only'
$borrower must be a Koha::Patron object
my $first_hold = $item->first_hold;
Returns the first Koha::Hold for the item.
my $sritem = Koha::Item->stockrotationitem;
Returns the stock rotation item associated with the current item.
my $item = $item->add_to_rota($rota_id);
Add this item to the rota identified by $ROTA_ID, which means associating it with the first stage of that rota. Should this item already be associated with a rota, then we will move it to the new rota.
my $is_pending_hold = $item->has_pending_hold();
This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false
my $has_pending_recall
Return if whether has pending recall of not.
my $field = $item->as_marc_field;
This method returns a MARC::Field object representing the Koha::Item object with the current mappings configuration.
Returns the branchcode to be recorded in statistics renewal of the item
Return the cover images associated with this item.
Return the cover image ids associated with this item.
my $values = $items->columns_to_str;
Return a hashref with the string representation of the different attribute of the item.
This is meant to be used for display purpose only.
my $attributes = $item->additional_attributes; $attributes->{k} = 'new k'; $item->update({ more_subfields => $attributes->to_marcxml });
Returns a Koha::Item::Attributes object that represents the non-mapped attributes for this item.
$self->_set_found_trigger
Finds the most recent lost item charge for this item and refunds the patron appropriately, taking into account any payments or writeoffs already applied against the charge.
Internal function, not exported, called only by Koha::Item->store.
This method returns the list of publicly readable database fields for both API and UI output purposes
Overloaded to_api method to ensure item-level itypes is adhered to.
This method returns the mapping for representing a Koha::Item object on the API.
my $itemtype = $item->itemtype;
Returns Koha object for effective itemtype
my $item_type = $item->item_type;
Returns the effective Koha::ItemType for the item.
FIXME: it should either return the 'real item type' or undef if no item type defined. And effective_itemtype should return... the effective itemtype. Right now it returns an id... This is all inconsistent. And the API should make it clear if the attribute is part of the resource, or a calculated value i.e. if the item is not linked to an item type on its own, then the API response should contain item_type: null! And the effective item type... be another attribute. I understand that this complicates filtering, but some query trickery could do it in the controller.
my $nfl = $item->effective_not_for_loan_status;
Returns the effective not for loan status of the item
my $bookable = $item->effective_bookable;
Returns the effective bookability of the current item, be that item or itemtype level
my $orders = $item->orders();
Returns a Koha::Acquisition::Orders object
my $tracked_links = $item->tracked_links();
Returns a Koha::TrackedLinks object
my $course_item = $item->course_item;
Returns a Koha::Course::Item object
$item->move_to_biblio($to_biblio[, $params]);
Move the item to another biblio and update any references in other tables.
The final optional parameter, $params
, is expected to contain the 'skip_record_index' key, which is relayed down to Koha::Item->store. There it prevents calling index_records, which takes most of the time in batch adds/deletes. The caller must take care of calling index_records separately.
$params: skip_record_index => 1|0
Returns undef if the move failed or the biblionumber of the destination record otherwise
my $bundle_items = $item->bundle_items;
Returns the items associated with this bundle
my $bundle_items = $item->bundle_items_not_lost;
Returns the items associated with this bundle that are not lost
my $bundle_items = $item->bundle_items_lost;
Returns the items associated with this bundle that are lost
my $is_bundle = $item->is_bundle;
Returns whether the item is a bundle or not
my $bundle = $item->bundle_host;
Returns the bundle item this item is attached to
my $in_bundle = $item->in_bundle;
Returns whether this item is currently in a bundle
my $link = $item->add_to_bundle($bundle_item);
Adds the bundle_item passed to this item
Remove this item from any bundle it may have been attached to.
Helper method that takes care of calling all plugin hooks
my $recall = $item->recall;
Return the relevant recall for this item
if ( $item->can_be_recalled({ patron => $patron_object }) ) # do recall
Does item-level checks and returns if items can be recalled by this borrower
if ( $item->can_be_waiting_recall ) { # allocate item as waiting for recall
Checks item type and branch of circ rules to return whether this item can be used to fill a recall. At this point the item has already been recalled. We are now at the checkin and set waiting stage.
my $recall = $item->check_recalls;
Get the most relevant recall for this item.
my $is_denied_renewal = $item->is_denied_renewal;
Determine whether or not this item can be renewed based on the rules set in the ItemsDeniedRenewal system preference.
my $analytics_count = $item->analytics_count;
Return the related analytic records count.
It returns 0 if EasyAnalyticalRecords is disabled.
Returns a map of column name to string representations including the string, the mapping type and the mapping category where appropriate.
Currently handles authorised value mappings, library, callnumber and itemtype expansions.
Accepts a param hashref where the 'public' key denotes whether we want the public or staff client strings.
$item->location_update_trigger( $action );
Updates the item location based on $action. It is done like this:
FIXME: It should return $self. See bug 35270.
my $statuses = $item->z3950_statuses( $status_strings );
Returns an array of statuses for use in z3950 results. Takes a hashref listing the display strings for the various statuses. Availability is determined by item statuses and the system preference z3950Status.
Status strings are defined in authorised values in the Z3950_STATUS category.
Kyle M Hall <kyle@bywatersolutions.com>