zoukankan      html  css  js  c++  java
  • doAddEditexpense

    function doAddEditexpense(gonext)
    618{
    619 focusDefaultButton(expense_machine);
    620 if (!window.isvalid) return false;
    621if (expense_machine.addline(gonext)) { setWindowChanged(window, true); }
    622}

    =================================
    function focusDefaultButton(machine)
    3179{
    3180
    3181 if(!focusButton(machine.name + "_addedit"))
    3182 {
    3183 focusButton(machine.name + "_edit");
    3184 }
    3185}
    =================================
    function focusButton(buttonId)
    3188{
    3189 var button = document.getElementById(buttonId);
    3190 if (button != null && isFocusable(button))
    3191 {
    3192 button.focus();
    3193 return true;
    3194 }
    3195 return false;
    3196}


    function isFocusable( fld )
    3174{
    3175 if ( fld == null || (typeof fld.type == "undefined" && !isNLDropDownSpan(fld)) || fld.type == "hidden" || fld.disabled || fld.type == "button")
    3176 return false;
    3177 return elementIsFocusable(fld);
    3178}

    ==================================
    function Machine_addline(gonext)
    1474{
    1475
    1476 if(this.isCurrentlySegmented)
    1477 gonext = true;
    1478
    1479 if (!window.isinited) return false;
    1480
    1481 var linenum = parseInt( this.getMachineIndex() );
    1482 var maxline = parseInt( this.getMaxIndex() );
    1483 if (!this.allow_insert && maxline < linenum+1)
    1484 {
    1485 alert("Please choose a line to edit");
    1486 return false;
    1487 }
    1488
    1489 if (document.forms['main_form'].elements.nlapiVL != null && !nlapiValidateLine(this.name))
    1490 return false;
    1491
    1492 if (!this.validateline())
    1493 return false;
    1494
    1495 var i;
    1496 var fields = new Array();
    1497 var labels = new Array();
    1498 var allFieldsAreEmpty = true;
    1499
    1500 for ( i = 0; i < this.countFormElements() ; i++)
    1501 {
    1502 if ( (this.isElementRequired( i ) && this.isMandatoryOnThisLine(linenum,i) ) || (this.getFormElementType( i ) == "namevaluelist" && this.getFormElement( i ).value.length > 0))
    1503 {
    1504 fields[fields.length] = this.getFormElement( i );
    1505 labels[labels.length] = this.getElementDisplayLabel( i );
    1506 }
    1507 // there are cases where machines have no mandatory fields. In this case you can hit the add button to add a row with no values.
    1508 // this does not make sense, and complicates the back end a great deal. As long as we think all the fields are
    1509 // empty, we'll check each field for a value
    1510 if( allFieldsAreEmpty && !isempty( this.getFormElement( i ) ) )
    1511 allFieldsAreEmpty = false;
    1512 }
    1513
    1514 if ( fields.length > 0 )
    1515 {
    1516 var emptylabels = checkMandatoryFields(fields, labels);
    1517 if ( emptylabels.length != 0 )
    1518 {
    1519 if (emptylabels.indexOf(",") != -1)
    1520 alert("Please enter value(s) for: "+emptylabels);
    1521 else
    1522 alert("Please enter a value for "+emptylabels);
    1523 return false;
    1524 }
    1525 }
    1526
    1527 // if all the fields are empty (a machine can have no mandatory fields) there is no point in adding the row
    1528 if ( allFieldsAreEmpty )
    1529 {
    1530 alert("Please enter a value into at least one field before adding the row.");
    1531 return false;
    1532 }
    1533
    1534 if (this.uniquefield != null && !this.checkunique())
    1535 return false;
    1536
    1537
    1538 this.updateLineData();
    1539
    1540 if (this.preferredfield != null && getEncodedValue(this.name,linenum,this.preferredfield) == 'T')
    1541 this.setPreferredValue(linenum);
    1542 this.recalc();
    1543 this.isinserting = false;
    1544
    1545 if (gonext == true && linenum < this.getNextIndex()-1)
    1546 {
    1547 this.ischanged=false;
    1548 this.viewline(linenum+1)
    1549 this.postprocessline(linenum);
    1550 }
    1551 else
    1552 {
    1553 this.clearline(false);
    1554 this.postprocessline(linenum);
    1555 this.getsyncline( linenum - 1);
    1556 }
    1557 return true;
    1558}

    ===============
    function Machine_getMachineIndex( )
    463{
    464 if (this.miniform.elements[this.name + "_lineindex"])
    465 return parseInt(this.miniform.elements[this.name + "_lineindex"].value);
    466 return parseInt(this.miniform.elements["lineindex"].value);
    467}

    ================
    function Machine_updateLineData( )
    1563{
    1564
    1565 var linenum = parseInt( this.getMachineIndex() );
    1566 var formElems = this.countFormElements();
    1567 var linedata = new Array();
    1568 for (var i=0; i < formElems; i++)
    1569 {
    1570 var curType = this.getFormElementType( i );
    1571 var curName = this.getFormElementName( i );
    1572 var curElement = this.getFormElement( i );
    1573
    1574 if ( curType == "select" || curType == "slaveselect" )
    1575 {
    1576 if (isMultiSelect( curElement ) || isPopupMultiSelect( curElement ))
    1577 {
    1578 linedata[i] = getMultiSelectValues( curElement );
    1579 }
    1580 else
    1581 {
    1582 linedata[i] = getSelectValue( curElement );
    1583 }
    1584 }
    1585 else if ( curType == "checkbox" )
    1586 {
    1587 linedata[i] = curElement.checked ? "T" : "F";
    1588 }
    1589 else if ( curType == "radio" )
    1590 {
    1591 for (var j=0; j < curElement.length; j++)
    1592 if ( curElement[j].checked)
    1593 linedata[i] = curElement[j].value;
    1594 }
    1595 else if ((curType == "text" || curType == "textarea") && this.isElementPopupDisplayField(i)
    1596 && i < this.countFormElements()-1
    1597 && (this.getFormElementType( i+1 ) == "integer" || this.getFormElementType( i+1 ) == "slaveselect")
    1598 && this.getFormElement( i+1 ).value.length == 0)
    1599 {
    1600 linedata[i] = '';
    1601 }
    1602 else if ( curType == "address" || curType == "textarea")
    1603 {
    1604 linedata[i] = curElement.value.replace(/\r/g,'').replace(/\n/g,String.fromCharCode(5));
    1605 }
    1606 else if (curType == 'fieldset_inline')
    1607 {
    1608 linedata[i] = getInlineTextValue(document.getElementById(this.getFormElementName(i)+"_val"));
    1609 }
    1610 else if (curType != "fieldset")
    1611 {
    1612 linedata[i] = curElement.value;
    1613 }
    1614
    1615 if (curElement != null && this.getFormElementFieldSet(i).length > 0)
    1616 {
    1617 var spanName = (curName.indexOf( '_display' ) == -1 ? curName : this.getFormElementName( i+1 )) + '_fs';
    1618 var spanObj = document.getElementById( spanName );
    1619 if (spanObj != null && spanObj.style.display == 'none')
    1620 {
    1621 linedata[i] = "";
    1622 }
    1623 }
    1624
    1625
    1626 if (linedata[i] != null)
    1627 {
    1628 var regExp = new RegExp("[" + String.fromCharCode(1) + String.fromCharCode(2) + "]", "g");
    1629
    1630 linedata[i] = new String(linedata[i]).replace(regExp,'.');
    1631 }
    1632
    1633 if ( window.virtualBrowser )
    1634 {
    1635 setEncodedValue(this.name, linenum, curName, linedata[i] != null ? linedata[i] : '')
    1636 }
    1637 }
    1638
    1639
    1640 var linearray2 = getLineArray( this.name );
    1641
    1642 var olddata = this.getMainFormData();
    1643 var linearray = (olddata.length == 0 ? new Array() : linearray2);
    1644
    1645 var maxline = parseInt( this.getNextIndex() );
    1646 if (maxline < linenum+1)
    1647 {
    1648 this.setIndex( (linenum+1).toString() );
    1649 linearray[linearray.length] = "";
    1650 }
    1651
    1652 linearray = (linearray.slice(0,linenum-1).concat(linedata.join(String.fromCharCode(1)))).concat(linearray.slice(linenum));
    1653 this.setMainFormData( linearray.join(String.fromCharCode(2)) );
    1654 clearLineArray(this.name);
    1655}


    function Machine_countFormElements()
    422{
    423 return this.form_elems.length;
    424}


    function Machine_getMainFormData( )
    476{
    477 return this.mainform.elements[ this.name+'data' ].value;
    478}

    function clearLineArray(machine_name)
    890{
    891 if( window.linearrayArray != null )
    892 window.linearrayArray[MACHINE_NAME_PREPEND + machine_name] = null;
    893}

    ================
    expense_machine.recalc = function(isOnLoad) { expense_machine.actualrecalc(isOnLoad); expense_machine.nlapirecalc(); }

    function Totalling_Machine_Recalc(onload)
    1024{
    1025 synctotal(onload);
    1026}

    =====================================
    function synctotal(isOnLoad) {
    419var total = 0.0;
    420var payment_total= 0.0
    421var bSubTotalChanged = false;
    422var bDiscountTotalChanged = false;
    423var haslines = false;
    424var tax_total = 0.0;
    425var dotax = true;
    426var taxableline = false;
    427var taxperline = true;
    428var expense_total = 0.0;
    429var expensetax_total = 0.0;
    430var linecount = document.forms['main_form'].elements['nextexpenseidx'].value-1, numapplied=0;
    431for (var i=1; i <= linecount; i++) {
    432 var amount = getEncodedValue('expense',i,'amount');
    433 amount = amount.replace(/,/g,"");
    434 var taxrate1 = getEncodedValue('expense',i,'taxrate1');
    435 if (amount.length) {
    436 amount = parseFloat(format_currency(parseFloat(amount)));
    437 expense_total += amount;
    438taxableline = true;
    439 dotax = true;
    440 var tax1amount = getEncodedValue('expense',i,'tax1amt');
    441 var tax = tax1amount.length ? parseFloat(tax1amount) : 0.0;
    442 tax_total += tax;
    443 haslines = true;
    444 numapplied++;
    445 }
    446}
    447expense_total =parseFloat(format_currency(expense_total));
    448total += expense_total;
    449if (dotax) {
    450tax_total = isNaN(tax_total) ? 0.0 : parseFloat(format_currency(parseFloat(tax_total)));
    451total += tax_total
    452}
    453document.forms['main_form'].elements['tax1amt'].value = dotax ? format_currency(tax_total) : '';
    454document.forms['main_form'].elements['total'].value = format_currency(total);
    455document.forms['main_form'].elements['haslines'].value = haslines ? 'T' : 'F';
    456if (bSubTotalChanged || bDiscountTotalChanged)
    457{
    458 item_machine.recalc(); item_machine.buildtable();
    459}
    460
    461if (document.forms[0].elements['total'].value.length > 0) {
    462if (document.forms[0].elements['advance'].value.length > 0)
    463document.forms[0].elements['amount'].value = format_currency(Math.max(0,document.forms[0].elements['total'].value - document.forms[0].elements['advance'].value))
    464else
    465document.forms[0].elements['amount'].value = document.forms[0].elements['total'].value; }
    466}
    467function create_memorized_transaction(create) {
    468 var actionsave = document.forms['main_form'].action;
    469 document.forms['main_form'].action = addParamToURL(document.forms['main_form'].action,'memorize','T');
    470 if (!create)
    471 {
    472 document.forms['main_form'].action = addParamToURL(document.forms['main_form'].action,'memupdate','T');
    473 }
    474 if (window.isvalid && save_record()) {
    475 window.ischanged=true;
    476 return true; }
    477 document.forms['main_form'].action = actionsave;
    478 return false;
    479}
    480function do_memorize() {
    481 window.ischanged=true;
    482 var prompt = 'You have already memorised this transaction.\n\nClick OK to create another memorised transaction.\n\nClick Cancel to update this memorised transaction.';
    483 if (document.forms['main_form'].elements['memdoc'] && !confirm(prompt))
    484 return create_memorized_transaction(false);
    485 else
    486 return create_memorized_transaction(true);
    487}


    function Machine_nlapirecalc()
    352{
    353 if ( document.forms['main_form'].elements['nlapiRC'] != null && !isValEmpty( document.forms['main_form'].elements['nlapiRC'].value ) )
    354 nlapiRecalc(this.name);
    355}


    function isValEmpty(val,nam)
    618{
    619 if (val == null)
    620 return true;
    621
    622 val = new String(val);
    623 return (val.length == 0) || (val.search(/\S/) < 0);
    624}


    function nlapiRecalc(type)
    153{
    154 if (nsapiGetMainForm( ).elements.nlapiRC != null && nsapiGetMainForm( ).elements.nlapiRC.value.length > 0)
    155 {
    156 var scripts = nsapiGetMainForm( ).elements.nlapiRC.value.split(',');
    157 for ( var i = 0; i < scripts.length; i++ )
    158 eval(scripts[ i ]+"(type)");
    159 }
    160}

    //////////////////////////============终于跟到了:

    function Machine_clearline(sync, startSegmentIndex)
    740{
    741
    742 if (!window.isinited) return false;
    743 if (this.isinserting)
    744 return this.deleteline();
    745
    746 this.setColToFirstEditable();
    747
    748 var oldidx = this.getAdjustedSegmentIndex( this.getMachineIndex(), false );
    749
    750 if (this.getFormName() == 'main_form')
    751 {
    752 for (var i = 0; i < this.countFormElements() ; i++ )
    753 {
    754 var elem = this.getFormElement( i );
    755 elem.value = '';
    756 if (isNLDropDown(elem)||isNLMultiDropDown(elem))
    757 {
    758 var dropdown = getDropdown(elem);
    759 if (dropdown)
    760 dropdown.resetDropDown();
    761 }
    762 }
    763 }
    764 else
    765 {
    766
    767
    768 for (var i=0; i < this.countFormElements(); i++)
    769 {
    770 if (this.getFormElement( i ).type == 'hidden' || this.requiresClearingOnReset( i ) )
    771 {
    772 this.getFormElement( i ).value = this.getFormElement( i ).getAttribute('defaultValue');
    773 }
    774 }
    775
    776 this.miniform.reset();
    777
    778 if (typeof(resetNLDropDowns) != 'undefined')
    779 resetNLDropDowns(this.miniform);
    780 }
    781 if (!sync)
    782 {
    783
    784 for (var i=0; i < this.countFormElements(); i++)
    785 if ( this.getFormElementType( i ) == "slaveselect" )
    786 deleteAllSelectOptions(this.getFormElement(i));
    787 }
    788
    789 this.setMachineIndex( this.getNextIndex() );
    790
    791
    792 if (sync)
    793 {
    794 for (var i=0; i < this.countFormElements() ; i++)
    795
    796 if (this.getFormElementFieldSet(i) == "" && this.getFormElementType( i ) == "slaveselect")
    797 eval( getSyncFunctionName( this.getFormElementName( i ), this.name ) + '(true,null,true);');
    798 }
    799
    800
    801 for (var i=0; i < this.countFormElements() ; i++)
    802 {
    803 if ((this.getFormElementType(i) == "text" || this.getFormElementType(i) == "textarea") && this.isElementPopupDisplayField(i)
    804 && i < this.countFormElements()-1
    805 && (this.getFormElementType( i+1 ) == "integer" && isSelect(this.getFormElement( i+1 ))))
    806 {
    807 setFormValue(this.getFormElement(i), getSelectText(this.getFormElement(i + 1)));
    808 }
    809 }
    810
    811
    812 this.synclinefields( );
    813
    814
    815 this.buildtable(startSegmentIndex);
    816 this.ischanged = false;
    817 this.isinserting = false;
    818
    819
    820}
    821


    function Machine_buildtable(startIndex, bNoFocus)
    1782{
    1783
    1784 var startTime = new Date().getTime();
    1785
    1786
    1787 var timerID = pTransferTimeouts[this.name];
    1788 if(timerID)
    1789 clearTimeout(timerID);
    1790 pTransferTimeouts[this.name] = null;
    1791
    1792 if(window.fieldSetDiv != null && window.fieldSetDiv.parentNode)
    1793 {
    1794 var parent = window.fieldSetDiv.parentNode;
    1795 parent.removeChild(window.fieldSetDiv);
    1796 }
    1797
    1798
    1799 if (this.currentRowNum == 0 && !this.allow_insert)
    1800 this.setupLineData(this.getMachineIndex());
    1801
    1802 this.currentRowNum = 0;
    1803 if (this.isinline && !this.hasInterceptedEvents)
    1804 {
    1805
    1806 this.focusElement = document.createElement("A");
    1807 this.focusElement.tabIndex = 0;
    1808 this.tableobj.parentNode.appendChild(this.focusElement);
    1809
    1810
    1811 for (var i=0; i < this.countFormElements(); i++)
    1812 {
    1813 if (this.getFormElementFieldSet(i).length == 0)
    1814 Mch_setUpEventHandlerInterception(this, this.getFormElement(i), this.getFormElementType(i));
    1815 }
    1816 this.hasInterceptedEvents = true;
    1817 }
    1818
    1819 this.suspendEdit();
    1820 var tablename = this.getTableName();
    1821
    1822
    1823 this.tableobj = document.getElementById(tablename);
    1824 var maintable = this.tableobj ;
    1825
    1826
    1827 if ( this.isinline && this.moveButtons)
    1828 moveButtonDiv(this.name);
    1829 if (maintable.hasChildNodes())  //开始删除列!20081008021
    1830 {
    1831 var trs = maintable.getElementsByTagName("TR");
    1832 for ( var j = trs.length; j >= 0; j-- )
    1833 {
    1834 if ( maintable.firstChild != null )
    1835 maintable.removeChild( maintable.firstChild );
    1836 }
    1837 }
    1838
    1839 var rowArray = new Array();
    1840 var rowCount = 0;
    1841
    1842
    1843 var row = document.createElement("TR");
    1844
    1845 row.id = this.name+"_headerrow";
    1846 var cell = null;
    1847
    1848
    1849 if (this.allowMoveLines)
    1850 {
    1851 cell = this.createColumnHeaderCell(' ');
    1852 cell.style.width = "5px";
    1853 cell.innerText = " ";
    1854 row.appendChild( cell );
    1855 }
    1856
    1857
    1858 if (this.showRowNumbers)
    1859 {
    1860 cell = this.createColumnHeaderCell(this.rowNumberLabel);
    1861 row.appendChild( cell );
    1862 }
    1863
    1864
    1865 var nHeaderLabelCount = 0;
    1866 for (var i = 0; i < this.countFormElements(); i++)
    1867 {
    1868 if ( this.getFormElementLabel( i ).length > 0 && this.getFormElementFieldSet( i ).length == 0 )
    1869 {
    1870 cell = document.createElement("TD");
    1871 cell = this.getDisplayHeaderCell( i, cell);
    1872 row.appendChild( cell );
    1873
    1874 nHeaderLabelCount++;
    1875 }
    1876 }
    1877 this.nHeaderLabelCount = nHeaderLabelCount;
    1878
    1879 rowArray[rowCount++] = row;
    1880
    1881
    1882 var linearray = getLineArray(this.name);
    1883 var maxline = parseInt( this.getNextIndex() );
    1884
    1885 this.segmentStartIndex = (startIndex && this.segmentable ? startIndex : this.segmentStartIndex);
    1886 var bUseSegment = this.manageSegmentSelect(maxline);
    1887 var actual = 1;
    1888 var segmentLimit = Math.max(0,parseInt(this.segmentStartIndex)) + parseInt(max_segment_size);
    1889
    1890 for (var linenum = 1; linenum < maxline; linenum++ )
    1891 {
    1892 if (bUseSegment && (linenum < this.segmentStartIndex || linenum >= segmentLimit ))
    1893 continue;
    1894 row = this.constructMainTableRow(linearray, linenum);
    1895 rowArray[rowCount++] = row;
    1896 actual++;
    1897 }
    1898
    1899
    1900 var limit = 1;
    1901 if (this.isinline && this.allow_insert)
    1902 limit = maxline;
    1903
    1904 var elemCount = this.countFormElements();
    1905 var fieldnames = this.getFormFieldNames();
    1906
    1907 var onClick = "if (window.isinited) { if("+this.name + "_machine.ischanged) " +
    1908 this.name + "_machine.addline(); " +
    1909 "else " +
    1910 this.name + "_machine.clearline(false, "+this.lastStartSegmentIndex+");}";
    1911 var bInLineEditingAwaitingInsert = this.isinline && this.allow_insert && ( this.getMachineIndex() != this.getNextIndex() || ( bUseSegment && this.getMachineIndex() != this.getAdjustedSegmentIndex(actual, true) ) );
    1912 for (; linenum <= limit; linenum++)
    1913 {
    1914 row = document.createElement("TR");
    1915
    1916 if(!this.isinline)
    1917 {
    1918 row.onclick = new Function(onClick);
    1919 }
    1920
    1921 row.className = 'listtextnonedit';
    1922
    1923 if(bInLineEditingAwaitingInsert)
    1924 {
    1925 var colspan = (this.showRowNumbers ? 1 : 0) + (this.allowMoveLines ? 1 : 0) + (this.allowQuickDeleteLines ? 1 : 0);
    1926
    1927
    1928 for (var i=0; i < elemCount; i++)
    1929 {
    1930 if (this.getFormElementLabel(i).length > 0 && this.getFormElementFieldSet(i).length == 0 )
    1931 {
    1932 colspan++;
    1933 }
    1934 }
    1935
    1936
    1937 cell = document.createElement("TD");
    1938 cell.colSpan = colspan;
    1939 cell.className = this.allWhiteDisplayMode ? "listtexthlwht" : "listtexthl";
    1940 cell.style.color="#666666";
    1941 cell.style.cursor="default";
    1942 cell.innerHTML = "[Click here for a new line]";
    1943 row.appendChild( cell );
    1944 row.onclick = new Function(onClick);
    1945 }
    1946 else
    1947 {
    1948 var iStartCol = (this.showRowNumbers ? 1 : 0) + (this.allowMoveLines ? 1 : 0);
    1949
    1950
    1951 for(var j=0; j < iStartCol; j++)
    1952 {
    1953 cell = document.createElement("TD");
    1954 cell.className = 'listtextnonedit';
    1955 cell.innerText = " ";
    1956 cell.style.width = "5px";
    1957 row.appendChild( cell );
    1958 }
    1959
    1960
    1961 for (var i=0; i < elemCount; i++)
    1962 {
    1963 if (this.getFormElementLabel(i).length > 0 && this.getFormElementFieldSet(i).length == 0)
    1964 {
    1965
    1966 cell = document.createElement("TD");
    1967 cell.align = this.getAlignmentForColumn(i);
    1968
    1969
    1970 if(this.isinline)
    1971 {
    1972 cell.className = 'listtextnonedit';
    1973 cell.style.cursor = "hand";
    1974 var di = this.isElementPopupDisplayField(i) ? 1 : 0;
    1975 var colnum = this.isElementDisplayOnlyWithField(i) ? null : (i+di);
    1976 var jsClk = this.name + "_machine.viewline(" + linenum + "," + colnum +", true); return true;";
    1977 cell.onclick = new Function(jsClk);
    1978 }
    1979 cell.innerText = " ";
    1980 row.appendChild( cell );
    1981 }
    1982 }
    1983 if(this.allowQuickDeleteLines)
    1984 {
    1985 cell = document.createElement("TD");
    1986 cell.className = 'listtextnonedit';
    1987 cell.innerText = " ";
    1988 cell.style.width = "5px";
    1989 row.appendChild( cell );
    1990 }
    1991 }
    1992 rowArray[rowCount++] = row;
    1993 }
    1994
    1995
    1996 row = document.createElement("TR");
    1997
    1998 if (cell = this.createGrippyCell())
    1999 {
    2000 row.appendChild( cell );
    2001 }
    2002
    2003 if (this.showRowNumbers)
    2004 {
    2005
    2006 cell = this.createColumnHeaderCell(this.rowNumberLabel);
    2007 cell.style.width = "10px";
    2008 row.appendChild( cell );
    2009 }
    2010
    2011 var i;
    2012 var countElems = this.countFormElements();
    2013 for ( i = 0; i < countElems; i++)
    2014 {
    2015 if ( this.getFormElementLabel( i ).length == 0 || this.getFormElementFieldSet( i ).length > 0 )
    2016 continue;
    2017 cell = document.createElement("TD");
    2018 cell.className = 'listtextnonedit';
    2019 cell.style.borderWidth = "1 0 1 1";
    2020 cell.align = this.getAlignmentForColumn(i);
    2021 cell.innerText = " ";
    2022 row.appendChild( cell );
    2023 }
    2024
    2025 if (cell = this.createDeleteCell())
    2026 {
    2027 row.appendChild( cell );
    2028 }
    2029
    2030 this.lastRow = row;  //关键的重刷入数据! 20081008028
    2031 this.lastRow.style.height = "1px";
    2032 this.lastRow.style.visibility = "hidden";
    2033 rowArray[rowCount++] = row;
    2034
    2035
    2036
    2037
    2038 var tb = document.createElement("TBODY");
    2039 for ( var i = 0; i < rowArray.length; i++ )
    2040 tb.appendChild( rowArray[i] );
    2041 maintable.appendChild(tb);
    2042
    2043
    2044 if(this.allow_insert || linearray.length>0)
    2045 {
    2046 if (this.showEditor)
    2047 {
    2048 this.editRow( this.getAdjustedSegmentIndex( this.getMachineIndex(), false), !bNoFocus );
    2049 }
    2050 else
    2051 {
    2052 this.setFocus(this.focusedColumn);
    2053 }
    2054 }
    2055 window.status = "";
    2056 this.hasRendered = true;
    2057
    2058 if(this.bResizeBackgroundDiv)
    2059 sizeLowerTabBGDiv(this.name);
    2060
    2061 this.postBuildTable();
    2062
    2063 editmachineConstructorTime += ( new Date().getTime() - startTime );
    2064 return false;
    2065
    2066}
    2067
    2068


    =================
    var MACHINE_NAME_PREPEND = "mch_";
    872
    873window.linearrayArray = new Array();
    874
    875
    876function getLineArray(machine_name)
    877{
    878
    879 var lineArrayIndex = MACHINE_NAME_PREPEND + machine_name;
    880 if( window.linearrayArray[lineArrayIndex] == null)
    881 {
    882 if ( document.forms['main_form'].elements[machine_name+'data'] != null )
    883 window.linearrayArray[lineArrayIndex] = splitIntoRows( document.forms['main_form'].elements[machine_name+'data'].value );
    884 }
    885 return window.linearrayArray[lineArrayIndex];
    886
    887}



    ===============================列字段 3663

    function Machine_getInputElements(allElements, fieldnames)
    3659{
    3660
    3661 var returnMe = new Array();
    3662 if (!fieldnames)
    3663 fieldnames = this.getFormFieldNames();
    3664 var lastWasDisplay = false;
    3665 if ( this.idMap == null )
    3666 this.createEditorMap();
    3667
    3668 for (var i=0; i < fieldnames.length; i++)
    3669 {
    3670 var field = null;
    3671 var label = (lastWasDisplay) ? this.getFormElementLabel(i-1) : this.getFormElementLabel(i);
    3672
    3673 field = this.idMap[i];
    3674
    3675 if (allElements != true && (label == null || label.length == 0 || this.getFormElementFieldSet(i).length > 0))
    3676 field = null;
    3677 returnMe[returnMe.length] = field;
    3678
    3679 lastWasDisplay = this.isElementPopupDisplayField(i);
    3680 }
    3681
    3682 return returnMe;
    3683}


    function Machine_getFormFieldNames( )
    481{
    482 return splitIntoCells( this.mainform.elements[this.name+'fields'].value );
    483}
    //////////////////////// expensefields

    只要搞定这个就能替换column的名称。20081008048

    nsapiGetMainForm().elements['expensefields'].value="expensedate,category,foreignamount,currency,exchangerate,amount,taxfffffffffffcode,taxrate1,tax1amt,grossamt,memo,class,customer_display,customer,location,isbillable,receipt,custcol42,custcol40,line,linked "


    html元文件中:function doAddEditexpense(gonext)
    618{
    619 focusDefaultButton(expense_machine);
    620 if (!window.isvalid) return false;
    621if (expense_machine.addline(gonext)) { setWindowChanged(window, true); }
    622}


    =================================
    function focusDefaultButton(machine)
    3179{
    3180
    3181 if(!focusButton(machine.name + "_addedit"))
    3182 {
    3183 focusButton(machine.name + "_edit");
    3184 }
    3185}
    =================================
    function focusButton(buttonId)
    3188{
    3189 var button = document.getElementById(buttonId);
    3190 if (button != null && isFocusable(button))
    3191 {
    3192 button.focus();
    3193 return true;
    3194 }
    3195 return false;
    3196}


    function isFocusable( fld )
    3174{
    3175 if ( fld == null || (typeof fld.type == "undefined" && !isNLDropDownSpan(fld)) || fld.type == "hidden" || fld.disabled || fld.type == "button")
    3176 return false;
    3177 return elementIsFocusable(fld);
    3178}

    ==================================
    function Machine_addline(gonext)
    1474{
    1475
    1476 if(this.isCurrentlySegmented)
    1477 gonext = true;
    1478
    1479 if (!window.isinited) return false;
    1480
    1481 var linenum = parseInt( this.getMachineIndex() );
    1482 var maxline = parseInt( this.getMaxIndex() );
    1483 if (!this.allow_insert && maxline < linenum+1)
    1484 {
    1485 alert("Please choose a line to edit");
    1486 return false;
    1487 }
    1488
    1489 if (document.forms['main_form'].elements.nlapiVL != null && !nlapiValidateLine(this.name))
    1490 return false;
    1491
    1492 if (!this.validateline())
    1493 return false;
    1494
    1495 var i;
    1496 var fields = new Array();
    1497 var labels = new Array();
    1498 var allFieldsAreEmpty = true;
    1499
    1500 for ( i = 0; i < this.countFormElements() ; i++)
    1501 {
    1502 if ( (this.isElementRequired( i ) && this.isMandatoryOnThisLine(linenum,i) ) || (this.getFormElementType( i ) == "namevaluelist" && this.getFormElement( i ).value.length > 0))
    1503 {
    1504 fields[fields.length] = this.getFormElement( i );
    1505 labels[labels.length] = this.getElementDisplayLabel( i );
    1506 }
    1507 // there are cases where machines have no mandatory fields. In this case you can hit the add button to add a row with no values.
    1508 // this does not make sense, and complicates the back end a great deal. As long as we think all the fields are
    1509 // empty, we'll check each field for a value
    1510 if( allFieldsAreEmpty && !isempty( this.getFormElement( i ) ) )
    1511 allFieldsAreEmpty = false;
    1512 }
    1513
    1514 if ( fields.length > 0 )
    1515 {
    1516 var emptylabels = checkMandatoryFields(fields, labels);
    1517 if ( emptylabels.length != 0 )
    1518 {
    1519 if (emptylabels.indexOf(",") != -1)
    1520 alert("Please enter value(s) for: "+emptylabels);
    1521 else
    1522 alert("Please enter a value for "+emptylabels);
    1523 return false;
    1524 }
    1525 }
    1526
    1527 // if all the fields are empty (a machine can have no mandatory fields) there is no point in adding the row
    1528 if ( allFieldsAreEmpty )
    1529 {
    1530 alert("Please enter a value into at least one field before adding the row.");
    1531 return false;
    1532 }
    1533
    1534 if (this.uniquefield != null && !this.checkunique())
    1535 return false;
    1536
    1537
    1538 this.updateLineData();
    1539
    1540 if (this.preferredfield != null && getEncodedValue(this.name,linenum,this.preferredfield) == 'T')
    1541 this.setPreferredValue(linenum);
    1542 this.recalc();
    1543 this.isinserting = false;
    1544
    1545 if (gonext == true && linenum < this.getNextIndex()-1)
    1546 {
    1547 this.ischanged=false;
    1548 this.viewline(linenum+1)
    1549 this.postprocessline(linenum);
    1550 }
    1551 else
    1552 {
    1553 this.clearline(false);
    1554 this.postprocessline(linenum);
    1555 this.getsyncline( linenum - 1);
    1556 }
    1557 return true;
    1558}

    ===============
    function Machine_getMachineIndex( )
    463{
    464 if (this.miniform.elements[this.name + "_lineindex"])
    465 return parseInt(this.miniform.elements[this.name + "_lineindex"].value);
    466 return parseInt(this.miniform.elements["lineindex"].value);
    467}

    ================
    function Machine_updateLineData( )
    1563{
    1564
    1565 var linenum = parseInt( this.getMachineIndex() );
    1566 var formElems = this.countFormElements();
    1567 var linedata = new Array();
    1568 for (var i=0; i < formElems; i++)
    1569 {
    1570 var curType = this.getFormElementType( i );
    1571 var curName = this.getFormElementName( i );
    1572 var curElement = this.getFormElement( i );
    1573
    1574 if ( curType == "select" || curType == "slaveselect" )
    1575 {
    1576 if (isMultiSelect( curElement ) || isPopupMultiSelect( curElement ))
    1577 {
    1578 linedata[i] = getMultiSelectValues( curElement );
    1579 }
    1580 else
    1581 {
    1582 linedata[i] = getSelectValue( curElement );
    1583 }
    1584 }
    1585 else if ( curType == "checkbox" )
    1586 {
    1587 linedata[i] = curElement.checked ? "T" : "F";
    1588 }
    1589 else if ( curType == "radio" )
    1590 {
    1591 for (var j=0; j < curElement.length; j++)
    1592 if ( curElement[j].checked)
    1593 linedata[i] = curElement[j].value;
    1594 }
    1595 else if ((curType == "text" || curType == "textarea") && this.isElementPopupDisplayField(i)
    1596 && i < this.countFormElements()-1
    1597 && (this.getFormElementType( i+1 ) == "integer" || this.getFormElementType( i+1 ) == "slaveselect")
    1598 && this.getFormElement( i+1 ).value.length == 0)
    1599 {
    1600 linedata[i] = '';
    1601 }
    1602 else if ( curType == "address" || curType == "textarea")
    1603 {
    1604 linedata[i] = curElement.value.replace(/\r/g,'').replace(/\n/g,String.fromCharCode(5));
    1605 }
    1606 else if (curType == 'fieldset_inline')
    1607 {
    1608 linedata[i] = getInlineTextValue(document.getElementById(this.getFormElementName(i)+"_val"));
    1609 }
    1610 else if (curType != "fieldset")
    1611 {
    1612 linedata[i] = curElement.value;
    1613 }
    1614
    1615 if (curElement != null && this.getFormElementFieldSet(i).length > 0)
    1616 {
    1617 var spanName = (curName.indexOf( '_display' ) == -1 ? curName : this.getFormElementName( i+1 )) + '_fs';
    1618 var spanObj = document.getElementById( spanName );
    1619 if (spanObj != null && spanObj.style.display == 'none')
    1620 {
    1621 linedata[i] = "";
    1622 }
    1623 }
    1624
    1625
    1626 if (linedata[i] != null)
    1627 {
    1628 var regExp = new RegExp("[" + String.fromCharCode(1) + String.fromCharCode(2) + "]", "g");
    1629
    1630 linedata[i] = new String(linedata[i]).replace(regExp,'.');
    1631 }
    1632
    1633 if ( window.virtualBrowser )
    1634 {
    1635 setEncodedValue(this.name, linenum, curName, linedata[i] != null ? linedata[i] : '')
    1636 }
    1637 }
    1638
    1639
    1640 var linearray2 = getLineArray( this.name );
    1641
    1642 var olddata = this.getMainFormData();
    1643 var linearray = (olddata.length == 0 ? new Array() : linearray2);
    1644
    1645 var maxline = parseInt( this.getNextIndex() );
    1646 if (maxline < linenum+1)
    1647 {
    1648 this.setIndex( (linenum+1).toString() );
    1649 linearray[linearray.length] = "";
    1650 }
    1651
    1652 linearray = (linearray.slice(0,linenum-1).concat(linedata.join(String.fromCharCode(1)))).concat(linearray.slice(linenum));
    1653 this.setMainFormData( linearray.join(String.fromCharCode(2)) );
    1654 clearLineArray(this.name);
    1655}


    function Machine_countFormElements()
    422{
    423 return this.form_elems.length;
    424}


    function Machine_getMainFormData( )
    476{
    477 return this.mainform.elements[ this.name+'data' ].value;
    478}

    function clearLineArray(machine_name)
    890{
    891 if( window.linearrayArray != null )
    892 window.linearrayArray[MACHINE_NAME_PREPEND + machine_name] = null;
    893}

    ================
    expense_machine.recalc = function(isOnLoad) { expense_machine.actualrecalc(isOnLoad); expense_machine.nlapirecalc(); }

    function Totalling_Machine_Recalc(onload)
    1024{
    1025 synctotal(onload);
    1026}

    =====================================
    function synctotal(isOnLoad) {
    419var total = 0.0;
    420var payment_total= 0.0
    421var bSubTotalChanged = false;
    422var bDiscountTotalChanged = false;
    423var haslines = false;
    424var tax_total = 0.0;
    425var dotax = true;
    426var taxableline = false;
    427var taxperline = true;
    428var expense_total = 0.0;
    429var expensetax_total = 0.0;
    430var linecount = document.forms['main_form'].elements['nextexpenseidx'].value-1, numapplied=0;
    431for (var i=1; i <= linecount; i++) {
    432 var amount = getEncodedValue('expense',i,'amount');
    433 amount = amount.replace(/,/g,"");
    434 var taxrate1 = getEncodedValue('expense',i,'taxrate1');
    435 if (amount.length) {
    436 amount = parseFloat(format_currency(parseFloat(amount)));
    437 expense_total += amount;
    438taxableline = true;
    439 dotax = true;
    440 var tax1amount = getEncodedValue('expense',i,'tax1amt');
    441 var tax = tax1amount.length ? parseFloat(tax1amount) : 0.0;
    442 tax_total += tax;
    443 haslines = true;
    444 numapplied++;
    445 }
    446}
    447expense_total =parseFloat(format_currency(expense_total));
    448total += expense_total;
    449if (dotax) {
    450tax_total = isNaN(tax_total) ? 0.0 : parseFloat(format_currency(parseFloat(tax_total)));
    451total += tax_total
    452}
    453document.forms['main_form'].elements['tax1amt'].value = dotax ? format_currency(tax_total) : '';
    454document.forms['main_form'].elements['total'].value = format_currency(total);
    455document.forms['main_form'].elements['haslines'].value = haslines ? 'T' : 'F';
    456if (bSubTotalChanged || bDiscountTotalChanged)
    457{
    458 item_machine.recalc(); item_machine.buildtable();
    459}
    460
    461if (document.forms[0].elements['total'].value.length > 0) {
    462if (document.forms[0].elements['advance'].value.length > 0)
    463document.forms[0].elements['amount'].value = format_currency(Math.max(0,document.forms[0].elements['total'].value - document.forms[0].elements['advance'].value))
    464else
    465document.forms[0].elements['amount'].value = document.forms[0].elements['total'].value; }
    466}
    467function create_memorized_transaction(create) {
    468 var actionsave = document.forms['main_form'].action;
    469 document.forms['main_form'].action = addParamToURL(document.forms['main_form'].action,'memorize','T');
    470 if (!create)
    471 {
    472 document.forms['main_form'].action = addParamToURL(document.forms['main_form'].action,'memupdate','T');
    473 }
    474 if (window.isvalid && save_record()) {
    475 window.ischanged=true;
    476 return true; }
    477 document.forms['main_form'].action = actionsave;
    478 return false;
    479}
    480function do_memorize() {
    481 window.ischanged=true;
    482 var prompt = 'You have already memorised this transaction.\n\nClick OK to create another memorised transaction.\n\nClick Cancel to update this memorised transaction.';
    483 if (document.forms['main_form'].elements['memdoc'] && !confirm(prompt))
    484 return create_memorized_transaction(false);
    485 else
    486 return create_memorized_transaction(true);
    487}


    function Machine_nlapirecalc()
    352{
    353 if ( document.forms['main_form'].elements['nlapiRC'] != null && !isValEmpty( document.forms['main_form'].elements['nlapiRC'].value ) )
    354 nlapiRecalc(this.name);
    355}


    function isValEmpty(val,nam)
    618{
    619 if (val == null)
    620 return true;
    621
    622 val = new String(val);
    623 return (val.length == 0) || (val.search(/\S/) < 0);
    624}


    function nlapiRecalc(type)
    153{
    154 if (nsapiGetMainForm( ).elements.nlapiRC != null && nsapiGetMainForm( ).elements.nlapiRC.value.length > 0)
    155 {
    156 var scripts = nsapiGetMainForm( ).elements.nlapiRC.value.split(',');
    157 for ( var i = 0; i < scripts.length; i++ )
    158 eval(scripts[ i ]+"(type)");
    159 }
    160}

    //////////////////////////============终于跟到了:

    function Machine_clearline(sync, startSegmentIndex)
    740{
    741
    742 if (!window.isinited) return false;
    743 if (this.isinserting)
    744 return this.deleteline();
    745
    746 this.setColToFirstEditable();
    747
    748 var oldidx = this.getAdjustedSegmentIndex( this.getMachineIndex(), false );
    749
    750 if (this.getFormName() == 'main_form')
    751 {
    752 for (var i = 0; i < this.countFormElements() ; i++ )
    753 {
    754 var elem = this.getFormElement( i );
    755 elem.value = '';
    756 if (isNLDropDown(elem)||isNLMultiDropDown(elem))
    757 {
    758 var dropdown = getDropdown(elem);
    759 if (dropdown)
    760 dropdown.resetDropDown();
    761 }
    762 }
    763 }
    764 else
    765 {
    766
    767
    768 for (var i=0; i < this.countFormElements(); i++)
    769 {
    770 if (this.getFormElement( i ).type == 'hidden' || this.requiresClearingOnReset( i ) )
    771 {
    772 this.getFormElement( i ).value = this.getFormElement( i ).getAttribute('defaultValue');
    773 }
    774 }
    775
    776 this.miniform.reset();
    777
    778 if (typeof(resetNLDropDowns) != 'undefined')
    779 resetNLDropDowns(this.miniform);
    780 }
    781 if (!sync)
    782 {
    783
    784 for (var i=0; i < this.countFormElements(); i++)
    785 if ( this.getFormElementType( i ) == "slaveselect" )
    786 deleteAllSelectOptions(this.getFormElement(i));
    787 }
    788
    789 this.setMachineIndex( this.getNextIndex() );
    790
    791
    792 if (sync)
    793 {
    794 for (var i=0; i < this.countFormElements() ; i++)
    795
    796 if (this.getFormElementFieldSet(i) == "" && this.getFormElementType( i ) == "slaveselect")
    797 eval( getSyncFunctionName( this.getFormElementName( i ), this.name ) + '(true,null,true);');
    798 }
    799
    800
    801 for (var i=0; i < this.countFormElements() ; i++)
    802 {
    803 if ((this.getFormElementType(i) == "text" || this.getFormElementType(i) == "textarea") && this.isElementPopupDisplayField(i)
    804 && i < this.countFormElements()-1
    805 && (this.getFormElementType( i+1 ) == "integer" && isSelect(this.getFormElement( i+1 ))))
    806 {
    807 setFormValue(this.getFormElement(i), getSelectText(this.getFormElement(i + 1)));
    808 }
    809 }
    810
    811
    812 this.synclinefields( );
    813
    814
    815 this.buildtable(startSegmentIndex);
    816 this.ischanged = false;
    817 this.isinserting = false;
    818
    819
    820}
    821


    function Machine_buildtable(startIndex, bNoFocus)
    1782{
    1783
    1784 var startTime = new Date().getTime();
    1785
    1786
    1787 var timerID = pTransferTimeouts[this.name];
    1788 if(timerID)
    1789 clearTimeout(timerID);
    1790 pTransferTimeouts[this.name] = null;
    1791
    1792 if(window.fieldSetDiv != null && window.fieldSetDiv.parentNode)
    1793 {
    1794 var parent = window.fieldSetDiv.parentNode;
    1795 parent.removeChild(window.fieldSetDiv);
    1796 }
    1797
    1798
    1799 if (this.currentRowNum == 0 && !this.allow_insert)
    1800 this.setupLineData(this.getMachineIndex());
    1801
    1802 this.currentRowNum = 0;
    1803 if (this.isinline && !this.hasInterceptedEvents)
    1804 {
    1805
    1806 this.focusElement = document.createElement("A");
    1807 this.focusElement.tabIndex = 0;
    1808 this.tableobj.parentNode.appendChild(this.focusElement);
    1809
    1810
    1811 for (var i=0; i < this.countFormElements(); i++)
    1812 {
    1813 if (this.getFormElementFieldSet(i).length == 0)
    1814 Mch_setUpEventHandlerInterception(this, this.getFormElement(i), this.getFormElementType(i));
    1815 }
    1816 this.hasInterceptedEvents = true;
    1817 }
    1818
    1819 this.suspendEdit();
    1820 var tablename = this.getTableName();
    1821
    1822
    1823 this.tableobj = document.getElementById(tablename);
    1824 var maintable = this.tableobj ;
    1825
    1826
    1827 if ( this.isinline && this.moveButtons)
    1828 moveButtonDiv(this.name);
    1829 if (maintable.hasChildNodes())  //开始删除列!20081008021
    1830 {
    1831 var trs = maintable.getElementsByTagName("TR");
    1832 for ( var j = trs.length; j >= 0; j-- )
    1833 {
    1834 if ( maintable.firstChild != null )
    1835 maintable.removeChild( maintable.firstChild );
    1836 }
    1837 }
    1838
    1839 var rowArray = new Array();
    1840 var rowCount = 0;
    1841
    1842
    1843 var row = document.createElement("TR");
    1844
    1845 row.id = this.name+"_headerrow";
    1846 var cell = null;
    1847
    1848
    1849 if (this.allowMoveLines)
    1850 {
    1851 cell = this.createColumnHeaderCell(' ');
    1852 cell.style.width = "5px";
    1853 cell.innerText = " ";
    1854 row.appendChild( cell );
    1855 }
    1856
    1857
    1858 if (this.showRowNumbers)
    1859 {
    1860 cell = this.createColumnHeaderCell(this.rowNumberLabel);
    1861 row.appendChild( cell );
    1862 }
    1863
    1864
    1865 var nHeaderLabelCount = 0;
    1866 for (var i = 0; i < this.countFormElements(); i++)
    1867 {
    1868 if ( this.getFormElementLabel( i ).length > 0 && this.getFormElementFieldSet( i ).length == 0 )
    1869 {
    1870 cell = document.createElement("TD");
    1871 cell = this.getDisplayHeaderCell( i, cell);
    1872 row.appendChild( cell );
    1873
    1874 nHeaderLabelCount++;
    1875 }
    1876 }
    1877 this.nHeaderLabelCount = nHeaderLabelCount;
    1878
    1879 rowArray[rowCount++] = row;
    1880
    1881
    1882 var linearray = getLineArray(this.name);
    1883 var maxline = parseInt( this.getNextIndex() );
    1884
    1885 this.segmentStartIndex = (startIndex && this.segmentable ? startIndex : this.segmentStartIndex);
    1886 var bUseSegment = this.manageSegmentSelect(maxline);
    1887 var actual = 1;
    1888 var segmentLimit = Math.max(0,parseInt(this.segmentStartIndex)) + parseInt(max_segment_size);
    1889
    1890 for (var linenum = 1; linenum < maxline; linenum++ )
    1891 {
    1892 if (bUseSegment && (linenum < this.segmentStartIndex || linenum >= segmentLimit ))
    1893 continue;
    1894 row = this.constructMainTableRow(linearray, linenum);
    1895 rowArray[rowCount++] = row;
    1896 actual++;
    1897 }
    1898
    1899
    1900 var limit = 1;
    1901 if (this.isinline && this.allow_insert)
    1902 limit = maxline;
    1903
    1904 var elemCount = this.countFormElements();
    1905 var fieldnames = this.getFormFieldNames();
    1906
    1907 var onClick = "if (window.isinited) { if("+this.name + "_machine.ischanged) " +
    1908 this.name + "_machine.addline(); " +
    1909 "else " +
    1910 this.name + "_machine.clearline(false, "+this.lastStartSegmentIndex+");}";
    1911 var bInLineEditingAwaitingInsert = this.isinline && this.allow_insert && ( this.getMachineIndex() != this.getNextIndex() || ( bUseSegment && this.getMachineIndex() != this.getAdjustedSegmentIndex(actual, true) ) );
    1912 for (; linenum <= limit; linenum++)
    1913 {
    1914 row = document.createElement("TR");
    1915
    1916 if(!this.isinline)
    1917 {
    1918 row.onclick = new Function(onClick);
    1919 }
    1920
    1921 row.className = 'listtextnonedit';
    1922
    1923 if(bInLineEditingAwaitingInsert)
    1924 {
    1925 var colspan = (this.showRowNumbers ? 1 : 0) + (this.allowMoveLines ? 1 : 0) + (this.allowQuickDeleteLines ? 1 : 0);
    1926
    1927
    1928 for (var i=0; i < elemCount; i++)
    1929 {
    1930 if (this.getFormElementLabel(i).length > 0 && this.getFormElementFieldSet(i).length == 0 )
    1931 {
    1932 colspan++;
    1933 }
    1934 }
    1935
    1936
    1937 cell = document.createElement("TD");
    1938 cell.colSpan = colspan;
    1939 cell.className = this.allWhiteDisplayMode ? "listtexthlwht" : "listtexthl";
    1940 cell.style.color="#666666";
    1941 cell.style.cursor="default";
    1942 cell.innerHTML = "[Click here for a new line]";
    1943 row.appendChild( cell );
    1944 row.onclick = new Function(onClick);
    1945 }
    1946 else
    1947 {
    1948 var iStartCol = (this.showRowNumbers ? 1 : 0) + (this.allowMoveLines ? 1 : 0);
    1949
    1950
    1951 for(var j=0; j < iStartCol; j++)
    1952 {
    1953 cell = document.createElement("TD");
    1954 cell.className = 'listtextnonedit';
    1955 cell.innerText = " ";
    1956 cell.style.width = "5px";
    1957 row.appendChild( cell );
    1958 }
    1959
    1960
    1961 for (var i=0; i < elemCount; i++)
    1962 {
    1963 if (this.getFormElementLabel(i).length > 0 && this.getFormElementFieldSet(i).length == 0)
    1964 {
    1965
    1966 cell = document.createElement("TD");
    1967 cell.align = this.getAlignmentForColumn(i);
    1968
    1969
    1970 if(this.isinline)
    1971 {
    1972 cell.className = 'listtextnonedit';
    1973 cell.style.cursor = "hand";
    1974 var di = this.isElementPopupDisplayField(i) ? 1 : 0;
    1975 var colnum = this.isElementDisplayOnlyWithField(i) ? null : (i+di);
    1976 var jsClk = this.name + "_machine.viewline(" + linenum + "," + colnum +", true); return true;";
    1977 cell.onclick = new Function(jsClk);
    1978 }
    1979 cell.innerText = " ";
    1980 row.appendChild( cell );
    1981 }
    1982 }
    1983 if(this.allowQuickDeleteLines)
    1984 {
    1985 cell = document.createElement("TD");
    1986 cell.className = 'listtextnonedit';
    1987 cell.innerText = " ";
    1988 cell.style.width = "5px";
    1989 row.appendChild( cell );
    1990 }
    1991 }
    1992 rowArray[rowCount++] = row;
    1993 }
    1994
    1995
    1996 row = document.createElement("TR");
    1997
    1998 if (cell = this.createGrippyCell())
    1999 {
    2000 row.appendChild( cell );
    2001 }
    2002
    2003 if (this.showRowNumbers)
    2004 {
    2005
    2006 cell = this.createColumnHeaderCell(this.rowNumberLabel);
    2007 cell.style.width = "10px";
    2008 row.appendChild( cell );
    2009 }
    2010
    2011 var i;
    2012 var countElems = this.countFormElements();
    2013 for ( i = 0; i < countElems; i++)
    2014 {
    2015 if ( this.getFormElementLabel( i ).length == 0 || this.getFormElementFieldSet( i ).length > 0 )
    2016 continue;
    2017 cell = document.createElement("TD");
    2018 cell.className = 'listtextnonedit';
    2019 cell.style.borderWidth = "1 0 1 1";
    2020 cell.align = this.getAlignmentForColumn(i);
    2021 cell.innerText = " ";
    2022 row.appendChild( cell );
    2023 }
    2024
    2025 if (cell = this.createDeleteCell())
    2026 {
    2027 row.appendChild( cell );
    2028 }
    2029
    2030 this.lastRow = row;  //关键的重刷入数据! 20081008028
    2031 this.lastRow.style.height = "1px";
    2032 this.lastRow.style.visibility = "hidden";
    2033 rowArray[rowCount++] = row;
    2034
    2035
    2036
    2037
    2038 var tb = document.createElement("TBODY");
    2039 for ( var i = 0; i < rowArray.length; i++ )
    2040 tb.appendChild( rowArray[i] );
    2041 maintable.appendChild(tb);
    2042
    2043
    2044 if(this.allow_insert || linearray.length>0)
    2045 {
    2046 if (this.showEditor)
    2047 {
    2048 this.editRow( this.getAdjustedSegmentIndex( this.getMachineIndex(), false), !bNoFocus );
    2049 }
    2050 else
    2051 {
    2052 this.setFocus(this.focusedColumn);
    2053 }
    2054 }
    2055 window.status = "";
    2056 this.hasRendered = true;
    2057
    2058 if(this.bResizeBackgroundDiv)
    2059 sizeLowerTabBGDiv(this.name);
    2060
    2061 this.postBuildTable();
    2062
    2063 editmachineConstructorTime += ( new Date().getTime() - startTime );
    2064 return false;
    2065
    2066}
    2067
    2068


    =================
    var MACHINE_NAME_PREPEND = "mch_";
    872
    873window.linearrayArray = new Array();
    874
    875
    876function getLineArray(machine_name)
    877{
    878
    879 var lineArrayIndex = MACHINE_NAME_PREPEND + machine_name;
    880 if( window.linearrayArray[lineArrayIndex] == null)
    881 {
    882 if ( document.forms['main_form'].elements[machine_name+'data'] != null )
    883 window.linearrayArray[lineArrayIndex] = splitIntoRows( document.forms['main_form'].elements[machine_name+'data'].value );
    884 }
    885 return window.linearrayArray[lineArrayIndex];
    886
    887}



    ===============================列字段 3663

    function Machine_getInputElements(allElements, fieldnames)
    3659{
    3660
    3661 var returnMe = new Array();
    3662 if (!fieldnames)
    3663 fieldnames = this.getFormFieldNames();
    3664 var lastWasDisplay = false;
    3665 if ( this.idMap == null )
    3666 this.createEditorMap();
    3667
    3668 for (var i=0; i < fieldnames.length; i++)
    3669 {
    3670 var field = null;
    3671 var label = (lastWasDisplay) ? this.getFormElementLabel(i-1) : this.getFormElementLabel(i);
    3672
    3673 field = this.idMap[i];
    3674
    3675 if (allElements != true && (label == null || label.length == 0 || this.getFormElementFieldSet(i).length > 0))
    3676 field = null;
    3677 returnMe[returnMe.length] = field;
    3678
    3679 lastWasDisplay = this.isElementPopupDisplayField(i);
    3680 }
    3681
    3682 return returnMe;
    3683}


    function Machine_getFormFieldNames( )
    481{
    482 return splitIntoCells( this.mainform.elements[this.name+'fields'].value );
    483}
    //////////////////////// expensefields

    只要搞定这个就能替换column的名称。20081008048

    nsapiGetMainForm().elements['expensefields'].value="expensedate,category,foreignamount,currency,exchangerate,amount,taxfffffffffffcode,taxrate1,tax1amt,grossamt,memo,class,customer_display,customer,location,isbillable,receipt,custcol42,custcol40,line,linked "
    html原文件中:
    <INPUT type='hidden' name='expensefields'  value='expensedate,category,foreignamount,currency,exchangerate,amount,taxcode,taxrate1,tax1amt,grossamt,memo,class,customer_display,customer,location,isbillable,receipt,custcol42,custcol40,line,linked'>



  • 相关阅读:
    2015.2.27 UltraEdit中显示XML结构
    2015.1.31 DataGridView自动滚动到某行
    2015.1.15 利用函数实现将一行记录拆分成多行记录 (多年想要的效果)
    2015.1.15 利用Oracle函数返回表结果 重大技术进步!
    2015.1.15 利用Oracle函数插入表结构 Bulk collect into 不用循环,简洁高效
    2015.1.8 Left join 左连接
    2015.1.10 解决DataGridView SelectionChanged事件自动触发问题
    delphi 遍历窗口
    delphi 访问 protected 属性 哈哈
    clientdataset 读取excel 如果excel 文件不存在的时候 相应的gird 会不显示数据, 鼠标掠过 gird 格子 才会显示数据。 这是一个bug 哈哈
  • 原文地址:https://www.cnblogs.com/backuper/p/1305976.html
Copyright © 2011-2022 走看看