%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'| |
'| Bom_Home |
'| |
'=====================================================
%>
<%
Option explicit
Response.Expires = 0
Response.buffer = True
%>
<%
'To enable the script timeout to 10 mins
Server.ScriptTimeout=600
%>
<%
'------------ ACCESS CONTROL ------------------
%>
<%
'------------ VARIABLE DEFINITION -------------
Dim rsQry
Dim parProd_id_select
Dim parShowall
Dim objFormCollector
Dim objFormComponent
Dim rsTemp
'------------ CONSTANTS DECLARATION -----------
Const LIMG_UPDATED = ""
Const LIMG_ADDED = ""
Const LIMG_REMOVED = ""
Const LIMG_NOTE_NEW = ""
Const LIMG_NOTE_EDIT = ""
'------------ VARIABLE INIT -------------------
Set objFormCollector = CreateObject("Scripting.Dictionary")
Set objFormComponent = New FormComponent
'------------ CONDITIONS ----------------------
'----------------------------------------------
%>
<%
'--------------------------------------------------------------------------------------------------------------------------
'Extract the parts of the version string into seperate variables
Sub GetMajorMinorPatch( ByVal versionString, ByRef Major, ByRef Minor, ByRef Patch)
Dim pos
' Find the first occurence of the dot in package version A
pos = InStr(versionString, ".")
If pos <> 0 Then
' Extract the Major Version for A
Major = Mid(versionString, 1, pos - 1)
' Delete the Major Version Value from the string to get the minor and patch version
versionString = Mid(versionString, pos + 1, Len(versionString))
' Find the second occurence of the dot in package version A
pos = InStr(versionString, ".")
' Extract the Minor Version for A
If pos <> 0 Then
Minor = Mid(versionString, 1, pos - 1)
' Delete the Minor Version value from the string to get the patch version
versionString = Mid(versionString, pos + 1, Len(versionString))
' Find the last occurence of the dot in package version A
pos = InStr(versionString, ".")
If pos <> 0 Then
' Extract the Patch Version for A
Patch = Mid(versionString, 1, pos - 1)
End If
End If
End If
End Sub
'--------------------------------------------------------------------------------------------------------------------------
Sub AdjustPatch(ByRef PatchA, ByRef PatchB)
If NOT isNull(PatchA) AND NOT isNull(PatchB) Then
If isNumeric(PatchA) AND isNumeric(PatchB) Then
If CLng(PatchA) < 1000 Then
PatchA = CLng(PatchA) * 1000
End If
If CLng(PatchB) < 1000 Then
PatchB = CLng(PatchB) * 1000
End If
End If
End If
End Sub
'--------------------------------------------------------------------------------------------------------------------------
' Return True if verA is same or newer than verB, else return false
' If for some reason verA cannot be compared to verB, return the defaultReturn value as specified.
' This might happen if for example one of the version inputs was null due to one BOM not containing the package
' that another BOM did contain.
Function Is_VerA_SameOrNewerThan_VerB(ByVal verA, ByVal verB, defaultReturn)
' Process the version numbers to see what the difference is
Dim MajorA, MajorB, MinorA, MinorB, PatchA, PatchB
MajorA = NULL
MajorB = NULL
MinorA = NULL
MinorB = NULL
PatchA = NULL
PatchB = NULL
Is_VerA_SameOrNewerThan_VerB = defaultReturn
Call GetMajorMinorPatch(verA, MajorA, MinorA, PatchA)
Call GetMajorMinorPatch(verB, MajorB, MinorB, PatchB)
Call AdjustPatch(PatchA, PatchB)
If MajorA = MajorB Then
If MinorA = MinorB Then
If IsNumeric(PatchA) AND IsNumeric(PatchB) Then
If CDbl(PatchB) > CDbl(PatchA) Then
Is_VerA_SameOrNewerThan_VerB = False
Else
Is_VerA_SameOrNewerThan_VerB = True
End If
End If
Else
If IsNumeric(MinorA) AND IsNumeric(MinorB) Then
If CInt(MinorB) > CInt(MinorA) Then
Is_VerA_SameOrNewerThan_VerB = False
Else
Is_VerA_SameOrNewerThan_VerB = True
End If
End If
End If
Else
If IsNumeric(MajorA) AND IsNumeric(MajorB) Then
If CInt(MajorB) > CInt(MajorA) Then
Is_VerA_SameOrNewerThan_VerB = False
Else
Is_VerA_SameOrNewerThan_VerB = True
End If
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Get the product ID, package version, and comments for a specifed package ID in a specified BOM
' The specified BOM is always going to be the production BOM, although the actual query used is general. Only
' the name of the oracle query parameter (PRODUCTION_BOM) implies that the BOM is expected to be the production BOM.
Function GetProductIDandVersionInBOM(bom_id, pkg_id, ByRef prod_id, ByRef pkg_version, ByRef comments)
Dim rsQry
OraDatabase.Parameters.Remove "PRODUCTION_BOM"
OraDatabase.Parameters.Remove "PKG_ID"
OraDatabase.Parameters.Add "PRODUCTION_BOM", bom_id, ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "PKG_ID", pkg_id, ORAPARM_INPUT, ORATYPE_NUMBER
Set rsQry = OraDatabase.DbCreateDynaset(GetQuery("ProdVersion.sql"), ORADYN_DEFAULT)
If rsQry.RecordCount > 0 Then
prod_id = rsQry("prod_id")
pkg_version = rsQry("pkg_version")
comments = rsQry("comments")
GetProductIDandVersionInBOM = True
Else
' must set these to NULL so that Is_VerA_SameOrNewerThan_VerB() doesn't do anything
prod_id = NULL
pkg_version = NULL
comments = NULL
GetProductIDandVersionInBOM = False
End If
rsQry.Close()
Set rsQry = Nothing
OraDatabase.Parameters.Remove "PRODUCTION_BOM"
OraDatabase.Parameters.Remove "PKG_ID"
End Function
'--------------------------------------------------------------------------------------------------------------------------
' This function returns True if for any package that is in both the comparison and production BOMs, the version in the
' comparison BOM is the same or newer than that in the production BOM
Function CheckProduction (ProductionBOM, ComparisonBOM)
Dim PkgIdInComparisonBOM
Dim PkgVersionInComparisonBOM
Dim ProdIdInProductionBOM
Dim PkgVersionInProductionBOM
Dim Comments
CheckProduction = False 'Setting it initially to be false
OraDatabase.Parameters.Remove "PRODUCTION_BOM"
OraDatabase.Parameters.Add "PRODUCTION_BOM", ProductionBOM, ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "CURRENT_BOM", ComparisonBOM, ORAPARM_INPUT, ORATYPE_NUMBER
Set rsTemp = OraDatabase.DbCreateDynaset( GetQuery ("BomCheck.sql"), ORADYN_DEFAULT )
OraDatabase.Parameters.Remove "CURRENT_BOM"
' iterate through packages
While (NOT rsTemp.BOF) AND (NOT rsTemp.EOF) AND (CheckProduction = False)
PkgIdInComparisonBOM = rsTemp("pkg_id")
PkgVersionInComparisonBOM = rsTemp("pkg_version")
' Get the version of this product that is currently in the production BOM
If (GetProductIDandVersionInBOM( ProductionBOM, PkgIdInComparisonBOM, ProdIdInProductionBOM, PkgVersionInProductionBOM, Comments ) = True) Then
'check to see if the comparison BOM has the same or newer version
CheckProduction = Is_VerA_SameOrNewerThan_VerB( PkgVersionInComparisonBOM, PkgVersionInProductionBOM, False )
End If
rsTemp.MoveNext()
WEnd
OraDatabase.Parameters.Remove "PRODUCTION_BOM"
rsTemp.Close()
Set rsTemp = Nothing
End Function
'--------------------------------------------------------------------------------------------------------------------------
Function AddTrailingZeros(byval n, byval count)
if len(n) >= count then
AddTrailingZeros = n
exit function
end if
dim c, s, i
c = count - len(n)
for i = 1 to c
s = s & "0"
next
s = cstr(n) & s
AddTrailingZeros = s
End function
'--------------------------------------------------------------------------------------------------------------
Sub GetProductList ( nBom_id, nComparedBomId, outProductList, Flag )
Dim rsQry, showAll
'' Use SHOWALL parameter is BOM has old bom
'showAll = "Y"
'If nBom_id <> nComparedBomId Then
' showAll = parShowall
'End If
OraDatabase.Parameters.Add "BOM_ID", nBom_id, ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "COMPARE_BOM_ID", nComparedBomId, ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "CURRENT_BOM", dbPARbom_id, ORAPARM_INPUT, ORATYPE_NUMBER
If Flag = TRUE Then
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("BomCompare.sql"), ORADYN_DEFAULT )
Else
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("BomCompare_BaseConfig.sql"), ORADYN_DEFAULT )
End If
If rsQry.RecordCount > 0 Then
outProductList = rsQry.GetRows()
Else
outProductList = NULL
End If
OraDatabase.Parameters.Remove "COMPARE_BOM_ID"
OraDatabase.Parameters.Remove "BOM_ID"
OraDatabase.Parameters.Remove "CURRENT_BOM"
End Sub
'--------------------------------------------------------------------------------------------------------------------------
Sub GetFormDetails ( nBom_id, ByRef outobjDetails )
Call GetBomDetails ( nBom_id, outobjDetails )
outobjDetails.Item("root_version") = GetRootVersion ( outobjDetails.Item("bom_version") )
'-- Set compare_bom_id
If Request("compare_bom_id") <> "" Then
outobjDetails.Item("compare_bom_id") = Request("compare_bom_id")
Else
outobjDetails.Item("compare_bom_id") = outobjDetails.Item("parent_bom_id")
End If
End Sub
'--------------------------------------------------------------------------------------------------------------
Function GetBomTreeList ()
Dim rsQry
OraDatabase.Parameters.Add "BRANCH_ID", objFormCollector.Item("rtag_id_fk"), ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "BOM_ID", objFormCollector.Item("bom_id"), ORAPARM_INPUT, ORATYPE_NUMBER
OraDatabase.Parameters.Add "BOM_NAME", objFormCollector.Item("bom_name"), ORAPARM_INPUT, ORATYPE_NUMBER
If objFormCollector.Item("rtag_id_fk") = 542 Then'This is because SFO uses Front Office and Back Office
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("ProductionTreeComboSFO.sql"), ORADYN_DEFAULT )
Else
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("ProductionTreeCombo.sql"), ORADYN_DEFAULT )
End If
If rsQry.RecordCount > 0 Then
GetBomTreeList = rsQry.GetRows()
Else
GetBomTreeList = NULL
End If
OraDatabase.Parameters.Remove "BRANCH_ID"
OraDatabase.Parameters.Remove "BOM_NAME"
OraDatabase.Parameters.Remove "BOM_ID"
rsQry.Close
Set rsQry = Nothing
End Function
'--------------------------------------------------------------------------------------------------------------
Function GetCompareBomDetails ( nBomId )
Dim rsQry
OraDatabase.Parameters.Add "BOM_ID", nBomId, ORAPARM_INPUT, ORATYPE_NUMBER
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("BomLocationDetails.sql"), ORADYN_DEFAULT )
If rsQry.RecordCount > 0 Then
GetCompareBomDetails = rsQry("proj_name") &" / "& rsQry("branch_name") &" / "& rsQry("bom_name") &" "& rsQry("bom_version") &"."& rsQry("bom_lifecycle")
Else
GetCompareBomDetails = NULL
End If
OraDatabase.Parameters.Remove "BOM_ID"
rsQry.Close
Set rsQry = Nothing
End Function
'--------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
objPMod.PersistInQryString ( Array("compare_bom_id") )
Call GetFormDetails ( dbPARbom_id, objFormCollector )
'----------------------------------------------
%>
<%
'-- FROM START --------------------------------------------------------------------------------------------------------------
objFormComponent.FormName = "OldVersion"
objFormComponent.Action = SCRIPT_NAME
objFormComponent.Method = "get"
Call objFormComponent.FormStart()
Dim numOfBomRows
Dim rowNumBom
If (NOT IsNull(GetBomTreeList())) Then
numOfBomRows = UBound( GetBomTreeList(), 2 )
Else
numOfBomRows = -1
End If
For rowNumBom = 0 To numOfBomRows
Dim thisBomId
Dim nextBomId
thisBomId = GetBomTreeList()( 0, rowNumBom )
If rowNumBom = numOfBomRows Then
nextBomId = 0
Else
nextBomId = GetBomTreeList()( 0, rowNumBom + 1 )
End If
Call GetFormDetails ( thisBomId, objBomCollector )
%>
<%= objFormater.TextToHTML( objBomCollector.Item("bom_comments") )%>
Products/Patches Introduced in <%Call RenderTitle( objBomCollector )%> but not yet deployed in Production BOM
<%If InStr(APP_ROOT, "DEPLOYMAN_WWW") > 0 Then%>
Click here to Download PDF
<%Else%>
Click here to Download PDF
<%End If%>
Product
Version
Reason For This Version
Approval
<%
If NOT CheckProduction( Request("bom_id"), thisBomId) Then
%>
Found Matching BOM or Older Versions...Exiting Comparison
<%
Exit For
End If
Dim aProductList
Call GetProductList ( thisBomId, nextBomId, aProductList, TRUE )
If NOT IsNull( aProductList ) Then
' Variable used to prevent multiple entries being rendered for the same package
Dim LastPkgId
LastPkgId = -1
Dim numOfProdRows
Dim rowNumProd
numOfProdRows = UBound( aProductList, 2 )
' Iterate through the list of products
For rowNumProd = 0 To numOfProdRows
Response.Flush
Dim thisProdId
Dim thisPkgName
Dim thisPkgVersion
Dim thisIsPatch
Dim thisIsRejected
Dim thisPkgId
'Extract values into named variables to make code more readable where the values are used later on
thisProdId = aProductList( 0, rowNumProd )
thisPkgName = aProductList( 1, rowNumProd )
thisPkgVersion = aProductList( 2, rowNumProd )
thisIsPatch = aProductList( 3, rowNumProd )
thisIsRejected = aProductList( 4, rowNumProd )
thisPkgId = aProductList( 5, rowNumProd )
' Get the version of this product that is currently in the production BOM
Dim ProdIdInProductionBOM
Dim PkgVersionInProductionBOM
Dim Comments
Call GetProductIDandVersionInBOM( dbPARbom_id, thisPkgId, ProdIdInProductionBOM, PkgVersionInProductionBOM, Comments )
' We want to figure out if we have to display this product. We only want to do so if the version of it is the
' same or newer than that currently in the production BOM
Dim IsDisplay
IsDisplay = True
If IsNull(thisIsPatch) Then
IsDisplay = Is_VerA_SameOrNewerThan_VerB( thisPkgVersion, PkgVersionInProductionBOM, IsDisplay )
End If
If IsDisplay Then
Set rsTemp = OraDatabase.DbCreateDynaset("SELECT * FROM PACKAGE_VERSIONS PV, PRODUCT_DETAILS PD WHERE PD.PROD_ID(+) = PV.PV_ID AND PV.PV_ID ="&thisProdId, ORADYN_DEFAULT )
%>
<%If IsNull(thisIsPatch) Then
If CDbl(LastPkgId) <> CDbl(thisPkgId) Then%>
<%
Dim rsForm, Tester, Manager
Tester = False
Manager = False
If objAccessControl.IsActive("ApprovedByManager") Then
Manager = True
ElseIf objAccessControl.IsActive("ApprovedByTester") Then
Tester = True
End If
Set rsForm = OraDatabase.DbCreateDynaset("SELECT * FROM RELEASE_AUTHORISATION WHERE PV_ID="&thisProdId&" AND BOM_ID="&Request("bom_id"), ORADYN_DEFAULT)
%>
<%If rsForm.RecordCount = 0 Then%>
<%If Tester Then%>
<%End If%>
<%
LastPkgId = CDbl(thisPkgId)
End If
' -------- END GROUP ------------------------
End If%>
<%
rsTemp.Close()
Set rsTemp = nothing
End If
Next 'For Next Loop End
Else%>
No Changes Detected In Comparison
<%End If%>
<%
Response.Flush
Next
Call objFormComponent.FormEnd()
'-- FROM END ----------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN AFTER PAGE RENDER -----------
Set objPMod = Nothing
Set objCrumbs = Nothing
Set objTabControl = Nothing
'----------------------------------------------
%>