Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'                   Update Label
'               --- PROCESS FORM ---
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#include file="../common/conf.asp"-->
<!--#include file="../common/globals.asp"-->
<!--#include file="../common/formating.asp"-->
<!--#include file="../common/qstr.asp"-->
<!--#include file="../common/common_subs.asp"-->
<!--#include file="../common/common_dbedit.asp"-->
<%

Dim pageName, noteContents
pageName = split(Request("redirectionDestination"), "?")(0)
noteContents = Request("description")

' Page Access Condition
If NOT objAccessControl.UserLogedIn Then
   Response.Redirect( "../message.asp?msg=401-1")
End If
%>
<%
'------------ Variable Definition -------------
DIM parFRrtag_id, parPv_id
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parFRrtag_id = Request("rtag_id")
parPv_id = Request("pv_id")
'----------------------------------------------

'------------------------------------------------------------------------------------------------------------------
Function Get_Package_Note ()
   Get_Package_Note = _
   "   SELECT description, last_user, last_date "&_
   "     FROM note_manager note"&_
   "    WHERE note.nid = :NOTE_ID"
End Function
'------------------------------------------------------------------------------------------------------------------

%>
<%
Sub Update_Note ( NNpv_id, NNrtag_id, description, last_user)
   Dim last_date, rsNote, action_type

   last_date = ORA_SYSDATETIME ()

   OraDatabase.Parameters.Add "NOTE_ID",      NNpv_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
   OraDatabase.Parameters.Add "LAST_USER",    last_user, ORAPARM_INPUT, ORATYPE_VARCHAR2
   OraDatabase.Parameters.Add "DESCRIPTION",  description, ORAPARM_INPUT, ORATYPE_VARCHAR2
   OraDatabase.Parameters.Add "USER_ID",      objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_VARCHAR2
   OraDatabase.Parameters.Add "PV_ID",        NNpv_id, ORAPARM_INPUT, ORATYPE_VARCHAR2

   Set rsNote = OraDatabase.DbCreateDynaset( Get_Package_Note (), cint(0))
   If rsNote.RecordCount = 1 Then
      OraDatabase.Parameters.Add "ACTION_TYPE_NAME",    "note_edit", ORAPARM_INPUT, ORATYPE_VARCHAR2
   Else
      OraDatabase.Parameters.Add "ACTION_TYPE_NAME",    "note_add", ORAPARM_INPUT, ORATYPE_VARCHAR2
   End If
   rsNote.close
   set   rsNote = nothing

   On Error Resume Next

   ' Delete the existing note
   objEH.TryORA ( OraSession )
   OraDatabase.ExecuteSQL _
   " DELETE FROM note_manager"&_
   " WHERE nid=:NOTE_ID "
   objEH.CatchORA ( OraSession )

   If objEH.LastOraFailed = FALSE Then
      If not (description = "") or not (description = null) Then
         ' Now add the updated note back in, and log the action
         objEH.TryORA ( OraSession )
         OraDatabase.ExecuteSQL _
         " INSERT INTO note_manager"&_
         " values (:NOTE_ID, :LAST_USER, "& last_date &", :DESCRIPTION)"
         objEH.CatchORA ( OraSession )
         If objEH.LastOraFailed = FALSE Then
            objEH.TryORA ( OraSession )
            OraDatabase.ExecuteSQL _
            "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :DESCRIPTION );  END;"
            objEH.CatchORA ( OraSession )
         End If
      Else
         ' Just log the note removal action
         OraDatabase.Parameters.remove "ACTION_TYPE_NAME"
         OraDatabase.Parameters.Add "ACTION_TYPE_NAME",  "note_remove", ORAPARM_INPUT, ORATYPE_VARCHAR2

         objEH.TryORA ( OraSession )
         OraDatabase.ExecuteSQL _
         "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :DESCRIPTION );  END;"
         objEH.CatchORA ( OraSession )
      End If
   End If

   OraDatabase.Parameters.remove "NOTE_ID"
   OraDatabase.Parameters.remove "LAST_USER"
   OraDatabase.Parameters.remove "DESCRIPTION"
   OraDatabase.Parameters.remove "USER_ID"
   OraDatabase.Parameters.remove "ACTION_TYPE_NAME"
   OraDatabase.Parameters.remove "PV_ID"

End Sub

%>
<%
'-----------------------  MAIN LINE  ---------------------------
'--- Process submition ---
call Update_Note ( parPv_id, parFRrtag_id, notecontents, Request("last_user") )
If Request("description") = "" Then
   Response.Redirect("../"& Request("redirectionDestination"))
Else
   Response.Redirect("../"& Request("redirectionDestination") &"&saved=true")
End If

%>