Commit 6b7f807f authored by Ajit Deshmukh's avatar Ajit Deshmukh

Upload New File

parent bb79655f
var rfq_wiz = {};
rfq_wiz.globalObjName = 'rfq_wiz';
//alert("zzz Inside rfq_wiz js file loaded successfully!")
console.log("Inside rfq_wiz js file loaded successfully!");
function wfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData)
{
//alert('zzz inside wfValData function');
console.log('inside wfValData function in js file');
return true;
}
function valData(objContext, action, objName, currentFormData, objFormName)
{
//alert('zzz inside valData function');
console.log('inside valData function in js file');
return true;
}
//called in offline mode
function localWfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData)
{
//alert('zzz inside localWfValData function');
var isValidWfData = true;
console.log('inside localWfValData function in js file **************************');
return isValidWfData;
}
function localValData(objContext, action, objName, currentFormData, objFormName)
{
//alert('zzz inside localValData function');
var isValidData = true;
console.log('objName is'+objName);
console.log('objFormName is'+objFormName);
console.log('objContext is'+objContext);
console.log('action is'+action);
console.log('inside localValData function in js file **************************'+currentFormData);
var currentFormData=currentFormData;
var action=action;
var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
if(currentFormData != null && currentFormData.trim().length > 0)
{
console.log("cureentform data is not null"+currentFormData);
if(xmlVersion == 0)
{
//console.log("inside if");
currentFormData = currentFormData;
}
else
{
//console.log("inside else");
currentFormData = "<Root>"+currentFormData+"</Root>";
}
}
else
{
console.log("null currentformdata");
}
if (window.DOMParser)
{
//alert("inside window.DOMParser");
parser=new DOMParser();
try
{
if(currentFormData != null && currentFormData.trim().length > 0)
{
xmlDoc = parser.parseFromString(currentFormData,"text/xml");
//console.log("xmlDoc =["+xmlDoc+"]");
}
}
catch(ex)
{
alert("Exception occurs while parsing xml data");
}
}
else // Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(txt);
}
if(xmlDoc != null )
{
if (objName === 'rfq_wiz') {
if (objContext === '2') {
console.log("=== RFQ_WIZ VALIDATION START ===");
console.log("Form Name :: [" + objName + "]");
console.log("Object Context :: [" + objContext + "]");
var detailElement = xmlDoc.getElementsByTagName("Detail" + objContext);
console.log("Total Detail Elements Found :: [" + detailElement.length + "]");
for (var i = 0; i < detailElement.length; i++) {
console.log("---- Processing Row Index :: [" + i + "] ----");
var detail = detailElement[i];
var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
console.log("updateFlag :: [" + attributeVal + "]");
if (attributeVal != 'D') {
var rateQuot = "";
var competitorRate = "";
var competitorName = "";
var competitorItem = "";
// rate_quot
if (detail.getElementsByTagName("rate_quot")[0] != null &&
detail.getElementsByTagName("rate_quot")[0].childNodes[0] != null) {
rateQuot = detail.getElementsByTagName("rate_quot")[0].childNodes[0].nodeValue;
}
// competitor_rate
if (detail.getElementsByTagName("competitor_rate")[0] != null &&
detail.getElementsByTagName("competitor_rate")[0].childNodes[0] != null) {
competitorRate = detail.getElementsByTagName("competitor_rate")[0].childNodes[0].nodeValue;
}
// competitor_name
if (detail.getElementsByTagName("competitor_name")[0] != null &&
detail.getElementsByTagName("competitor_name")[0].childNodes[0] != null) {
competitorName = detail.getElementsByTagName("competitor_name")[0].childNodes[0].nodeValue;
}
// competitor_item
if (detail.getElementsByTagName("competitor_item")[0] != null &&
detail.getElementsByTagName("competitor_item")[0].childNodes[0] != null) {
competitorItem = detail.getElementsByTagName("competitor_item")[0].childNodes[0].nodeValue;
}
console.log("rate_quot :: [" + rateQuot + "]");
console.log("competitor_rate :: [" + competitorRate + "]");
console.log("competitor_name :: [" + competitorName + "]");
console.log("competitor_item :: [" + competitorItem + "]");
// ===== Existing rate validation =====
if (rateQuot == null) {
console.log("Validation Failed :: rate_quot is NULL");
} else if (rateQuot.trim().length == 0) {
console.log("Validation Failed :: rate_quot is EMPTY");
} else if (isNaN(rateQuot)) {
console.log("Validation Failed :: rate_quot is NOT A NUMBER");
} else if (Number(rateQuot) <= 0) {
console.log("Validation Failed :: rate_quot <= 0");
}
if (rateQuot == null || rateQuot.trim().length == 0 || isNaN(rateQuot) || Number(rateQuot) <= 0) {
console.log("L Invalid rate_quot detected at row :: [" + i + "]");
alert("Invalid Rate Quot! Value should be greater than 0");
isValidData = false;
return isValidData;
}
// ===== NEW VALIDATION =====
if (Number(rateQuot) > 0) {
if (
competitorRate == null || competitorRate.trim().length == 0 ||
competitorName == null || competitorName.trim().length == 0 ||
competitorItem == null || competitorItem.trim().length == 0
) {
console.log("L Competitor details missing at row :: [" + i + "]");
alert("Competitor details cannot be empty for manually entering special rate");
isValidData = false;
return isValidData;
}
}
console.log(" Valid row :: [" + i + "]");
} else {
console.log("Skipping row [" + i + "] as updateFlag is D (Deleted)");
}
}
console.log("=== RFQ_WIZ VALIDATION END ===");
}
}
}
return isValidData;
}
function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, freeFormDataMap, fldName, fldValue, maxDomValue , isDoneSucess)
{
//alert('zzz inside localAutoNumberChange function');
console.log('inside localAutoNumberChange function in js file **************************');
var checkitemchangeData = 1;
console.log("Testing editorObjName ["+editorObjName+"] currentFormNo ["+currentFormNo+"] offlineRefVal ["+offlineRefVal+"] fldName ["+fldName+"] freeFormDataMap ["+freeFormDataMap+"] fldValue ["+fldValue+"] maxDomValue ["+maxDomValue+"] isDoneSucess ["+isDoneSucess+"]");
if( maxDomValue != "" && maxDomValue.length > 0 )
{
console.log("Testing maxDomValue ["+maxDomValue+"]");
if( isDoneSucess )
{
checkitemchangeData = parseInt(maxDomValue)+1;
}
else
{
checkitemchangeData = parseInt(maxDomValue)-1;
}
}
/*if( fldValue != "" && fldValue.length > 0 )
{
console.log("Testing fldValue ["+fldValue+"]");
if( isDoneSucess )
{
checkitemchangeData = parseInt(fldValue)+1;
}
else
{
checkitemchangeData = parseInt(fldValue)-1;
}
}*/
console.log("Testing final fldValue ["+fldValue+"] checkitemchangeData ["+checkitemchangeData+"]");
return checkitemchangeData;
}
function localItemChange(objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue, parentFormNo, parentDomID, buttonId, prevValue, itemCode, allFormDetaildata, dataModelJson) {
//alert('zzz inside localItemChange function');
console.log("inside localItemChange"+objFormName +"action::"+action + "domId:::"+domId + "fieldName:::"+fieldName);
var isItemchangeData = "";
var retString = "";
// var orderMap = new Map();
var domArr = [];
var orderArr = [];
console.log("dataModelJson::"+dataModelJson);
console.log('inside localItemChange function in js file **************************');
var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
//console.log("xmlVersion is : "+xmlVersion)
if(currentFormData != null && currentFormData.trim().length > 0)
{
console.log("cureentform data is not null"+currentFormData);
if(xmlVersion == 0)
{
//console.log("inside if");
currentFormData = currentFormData;
}
else
{
//console.log("inside else");
currentFormData = "<Root>"+currentFormData+"</Root>";
}
}
else
{
console.log("null currentformdata");
}
if (window.DOMParser)
{
//alert("inside window.DOMParser");
parser=new DOMParser();
try
{
if(currentFormData != null && currentFormData.trim().length > 0)
{
xmlDoc = parser.parseFromString(currentFormData,"text/xml");
//console.log("xmlDoc =["+xmlDoc+"]");
}
}
catch(ex)
{
alert("Exception occurs while parsing xml data");
}
}
else // Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(txt);
}
if(xmlDoc != null )
{
if(objContext == 3)
{
// console.log("in place action is"+action +"::"+ objContext);
if(action == 'itemchange' && fieldName == 'deselect')
{
// console.log("in place cureentform data is ::"+currentFormData);
var orderVisit = "";
var orderDomId = "";
var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
for (var i = 0; i < detailElement.length; i++)
{
var detail = detailElement[i];
var attributeVal = detail.getAttribute("selected");
// console.log("attributeVal is"+attributeVal);
//console.log("inside detailElement"+detail);
if( detail.getElementsByTagName("order_of_visit")[0] != null && detail.getElementsByTagName("order_of_visit")[0].childNodes[0] != null && attributeVal != null && attributeVal == 'Y')
{
orderVisit = detail.getElementsByTagName("order_of_visit")[0].childNodes[0].nodeValue;
// console.log("order_of_visit is:"+orderVisit);
orderDomId = detail.getAttribute("domID");
// console.log("orderDomId is:"+orderDomId);
/*orderMap.set(orderVisit, orderDomId);
console.log("map is:"+orderMap);*/
domArr.push(orderDomId);
orderArr.push(orderVisit);
}
}
var visitNo = 1;
retString = "<Root><Detail3>";
/*orderMap.forEach(function (item, key, mapObj) {
console.log(item.toString());
if(item.toString() != domId)
{
retString = retString + "<Detail2_SEP1_"+item.toString() +"_SEP1_order_of_visit><![CDATA["+ visitNo +"]]></Detail2_SEP1_"+item.toString() +"_SEP1_order_of_visit>"
visitNo++
}
}); */
for(var i = 0; i < domArr.length; i++)
{
if(domArr[i] != domId)
{
retString = retString + "<Detail3_SEP1_"+ domArr[i] +"_SEP1_order_of_visit><![CDATA["+ visitNo +"]]></Detail3_SEP1_"+ domArr[i] +"_SEP1_order_of_visit>"
visitNo++
}
}
retString = retString + "</Detail3></Root>";
console.log("outside map::::"+retString);
}
isItemchangeData = retString;
}
else if(objContext == 1)
{
if( fieldName === 'activity_code' || fieldName === 'event_date')
{
//console.log("fieldName is"+fieldName);
var activityType="";
var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
for (var i = 0; i < detailElement.length; i++)
{
var detail = detailElement[i];
//console.log("inside detailElement"+detail);
if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
{
activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
console.log("activity type is:"+activityType);
}
}
if( activityType == 'NFW' || activityType == 'LEAVE')
{
//console.log("inside if:");
document.getElementById(buttonId).setAttribute("style", "opacity: 0.7; pointer-events :none;");
}
else
{
console.log("inside else:");
document.getElementById(buttonId).removeAttribute("style");
}
}
}
}
return isItemchangeData;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment