From: Bill Erickson Date: Mon, 20 Apr 2015 21:21:43 +0000 (-0400) Subject: JBAS-231 blanket PO local template cross-ports X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fd622dbb9e8bf111feeed170490854f3bd8cbf74;p=working%2FEvergreen.git JBAS-231 blanket PO local template cross-ports Port blanket PO changes to local templates and scripts. Signed-off-by: Bill Erickson --- diff --git a/KCLS/openils/var/templates_kcls/acq/po/view.tt2 b/KCLS/openils/var/templates_kcls/acq/po/view.tt2 index 9e15172b87..ce58e62a51 100644 --- a/KCLS/openils/var/templates_kcls/acq/po/view.tt2 +++ b/KCLS/openils/var/templates_kcls/acq/po/view.tt2 @@ -30,6 +30,11 @@ [% l('Activate Without Loading Items') %] + diff --git a/Open-ILS/web/js/ui/kcls/acq/common/li_table.js b/Open-ILS/web/js/ui/kcls/acq/common/li_table.js index a983a377dd..187cd2d6fe 100644 --- a/Open-ILS/web/js/ui/kcls/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/kcls/acq/common/li_table.js @@ -1409,6 +1409,7 @@ function AcqLiTable() { var allSet = true; dojo.forEach(priceNodes, function(node) { if (node.value == '') allSet = false}); if (allSet) checkCouldActivatePo(); + refreshPOSummaryAmounts(); } } } @@ -2648,6 +2649,7 @@ function AcqLiTable() { oncomplete: function() { self.drawCopies(liId, true /* force_fetch */); openils.Util.hide("acq-lit-update-copies-progress"); + refreshPOSummaryAmounts(); } } ); diff --git a/Open-ILS/web/js/ui/kcls/acq/po/view_po.js b/Open-ILS/web/js/ui/kcls/acq/po/view_po.js index e8ea814dc0..5a67e8f09c 100644 --- a/Open-ILS/web/js/ui/kcls/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/kcls/acq/po/view_po.js @@ -299,6 +299,33 @@ function prepareInvoiceFeatures() { openils.Util.show("acq-po-invoice-stuff", "table-cell"); } +function setSummaryAmounts() { + dojo.byId("acq-po-view-total-enc").innerHTML = PO.amount_encumbered().toFixed(2); + dojo.byId("acq-po-view-total-spent").innerHTML = PO.amount_spent().toFixed(2); + dojo.byId("acq-po-view-total-estimated").innerHTML = PO.amount_estimated().toFixed(2); +} + +function refreshPOSummaryAmounts() { + fieldmapper.standardRequest( + ['open-ils.acq', + 'open-ils.acq.purchase_order.retrieve.authoritative'], + { async: true, + params: [openils.User.authtoken, poId, { + "flesh_price_summary": true + }], + oncomplete: function(r) { + // update the global PO instead of replacing it, since other + // code outside our control may be referencing it. + var po = openils.Util.readResponse(r); + PO.amount_encumbered(po.amount_encumbered()); + PO.amount_spent(po.amount_spent()); + PO.amount_estimated(po.amount_estimated()); + setSummaryAmounts(); + } + } + ); +} + /* renderPo() is the best place to add tests that depend on PO-state * (or simple ordered-or-not? checks) to enable/disable UI elements * across the whole interface. */ @@ -310,9 +337,9 @@ function renderPo() { dojo.byId("acq-po-view-provider"), PO.provider() ); + + setSummaryAmounts(); dojo.byId("acq-po-view-total-li").innerHTML = PO.lineitem_count(); - dojo.byId("acq-po-view-total-enc").innerHTML = PO.amount_encumbered().toFixed(2); - dojo.byId("acq-po-view-total-spent").innerHTML = PO.amount_spent().toFixed(2); dojo.byId("acq-po-view-state").innerHTML = po_state; // TODO i18n if(PO.order_date()) { @@ -368,6 +395,7 @@ function renderPo() { } else { if (PO.order_date()) { dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.PO_ALREADY_ACTIVATED; + checkCouldBlanketFinalize(); } else { dojo.byId("acq-po-activate-checking").innerHTML = localeStrings.NO; } @@ -448,7 +476,6 @@ function init() { function init2() { - var totalEstimated = 0; var zeroLi = true; fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.lineitem.search'], @@ -462,13 +489,10 @@ function init2() { zeroLi = false; liTable.show('list'); var li = openils.Util.readResponse(r); - // TODO: Add po_item's to total estimated amount - totalEstimated += (Number(li.item_count() || 0) * Number(li.estimated_unit_price() || 0)); liTable.addLineitem(li); }, oncomplete : function() { - dojo.byId("acq-po-view-total-estimated").innerHTML = totalEstimated.toFixed(2); if (liFocus) liTable.drawCopies(liFocus); if(zeroLi) openils.Util.show('acq-po-no-lineitems'); } @@ -495,6 +519,30 @@ function init2() { ); } +function checkCouldBlanketFinalize() { + + if (PO.state() == 'received') return; + + var inv_types = []; + + // get the unique set of invoice item type IDs + PO.po_items().forEach(function(item) { + if (inv_types.indexOf(item.inv_item_type()) == -1) + inv_types.push(item.inv_item_type()); + }); + + if (inv_types.length == 0) return; + + pcrud.search('aiit', + {code : inv_types, blanket : 't'}, { + oncomplete : function(r) { + r = openils.Util.readResponse(r); + if (r.length == 0) return; + openils.Util.show(dojo.byId('acq-po-finalize-links'), 'inline'); + } + }); +} + function checkCouldActivatePo() { var d = dojo.byId("acq-po-activate-checking"); var a = dojo.byId("acq-po-activate-links"); /* not now, but no diff */ @@ -583,6 +631,24 @@ function checkCouldActivatePo() { ); } +function finalizePo() { + + if (!confirm(localeStrings.FINALIZE_PO)) return; + + finalizePoButton.attr('disabled', true); + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.purchase_order.blanket.finalize'], + { async : true, + params : [openils.User.authtoken, PO.id()], + oncomplete : function(r) { + if (openils.Util.readResponse(r) == 1) + location.href = location.href; + } + } + ); +} + function activatePo(argument) { activatePoButton.attr("disabled", true); activatePoNoAssetsButton.attr("disabled", true);