Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|                                                   |
'|                                wAddProdNew                                    |
'|                                                   |
'=====================================================
%>
<%
Option explicit
Response.Expires = 0
%>
<!--#include file="common/globals.asp"-->
<!--#include file="common/config.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_popup_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_general.asp"-->
<%
'------------ VARIABLE DEFINITION -------------
Dim rsQry
Dim objFormCollector
Dim sMessage
'------------ CONSTANTS DECLARATION -----------
Const LIMG_PRODUCT = "<img src='icons/i_product.gif' width='19' height='19' hspace='2' align='absmiddle'>"
Const LIMG_PRODUCT_UNPACKAGED = "<img src='icons/i_product_unpackaged.gif' width='19' height='19' hspace='2' align='absmiddle' title='Product is unofficial'>"
'------------ VARIABLE INIT -------------------
sMessage = NULL
parBom_id = Request("bom_id")
parOs_id = Request("os_id")
Set objFormCollector = CreateObject("Scripting.Dictionary")
'------------ CONDITIONS ----------------------
'----------------------------------------------
%>
<%
'--------------------------------------------------------------------------------------------------------------------------
Function HasSimilarNames ( sProdName )
        Dim rsQry
        
        HasSimilarNames = FALSE
        
        OraDatabase.Parameters.Add "PROD_NAME", sProdName, ORAPARM_INPUT, ORATYPE_VARCHAR2
        
        Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("SimilarProductNames.sql"), ORADYN_DEFAULT )
        If rsQry.RecordCount > 0 Then
                HasSimilarNames = TRUE
        End If
        
        OraDatabase.Parameters.Remove "PROD_NAME"
        
        rsQry.Close
        Set rsQry = Nothing
End Function
'--------------------------------------------------------------------------------------------------------------------------
Sub AddProdToOs ()
        On Error Resume Next
        
        OraDatabase.Parameters.Add "PROD_NAME",         Request("prod_name"),           ORAPARM_INPUT, ORATYPE_VARCHAR2
        OraDatabase.Parameters.Add "PROD_VERSION",      Request("prod_version"),        ORAPARM_INPUT, ORATYPE_VARCHAR2
        OraDatabase.Parameters.Add "OS_ID",             Request("os_id"),                       ORAPARM_INPUT, ORATYPE_NUMBER 
        OraDatabase.Parameters.Add "USER_ID",           objAccessControl.UserId,        ORAPARM_INPUT, ORATYPE_NUMBER 
        
        objEH.TryORA ( OraSession )
        
        OraDatabase.ExecuteSQL _
        "DECLARE "&_
        "   outProdId NUMBER;"&_
        "BEGIN   "&_
        "   pk_Product.New_Product ( :PROD_NAME, :PROD_VERSION, :USER_ID, outProdId );"&_
        "   pk_Product.Add_Product ( outProdId, :OS_ID, :USER_ID );"&_
        "END;"
        
        objEH.CatchORA ( OraSession )
        
        
        OraDatabase.Parameters.Remove "PROD_NAME"
        OraDatabase.Parameters.Remove "PROD_VERSION"
        OraDatabase.Parameters.Remove "OS_ID"
        OraDatabase.Parameters.Remove "USER_ID"
End Sub
'--------------------------------------------------------------------------------------------------------------------------
Sub AddProdToBaseEnv ()
        On Error Resume Next
        
        OraDatabase.Parameters.Add "PROD_NAME",         Request("prod_name"),           ORAPARM_INPUT, ORATYPE_VARCHAR2
        OraDatabase.Parameters.Add "PROD_VERSION",      Request("prod_version"),        ORAPARM_INPUT, ORATYPE_VARCHAR2
        OraDatabase.Parameters.Add "BASE_ENV_ID",       Request("base_env_id"),                         ORAPARM_INPUT, ORATYPE_NUMBER 
        OraDatabase.Parameters.Add "OS_ID",             Request("os_id"),                       ORAPARM_INPUT, ORATYPE_NUMBER 
        OraDatabase.Parameters.Add "USER_ID",           objAccessControl.UserId,        ORAPARM_INPUT, ORATYPE_NUMBER 
        
        objEH.TryORA ( OraSession )
        
        OraDatabase.ExecuteSQL _
        "DECLARE "&_
        "   outProdId NUMBER;"&_
        "BEGIN   "&_
        "   pk_Product.New_Product ( :PROD_NAME, :PROD_VERSION, :USER_ID, outProdId );"&_
        "   pk_Base_Env.Add_Product ( outProdId, :BASE_ENV_ID, :OS_ID, :USER_ID );"&_
        "END;"
        
        objEH.CatchORA ( OraSession )
        
        
        OraDatabase.Parameters.Remove "PROD_NAME"
        OraDatabase.Parameters.Remove "PROD_VERSION"
        OraDatabase.Parameters.Remove "BASE_ENV_ID"
        OraDatabase.Parameters.Remove "OS_ID"
        OraDatabase.Parameters.Remove "USER_ID"
