Escolar Documentos
Profissional Documentos
Cultura Documentos
// Remove <CIP> and <Accessory> data. Its not needed and causes problems wit
h extracting data.
xml = RemoveAllInstancesOfTags(xml, "<CIP>", "</CIP>");
xml = RemoveAllInstancesOfTags(xml, "<Accessory", "</Accessory>");
var incrementalItemNumber = 1;
// Get all unit xml
var xmlCompositeUnits = GetAllPieces(xml, "<Composite>", "</Composite>");
xml = RemoveAllInstancesOfTags(xml, "<Composite>", "</Composite>");
var compositeUnits = [];
for (var i = 0; i < xmlCompositeUnits.length; i++) {
var unit = xmlCompositeUnits[i];
var unitPrice = "", quantity = "tmp", width = "", height = "", color = "
", unitSize = "", isWindow = "", shape = "", prodDescArray = [];
var allAttributes = GetAllPieces(unit.str, "<Attribute", "</Attribute>")
;
for (var k = 0; k < allAttributes.length; k++) {
var attrStr = allAttributes[k].str;
if (attrStr.indexOf("PRODTYPE") >= 0 || attrStr.indexOf("PRODSTYLE")
>= 0 || attrStr.indexOf("PRODSHAPE") >= 0) {
prodDescArray.push(GetTextBetweenTags(attrStr, ">", "<"));
}
}
var tmpStr = RemoveAllInstancesOfTags(unit.str, "<Group>", "</Group>");
tmpStr = RemoveAllInstancesOfTags(unit.str, "<Unit>", "</Unit>");
var compositeAttributes = GetAllPieces(tmpStr, "<Attribute", "</Attribut
e>");
for (var k = 0; k < compositeAttributes.length - 1; k++) {
var attrStr = compositeAttributes[k].str;
if (attrStr.indexOf("Order_Quantity") >= 0 || attrStr.indexOf("ORDER
_QUANTITY") >= 0) {
if (isNaN(quantity)) {
quantity = parseInt(GetTextBetweenTags(attrStr, ">", "<"));
}
}
if (attrStr.indexOf("RO_HIGH") >= 0) {
var tmpHeight = parseFloat(GetTextBetweenTags(attrStr, ">", "<")
);
if (height === "") {
height = GetTextBetweenTags(attrStr, ">", "<");
} else if (tmpHeight > height) {
height = GetTextBetweenTags(attrStr, ">", "<");
}
}
if (attrStr.indexOf("RO_WIDE") >= 0) {
var tmpWidth = parseFloat(GetTextBetweenTags(attrStr, ">", "<"))
;
if (width === "") {
width = GetTextBetweenTags(attrStr, ">", "<");
} else if (tmpHeight > width) {
width = GetTextBetweenTags(attrStr, ">", "<");
}
}
if (attrStr.indexOf("FS_WIDE") >= 0) {
var tmpWidth = parseFloat(GetTextBetweenTags(attrStr, ">", "<"))
;
if (width
width
} else if
width
}
=== "") {
= GetTextBetweenTags(attrStr, ">", "<");
(tmpHeight > width) {
= GetTextBetweenTags(attrStr, ">", "<");
}
if (attrStr.indexOf("FS_HIGH") >= 0) {
var tmpHeight = parseFloat(GetTextBetweenTags(attrStr, ">", "<")
);
if (height === "") {
height = GetTextBetweenTags(attrStr, ">", "<");
} else if (tmpHeight > height) {
height = GetTextBetweenTags(attrStr, ">", "<");
}
}
if (attrStr.indexOf('"UNIT_CODE"') >= 0) {
if (unitSize == "") {
unitSize = GetTextBetweenTags(attrStr, ">", "<");
}
}
if (attrStr.indexOf("PRODCAT") >= 0) {
var productCategory = GetTextBetweenTags(attrStr, ">", "<").toUp
perCase();
if (productCategory.indexOf("WINDOW") !== -1) {
isWindow = true;
} else {
isWindow = false;
}
}
if (attrStr.indexOf("EXTR_COLOR") >= 0) {
color = GetTextBetweenTags(attrStr, ">", "<");
}
if (attrStr.indexOf("Total_Price_in_USD") >= 0) {
unitPrice = parseFloat(GetTextBetweenTags(attrStr, ">", "<"));
}
}
for (var k = 0; k < quantity; k++) {
var tmpUnit = {};
tmpUnit.UnitSize = unitSize;
tmpUnit.ProductLineCode = "";
tmpUnit.ItemNumber = incrementalItemNumber;
incrementalItemNumber++;
tmpUnit.Width = ConvertFracToDec(width);
tmpUnit.Height = ConvertFracToDec(height);
tmpUnit.IsWindow = isWindow;
tmpUnit.Shape = DescriptionToShape(prodDescArray);;
tmpUnit.Color = color;
tmpUnit.UnitPrice = parseFloat(unitPrice);
compositeUnits.push(tmpUnit);
}
unitPrice = "", quantity = "tmp", width = "", height = "", color = "", u
nitSize = "", isWindow = "", shape = "", prodDescArray = [];
}
result.units = compositeUnits.concat(resultUnits);
result.fileName = fileName;
result.companyName = companyName;
return result;
}