create acq.created and acq.rejected events
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 20:36:06 +0000 (20:36 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Mar 2010 20:36:06 +0000 (20:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16041 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm

index 4aac65d..b909114 100644 (file)
@@ -2639,6 +2639,7 @@ sub update_user_request {
             if ( $cancel_reason ) {
                 $aur_obj->cancel_reason( $cancel_reason );
                 $e->update_acq_user_request($aur_obj) or return $e->die_event;
+                create_user_request_events( [ $aur_obj ], 'aur.rejected' );
             } else {
                 $e->delete_acq_user_request($aur_obj);
             }
@@ -2707,9 +2708,26 @@ sub new_user_request {
 
     $e->commit;
 
+    create_user_request_events( [ $aur_obj ], 'aur.created' );
+
     return $aur_obj;
 }
 
+sub create_user_request_events {
+    my($user_reqs, $hook) = @_;
+
+    my $ses = OpenSRF::AppSession->create('open-ils.trigger');
+    $ses->connect;
+
+    for my $user_req (@$user_reqs) {
+        my $req = $ses->request('open-ils.trigger.event.autocreate', $hook, $user_req, $user_req->usr->home_ou);
+        $req->recv;
+    }
+
+    $ses->disconnect;
+    return undef;
+}
+
 
 __PACKAGE__->register_method(
        method => "po_note_CUD_batch",