A/T components of Curbside
authorMike Rylander <mrylander@gmail.com>
Tue, 19 May 2020 19:13:57 +0000 (15:13 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 21 May 2020 21:25:53 +0000 (17:25 -0400)
This commit adds a reactor and validator for automating parts of the
basic Curbside workflows.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/CurbsideSlot.pm [new file with mode: 0644]
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator/Curbside.pm [new file with mode: 0644]

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 (file)
index 0000000..e95b09f
--- /dev/null
@@ -0,0 +1,44 @@
+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 <<ABOUT;
+    
+    Creates a curbside appointment slot at the hold pickup library when
+    a hold becomes ready for pickup, if one does not exist.
+
+ABOUT
+}
+
+sub handler {
+    my $self = shift;
+    my $env = shift;
+    my $e = new_editor(xact => 1);
+
+    my $h = $$env{target};
+    my ($slot) = $e->search_action_curbside({patron => $h->usr, org => $h->pickup_lib, slot => 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 (file)
index 0000000..f6101fb
--- /dev/null
@@ -0,0 +1,13 @@
+package OpenILS::Application::Trigger::Validator::Curbside;
+use strict; use warnings;
+use OpenILS::Application::AppUtils;
+my $U = 'OpenILS::Application::AppUtils';
+
+sub handler {
+    my ($self, $env) = @_;
+    return $U->is_true(
+        $U->ou_ancestor_setting_value($env->{target}->pickup_lib, 'circ.curbside')
+    );
+}
+
+1;