# Customized Panes for 'xxxxxxxx' Created: 2009/04/09
# PANE:Sales History Quantities
[PANE]
ADMIN INVPENLZ 01000Sales History Quantities 020 000000500000INVPEN000M
[VBSCRIPT]
' This script contains functions for customized pane events.
' You must not modify the name of the functions.
Option Explicit
Function CustomizedPane_OnLoad()
' Define the variable to hold the XML that defines the listview structure
dim ListXML
' Build the XML that defines the listview structure. Those items containing the
' attribute Hidden=true will not appear.
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
ListXML = ListXML & ""
' Load the XML in to the ListviewProperties variable
CustomizedPane.CodeObject.ListviewProperties = ListXML
End Function
Function CustomizedPane_OnRefresh()
' Define the variables required for building the XML and calling the business object
dim XMLOut, XMLParam, Stockcode, PaneDescription
PaneDescription = ""
CustomizedPane.CodeObject.ListviewData = " "
' Populate the Stockcode variable with the refresh value
Stockcode = CustomizedPane.CodeObject.RefreshValue
if Stockcode = "" then
exit function
end if
' Build the XML input to the business object
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
XMLParam = XMLParam & " "
on error resume next
' Call the business object and supply the XML. The resulting XML is placed in the XMLOut variable
XMLOut = CallBO("INVQRY",XMLParam,"auto")
if err then
exit function
end if
' Switch on error handling
on error goto 0
' Define the variables required for building the new XML structure and extracting the information from
' the DOM. This is required because the Warehouse element is held at a different level in the original
' XML, so was not available to be used in the listview
Dim NewXML, NewXMLE, xDoc, xList, xList2, Counter, Counter2, Counter3, Counter4, XMLDoc, XMLDocInitialCheck, InitialCheck
Dim SQMB, SQME, SQ1B, SQ1E, WHB, WHE, WHDB, WHDE, SQ2B, SQ2E, SQ3B, SQ3E, SQ4B, SQ4E, SQ5B, SQ5E, SQ6B, SQ6E, SQ7B
Dim SQ7E, SQ8B, SQ8E, SQ9B, SQ9E, SQ10B, SQ10E, SQ11B, SQ11E, SQ12B, SQ12E, GraphXAML, GraphXAMLB, GraphXAMLE
Dim Graph1, Graph2, Graph3, Graph4, Graph5, Graph6, Graph7, Graph8, Graph9
NewXML = ""
NewXMLE = ""
SQMB = ""
SQME = ""
WHB = ""
WHE = ""
WHDB = ""
WHDE = ""
SQ1B = ""
SQ1E = ""
SQ2B = ""
SQ2E = ""
SQ3B = ""
SQ3E = ""
SQ4B = ""
SQ4E = ""
SQ5B = ""
SQ5E = ""
SQ6B = ""
SQ6E = ""
SQ7B = ""
SQ7E = ""
SQ8B = ""
SQ8E = ""
SQ9B = ""
SQ9E = ""
SQ10B = ""
SQ10E = ""
SQ11B = ""
SQ11E = ""
SQ12B = ""
SQ12E = ""
GraphXAMLB = ""
GraphXAMLE = ""
Set XMLDocInitialCheck = createobject("Msxml2.FreeThreadedDOMDocument")
XMLDocInitialCheck.async = false
XMLDocInitialCheck.LoadXML(XMLout)
Set InitialCheck = XMLDocInitialCheck.DocumentElement.SelectSingleNode("StockItem/StockAndAltUm")
If InitialCheck.text = "Y" then
GraphXAML="100|100|100|100|100|100|100|100|100|100|100|100|0|0|0|0|0|0|0|0|0|0|0|Unit Quantity Processing item "
NewXML = NewXML & SQMB
NewXML = NewXML & WHB & "Item cannot be displayed|as it is a Unit Quantity|Processing item" & WHE
NewXML = NewXML & GraphXAMLB & GraphXAML & GraphXAMLE
NewXML = NewXML & SQME
NewXML = NewXML & NewXMLE
CustomizedPane.CodeObject.ListviewData = NewXML
Else
' Load the output from the business object in to the DOM
Set XMLDoc = createobject("MSXML2.DOMDocument")
XMLDoc.async = false
XMLDoc.LoadXML(XMLOut)
Dim SalesArray(12), numHighValue, numHighValuePerc, VectorPoint(12), VectorPointA(12), VectorPointB(12), VectorPointC(12)
' Look for all WarehouseItem elements
Set xList = XMLDoc.SelectNodes("//WarehouseItem")
' Loop through each of the WarehouseItem elements
For Counter = 0 To xList.length - 1
' Within the WarehouseItem elements, locate the SerialItem elements
Set xList2 = xList(Counter).SelectNodes("SalesQtyByMonth")
' Loop through each SerialItem section
For Counter2 = 0 To xList2.length- 1
' Intialize variables
numHighValue = 0
SalesArray(0) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty1").Text)
SalesArray(1) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty2").Text)
SalesArray(2) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty3").Text)
SalesArray(3) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty4").Text)
SalesArray(4) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty5").Text)
SalesArray(5) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty6").Text)
SalesArray(6) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty7").Text)
SalesArray(7) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty8").Text)
SalesArray(8) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty9").Text)
SalesArray(9) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty10").Text)
SalesArray(10) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty11").Text)
SalesArray(11) = CDbl(xList2(Counter2).SelectSingleNode("SalesQty12").Text)
' Loop through array and then write the highest to the variable numHighValue
For Counter3 = LBound(SalesArray) To UBound(SalesArray)
If SalesArray(Counter3) > numHighValue Then
numHighValue = SalesArray(Counter3)
End If
Next
If numHighValue > 0 then
numHighValuePerc = numHighValue / 100
' Loop through array and calculate the vector position for each budget.
' Calculate the value as a percentage of the highest value.
' The full scale is 110. Subtract this from 160 as the position is relative to the highest point
' Add 10 to the value, which is the offest for the highest row that is not being used
For Counter4 = LBound(SalesArray) To UBound(SalesArray)
' msgbox SalesArray(Counter4),, "SalesArray(Counter4)"
VectorPointA(Counter4) = SalesArray(Counter4) / numHighValuePerc
' VectorPointC(Counter4) = 100 - VectorPointA(Counter4)
' msgbox VectorPointC(Counter3) ,,"VectorPointC(Counter3) "
VectorPoint(Counter4) = 100 - CInt(VectorPointA(Counter4))
' VectorPoint(Counter4) = CInt(VectorPointC(Counter4) + 10)
' msgbox VectorPoint(Counter4) ,,"VectorPoint(Counter4) "
Next
Graph1 = CInt(numHighValue * 0.9)
Graph2 = CInt(numHighValue * 0.8)
Graph3 = CInt(numHighValue * 0.7)
Graph4 = CInt(numHighValue * 0.6)
Graph5 = CInt(numHighValue * 0.5)
Graph6 = CInt(numHighValue * 0.4)
Graph7 = CInt(numHighValue * 0.3)
Graph8 = CInt(numHighValue * 0.2)
Graph9 = CInt(numHighValue * 0.1)
GraphXAML= "-|" & VectorPoint(0) & "|" & VectorPoint(1) & "|" & VectorPoint(2) & "|" & VectorPoint(3) & "|"
GraphXAML= GraphXAML & VectorPoint(4) & "|" & VectorPoint(5) & "|" & VectorPoint(6) & "|" & VectorPoint(7) & "|"
GraphXAML= GraphXAML & VectorPoint(8) & "|" & VectorPoint(9) & "|" & VectorPoint(10) & "|" & VectorPoint(11) & "|" & numHighValue
GraphXAML= GraphXAML & "|" & Graph1 & "|" & Graph2 & "|" & Graph3 & "|" & Graph4 & "|" & Graph5 & "|" & Graph6
GraphXAML= GraphXAML & "|" & Graph7 & "|" & Graph8 & "|" & Graph9 & "|0" & "|" & PaneDescription
Else
GraphXAML="-|100|100|100|100|100|100|100|100|100|100|100|100|0|0|0|0|0|0|0|0|0|0|0|" & PaneDescription
End If
' Build the new XML containing the original content of the SerialItem nodes and
' include the Warehouse from several levels above.
NewXML = NewXML & SQMB
NewXML = NewXML & WHB & "" & WHE
NewXML = NewXML & GraphXAMLB & GraphXAML & GraphXAMLE
NewXML = NewXML & SQ1B & SalesArray(0) & SQ1E
NewXML = NewXML & SQ2B & SalesArray(1) & SQ2E
NewXML = NewXML & SQ3B & SalesArray(2) & SQ3E
NewXML = NewXML & SQ4B & SalesArray(3) & SQ4E
NewXML = NewXML & SQ5B & SalesArray(4) & SQ5E
NewXML = NewXML & SQ6B & SalesArray(5) & SQ6E
NewXML = NewXML & SQ7B & SalesArray(6) & SQ7E
NewXML = NewXML & SQ8B & SalesArray(7) & SQ8E
NewXML = NewXML & SQ9B & SalesArray(8) & SQ9E
NewXML = NewXML & SQ10B & SalesArray(9) & SQ10E
NewXML = NewXML & SQ11B & SalesArray(10) & SQ11E
NewXML = NewXML & SQ12B & SalesArray(11) & SQ12E
NewXML = NewXML & SQME
Next
Next
' Complete the XML by closing off the root element
NewXML = NewXML & NewXMLE
' Load the new XML file in to the ListviewData variable
CustomizedPane.CodeObject.ListviewData = NewXML
End If
End Function