phpBMS

Ticket #364: 0002-Add-JS-calculateExtendedRev.patch

File 0002-Add-JS-calculateExtendedRev.patch, 4.0 KB (added by vlad@…, 3 years ago)

Patch to enable editing of extended field.

  • modules/bms/invoices_addedit.php

    From 57b56a0932bf6d9fff2be701a20583de78088020 Mon Sep 17 00:00:00 2001
    From: Vladimir Hidalgo <vlad@todosv.com>
    Date: Tue, 13 Oct 2009 08:52:31 -0600
    Subject: [PATCH 2/2] Add JS calculateExtendedRev()
    
    This patch enable the user to type into the extended field and calculate UnitPrice.
    theprice = extended / qty
    ---
     modules/bms/invoices_addedit.php  |    2 +-
     modules/bms/javascript/invoice.js |   58 +++++++++++++++++++++++++++++++++++-
     2 files changed, 57 insertions(+), 3 deletions(-)
    
    diff --git a/modules/bms/invoices_addedit.php b/modules/bms/invoices_addedit.php
    index a138bd1..03ceaf7 100644
    a b  
    412412                        <td><input name="memo" type="text" id="memo" size="12" maxlength="255" /></td> 
    413413                        <td align="right" nowrap="nowrap"><input name="price" type="text" id="price" value="<?php echo htmlQuotes(numberToCurrency(0))?>" size="10" maxlength="16" class="fieldCurrency" /></td> 
    414414                        <td align="center" nowrap="nowrap"><input name="qty" type="text" id="qty" value="1" size="5" maxlength="16" /></td> 
    415                         <td align="right" nowrap="nowrap"><input name="extended" type="text" id="extended" class="uneditable fieldCurrency" value="<?php echo htmlQuotes(numberToCurrency(0))?>" size="12" maxlength="16" readonly="readonly" /></td> 
     415                        <td align="right" nowrap="nowrap"><input name="extended" type="text" id="extended" class="fieldCurrency" value="<?php echo htmlQuotes(numberToCurrency(0))?>" size="12" maxlength="16" /></td> 
    416416                        <td nowrap="nowrap" align="left"><button type="button" id="lineitemAddButton" class="graphicButtons buttonPlus" title="Add Line Item"><span>+</span></button></td> 
    417417                </tr><?php }//end if 
    418418                 
  • modules/bms/javascript/invoice.js

    diff --git a/modules/bms/javascript/invoice.js b/modules/bms/javascript/invoice.js
    index 03f1155..4f13983 100644
    a b  
    747747 
    748748                tempinput = document.createElement("input"); 
    749749                tempinput.id = thetr.id + "Extended"; 
    750                 tempinput.className = "uneditable fieldCurrency lineitemExtendeds" 
    751                 tempinput.readOnly = true; 
     750                tempinput.className = "fieldCurrency lineitemExtendeds" 
     751                connect(tempinput, "onchange", lineitems.calculateExtendedRev); 
    752752                tempinput.value = extended.value; 
    753753                temptd.appendChild(tempinput); 
    754754 
     
    881881                 
    882882        },//end function 
    883883         
     884        calculateExtendedRev: function(e){ 
     885                 
     886                theTR = e.src().parentNode.parentNode; 
     887                 
     888                lineitems._calculateExtendedRev(theTR) 
     889                 
     890        }, //end function 
     891 
     892 
     893        _calculateExtendedRev: function(theTR){          
     894 
     895                if(theTR.id == "LIAdd"){ 
     896                         
     897                        var thecurrency = getObjectFromID("price");      
     898                        var quantity = getObjectFromID("qty"); 
     899                        var extField = getObjectFromID("extended");                              
     900                         
     901                } else { 
     902                         
     903                        var thecurrency = getObjectFromID(theTR.id+"UnitPrice");         
     904                        var quantity = getObjectFromID(theTR.id+"Quantity"); 
     905                        var extField = getObjectFromID(theTR.id+"Extended");     
     906                         
     907                }//end if 
     908         
     909                // Last, figure extended and reformat to dollar 
     910                var extended = currencyToNumber(extField.value); 
     911                extField.value = numberToCurrency(extended); 
     912                                 
     913                // Next verify that qty is a number 
     914                var qty = parseFloat(quantity.value); 
    884915         
     916                if(isNaN(qty)) 
     917                        qty = 1; 
     918                         
     919                quantity.value = qty; 
     920         
     921                // Figure out the price and format it 
     922                theprice = roundForCurrency(extended / qty); 
     923                thecurrency.value = theprice; 
     924                 
     925                //if this is a modification, we also need to calculate totals and mark line items changed 
     926                if(theTR.id != "LIAdd"){ 
     927 
     928                        invoice.doAllTotals(); 
     929                        lineitems.markChanged(); 
     930 
     931                }//end if 
     932                 
     933        },//end function 
     934 
    885935        del: function(e){ 
    886936                 
    887937                var theTR = e.src().parentNode.parentNode.parentNode; 
     
    16871737                if(unitprice) 
    16881738                        connect(unitprice, "onchange", lineitems.calculateExtended) 
    16891739 
     1740        var unitprice = getObjectFromID("extended"); 
     1741                if(unitprice) 
     1742                        connect(unitprice, "onchange", lineitems.calculateExtendedRev) 
     1743 
    16901744        var quantity = getObjectFromID("qty"); 
    16911745                if(quantity) 
    16921746                        connect(quantity, "onchange", lineitems.calculateExtended) 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.