From: senator Date: Mon, 3 May 2010 21:23:38 +0000 (+0000) Subject: Acq: view vouchers from previously issued claims in LI/LID claim interface X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f0b3012b42d5603d954b94949fcf11284cd36710;p=evergreen%2Fmasslnc.git Acq: view vouchers from previously issued claims in LI/LID claim interface git-svn-id: svn://svn.open-ils.org/ILS/trunk@16383 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm index 0873fa373c..5f4c2a9cb5 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Claims.pm @@ -248,5 +248,85 @@ sub claim_lineitem_detail { } +__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; diff --git a/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js b/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js index ede0aff45b..a34e2bed01 100644 --- a/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js +++ b/Open-ILS/web/js/ui/default/acq/common/claim_dialog.js @@ -116,15 +116,10 @@ function ClaimDialogManager( 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 @@ function ClaimDialogManager( win = openClaimVoucherWindow(); } dojo.byId("main", win.document).innerHTML += - (contents + "
"); + (r.template_output().data() + "
"); }, "oncomplete": function() { var print_button = dojo.byId("print", win.document); @@ -142,7 +137,6 @@ function ClaimDialogManager( } } ); - */ }; dojo.place(