Subversion Repositories DevTools

Rev

Rev 6579 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
Option explicit
Response.Expires = 0   ' always load the page, dont store
%>
<%
'=====================================================
'   _wform_change_licence.asp
'
'   This form is designed to work within an iframe pop up
'=====================================================
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/common_dbedit.asp"-->
<!--#include file="common/_popup_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim parPv_id
Dim sMessage, sMessageType
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
parPv_id = QStrPar("pv_id")
sMessage = NULL
sMessageType = 3
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------------------------------------------------------------------
'
' Add a line of text to the System Message
'   eLevel - 1 == Critical, 2==Warning, 3==Note
Sub sMessageAdd(eLevel, text)
    If NOT isNull(sMessage) Then
        sMessage = sMessage & "<br>"
    End If
    sMessage = sMessage & text

    If eLevel < sMessageType  Then
        sMessageType = eLevel
    End If
End Sub

Sub Get_Pkg_Info_With_Licence ( NNpv_id )
   Dim rsTemp, Query_String

   Query_String = _
   " SELECT pkg.pkg_name, pv.pkg_version, NVL(ld.licence, -2) as licence_id"&_
   "   FROM packages pkg, package_versions pv, licencing ld"&_
   "  WHERE pkg.pkg_id = pv.pkg_id"&_
   "    AND pv.pv_id = " & NNpv_id &_
   "    AND ld.pv_id(+) = pv.pv_id" 
 
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))

   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
      pkgInfoHash.Add "pkg_name", (rsTemp.Fields("pkg_name"))
      pkgInfoHash.Add "pkg_version", (rsTemp.Fields("pkg_version"))
      pkgInfoHash.Add "licence_id", (rsTemp.Fields("licence_id"))
   End If

   rsTemp.Close
   Set rsTemp = nothing
End Sub

Function Licence_List ( )
   Licence_List = _
   " SELECT l.licence as licence_id, l.name"&_
    "   FROM licences l "&_
   "  ORDER BY UPPER(l.name)"
End Function

Function Update_Licence ( NNpv_id, NNlicence_id )
   Dim rsTemp, Query_String, sComments
   Dim licenceText

   Update_Licence = FALSE

    If CInt(NNlicence_id) < 0 Then
        Update_Licence = TRUE
        Exit Function
    End If


    ' Check for a change
     If CInt(NNlicence_id) = CInt(pkgInfoHash.Item("licence_id")) Then
        Update_Licence = TRUE
        Exit Function
     End If

   '-- Get licence details. Next text name for logging
   Query_String = _
   " SELECT licence, name"&_
   " FROM licences"&_
   " WHERE licence = "& NNlicence_id

   Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
   licenceText = rsTemp.Fields("name").Value
   If isNUll(licenceText) OR licenceText = "" Then
        sMessageAdd 1, "Licence text cannot be found"
        Exit Function
   End If

   rsTemp.Close
   Set rsTemp = nothing

   Query_String = _
        "MERGE INTO LICENCING ld" &_
        " USING (SELECT "& NNpv_id & " pv_id, "& NNlicence_id & " licence from dual) s" &_
        " ON (ld.pv_id = s.pv_id)" &_
        " WHEN MATCHED THEN UPDATE SET ld.licence = s.licence" &_
        " WHEN NOT MATCHED THEN INSERT (pv_id, licence) VALUES (s.pv_id, s.licence)"

    sComments = "Set: " & licenceText

   '-- Update database to change the owner
   objEH.ErrorRedirect = FALSE
   objEH.TryORA ( OraSession )
   On Error Resume Next

   ' Update the licence
   OraDatabase.ExecuteSQL Query_String
   objEH.CatchORA ( OraSession )

   If objEH.LastOraFailed = FALSE Then
      '-- Log the change
      Call Log_Action ( NNpv_id, "software_licence", sComments )
      Update_Licence = TRUE
   End If
End Function

Function Delete_Licence ( NNpv_id )
   Dim rsTemp, Query_String, sComments
   Delete_Licence = FALSE

    '   Delete any exsiting licence
    '   Check for a change
     If CInt(pkgInfoHash.Item("licence_id")) < 0 Then
        Delete_Licence = TRUE
        Exit Function
     End If

   '-- Update database to change the owner
   objEH.ErrorRedirect = FALSE
   objEH.TryORA ( OraSession )
   On Error Resume Next

   ' Update the licence
   OraDatabase.ExecuteSQL _
      " DELETE from LICENCING ld "&_
      " WHERE ld.pv_id = "& NNpv_id

   objEH.CatchORA ( OraSession )

   If objEH.LastOraFailed = FALSE Then
      '-- Log the change
      Call Log_Action ( NNpv_id, "software_licence", "Deleted Licence" )
      Delete_Licence = TRUE
   End If
