Subversion Repositories DevTools

Rev

Rev 64 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|                                                   |
'|                RequestProductNotes                |
'|                                                   |
'=====================================================
%>
<%
Option explicit
Response.Expires = 0
%>
<!--#include file="common/globals.asp"-->
<!--#include file="common/config.asp"-->
<!--#include file="common/common_subs.asp"-->
<%
'------------ VARIABLE DEFINITION -------------
Dim bgColor
Dim newProdId, ProdId
Dim notesCount
'------------ CONSTANTS DECLARATION -----------
'------------ VARIABLE INIT -------------------
newProdId  = Request("new_prod_id")  ' The PV_ID of the product in the target BOM
ProdId     = Request("prod_id")      ' The PV_ID of the product in the production BOM

bgColor    = NULL
notesCount = 0
'------------ RUN BEFORE PAGE RENDER ----------
'----------------------------------------------
Sub DisplayNoteHistory(ByVal thisBomProduct_PV_ID, ByVal prodBomProduct_PV_ID)

   Dim this_PV_ID

   ' if the product in this BOM looks like it was created after the equivalent product in the production BOM...
   If CLng(thisBomProduct_PV_ID) >= CLng(prodBomProduct_PV_ID) Then

      Call Notes(thisBomProduct_PV_ID)

      this_PV_ID = thisBomProduct_PV_ID
      Do
         this_PV_ID = LastPvId(this_PV_ID)

         If (NOT IsNull(this_PV_ID)) AND CLng(this_PV_ID) >= CLng(prodBomProduct_PV_ID) Then
            Call Notes(this_PV_ID)
         End If

      Loop While (NOT IsNull(this_PV_ID)) AND (CLng(this_PV_ID) > CLng(prodBomProduct_PV_ID))

   ' if the product in this BOM looks like it was created before the equivalent product in the production BOM...
   ElseIf CLng(thisBomProduct_PV_ID) < CLng(prodBomProduct_PV_ID) Then

      Call Notes(prodBomProduct_PV_ID)

      this_PV_ID = prodBomProduct_PV_ID
      Do
         this_PV_ID = LastPvId(this_PV_ID)

         If (NOT IsNull(this_PV_ID)) AND CLng(this_PV_ID) >= CLng(thisBomProduct_PV_ID) Then
            Call Notes(this_PV_ID)
         End If

      Loop While (NOT IsNull(this_PV_ID)) AND (CLng(this_PV_ID) > CLng(thisBomProduct_PV_ID))

   End If

End Sub
'--------------------------------------------------------------------------------------------------------------------------
Function LastPvId(ByVal pvId)
   Dim rsQry
   Set rsQry = OraDatabase.DbCreateDynaset("SELECT LAST_PV_ID FROM PACKAGE_VERSIONS WHERE PV_ID="&pvId , cint(0))

   If IsNull(rsQry("last_pv_id")) OR (rsQry("last_pv_id") = 0) OR (rsQry.RecordCount = 0) Then
      LastPvId = NULL
   Else
      If pvId <> rsQry("last_pv_id") Then
         LastPvId = rsQry("last_pv_id")
      Else
         LastPvId = NULL
      End If
   End If

   rsQry.Close()
   Set rsQry = Nothing

End Function
'--------------------------------------------------------------------------------------------------------------------------
Sub Notes(Pv_Id)
   Dim notes
   Set notes = OraDatabase.DbCreateDynaset("SELECT PN.NOTES, PV.PKG_VERSION FROM PACKAGE_VERSIONS PV, PRODUCT_NOTES PN WHERE PN.PROD_ID = PV.PV_ID AND PN.PROD_ID="&Pv_id , cint(0))
   If notes.RecordCount > 0 Then
      notesCount = notesCount + 1
      %>
      <tr>
         <td <%=bgColor%> wrap valign="top" class="body_row" colspan="4"><%=notes("pkg_version")%> - <%=notes("notes")%></td>
      </tr>
      <%
   End If
   notes.Close()
   Set notes = Nothing
End Sub
'--------------------------------------------------------------------------------------------------------------------------

%>
<table width="100%"  border="0" cellspacing="3" cellpadding="0">
   <%

   If IsNull(newProdId) OR newProdId = "" Then
      ' do nothing
   Else
      ' For some reason, this page can be called with a null ProdId value. To keep things safe for later on, set it
      ' to the same value as the newProdId
      If IsNull(ProdId) OR ProdId = "" Then
         ProdId = newProdId
      End If

      Call DisplayNoteHistory( newProdId, ProdId )
   End If

   If notesCount = 0 Then
      %>
      <tr>
         <td <%=bgColor%> wrap valign="top" class="body_row" colspan="4">Product contains no notes.</td>
     </tr>
      <%
   End If


   %>
</table>



<%
'------------ RUN AFTER PAGE RENDER -----------
'----------------------------------------------
%><!--#include file="common/globals_destructor.asp"-->