From: Mike Rylander Date: Tue, 19 May 2020 19:13:57 +0000 (-0400) Subject: LP#1879983: A/T components of Curbside X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=773b7b7e338d444bb96a5a23c5b42dddcfb58b68;p=Evergreen.git LP#1879983: A/T components of Curbside This commit adds a reactor and validator for automating parts of the basic Curbside workflows: * Curbside validator: check whether curbside is enabled at the org unit applicable an A/T event's target, which could be a user, org unit, curbside appointment, or hold request. * CurbsideSlot reactor: Creates a curbside appointment slot at the hold pickup library when a hold becomes ready for pickup, if one does not exist. This is meant to be triggered by the hold.available hook. Appointments created by this reactor do not have an appointment time set, as that is meant to be supplied by the patron or a staff member acting on behalf of the patron. In addition to Mike Rylander, significant contributions to this patch were made by Jason Boyer. Sponsored-by: PaILS Signed-off-by: Mike Rylander Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton Signed-off-by: Michele Morgan --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/CurbsideSlot.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/CurbsideSlot.pm new file mode 100644 index 0000000000..bb07c3f307 --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/CurbsideSlot.pm @@ -0,0 +1,51 @@ +package OpenILS::Application::Trigger::Reactor::CurbsideSlot; +use base 'OpenILS::Application::Trigger::Reactor'; +use strict; use warnings; +use OpenILS::Utils::CStoreEditor q/:funcs/; +use OpenILS::Application::AppUtils; +my $U = "OpenILS::Application::AppUtils"; + +$Data::Dumper::Indent = 0; + + +sub ABOUT { + return < 1); + + my $h = $$env{target}; + + # see if there's an undelivered appointment in the future + my $slot = $e->search_action_curbside({ + patron => $h->usr, + org => $h->pickup_lib, + delivered => undef + }); + + if (!@$slot) { + $slot = Fieldmapper::action::curbside->new; + $slot->org($h->pickup_lib); + $slot->patron($h->usr); + $e->create_action_curbside($slot); + $e->commit; + + my $ses = OpenSRF::AppSession->create('open-ils.trigger'); + $ses->request('open-ils.trigger.event.autocreate', 'hold.offer_curbside', $h, $h->pickup_lib); + + } else { + $e->rollback; + } + + return 1; +} + +1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator/Curbside.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator/Curbside.pm new file mode 100644 index 0000000000..3fab8ffa50 --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator/Curbside.pm @@ -0,0 +1,29 @@ +package OpenILS::Application::Trigger::Validator::Curbside; +use strict; use warnings; +use OpenILS::Application::AppUtils; +my $U = 'OpenILS::Application::AppUtils'; + +sub handler { + my ($self, $env) = @_; + my $org; + + # support a few different target types + if ($env->{target}->isa('Fieldmapper::action::curbside')) { + $org = $env->{target}->org; + } elsif ($env->{target}->isa('Fieldmapper::action::hold_request')) { + $org = $env->{target}->pickup_lib; + } elsif ($env->{target}->isa('Fieldmapper::actor::usr')) { + $org = $env->{target}->home_ou; + } elsif ($env->{target}->isa('Fieldmapper::actor::org_unit')) { + $org = $env->{target}->id; + } + + return 0 unless (defined $org); + + $org = $org->id if ref($org); # somehow we got a fleshed org object on the target + return $U->is_true( + $U->ou_ancestor_setting_value($org, 'circ.curbside') + ); +} + +1;