End Sub
'--------------------------------------------------------------------------------------------------------------------------
Sub AddProdNew ()
        
        If Request("skip_similar_names") = "" Then
                If HasSimilarNames( Request("prod_name") ) Then
                        Call OpenInWindow ( "wAddProdSimilarNames.asp?prod_name="& Request("prod_name") &"&prod_version="& Request("prod_version") &"&"& objPMod.ComposeURL() )
                End If
        End If
        
        '-- Now add product
        If Request("base_env_id") = "" Then
                '-- Add to OS
                Call AddProdToOs()
                
        Else
                '-- Add to Base Env
                Call AddProdToBaseEnv()
                
        End If
        
        
        
End Sub

'--------------------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
objPMod.PersistInQryString ( Array("base_env_id") )

' --- Get Form details from DB ---

' --- Load Validation Rules ---
Call objForm.LoadValidationRules ( Array("prod_name","prod_version"), OraDatabase )             ' Load Validation Rules

' --- Enter Form Validation Rule Changes here... ----
'If Request("base_env_id") <> "" Then
        ' /* There is a problem if you want to add 3rd party product in OS and the Product Name is not to ERG standards.
        '    I will allow entry of any kind of names and versions for now. */
        objForm.UpdateRules ("id='prod_name' RegExp=''")
        objForm.UpdateRules ("id='prod_version' RegExp=''")
'End If
'----------------------------------------------------

If CBool(Request("action")) Then
        If objForm.IsValidOnPostBack Then
                '-- Add Product
                Call AddProdNew()
                
                If objEH.Finally Then
                        Call OpenInParentWindow ( Request("rfile") &"?ADDED=OK"& objPMod.ComposeURLWithout("rfile") )
                        Call CloseWindow()
                End If
        End If
End If

'----------------------------------------------
%>
<html>
<head>
<title>Deployment Manager</title>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="scripts/deployment_manager.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="scripts/common.js"></script>
</head>

<body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" onLoad="self.focus();FormName.prod_name.focus();">
<table width="100%"  border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td bgcolor="#FFFFFF" class="body_txt"><span class="body_h1"><img src="icons/i_linkarrow_black.gif" width="11" height="11" align="absmiddle">&nbsp;Add Product </span> <br>
    Enter Product Name and Version.
      </td>
  </tr>
<%
'-- FROM START --------------------------------------------------------------------------------------------------------------
objFormComponent.FormName = "FormName"
objFormComponent.Action = SCRIPT_NAME
objFormComponent.OnSubmit = "ShowProgress();"
Call objFormComponent.FormStart()
%>  
  <tr>
    <td background="images/bg_login.gif"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><%=ProgressBar()%></td>
        <td align="right"><input name="btn" type="reset" class="form_btn" value="&laquo; Back" onClick="history.back();">
        &nbsp;&nbsp;
        <input name="btn" type="submit" class="form_btn" value="Add">
          <input name="btn" type="reset" class="form_btn" value="Cancel" onClick="self.close();"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
<!-- NEW PRODUCT ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->         
        <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->    
        <!--#include file="messages/_msg_inline.asp"-->
    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
        <table width="100%"  border="0" cellspacing="2" cellpadding="0">
      <tr>
        <td nowrap class="form_iname" valign="top">Product Name </td>
        <td valign="top"><%=objFormComponent.TextBox ( "prod_name", objForm.GetValue( "prod_name", objFormCollector.Item("prod_name") ), "size='60' class='form_ivalue'" )%></td>
                <td valign="top"><%=objForm.Validate ("prod_name")%></td>
      </tr>
      <tr>
        <td nowrap class="form_iname" valign="top">Product Version</td>
        <td valign="top"><%=objFormComponent.TextBox ( "prod_version", objForm.GetValue( "prod_version", objFormCollector.Item("prod_version") ), "size='60' class='form_ivalue'" )%></td>
                <td valign="top"><%=objForm.Validate ("prod_version")%></td>
      </tr>
      <tr>
        <td width="10%" class="form_iname">&nbsp;</td>
        <td width="1%">&nbsp;</td>
                <td width="90%" class="val_err"></td>
      </tr>
    </table>
        <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
    </td>
  </tr>
  <%=objPMod.ComposeHiddenTags()%>
  <input type="hidden" name="action" value="true">
<%
Call objFormComponent.FormEnd()
'-- FROM END ----------------------------------------------------------------------------------------------------------------
%>
</table>
</body>
</html>
<%
'------------ RUN AFTER PAGE RENDER -----------
Set objFormCollector = Nothing
'----------------------------------------------
%><!--#include file="common/globals_destructor.asp"-->