// JavaScript Document var rows = 0; var selectedRow = 0; var pcolid = 0; var prowid = 0; var arr = new Array(); var json; var rowSelected = false; function save() { var head = ""; arr = new Array(); // setting the hidden grades setHiddenGrade(); var redigit=/^[A-Z][0-9]{7}$/; //regular expression defining char with a 6 digit number /* if (document.getElementById('invoice_no').value.search(redigit)==-1){ //if match failed alert("Please enter a valid Invoice Note no"); document.getElementById('invoice_no').focus(); return; }*/ /* if(checkGradings() == false) { //alert('error log foind'); alert('You Must set the Grading for Teak logs, minimum value is 40%'); } */ //if (formcheck.checkValidation()) { //if (formcheck.checkValidation() && checkGradings() != false) { if (formcheck.checkValidation()) { var ele = document.getElementById("grid_content"); var checkNumRecors = checkTableFields(); if (checkNumRecors) { $$('input').each( function(el) { if (!empty(el.value)) { if (el.className == "gridField") { var expl = el.id.split("_"); if (!empty(document.getElementById("col8_" + expl[1]).value)) { if (arr[expl[1]] == null) arr[expl[1]] = new Array(); var bcol = expl[0].split("col"); arr[expl[1]][bcol[1]] = el.value; } } else if (el.name != "" ) { head += "\"" + el.name + "\":\"" + el.value + "\","; } } }); $$('textarea').each(function(el) { if (el.name != "") { head += "\"" + el.name + "\":\"" + el.innerHTML + "\","; } }); $$('select') .each( function(el) { if (el.name != "" && !(el.name == "precent" || el.name == "grade" || el.name == "transCost")) { head += "\"" + el.name + "\":\"" + el.value + "\","; } else if(el.name != "" && (el.name == "transCost" )){ var expl = el.id.split("_"); if(arr[expl[1]] == null) arr[expl[1]] = new Array(); var bcol = expl[0].split("col"); arr[expl[1]][bcol[1]] = el.value; } }); head = head.substr(0, head.length - 1); var str = "headdata={" + head + "}&itemdata=" + JSON.encode(arr); //alert(str); if (arr.length > 0) { //alert(str); var myRequest = new Request({ method : 'post', data : str, url : '/stock/ajax/savePreInvoice.php', onSuccess : function(result) { hideImgContent('waitingDiv'); alert("Record Saved Successfully.."); window.location.reload(); } }); showImgContent('waitingDiv'); myRequest.send(); } else { alert("Please fill the table data"); } } } } function resetRow() { // if(document.getElementById("col2_"+selectedRow)!=null) // { // // var inputElemnts = document.getElementsByName("materialNo"); // if(!empty(inputElemnts)) // { // for(var i=1; i<= inputElemnts.length ;i++) // { // document.getElementById("col"+i+"_"+selectedRow).parentNode.style.backgroundColor // = "#fff" // } // } // } if (document.getElementById("colHead_" + selectedRow) != null) document.getElementById("colHead_" + selectedRow).className = "gridRowHandle"; if (document.getElementById("dishead" + pcolid) != null) document.getElementById("dishead" + pcolid).className = "gridHeadCol"; if (document.getElementById("colHead_" + prowid) != null) document.getElementById("colHead_" + prowid).className = "gridRowHandle"; selectedRow = null; rowSelected = false; } function markRow(el) { resetRow(); expl = el.id.split("_"); var rowid = expl[1]; var inputElemnts = document.getElementsByName("materialNo"); if (!empty(inputElemnts)) { for ( var i = 1; i <= inputElemnts.length; i++) { if (document.getElementById('row_' + i) != null) { document.getElementById("col" + i + "_" + rowid).parentNode.style.backgroundColor = "#ffe38d"; } } } if (document.getElementById("colHead_" + rowid) != null) document.getElementById("colHead_" + rowid).className = "gridRowHandleSelected"; selectedRow = rowid; rowSelected = true; } /** * this function is used to mark the entire row item * * @param el * element */ function markRowColor(el) { // resetRow(); expl = el.id.split("_"); var rowid = expl[1]; var inputElemnts = document.getElementsByName("materialNo"); if (!empty(inputElemnts)) { for ( var i = 1; i <= inputElemnts.length; i++) { if (document.getElementById('row_' + i) != null) { document.getElementById("row_" + i).style.backgroundColor = ""; document.getElementById("colHead_" + i).className = "gridRowHandle"; } else { var keyValue = inputElemnts[i - 1].id; var idNumber = keyValue.split("_"); if (document.getElementById('row_' + idNumber[1]) != null) { document.getElementById("row_" + idNumber[1]).style.backgroundColor = ""; document.getElementById("colHead_" + i).className = "gridRowHandle"; } } } } document.getElementById("row_" + rowid).style.backgroundColor = "#ffe38d"; if (document.getElementById("colHead_" + rowid) != null) document.getElementById("colHead_" + rowid).className = "gridRowHandleSelected"; selectedRow = rowid; rowSelected = true; } function selectAxis(el) { var expl = el.id.split("_"); var rowid = expl[1]; expl = expl[0].split("col"); var colid = expl[1]; if (document.getElementById("dishead" + pcolid) != null) document.getElementById("dishead" + pcolid).className = "gridHeadCol"; if (document.getElementById("colHead_" + prowid) != null) document.getElementById("colHead_" + prowid).className = "gridRowHandle"; document.getElementById("dishead" + colid).className = "gridHeadColSelected"; document.getElementById("colHead_" + rowid).className = "gridRowHandleSelected"; pcolid = colid; prowid = rowid; markRowColor(el); } function printRowOrder() { var row = 1; $$('div').each( function(el) { if (el.className == "gridRowHandle" || el.className == "gridRowHandleSelected") { el.innerHTML = row++; } }); } function removerow() { if (rowSelected != false) { if (document.getElementById("row_" + selectedRow) != null) { var el = document.getElementById("row_" + selectedRow); el.parentNode.removeChild(el); } } rowSelected = false; selectedRow = null; printRowOrder(); resetTotalPrice(); // getting the total volume calculateTotalVolume(); //calculateTransCost(); } var species = new Array(); var category = new Array("Logs", "Sawn", "Other"); var classes = new Array(); function load_species() { var req = new Request({ method : 'GET', data : '', url : '/stock/ajax/species.php', onSuccess : function(result) { var jObj = JSON.decode(result); for ( var i = 0; i < jObj.length; i++) { species[i] = new Array(); species[i][0] = jObj[i]['species_id']; species[i][1] = jObj[i]['species_txt']; } } }); req.send(); var req1 = new Request({ method : 'GET', data : '', url : '/stock/ajax/classes.php', onSuccess : function(result) { var jObj = JSON.decode(result); for ( var i = 0; i < jObj.length; i++) { classes[i] = new Array(); classes[i][0] = jObj[i]['class_id']; classes[i][1] = jObj[i]['class_txt']; } } }); req1.send(); } function getMaterialData(e, el) { var row = el.id.split("_"); var query = "id=" + el.value + "&depot=" + document.getElementById('depot').value; if (e.keyCode == 13) { var req1 = new Request( { method : 'GET', data : query, url : '/stock/ajax/get_logs.php', onSuccess : function(result) { var jObj = JSON.decode(result); if (jObj.length == 0) { alert("No entries found"); el.parentNode.style.backgroundColor = "#ff7373"; } else { alert("Entry Found.."); if (jObj[0]['active'] == 1) { document.getElementById("col2_" + row[1]).innerHTML = jObj[0]['category']; document.getElementById("col3_" + row[1]).innerHTML = jObj[0]['class_txt']; document.getElementById("col5_" + row[1]).innerHTML = jObj[0]['species_txt']; document.getElementById("col6_" + row[1]).innerHTML = jObj[0]['length']; document.getElementById("col7_" + row[1]).innerHTML = jObj[0]['girth']; document.getElementById("col9_" + row[1]).value = jObj[0]['volume']; document.getElementById("volume_" + row[1]).value = jObj[0]['volume']; document.getElementById("col12_" + row[1]).value = jObj[0]['material_no']; // el.parentNode.style.backgroundColor = "#fff"; } else if (jObj[0]['active'] == 2) { alert("Specific Log has been sold out"); el.parentNode.style.backgroundColor = "#ff7373"; } else { alert("Specific Log is not Confirmed yet"); el.parentNode.style.backgroundColor = "#ff7373"; } } // adjust_grid() // getting the total volume calculateTotalVolume(); } }); req1.send(); } } function adjust_grid() { var lotno = ""; var total_volume = 0; var total_cost = 0; var ele = document.getElementById("grid_content"); $$('input') .each( function(el) { if (el.className == "gridField") { var expl = el.id.split("_"); var bcol = expl[0].split("col"); if (bcol[1] == "1") { // adjusting the totals if (document.getElementById("col8_" + expl[1]).innerHTML != "") total_volume += document .getElementById("col8_" + expl[1]).innerHTML * 1; if (document.getElementById("col9_" + expl[1]).value != "") total_cost += document .getElementById("col9_" + expl[1]).value * 1; if (lotno != el.value && el.value != "") { lotno = el.value; document.getElementById("col9_" + expl[1]).style.display = "block"; for ( var i = 1; i < 10; i++) document.getElementById("col" + i + "_" + expl[1]).parentNode.style.backgroundColor = "#f0fff3"; } else { for ( var i = 1; i < 10; i++) document.getElementById("col" + i + "_" + expl[1]).parentNode.style.backgroundColor = "#fff"; el.parentNode.style.backgroundColor = "#eee"; document.getElementById("col9_" + expl[1]).parentNode.style.backgroundColor = "#eee"; document.getElementById("col9_" + expl[1]).style.display = "none"; } } } }); document.getElementById('total_volume').innerHTML = total_volume; // document.getElementById('total_cost').innerHTML = total_cost; } function addrow() { rows++; var container = document.getElementById("grid_content"); // starting the new row of the table var row = document.createElement("div"); row.className = "gridRowi"; row.id = "row_" + rows; // first column ----- id (number) var colHead = document.createElement("div"); colHead.className = "gridRowHandle"; colHead.id = "colHead_" + rows; colHead.setAttribute("style", "cursor:pointer"); colHead.onclick = function() { markRowColor(this); }; row.appendChild(colHead); /* * removing the cell of the lot no var col1 = document.createElement("div"); * col1.className = "gridCol"; var input1 = document.createElement("input"); * input1.id = "col1_"+rows; input1.className = "gridField"; input1.onclick = * function(){resetRow();selectAxis(this);} input1.onblur = * function(){adjust_grid()} col1.appendChild(input1); * row.appendChild(col1); */ // category cell information var col2 = document.createElement("div"); col2.className = "gridCol"; col2.id = "col2_" + rows; col2.setAttribute("style", "width:50px;"); row.appendChild(col2); // timber class cell information var col3 = document.createElement("div"); col3.className = "gridCol"; col3.id = "col3_" + rows; col3.setAttribute("style", "width:70px;"); row.appendChild(col3); // log number cell information var col4 = document.createElement("div"); col4.className = "gridCol"; var input4 = document.createElement("input"); input4.id = "col4_" + rows; input4.className = "gridField"; col4.setAttribute("style", "width:95px;"); // input4.onblur = function(){adjust_grid()} input4.onclick = function() { resetRow(); selectAxis(this); }; input4.onkeydown = function(event) { getMaterialData(event, this); }; var materialNo = document.createElement("input"); materialNo.type = "hidden"; materialNo.id = "col12_" + rows; materialNo.name = "materialNo"; materialNo.className = "gridField"; col4.appendChild(materialNo); var hiddenGrade = document.createElement("input"); hiddenGrade.type = "hidden"; hiddenGrade.id = "col13_" + rows; hiddenGrade.name = "hiddenGrading"; hiddenGrade.className = "gridField"; col4.appendChild(hiddenGrade); col4.appendChild(input4); col4.setAttribute("style", "width:95px;"); row.appendChild(col4); // species cell information var col5 = document.createElement("div"); col5.className = "gridCol"; col5.id = "col5_" + rows; row.appendChild(col5); // length cell information var col6 = document.createElement("div"); col6.className = "gridCol"; col6.id = "col6_" + rows; col6.setAttribute("style", "width:75px;"); row.appendChild(col6); // Mid girth cell information var col7 = document.createElement("div"); col7.className = "gridCol"; col7.id = "col7_" + rows; col7.setAttribute("style", "width:85px;"); row.appendChild(col7); // Mid girth Price cell information var col8 = document.createElement("div"); col8.className = "gridCol"; // Mid girth price hidden field // keep the real price var input8 = document.createElement("input"); input8.className = "gridField"; input8.id = "cols8_" + rows; input8.type = "hidden"; col8.appendChild(input8); // keep the changing price var midPriceInput = document.createElement("input"); midPriceInput.className = "gridField"; midPriceInput.id = "col8_" + rows; midPriceInput.name = "midPrice"; midPriceInput.onclick = function() { resetRow(); selectAxis(this); setPriceToHidden(rows); }; midPriceInput.onblur = function() { calculateTotalPrice(rows,this); }; col8.appendChild(midPriceInput); col8.setAttribute("style", "width:100px;"); row.appendChild(col8); // volume cell information var col9 = document.createElement("div"); col9.className = "gridCol"; var input9 = document.createElement("input"); input9.id = "col9_" + rows; input9.onblur = function() { adjust_grid(); }; input9.className = "gridField"; input9.setAttribute("style", "width:70px;"); col9.setAttribute("style", "width:70px;"); input9.onclick = function() { resetRow(); selectAxis(this); }; col9.appendChild(input9); var volumeInput = document.createElement("input"); volumeInput.id = "volume_" + rows; volumeInput.name = "volume"; volumeInput.type = "hidden"; col9.appendChild(volumeInput); row.appendChild(col9); var col10 = document.createElement("div"); col10.className = "gridCol"; /* * removeing the input element var input10 = * document.createElement("input"); input10.id = "col10_"+rows; * input10.onblur = function(){adjust_grid()} input10.className = * "gridField"; input10.onclick = function(){ resetRow();selectAxis(this);} * col10.appendChild(input10); */ // getting the combo select element var gradeSelect = createComboGrade(rows); var percentSelect = createComboGradePresentage(rows); col10.appendChild(gradeSelect); col10.appendChild(percentSelect); row.appendChild(col10); var col11 = document.createElement("div"); col11.className = "gridCol"; var input11 = document.createElement("input"); input11.id = "col11_" + rows; input11.name = "totalPrice"; input11.onblur = function() { resetTotalPrice(); }; input11.className = "gridField"; input11.setAttribute("style", "width:70px;"); input11.onclick = function() { resetRow(); selectAxis(this); }; col11.appendChild(input11); var hiddenTotPrice = document.createElement("input"); hiddenTotPrice.type = "hidden"; hiddenTotPrice.id = "hiddenPrice_" + rows; col11.appendChild(hiddenTotPrice); col11.setAttribute("style", "width:70px;"); row.appendChild(col11); // volume cell information var col12 = document.createElement("div"); col12.className = "gridCol"; var input12 = createComboTransfer(rows); /* input12.id = "col14_" + rows; input12.name = "transCost"; input12.className = "gridField"; input12.setAttribute("style", "width:70px;"); */ input12.onchange = function() { calculateTransCost(this); }; input12.onclick = function() { resetRow(); selectAxis(this); }; col12.appendChild(input12); row.appendChild(col12); if (rowSelected == false) container.appendChild(row); else { if (document.getElementById("row_" + selectedRow) != null) { var el = document.getElementById("row_" + selectedRow); el.parentNode.insertBefore(row, el.nextSibling); } } printRowOrder(); } /* * this function is used to create the grading combo box in the table cell * * @param id use to create the id of the element */ function createComboGrade(id) { var selectElement = document.createElement("select"); selectElement.id = "grade_" + id; selectElement.name = "grade"; selectElement.setAttribute("style", "text-align:left;width:50px;height:15px;font-size:9px;"); selectElement.onchange = function() { viewPerCentCombo(id); }; var gradeA = document.createElement("option"); gradeA.value = "A"; gradeA.appendChild(document.createTextNode('A')); var gradeB = document.createElement("option"); gradeB.value = "B"; gradeB.appendChild(document.createTextNode('B')); gradeB.selected = true; var gradeC = document.createElement("option"); gradeC.value = "C"; gradeC.appendChild(document.createTextNode('C')); selectElement.appendChild(gradeA); selectElement.appendChild(gradeB); selectElement.appendChild(gradeC); return selectElement; } /* * this function is used to create the percentage combo box * * @param id this is used to create the id of the element */ function createComboGradePresentage(id) { var selectElement = document.createElement("select"); selectElement.id = "precent_" + id; selectElement.name = "precent"; selectElement .setAttribute("style", "text-align:left;width:50px;height:15px;font-size:9px;display:none;"); selectElement.onchange = function() { calculateTotalPrice(id,this); }; for ( var i = 5; i < 251; i += 5) { var grade = document.createElement("option"); grade.value = i; grade.appendChild(document.createTextNode(i + ' %')); selectElement.appendChild(grade); } return selectElement; } /* * this function is used to view the hidden precentage combo box * * @param id element id value */ function viewPerCentCombo(id) { if (!empty(document.getElementById('grade_' + id))) { var selectedCombo = document.getElementById('grade_' + id); var selectedValue = selectedCombo.options[selectedCombo.selectedIndex].value; if (selectedValue == 'A' || selectedValue == 'C') { document.getElementById('precent_' + id).setAttribute("style", "text-align:left;width:50px;height:15px;font-size:9px;"); } else { document .getElementById('precent_' + id) .setAttribute("style", "text-align:left;width:50px;height:15px;font-size:9px;display:none;"); } setPriceToHidden(id); calculateTotalPrice(id); } } /* * this function is used to create the total price of the singel timber item * * @param id the id value of the selected element */ function calculateTotalPrice(elem_id,elem) { var id ; if(elem != undefined && elem != null) { var ids = elem.id.split("_"); id = ids[1]; } else { id = elem_id; } var elementValue = document.getElementById('col8_' + id).value; if (!empty(elementValue)) { if (!isNaN(elementValue)) { var num = parseFloat(elementValue); var volume = parseFloat(document.getElementById('volume_' + id).value); var selectedGrade = document.getElementById('grade_' + id).options[document .getElementById('grade_' + id).selectedIndex].value; var trans_cost = document.getElementById('col14_' + id).options[document.getElementById('col14_' + id).selectedIndex].value; var trans_cost_price = (parseFloat(trans_cost)*volume); // selected grading B if (selectedGrade == 'B') { var totalPrice = (num * volume) + trans_cost_price; document.getElementById('col11_' + id).value = totalPrice .toFixed(2); // document.getElementById("hiddenPrice_" + id).value = // totalPrice.toFixed(2); viewMainPrice(totalPrice, id); } else { if (selectedGrade == 'A') { // upgrading the value var precentElement = document.getElementById("precent_" + id); var selectedPercent = precentElement.options[precentElement.selectedIndex].value; //updated by kriska var upgradeValue =Math.round(( num + ((num * selectedPercent) / 100))*100)/100; // var upgradeValue = num + ((num * selectedPercent) / 100); // calculating // the // new // price var totalPrice = (upgradeValue * volume) + trans_cost_price; document.getElementById('col11_' + id).value = totalPrice .toFixed(2); // document.getElementById("hiddenPrice_" + id).value = // totalPrice.toFixed(2); viewMainPrice(totalPrice, id); } else { // degrading the value var precentElement = document.getElementById("precent_" + id); var selectedPercent = precentElement.options[precentElement.selectedIndex].value; //updated by kriska var upgradeValue =Math.round(( num - ((num * selectedPercent) / 100))*100)/100; // var upgradeValue = num - ((num * selectedPercent) / 100); // calculating // the // new // price var totalPrice = (upgradeValue * volume) + trans_cost_price; document.getElementById('col11_' + id).value = totalPrice .toFixed(2); // document.getElementById("hiddenPrice_" + id).value = // totalPrice.toFixed(2); viewMainPrice(totalPrice, id); } } } else { alert("Worng Price Value"); } } else { // dont view the final total } // calculateTotalVolume(); } /** * this function is used to view the main price in the page * * @param priceValue * @param id */ function viewMainPrice(priceValue, id) { var priceElement = document.getElementById('priceValue'); if (!empty(priceElement)) { var currentPrice = parseFloat(priceElement.innerHTML); // alert(currentPrice); if (!isNaN(priceValue)) { // calculating the whole amount in the total price of the items // getting the values of whole element var priceElements = document.getElementsByName('totalPrice'); var total = 0; for ( var i = 0; i < priceElements.length; i++) { if (!empty(priceElements[i].value)) { var priceValue = parseFloat(priceElements[i].value); total = total + priceValue; } } priceElement.innerHTML = parseFloat(total).toFixed(2); document.getElementById("priceHead").style.display = ''; } else { // alert("Wrong Price value."); } } calculateTotalAmount(); } /* * this function is used to set the current price before editing */ function setPriceToHidden(id) { var selectedElement = document.getElementById("col11_" + id); var hiddenElement = document.getElementById("hiddenPrice_" + id); hiddenElement.value = selectedElement.value; } /** * this function is used to recalculate the total price */ function resetTotalPrice() { // recalculate the total according to the existing items var priceElements = document.getElementsByName('totalPrice'); var priceElement = document.getElementById('priceValue'); if (priceElements.length > 0) { var total = 0; for ( var i = 0; i < priceElements.length; i++) { if (!empty(priceElements[i].value)) { var priceValue = parseFloat(priceElements[i].value); total = total + priceValue; } } if (total != 0) { priceElement.innerHTML = parseFloat(total).toFixed(2); document.getElementById("priceHead").style.display = ''; } else { // hide the price element document.getElementById("priceHead").style.display = "none"; document.getElementById("priceValue").innerHTML = "0.00"; } } else { // hide the price element document.getElementById("priceHead").style.display = "none"; document.getElementById("priceValue").innerHTML = "0.00"; } calculateTotalAmount(); } /** * this function is used to set the grading values */ function setHiddenGrade() { var hiddenGrades = document.getElementsByName('hiddenGrading'); if (hiddenGrades.length > 0) { for ( var i = 0; i < hiddenGrades.length; i++) { var elementId = hiddenGrades[i].id; var splitId = elementId.split("_"); var gradingSelect = document.getElementById("grade_" + splitId[1]); var selectedGrading = gradingSelect.options[gradingSelect.selectedIndex].value; if (selectedGrading == "B") { hiddenGrades[i].value = "B"; } else if (selectedGrading == "A") { var precentElement = document.getElementById("precent_" + splitId[1]); var selectedPercent = precentElement.options[precentElement.selectedIndex].value; hiddenGrades[i].value = "A" + selectedPercent; } else { var precentElement = document.getElementById("precent_" + splitId[1]); var selectedPercent = precentElement.options[precentElement.selectedIndex].value; hiddenGrades[i].value = "C" + selectedPercent; } } } } /** * this function is used to calculate the total volume */ function calculateTotalVolume() { var volumeHiddenElement = document.getElementsByName('volume'); if (volumeHiddenElement.length > 0) { var totalVolume = 0; for ( var i = 0; i < volumeHiddenElement.length; i++) { totalVolume += parseFloat(volumeHiddenElement[i].value); } if (totalVolume > 0) { document.getElementById("total_volume").innerHTML = parseFloat( totalVolume).toFixed(2); } } } /** * this function is used to count the no of records */ function checkTableFields() { var girthPriceElements = document.getElementsByName("midPrice"); if (girthPriceElements.length == 0) { alert("Please insert at least one record"); return false; } else { return true; } } function calculateTransCost(elem) { var elem_id = elem.id; calculateTotalPrice(elem_id,elem) /* var transCostElement = document.getElementsByName("transCost"); var totalTransCost = 0; if (transCostElement.length > 0) { for ( var i = 0; i < transCostElement.length; i++) { var costElement = transCostElement[i]; var expl = costElement.id.split("_"); if (costElement.value != "") { var volumeValue = document.getElementById('col9_' + expl[1]).value; if(volumeValue != "") { var volumeCost = parseFloat(volumeValue) * parseFloat(costElement.value); totalTransCost = totalTransCost + parseFloat(volumeCost); } } } } document.getElementById("total_trans_cost").innerHTML = totalTransCost.toFixed(2); */ calculateTotalAmount(); } function calculateTotalAmount() { var logPrice = parseFloat(document.getElementById('priceValue').innerHTML != "" ? document.getElementById('priceValue').innerHTML : 0); var transportCost = parseFloat(document.getElementById('total_trans_cost').innerHTML != "" ? document.getElementById('total_trans_cost').innerHTML : 0); var packingCost = parseFloat(document.getElementById('packingCost').value); var loadingCost = parseFloat(document.getElementById('loadCost').value); var totalPriceValue = logPrice + transportCost + packingCost + loadingCost ; document.getElementById('totalPrice').innerHTML = "Rs " + totalPriceValue.toFixed(2); } function createComboTransfer(id) { var selectElement = document.createElement("select"); selectElement.id = "col14_" + id; selectElement.name = "transCost"; selectElement.setAttribute("style", "text-align:left;width:50px;height:15px;font-size:9px;"); selectElement.onchange = function() { }; var gradeA = document.createElement("option"); gradeA.value = "0"; gradeA.appendChild(document.createTextNode('0')); var gradeB0 = document.createElement("option"); gradeB0.value = "1.75"; gradeB0.appendChild(document.createTextNode('1.75')); gradeB0.selected = true; var gradeB = document.createElement("option"); gradeB.value = "2.00"; gradeB.appendChild(document.createTextNode('2.00')); gradeB.selected = true; var gradeB1 = document.createElement("option"); gradeB1.value = "2.50"; gradeB1.appendChild(document.createTextNode('2.50')); gradeB1.selected = true; var gradeB2 = document.createElement("option"); gradeB2.value = "3.30"; gradeB2.appendChild(document.createTextNode('3.30')); gradeB2.selected = true; //new var gradeBN2 = document.createElement("option"); gradeBN2.value = "3.60"; gradeBN2.appendChild(document.createTextNode('3.60')); // new var gradeNC = document.createElement("option"); gradeNC.value = "4.35"; gradeNC.appendChild(document.createTextNode('4.35')); var gradeC = document.createElement("option"); gradeC.value = "4.00"; gradeC.appendChild(document.createTextNode('4.00')); var gradeD = document.createElement("option"); gradeD.value = "4.80"; gradeD.appendChild(document.createTextNode('4.80')); //new /* var gradeND = document.createElement("option"); gradeND.value = "5.60"; gradeND.appendChild(document.createTextNode('5.60')); var gradeE = document.createElement("option"); gradeE.value = "6.00"; gradeE.appendChild(document.createTextNode('6.00')); */ var gradeND1 = document.createElement("option"); gradeND1.value = "5.40"; gradeND1.appendChild(document.createTextNode('5.40')); var gradeND = document.createElement("option"); gradeND.value = "5.60"; gradeND.appendChild(document.createTextNode('5.60')); var gradeE = document.createElement("option"); gradeE.value = "6.00"; gradeE.appendChild(document.createTextNode('6.00')); selectElement.appendChild(gradeA); selectElement.appendChild(gradeB0); selectElement.appendChild(gradeB); selectElement.appendChild(gradeB1); selectElement.appendChild(gradeB2); selectElement.appendChild(gradeC); selectElement.appendChild(gradeD); selectElement.appendChild(gradeE); selectElement.appendChild(gradeBN2); selectElement.appendChild(gradeNC); selectElement.appendChild(gradeND1); selectElement.appendChild(gradeND); selectElement.selectedIndex = 0; return selectElement; } ///////////////// 2014- 04 - 24 function checkGradings() { var invalidGradingFound = 'no'; var TeakMaxLowesRate = 39; var Gradings = $$('select[id^=grade]'); var lotNoFound = 'no'; //var depotIDArray = Array('A061','A062','A065','A066','A067','A068','A070','A076'); //var depotID = $('depot').value; var getOrNotGet = 0; /* if(depotID =='A141' || depotID == 'A061' || depotID == 'A062' || depotID == 'A065' || depotID == 'A066' || depotID == 'A067' || depotID == 'A068' || depotID == 'A070' || depotID == 'A076') {*/ if(Gradings.length >0) { Gradings.each(function(lotEle) { var gradingID = lotEle.id; var splitedText = gradingID.split('_'); var speciesID = 'col5_'+splitedText[1]; var speciesName = $(speciesID).get('html'); if(speciesName == 'Teak') { //alert('Teak log found'); var comboBoxID = 'grade_'+splitedText[1] var comboItemValue = $(comboBoxID).value; var RateBoxID = 'precent_'+splitedText[1] var RateItemValue = $(RateBoxID).value; //precent_1 //alert(RateItemValue); if(comboItemValue != 'A' || parseInt(RateItemValue) <= TeakMaxLowesRate) { invalidGradingFound = 'yes'; //alert('You Must set the Grading for Teak logs, minimum value is '+ TeakMaxLowesRate +'%'); } else { invalidGradingFound = 'no'; } } }); } //} if(invalidGradingFound == 'yes') { return false; } else { return true; } }