You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2009/12/09 08:54:28 UTC

svn commit: r888721 - in /ofbiz/trunk/applications/accounting/webapp/accounting: images/costCenters.js ledger/CostCenters.ftl

Author: apatel
Date: Wed Dec  9 07:54:28 2009
New Revision: 888721

URL: http://svn.apache.org/viewvc?rev=888721&view=rev
Log:
Adding field validation for each cost center share in glAccount.

Modified:
    ofbiz/trunk/applications/accounting/webapp/accounting/images/costCenters.js
    ofbiz/trunk/applications/accounting/webapp/accounting/ledger/CostCenters.ftl

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/images/costCenters.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/images/costCenters.js?rev=888721&r1=888720&r2=888721&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/images/costCenters.js (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/images/costCenters.js Wed Dec  9 07:54:28 2009
@@ -16,9 +16,47 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 Event.observe(window, 'load', function() {
     Event.observe($('costCentersSubmit'), 'click', processCostCenterData);
+    // Find all text boxes in form and add a method to list on for on change.
+    var categoryShareInputs = $('costCenters').getInputs('text');
+    categoryShareInputs.each(function (element) {
+        Event.observe(element, 'change', function(){
+            var textIdSplit = element.id.split('|');
+            var tableRowId = 'row_' + textIdSplit[0];
+            var tableRow = $(tableRowId);
+            // get all text inputs
+            var rowInputs = $(tableRowId).select('input[type="text"]');
+            var totalPercentage = 0;
+            rowInputs.each(function (inputElement) {
+                var inputElementIdSplit = inputElement.id.split("|");
+                if (inputElement.value) {
+                    totalPercentage = totalPercentage + parseFloat(inputElement.value) 
+                }
+            });
+            if (totalPercentage == 100 || totalPercentage == 0 ) {
+                if ( $(tableRowId).hasClassName('alternate-rowWarn')){
+                    $(tableRowId).removeClassName('alternate-rowWarn');
+                }
+                if ($('costCentersSubmit').hasClassName('buttontextdisabled')) {
+                    $('costCentersSubmit').removeClassName('buttontextdisabled')
+                    $('costCentersSubmit').disabled = false;
+                }
+
+            } else {
+                if ( !$(tableRowId).hasClassName('alternate-rowWarn')){
+                    $(tableRowId).addClassName('alternate-rowWarn');
+                }
+                if (!$('costCentersSubmit').hasClassName('buttontextdisabled')) {
+                    $('costCentersSubmit').addClassName('buttontextdisabled')
+                    $('costCentersSubmit').disabled = true;
+                }
+            }
+        });
+    });
 });
+
 function processCostCenterData() {
     new Ajax.Request($('costCenters').action, {
         asynchronous: false,

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/ledger/CostCenters.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/ledger/CostCenters.ftl?rev=888721&r1=888720&r2=888721&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/ledger/CostCenters.ftl (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/ledger/CostCenters.ftl Wed Dec  9 07:54:28 2009
@@ -32,23 +32,25 @@
         </#list>
       </tr>
 
+    <#assign alt_row = false>
       <#list glAcctgAndAmountPercentageList as glAcctgAndAmountPercentage>
         <input type="hidden" id="glAccountId_${glAcctgAndAmountPercentage.glAccountId}" name="glAccountId_o_${glAcctgAndAmountPercentage_index}" value="${glAcctgAndAmountPercentage.glAccountId!}"/>
-        <tr>
+        <tr id="row_${glAcctgAndAmountPercentage.glAccountId}" <#if alt_row> class="alternate-row"</#if>>
           <td>${glAcctgAndAmountPercentage.glAccountId}</td>
           <td>${glAcctgAndAmountPercentage.accountCode!}</td>
           <td>${glAcctgAndAmountPercentage.accountName!}</td>
           <#list glAccountCategories as glAccountCategory>
             <td>
               <#if (glAcctgAndAmountPercentage[glAccountCategory.glAccountCategoryId!])??>
-                <input type="text" name="amp_${glAccountCategory.glAccountCategoryId!}_o_${glAcctgAndAmountPercentage_index}" value="${(glAcctgAndAmountPercentage[glAccountCategory.glAccountCategoryId!])!}"/>
+                <input type="text" id="${glAcctgAndAmountPercentage.glAccountId}|${glAccountCategory.glAccountCategoryId}" name="amp_${glAccountCategory.glAccountCategoryId!}_o_${glAcctgAndAmountPercentage_index}" value="${(glAcctgAndAmountPercentage[glAccountCategory.glAccountCategoryId!])!}"/>
               <#else>
-                <input type="text" name="amp_${glAccountCategory.glAccountCategoryId!}_o_${glAcctgAndAmountPercentage_index}" value=""/>
+                <input type="text" id="${glAcctgAndAmountPercentage.glAccountId}|${glAccountCategory.glAccountCategoryId}" name="amp_${glAccountCategory.glAccountCategoryId!}_o_${glAcctgAndAmountPercentage_index}" value=""/>
               </#if>
             </td>
           </#list>
           <input name="_rowSubmit_o_${glAcctgAndAmountPercentage_index}" type="hidden" value="Y"/>
         </tr>
+        <#assign alt_row = !alt_row>
       </#list>
     </table>
     <div align="right"><input type="button" id="costCentersSubmit" value="${uiLabelMap.CommonSubmit}"/></div>