[Koha-bugs] [Bug 17712] Move availability calculation to the Koha namespace

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Dec 27 17:20:34 CET 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17712

--- Comment #10 from Lari Taskula <lari.taskula at jns.fi> ---
Created attachment 58451
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=58451&action=edit
Bug 17712: Item availability for hold

Adds Koha::Item::Availability::Hold class for item hold availability.

This patch adds item holdability queries in two contexts:
1. in_opac     (perspective of patron themselves)
2. in_intranet (perspective of a librarian to patron)

Returns a Koha::Item::Availability::Hold object, which contains all information
on
availability for hold in that context. This may include additional notes,
reasons
to ask for confirmation or reasons for unavailability.

Example: To find out if patron can hold an item in OPAC, we will write:

my $availability = Koha::Availability::Hold->item({
    patron => $patron,
    item => $item,
    to_branch => $branchcode, # transfer allowed from holdingbranch to
to_branch?
})->in_opac;
if ($availability->available) {
    # yes!
} else {
    foreach my $reason (keys %{$availability->unavailabilities}) {
        # each reason for unavailability
    }
    foreach my $reason (keys %{$availability->confirmations}) {
        # each reason that requires confirmation
    }
    foreach my $reason (keys %{$availability->notes}) {
        # each additional note
    }
}

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list