End Function

%>
<%
Call Get_Pkg_Info_With_Licence ( parPv_id )

'Process submition
If CBool(QStrPar("action")) AND  objAccessControl.UserLogedIn Then
   If Request("btn") = "Delete" Then
        If Delete_Licence (parPv_id) Then
           Call ReloadParentWindow
           Call CloseWindow
        End If
   Else
        If Update_Licence ( parPv_id, Request("licence_id") ) Then
           Call ReloadParentWindow
           Call CloseWindow
        End If
    End If
End If
%>
<%
If objAccessControl.UserId = "" Then
    sMessageAdd 1, "No longer logged in"
End If
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
<link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
<script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
<form name="chowner" method="post" action="<%=scriptName%>" class="form_tight">
  <table border="0" cellspacing="0" cellpadding="2" width="100%">
    <tr>
      <td valign="top" nowrap colspan="3" class="wform_ttl" background="images/bg_form_lightgray.gif">
         <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <%Call Messenger ( sMessage , sMessageType, "100%" )%>
         <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <!--#include file="messages/_msg_inline.asp"-->
        <table width="100%" border="0" cellspacing="1" cellpadding="2">
          <tr>
              <!-- Package Name and Version -->
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Package</td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt">
              <%=pkgInfoHash.Item ("pkg_name") &" "& pkgInfoHash.Item ("pkg_version")%></td>
          </tr>
          <tr>
              <!-- Usage in other versions -->
            <%
                Dim otherUse
                Set otherUse = OraDatabase.DbCreateDynaset( _
                        "SELECT ld.NAME, count(*) as count" &_
                        " FROM licencing l," &_
                        "  LICENCES ld" &_
                        " WHERE l.pv_id IN" &_
                        "  (SELECT pv_id FROM package_versions WHERE pkg_id IN (SELECT pkg_id FROM package_versions WHERE pv_id="&parPv_id&" )" &_
                        "  )" &_
                        " AND l.LICENCE = ld.LICENCE" &_
                        " group by ld.NAME" &_
                        " ORDER BY UPPER(ld.NAME)" _ 
                    , cint(0))
            %>
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Usage</td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif" class="form_txt">
                <%If otherUse.RecordCount > 0 Then%>
                <table width="100%" border="0" cellspacing="1" cellpadding="2" >
                    <tr class="form_field">
                    <td>Licence</td>
                    <td>Count</td>
                    </tr>
                    <%
                     While ((NOT otherUse.BOF) AND (NOT otherUse.EOF))
                        %><tr class="form_item">
                            <td><%=otherUse("name")%></td>
                            <td><%=otherUse("count")%></td>
                         </tr><%
                        otherUse.MoveNext
                     WEnd
                     otherUse.Close
                     set otherUse = nothing
                    %>
                </table>
                <%End If%>
            </td>
          </tr>
          <tr>
              <!-- Package Licence -->
            <td width="1%" nowrap class="form_field" background="images/bg_form_lightbluedark.gif">Licence</td>
            <td nowrap width="100%" background="images/bg_form_lightbluedark.gif">
         <select name="licence_id" class="form_item">
             <option value=-2>None Selected</option>
<%
         Dim rsLicences
         Set rsLicences = OraDatabase.DbCreateDynaset( Licence_List( ), cint(0))
         While ((NOT rsLicences.BOF) AND (NOT rsLicences.EOF))%>
                <option <%If CInt(rsLicences("licence_id")) = CInt(pkgInfoHash.Item("licence_id")) Then%>selected<%End If%> value="<%=rsLicences.Fields("licence_id")%>"><%=rsLicences.Fields("name")%></option>
<%            rsLicences.MoveNext
         WEnd
         rsLicences.Close
         set rsLicences = nothing
         %>
         </select>
            <input type="hidden" name="pv_id" value="<%=parPv_id%>">
         <input type="hidden" name="rtag_id" value="<%=parRtag_id%>">
         <input type="hidden" name="action" value="true">
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td align="right">
        <input type="submit" name="btn" value="Update" class="form_btn_comp">
        <input type="submit" name="btn" value="Delete" class="form_btn_comp">
        <input type="reset" name="btn" value="Cancel" class="form_btn_comp" onclick="parent.closeIFrame();">
      </td>
    </tr>
  </table>
</form>
</body>
</html>
<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->