From: Bill Erickson Date: Tue, 10 Jul 2012 20:29:39 +0000 (-0400) Subject: Show zero-copy lineitem's in zero-copy activation warning X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=827c7f915a1175f663e4c9371e6883a3bb7784b1;p=evergreen%2Fequinox.git Show zero-copy lineitem's in zero-copy activation warning When PO activation fails as a result of zero-copy lineitems, show the IDs of the zero-copy lineitems along with the failure message. This adds a new API call open-ils.acq.purchase_order.no_copy_lineitems.id_list(auth, po_id) Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 8116ca3b3b..6e4711e560 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -3390,5 +3390,44 @@ sub add_li_to_po { return {success => 1}; } +__PACKAGE__->register_method( + method => 'po_lineitems_no_copies', + api_name => 'open-ils.acq.purchase_order.no_copy_lineitems.id_list', + stream => 1, + authoritative => 1, + signature => { + desc => q/Returns the set of lineitem IDs for a given PO that have no copies attached/, + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'The purchase order id', type => 'number'}, + ], + return => {desc => 'Stream of lineitem IDs on success, event on error'} + } +); + +sub po_lineitems_no_copies { + my ($self, $conn, $auth, $po_id) = @_; + + my $e = new_editor(authtoken => $auth); + return $e->event unless $e->checkauth; + + # first check the view perms for LI's attached to this PO + my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->event; + return $e->event unless $e->allowed('VIEW_PURCHASE_ORDER', $po->ordering_agency); + + my $ids = $e->json_query({ + select => {jub => ['id']}, + from => {jub => {acqlid => {type => 'left'}}}, + where => { + '+jub' => {purchase_order => $po_id}, + '+acqlid' => {lineitem => undef} + } + }); + + $conn->respond($_->{id}) for @$ids; + return undef; +} + + 1; diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 626e5ce9b3..53acfa444d 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -481,6 +481,21 @@ function checkCouldActivatePo() { d.innerHTML = localeStrings.NO + ": " + other[0].desc + " (" + other[0].textcode + ")"; openils.Util.hide(a); + + if (other[0].textcode == 'ACQ_LINEITEM_NO_COPIES') { + // when LIs w/ zero LIDs are present, list them + fieldmapper.standardRequest( + [ 'open-ils.acq', + 'open-ils.acq.purchase_order.no_copy_lineitems.id_list.authoritative.atomic' ], + { async : true, + params : [openils.User.authtoken, poId], + oncomplete : function(r) { + var ids = openils.Util.readResponse(r); + d.innerHTML += ' (' + ids + ')'; + } + } + ); + } } else if (stops.length) { d.innerHTML = dojo.string.substitute(