added seed data for hold-available notifications. update holdisavail validator to...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 19 Jul 2009 15:36:22 +0000 (15:36 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 19 Jul 2009 15:36:22 +0000 (15:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@13626 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql

index f24a471..b3f2389 100644 (file)
@@ -4,6 +4,7 @@ use DateTime;
 use DateTime::Format::ISO8601;
 use OpenSRF::Utils qw/:datetime/;
 use OpenSRF::Utils::Logger qw/:logger/;
+use OpenILS::Const qw/:const/;
 sub fourty_two { return 42 }
 sub NOOP_True { return 1 }
 sub NOOP_False { return 0 }
@@ -33,16 +34,15 @@ sub HoldIsAvailable {
     my $self = shift;
     my $env = shift;
 
-    my $t = $env->{target}->transit;
+    my $hold = $env->{target};
 
-    die "Transit object exists, but is not fleshed.  Add 'transit' to the environment in order to use this Validator."
-        if ($t && !ref($t));
+    return 1 if 
+        !$hold->cancel_time and
+        $hold->capture_time and 
+        $hold->current_copy and
+        $hold->current_copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF;
 
-    if ($t) {
-        return (defined($env->{target}->capture_time) && defined($t->dest_recv_time)) ? 1 : 0;
-    }
-
-    return defined($env->{target}->capture_time) ? 1 : 0;
+    return 0;
 }
 
 1;
index 9bbd9f6..12e8843 100644 (file)
@@ -1855,5 +1855,34 @@ INSERT INTO action_trigger.environment (event_def, path) VALUES
     (4, 'provider.addresses'),
     (4, 'lineitems.attributes');
 
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
+    VALUES (5, 'f', 1, 'Hold Ready for Pickup Email Notification', 'hold.available', 'HoldIsAvailable', 'SendEmail', '30 minutes', 'capture_time', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Available Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The item(s) you requested are available for pickup from the Library.
+
+[% FOR hold IN target %]
+    Title: [% hold.current_copy.call_number.record.simple_record.title %]
+    Author: [% hold.current_copy.call_number.record.simple_record.author %]
+    Call Number: [% hold.current_copy.call_number.label %]
+    Barcode: [% hold.current_copy.barcode %]
+    Library: [% hold.pickup_lib.name %]
+[% END %]
+
+$$);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    (5, 'current_copy.call_number.record.simple_record'),
+    (5, 'usr'),
+    (5, 'pickup_lib.billing_address');
+
+
 SELECT SETVAL('action_trigger.event_definition_id_seq'::TEXT, 100);