[open-ils-commits] r16383 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Acq web/js/ui/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon May 3 17:23:44 EDT 2010


Author: senator
Date: 2010-05-03 17:23:38 -0400 (Mon, 03 May 2010)
New Revision: 16383

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm
   trunk/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js
Log:
Acq: view vouchers from previously issued claims in LI/LID claim interface


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm	2010-05-03 19:02:30 UTC (rev 16382)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm	2010-05-03 21:23:38 UTC (rev 16383)
@@ -248,5 +248,85 @@
 }
 
 
+__PACKAGE__->register_method(
+    method => "get_claim_voucher_by_lid",
+    api_name => "open-ils.acq.claim.voucher.by_lineitem_detail",
+    stream => 1,
+    signature => {
+        desc => q/Retrieve existing claim vouchers by lineitem detail ID/,
+        params => [
+            {desc => "Authentication token", type => "string"},
+            {desc => "Lineitem detail ID", type => "number"}
+        ],
+        return => {
+            desc => "Claim ready data", type => "object", class => "atev"
+        }
+    }
+);
 
+sub get_claim_voucher_by_lid {
+    my ($self, $conn, $auth, $lid_id) = @_;
+
+    my $e = new_editor("authtoken" => $auth);
+    return $e->die_event unless $e->checkauth;
+
+    my $lid = $e->retrieve_acq_lineitem_detail([
+        $lid_id, {
+            "flesh" => 2,
+            "flesh_fields" => {
+                "acqlid" => ["lineitem"], "jub" => ["purchase_order"]
+            }
+        }
+    ]);
+
+    return $e->die_event unless $e->allowed(
+        "VIEW_PURCHASE_ORDER", $lid->lineitem->purchase_order->ordering_agency
+    );
+
+    my $id_list = $e->json_query({
+        "select" => {"atev" => ["id"]},
+        "from" => {
+            "atev" => {
+                "atevdef" => {"field" => "id", "fkey" => "event_def"},
+                "acqcle" => {
+                    "field" => "id", "fkey" => "target",
+                    "join" => {
+                        "acqcl" => {
+                            "field" => "id", "fkey" => "claim",
+                            "join" => {
+                                "acqlid" => {
+                                    "fkey" => "lineitem_detail",
+                                    "field" => "id"
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "where" => {
+            "-and" => {
+                "+atevdef" => {"hook" => "format.acqcle.html"},
+                "+acqlid" => {"id" => $lid_id}
+            }
+        }
+    }) or return $e->die_event;
+
+    if ($id_list && @$id_list) {
+        foreach (@$id_list) {
+            $conn->respond(
+                $e->retrieve_action_trigger_event([
+                    $_->{"id"}, {
+                        "flesh" => 1,
+                        "flesh_fields" => {"atev" => ["template_output"]}
+                    }
+                ])
+            );
+        }
+    }
+
+    $e->disconnect;
+    undef;
+}
+
 1;

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js	2010-05-03 19:02:30 UTC (rev 16382)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js	2010-05-03 21:23:38 UTC (rev 16383)
@@ -116,15 +116,10 @@
         var claimNode = dojo.clone(this.showingClaimTemplate);
         nodeByName("type", claimNode).innerHTML = claim.type().code();
         nodeByName("voucher", claimNode).onclick = function() {
-            alert("unimplemented"); // XXX
-            // TODO For some reason, the format.acqcle.html events that get
-            // fired by claim_item() in Claims.pm don't stick around in
-            // the database.  Must find out why and fix this before writing
-            // the ML method that the following code would call.
-            /*
             var win;
             fieldmapper.standardRequest(
-                ["open-ils.acq", "open-ils.acq.claim.get_format_events"], {
+                ["open-ils.acq",
+                    "open-ils.acq.claim.voucher.by_lineitem_detail"], {
                     "params": [openils.User.authtoken, lid.id()],
                     "async": true,
                     "onresponse": function(r) {
@@ -133,7 +128,7 @@
                                 win = openClaimVoucherWindow();
                         }
                         dojo.byId("main", win.document).innerHTML +=
-                            (contents + "<hr />");
+                            (r.template_output().data() + "<hr />");
                     },
                     "oncomplete": function() {
                         var print_button = dojo.byId("print", win.document);
@@ -142,7 +137,6 @@
                     }
                 }
             );
-            */
         };
 
         dojo.place(



More information about the open-ils-commits mailing list