From c683574e96d7dc975db179a1fe8e068642681443 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 9 Apr 2010 13:48:48 +0000 Subject: [PATCH] when amount paid exceeds amount billed, disable save/prorate buttons and style the amount paid box. if either paid/billed are < 0, style their respective boxes git-svn-id: svn://svn.open-ils.org/ILS/trunk@16193 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/css/skin/default/acq.css | 2 ++ Open-ILS/web/js/ui/default/acq/invoice/view.js | 41 +++++++++++++++++----- .../web/templates/default/acq/invoice/view.tt2 | 6 ++-- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index aa942c859..ffdb200b7 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -221,3 +221,5 @@ option[disabled="disabled"] { font-style: italic; } .acq-inoice-item-extra-info { padding-left: 10px; } .acq-inoice-item-info { font-weight: bold; } .acq-invoice-row td { border-bottom: 1px solid #e0e0e0; } +.acq-invoice-invalid-amount input { color: red; font-weight: bold; } + diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js index cf1d1b31f..bac605db0 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -164,31 +164,56 @@ function doAttachPo() { } function updateTotalCost() { - var total = 0; + + var totalCost = 0; if(!totalInvoicedBox) { totalInvoicedBox = new dijit.form.CurrencyTextBox( {style : 'width: 5em'}, dojo.byId('acq-invoice-total-invoiced')); } for(var id in widgetRegistry.acqii) if(!widgetRegistry.acqii[id]._object.isdeleted()) - total += widgetRegistry.acqii[id].cost_billed.getFormattedValue(); + totalCost += widgetRegistry.acqii[id].cost_billed.getFormattedValue(); for(var id in widgetRegistry.acqie) if(!widgetRegistry.acqie[id]._object.isdeleted()) - total += widgetRegistry.acqie[id].cost_billed.getFormattedValue(); - totalInvoicedBox.attr('value', total); + totalCost += widgetRegistry.acqie[id].cost_billed.getFormattedValue(); + totalInvoicedBox.attr('value', totalCost); - total = 0; + totalPaid = 0; if(!totalPaidBox) { totalPaidBox = new dijit.form.CurrencyTextBox( {style : 'width: 5em'}, dojo.byId('acq-invoice-total-paid')); } for(var id in widgetRegistry.acqii) if(!widgetRegistry.acqii[id]._object.isdeleted()) - total += widgetRegistry.acqii[id].amount_paid.getFormattedValue(); + totalPaid += widgetRegistry.acqii[id].amount_paid.getFormattedValue(); for(var id in widgetRegistry.acqie) if(!widgetRegistry.acqie[id]._object.isdeleted()) - total += widgetRegistry.acqie[id].amount_paid.getFormattedValue(); - totalPaidBox.attr('value', total); + totalPaid += widgetRegistry.acqie[id].amount_paid.getFormattedValue(); + totalPaidBox.attr('value', totalPaid); + + var buttonsDisabled = false; + if(totalPaid > totalCost || totalPaid < 0) { + openils.Util.addCSSClass(totalPaidBox.domNode, 'acq-invoice-invalid-amount'); + invoiceSaveButton.attr('disabled', true); + invoiceProrateButton.attr('disabled', true); + buttonsDisabled = true; + } else { + openils.Util.removeCSSClass(totalPaidBox.domNode, 'acq-invoice-invalid-amount'); + invoiceSaveButton.attr('disabled', false); + invoiceProrateButton.attr('disabled', false); + } + + if(totalCost < 0) { + openils.Util.addCSSClass(totalInvoicedBox.domNode, 'acq-invoice-invalid-amount'); + invoiceSaveButton.attr('disabled', true); + invoiceProrateButton.attr('disabled', true); + } else { + openils.Util.removeCSSClass(totalInvoicedBox.domNode, 'acq-invoice-invalid-amount'); + if(!buttonsDisabled) { + invoiceSaveButton.attr('disabled', false); + invoiceProrateButton.attr('disabled', false); + } + } } diff --git a/Open-ILS/web/templates/default/acq/invoice/view.tt2 b/Open-ILS/web/templates/default/acq/invoice/view.tt2 index 3368e6be7..190dbd7d9 100644 --- a/Open-ILS/web/templates/default/acq/invoice/view.tt2 +++ b/Open-ILS/web/templates/default/acq/invoice/view.tt2 @@ -98,8 +98,10 @@ - - + +
-- 2.11.0