<%
'
'    Filename: mld_workflowrecord1.asp
'    Generated with CodeCharge 2.0.5
'    ASP 2.0 & Templates.ccp build 11/30/2001
'

'-------------------------------
' 
' mld_workflowrecord1 CustomIncludes Event begin
%>
<!-- #INCLUDE FILE="Common.asp" -->
<%
' mld_workflowrecord1 CustomIncludes Event end


'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "mld_workflowrecord1.asp"
sTemplateFileName = "mld_workflowrecord1.html"
'===============================


'===============================
' mld_workflowrecord1 PageSecurity begin
' mld_workflowrecord1 PageSecurity end
'===============================

'===============================
' mld_workflowrecord1 Open Event begin
' mld_workflowrecord1 Open Event end
'===============================

'===============================
' mld_workflowrecord1 OpenAnyPage Event begin
' mld_workflowrecord1 OpenAnyPage Event end
'===============================

'===============================
'Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================

' mld_workflowrecord1 Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sWorkflowRecordErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "WorkflowRecord"
    WorkflowRecordAction(sAction)
end select
'===============================

'===============================
' Display page
'-------------------------------
' Load HTML template for this page
'-------------------------------
LoadTemplate sAppPath & sTemplateFileName, "main"
'-------------------------------
' Load HTML template of Header and Footer
'-------------------------------
'-------------------------------
SetVar "FileName", sFileName


'-------------------------------
' Step through each form
'-------------------------------
WorkflowRecord_Show
Afgemeld_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' mld_workflowrecord1 Show end

'-------------------------------
' Destroy all object variables
'-------------------------------

' mld_workflowrecord1 Close Event begin
' mld_workflowrecord1 Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub WorkflowRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKMLD_WORKFLOWSTEP_KEY : pPKMLD_WORKFLOWSTEP_KEY = ""
  Dim fldMLD_WORKFLOWSTEP_START_KEY : fldMLD_WORKFLOWSTEP_START_KEY = ""
  Dim fldMLD_STDMELDING_KEY : fldMLD_STDMELDING_KEY = ""
  Dim fldMLD_WORKFLOWSTEP_OMSCHRIJVING : fldMLD_WORKFLOWSTEP_OMSCHRIJVING = ""
'-------------------------------

'-------------------------------
' WorkflowRecord Action begin
'-------------------------------
  sActionFileName = "mld_workflowstepgrid.asp"
  sParams = sParams & "F_MLD_WORKFLOWSTEP_KEY=" & ToURL(GetParam("Trn_F_MLD_WORKFLOWSTEP_KEY"))

'-------------------------------
' CANCEL action
'-------------------------------
  if sAction = "cancel" then

'-------------------------------
' WorkflowRecord BeforeCancel Event begin
' WorkflowRecord BeforeCancel Event end
'-------------------------------
    cn.Close
    Set cn = Nothing
    response.redirect sActionFileName & sParams
  end if
'-------------------------------

'-------------------------------
' Build WHERE statement
'-------------------------------
  if sAction = "update" or sAction = "delete" then
    pPKMLD_WORKFLOWSTEP_KEY = GetParam("PK_MLD_WORKFLOWSTEP_KEY")
    if IsEmpty(pPKMLD_WORKFLOWSTEP_KEY) then exit sub
    sWhere = "MLD_WORKFLOWSTEP_KEY=" & ToSQL(pPKMLD_WORKFLOWSTEP_KEY, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldMLD_WORKFLOWSTEP_START_KEY = GetParam("MLD_WORKFLOWSTEP_START_KEY")
  fldMLD_STDMELDING_KEY = GetParam("MLD_STDMELDING_KEY")
  fldMLD_WORKFLOWSTEP_OMSCHRIJVING = GetParam("MLD_WORKFLOWSTEP_OMSCHRIJVING")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldMLD_STDMELDING_KEY) then
      sWorkflowRecordErr = sWorkflowRecordErr & "The value in field Melding is required.<br>"
    end if
    if not isNumeric(fldMLD_WORKFLOWSTEP_START_KEY) then
      sWorkflowRecordErr = sWorkflowRecordErr & "The value in field MLD_WORKFLOWSTEP_START_KEY is incorrect.<br>"
    end if
    if not isNumeric(fldMLD_STDMELDING_KEY) then
      sWorkflowRecordErr = sWorkflowRecordErr & "The value in field Melding is incorrect.<br>"
    end if
'-------------------------------
' WorkflowRecord Check Event begin
' WorkflowRecord Check Event end
'-------------------------------
    If len(sWorkflowRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' WorkflowRecord Insert Event begin
' WorkflowRecord Insert Event end
'-------------------------------
      sSQL = "insert into MLD_WORKFLOWSTEP (" & _
          "MLD_WORKFLOWSTEP_START_KEY," & _
          "MLD_STDMELDING_KEY," & _
          "MLD_WORKFLOWSTEP_OMSCHRIJVING)" & _
          " values (" & _
          ToSQL(fldMLD_WORKFLOWSTEP_START_KEY, "Number") & "," & _
          ToSQL(fldMLD_STDMELDING_KEY, "Number") & "," & _
          ToSQL(fldMLD_WORKFLOWSTEP_OMSCHRIJVING, "Text") & _
          ")"
    case "update"
'-------------------------------
' WorkflowRecord Update Event begin
' WorkflowRecord Update Event end
'-------------------------------
      sSQL = "update MLD_WORKFLOWSTEP set " & _
        "MLD_WORKFLOWSTEP_START_KEY=" & ToSQL(fldMLD_WORKFLOWSTEP_START_KEY, "Number") & _
        ",MLD_STDMELDING_KEY=" & ToSQL(fldMLD_STDMELDING_KEY, "Number") & _
        ",MLD_WORKFLOWSTEP_OMSCHRIJVING=" & ToSQL(fldMLD_WORKFLOWSTEP_OMSCHRIJVING, "Text")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' WorkflowRecord Delete Event begin
' WorkflowRecord Delete Event end
'-------------------------------
      sSQL = "delete from MLD_WORKFLOWSTEP where " & sWhere
  end select
'-------------------------------
'-------------------------------
' WorkflowRecord BeforeExecute Event begin
' WorkflowRecord BeforeExecute Event end
'-------------------------------

'-------------------------------
' Execute SQL statement
'-------------------------------
if len(sWorkflowRecordErr) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  sWorkflowRecordErr = ProcessError
  on error goto 0
  if len(sWorkflowRecordErr) > 0 then Exit Sub
  cn.Close
  Set cn = Nothing
  response.redirect sActionFileName & sParams
'-------------------------------
' WorkflowRecord Action end
'-------------------------------
end sub
'===============================

'===============================
' Display Record Form
'-------------------------------
Sub WorkflowRecord_Show()
'-------------------------------
' WorkflowRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details workflowstap"
  Dim bPK : bPK = True
  Dim sMLD_STDMELDING_KEYDisplayValue: sMLD_STDMELDING_KEYDisplayValue = ""

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sWorkflowRecordErr = "" then
    SetVar "Trn_F_MLD_WORKFLOWSTEP_KEY", GetParam("F_MLD_WORKFLOWSTEP_KEY")
    pMLD_WORKFLOWSTEP_KEY = GetParam("MLD_WORKFLOWSTEP_KEY")
    SetVar "WorkflowRecordError", ""
  else
    fldMLD_WORKFLOWSTEP_START_KEY = GetParam("MLD_WORKFLOWSTEP_START_KEY")
    fldMLD_STDMELDING_KEY = GetParam("MLD_STDMELDING_KEY")
    fldMLD_WORKFLOWSTEP_OMSCHRIJVING = GetParam("MLD_WORKFLOWSTEP_OMSCHRIJVING")
    SetVar "Trn_F_MLD_WORKFLOWSTEP_KEY", GetParam("Trn_F_MLD_WORKFLOWSTEP_KEY")
    pMLD_WORKFLOWSTEP_KEY = GetParam("PK_MLD_WORKFLOWSTEP_KEY")
    SetVar "sWorkflowRecordErr", sWorkflowRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "WorkflowRecordError", False
  end if
'-------------------------------

'-------------------------------
' Load all form fields

'-------------------------------

'-------------------------------
' Build WHERE statement

  if IsEmpty(pMLD_WORKFLOWSTEP_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_WORKFLOWSTEP_KEY=" & ToSQL(pMLD_WORKFLOWSTEP_KEY, "Number")
  SetVar "PK_MLD_WORKFLOWSTEP_KEY", pMLD_WORKFLOWSTEP_KEY
'-------------------------------
'-------------------------------
' WorkflowRecord Open Event begin
' WorkflowRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from MLD_WORKFLOWSTEP where " & sWhere
  openrs rs, sSQL
  bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "WorkflowRecord") and not rs.eof)
'-------------------------------

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldMLD_WORKFLOWSTEP_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_KEY")
    fldMLD_WORKFLOWSTEP_START_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_START_KEY")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sWorkflowRecordErr = "" then
      fldMLD_STDMELDING_KEY = GetValue(rs, "MLD_STDMELDING_KEY")
      fldMLD_WORKFLOWSTEP_OMSCHRIJVING = GetValue(rs, "MLD_WORKFLOWSTEP_OMSCHRIJVING")
    end if
    SetVar "WorkflowRecordInsert", ""
    Parse "WorkflowRecordEdit", False
'-------------------------------
' WorkflowRecord ShowEdit Event begin
' WorkflowRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "WorkflowRecordEdit", ""
    Parse "WorkflowRecordInsert", False
'-------------------------------
' WorkflowRecord ShowInsert Event begin
' WorkflowRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "WorkflowRecordCancel", false
'-------------------------------
' WorkflowRecord Show Event begin
' WorkflowRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_WORKFLOWSTEP_KEY", ToHTML(fldMLD_WORKFLOWSTEP_KEY)
      SetVar "MLD_WORKFLOWSTEP_START_KEY", ToHTML(fldMLD_WORKFLOWSTEP_START_KEY)
      SetVar "WorkflowRecordLBMLD_STDMELDING_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sMLD_STDMELDING_KEYDisplayValue
      Parse "WorkflowRecordLBMLD_STDMELDING_KEY", True
      openrs rsMLD_STDMELDING_KEY, "select s.mld_stdmelding_key, sr.ins_srtdiscipline_prefix || '-' || d.ins_discipline_omschrijving || ' / ' || s.mld_stdmelding_omschrijving from mld_discipline d, mld_stdmelding s,INS_SRTDISCIPLINE sr where  d.ins_discipline_verwijder is null and        s.mld_ins_discipline_key = d.ins_discipline_key and d.ins_srtdiscipline_key = sr.ins_srtdiscipline_key and s.mld_stdmelding_key not in (select mld_stdmelding_key from mld_workflowstep where not mld_stdmelding_key="&ToSQL(fldMLD_STDMELDING_KEY,"Number")&" ) order by 2"
      while not rsMLD_STDMELDING_KEY.EOF
        SetVar "ID", GetValue(rsMLD_STDMELDING_KEY, 0) : SetVar "Value", GetValue(rsMLD_STDMELDING_KEY, 1)
        if cstr(GetValue(rsMLD_STDMELDING_KEY, 0)) = cstr(fldMLD_STDMELDING_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "WorkflowRecordLBMLD_STDMELDING_KEY", True
        rsMLD_STDMELDING_KEY.MoveNext
      wend
      set rsMLD_STDMELDING_KEY = nothing
    
      SetVar "MLD_WORKFLOWSTEP_OMSCHRIJVING", ToHTML(fldMLD_WORKFLOWSTEP_OMSCHRIJVING)
  Parse "FormWorkflowRecord", False

'-------------------------------
' WorkflowRecord Close Event begin
' WorkflowRecord Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' WorkflowRecord Show end
'-------------------------------
End Sub
'===============================

'===============================
' Display Grid Form
'-------------------------------
Sub Afgemeld_Show()
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim rs
  Dim sWhere : sWhere = ""
  Dim sOrder : sOrder = ""
  Dim sSQL : sSQL = ""
  Dim sFormTitle: sFormTitle = "Volgende bij afgemeld"
  Dim HasParam : HasParam = false
  Dim iSort : iSort = ""
  Dim iSorted : iSorted = ""
  Dim sDirection : sDirection = ""
  Dim sSortParams : sSortParams = ""
  Dim iRecordsPerPage : iRecordsPerPage = 25
  Dim iCounter : iCounter = 0
  Dim iPage : iPage = 0
  Dim bEof : bEof = False
  Dim iTmpI : iTmpI = 0
  Dim iTmpJ : iTmpJ = 0
  Dim sCountSQL : sCountSQL = ""
  Dim sActionFileName : sActionFileName = "mld_workflowrecord2.asp"

  SetVar "TransitParams", "MLD_WORKFLOWSTEP_KEY=" & ToURL(GetParam("MLD_WORKFLOWSTEP_KEY")) & "&"
  SetVar "FormParams", "MLD_WORKFLOWSTEP_KEY=" & ToURL(GetParam("MLD_WORKFLOWSTEP_KEY")) & "&"

'-------------------------------
' Build WHERE statement
'-------------------------------
  pMLD_WORKFLOWSTEP_KEY = GetParam("MLD_WORKFLOWSTEP_KEY")
  if IsNumeric(pMLD_WORKFLOWSTEP_KEY) and not isEmpty(pMLD_WORKFLOWSTEP_KEY) then pMLD_WORKFLOWSTEP_KEY = ToSQL(pMLD_WORKFLOWSTEP_KEY, "Number") else pMLD_WORKFLOWSTEP_KEY = Empty
  if not isEmpty(pMLD_WORKFLOWSTEP_KEY) then
    HasParam = true
    sWhere = sWhere & "MLD_WORKFLOWSTEP_KEY=" & pMLD_WORKFLOWSTEP_KEY
  end if


  if HasParam then
    sWhere = " AND (" & sWhere & ")"
  end if
  
'-------------------------------
' Build ORDER BY statement
'-------------------------------
  iSort = GetParam("FormAfgemeld_Sorting")
  iSorted = GetParam("FormAfgemeld_Sorted")
  sDirection = ""
  if IsEmpty(iSort) then
    SetVar "Form_Sorting", ""
  else
    if iSort = iSorted then 
      SetVar "Form_Sorting", ""
      sDirection = " DESC"
      sSortParams = "FormAfgemeld_Sorting=" & iSort & "&FormAfgemeld_Sorted=" & iSort & "&"
    else
      SetVar "Form_Sorting", iSort
      sDirection = " ASC"
      sSortParams = "FormAfgemeld_Sorting=" & iSort & "&FormAfgemeld_Sorted=" & "&"
    end if
  end if

'-------------------------------
' Build base SQL statement
'-------------------------------
  sSQL = "SELECT M.MLD_WORKFLOWRULE_KEY,     M.MLD_WORKFLOWRULE_OMSCHRIJVING,     M.MLD_WORKFLOWRULE_RESULT,     M.MLD_WORKFLOWRULE_CONDITION,     M.MLD_WORKFLOWSTEP_KEY,     M.MLD_WORKFLOWSTEP_NEXT_KEY,     w.mld_workflowstep_omschrijving ||' ('||d.ins_discipline_omschrijving || ' / '|| s.mld_stdmelding_omschrijving ||')' as step_omschrijving FROM MLD_WORKFLOWRULE M , mld_workflowstep w ,mld_discipline d ,mld_stdmelding s WHERE M.MLD_WORKFLOWRULE_RESULT = 1 and s.mld_ins_discipline_key = d.ins_discipline_key  and s.mld_stdmelding_key=w.mld_stdmelding_key and w.mld_workflowstep_key = M.MLD_WORKFLOWSTEP_next_KEY"
  sOrder = ""
'-------------------------------

'-------------------------------
' Afgemeld Open Event begin
sTransitParams="MLD_WORKFLOWSTEP_FROM_KEY="&ToURL(getParam("MLD_WORKFLOWSTEP_KEY"))&_
               "&MLD_WORKFLOWRULE_RESULT=1"&_
               "&MLD_WORKFLOWSTEP_START_KEY="&ToURL(getParam("MLD_WORKFLOWSTEP_KEY"))&_
               "&F_MLD_WORKFLOWSTEP_KEY="&ToURL(getParam("F_MLD_WORKFLOWSTEP_KEY"))
setvar "TransitParams",sTransitParams

HasParam = false
sWhere = ""
if getParam("MLD_WORKFLOWSTEP_KEY") <> "" then
  sWhere = sWhere & " and M.mld_workflowstep_key = "&ToSQL(getParam("MLD_WORKFLOWSTEP_KEY"), "Number")
elseif GetParam("PK_MLD_WORKFLOWSTEP_KEY") <> "" then
  sWhere = sWhere & " and M.mld_workflowstep_key = "&ToSQL(GetParam("PK_MLD_WORKFLOWSTEP_KEY"), "Number")
else
  sWhere = sWhere & " and 1=0"
end if

if iSort = 1 then sOrder = " order by M.MLD_WORKFLOWRULE_KEY" & sDirection
if iSort = 2 then sOrder = " order by M.MLD_WORKFLOWRULE_OMSCHRIJVING" & sDirection
if iSort = 3 then sOrder = " order by step_omschrijving" & sDirection
' Afgemeld Open Event end
'-------------------------------

'-------------------------------
' Assemble full SQL statement
'-------------------------------
  sSQL = sSQL & sWhere & sOrder
  if sCountSQL = "" then
    iTmpI = instr(lcase(sSQL), "select")
    iTmpJ = instr(lcase(sSQL), "from") - 1
    sCountSQL = replace(sSQL, mid(sSQL, iTmpI + 6, iTmpJ - 6), " count(*) ")
    iTmpI = instr(lcase(sCountSQl), "order by")
    if iTmpI > 1 then sCountSQL = left(sCountSQL, iTmpI - 1)
  end if
'-------------------------------

SetVar "FormTitle", sFormTitle

'-------------------------------
' Process the link to the record page
'-------------------------------
  SetVar "FormAction", sActionFileName
'-------------------------------

'-------------------------------
' Process the parameters for sorting
'-------------------------------
  SetVar "SortParams", sSortParams
'-------------------------------

'-------------------------------
' Open the recordset
'-------------------------------
  openrs rs, sSQL
'-------------------------------

'-------------------------------
' Process empty recordset
'-------------------------------
  if rs.eof then
    set rs = nothing
    SetVar "DListAfgemeld", ""
    Parse "AfgemeldNoRecords", False
    SetVar "AfgemeldNavigator", ""
    Parse "FormAfgemeld", False
    exit sub
  end if
'-------------------------------

'-------------------------------
' Initialize page counter and records per page
'-------------------------------
  iRecordsPerPage = 25
  iCounter = 0
'-------------------------------

'-------------------------------
' Process page scroller
'-------------------------------
  iPage = GetParam("FormAfgemeld_Page")
  openrs rsCount, sCountSQL
  dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage
  iPageCount = int(dResult)
  if iPageCount < dResult then iPageCount = iPageCount + 1
  SetVar "AfgemeldPageCount", iPageCount
  set rsCount = nothing
  if IsEmpty(iPage) then
    iPage = 1
  else
    if iPage = "last" then iPage = iPageCount
  end if
  while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage
    rs.movenext
    iCounter = iCounter + 1
  wend
  iCounter = 0
'-------------------------------

'-------------------------------
' Display grid based on recordset
'-------------------------------
  while not rs.EOF  and iCounter < iRecordsPerPage
'-------------------------------
' Create field variables based on database fields
'-------------------------------
    fldMLD_WORKFLOWRULE_CONDITION = GetValue(rs, "MLD_WORKFLOWRULE_CONDITION")
    fldMLD_WORKFLOWRULE_KEY_URLLink = "mld_workflowrecord3.asp"
    fldMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWRULE_KEY = GetValue(rs, "MLD_WORKFLOWRULE_KEY")
    fldMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWSTEP_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_KEY")
    fldMLD_WORKFLOWRULE_KEY_F_MLD_WORKFLOWRULE_KEY = GetValue(rs, "MLD_WORKFLOWRULE_KEY")
    fldMLD_WORKFLOWRULE_KEY = GetValue(rs, "MLD_WORKFLOWRULE_KEY")
    fldMLD_WORKFLOWRULE_OMSCHRIJVING_URLLink = "mld_workflowrecord3.asp"
    fldMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWRULE_KEY = GetValue(rs, "MLD_WORKFLOWRULE_KEY")
    fldMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWSTEP_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_KEY")
    fldMLD_WORKFLOWRULE_OMSCHRIJVING_F_MLD_WORKFLOWSTEP_KEY = GetValue(rs, "MLD_WORKFLOWRULE_KEY")
    fldMLD_WORKFLOWRULE_OMSCHRIJVING = GetValue(rs, "MLD_WORKFLOWRULE_OMSCHRIJVING")
    fldMLD_WORKFLOWRULE_RESULT = GetValue(rs, "MLD_WORKFLOWRULE_RESULT")
    fldMLD_WORKFLOWSTEP_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_KEY")
    fldMLD_WORKFLOWSTEP_NEXT_KEY = GetValue(rs, "MLD_WORKFLOWSTEP_NEXT_KEY")
    fldSTEP_OMSCHRIJVING = GetValue(rs, "STEP_OMSCHRIJVING")
'-------------------------------
' Afgemeld Show begin
'-------------------------------

'-------------------------------
' Afgemeld Show Event begin
fldMLD_WORKFLOWRULE_OMSCHRIJVING_F_MLD_WORKFLOWSTEP_KEY = getParam("F_MLD_WORKFLOWSTEP_KEY")
' Afgemeld Show Event end
'-------------------------------

'-------------------------------
' Replace Template fields with database values
'-------------------------------
    
      SetVar "MLD_WORKFLOWRULE_KEY", ToHTML(fldMLD_WORKFLOWRULE_KEY)
      SetVar "MLD_WORKFLOWRULE_KEY_URLLink", fldMLD_WORKFLOWRULE_KEY_URLLink
      SetVar "PrmMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWRULE_KEY", ToURL(fldMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWRULE_KEY)
      SetVar "PrmMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWSTEP_KEY", ToURL(fldMLD_WORKFLOWRULE_KEY_MLD_WORKFLOWSTEP_KEY)
      SetVar "PrmMLD_WORKFLOWRULE_KEY_F_MLD_WORKFLOWRULE_KEY", ToURL(fldMLD_WORKFLOWRULE_KEY_F_MLD_WORKFLOWRULE_KEY)
      SetVar "MLD_WORKFLOWSTEP_KEY", ToHTML(fldMLD_WORKFLOWSTEP_KEY)
      SetVar "MLD_WORKFLOWRULE_OMSCHRIJVING", ToHTML(fldMLD_WORKFLOWRULE_OMSCHRIJVING)
      SetVar "MLD_WORKFLOWRULE_OMSCHRIJVING_URLLink", fldMLD_WORKFLOWRULE_OMSCHRIJVING_URLLink
      SetVar "PrmMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWRULE_KEY", ToURL(fldMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWRULE_KEY)
      SetVar "PrmMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWSTEP_KEY", ToURL(fldMLD_WORKFLOWRULE_OMSCHRIJVING_MLD_WORKFLOWSTEP_KEY)
      SetVar "PrmMLD_WORKFLOWRULE_OMSCHRIJVING_F_MLD_WORKFLOWSTEP_KEY", ToURL(fldMLD_WORKFLOWRULE_OMSCHRIJVING_F_MLD_WORKFLOWSTEP_KEY)
      SetVar "MLD_WORKFLOWRULE_RESULT", ToHTML(fldMLD_WORKFLOWRULE_RESULT)
      SetVar "MLD_WORKFLOWSTEP_NEXT_KEY", ToHTML(fldMLD_WORKFLOWSTEP_NEXT_KEY)
      SetVar "STEP_OMSCHRIJVING", ToHTML(fldSTEP_OMSCHRIJVING)
      SetVar "MLD_WORKFLOWRULE_CONDITION", ToHTML(fldMLD_WORKFLOWRULE_CONDITION)
    Parse "DListAfgemeld", True

'-------------------------------
' Afgemeld Show end
'-------------------------------

'-------------------------------
' Move to the next record and increase record counter
'-------------------------------
    rs.MoveNext
    iCounter = iCounter + 1
  wend
'-------------------------------


'-------------------------------
' Afgemeld Navigation begin
'-------------------------------
  bEof = rs.eof
  if rs.eof and iPage = 1 then
	SetVar "AfgemeldNavigator", ""
  else
    iCounter = 1
    iHasPages = iPage
    iDisplayPages = 0
    iNumberOfPages = 10
    iHasPages = iPageCount
    if (iHasPages - iPage) < int(iNumberOfPages/2) then
      iStartPage = iHasPages - iNumberOfPages
    else
      iStartPage = iPage - iNumberOfPages + int(iNumberOfPages/2)
    end if
    if iStartPage < 0 then iStartPage = 0
    for iPageCount = iStartPage + 1 to iPage - 1
      SetVar "NavigatorPageNumber", iPageCount
      SetVar "NavigatorPageNumberView", iPageCount
      Parse "AfgemeldNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
    next
    SetVar "NavigatorPageSwitch", "_"
    SetVar "NavigatorPageNumber", iPage
    SetVar "NavigatorPageNumberView", iPage
    Parse "AfgemeldNavigatorPages", true
    iDisplayPages = iDisplayPages + 1
    SetVar "NavigatorPageSwitch", ""
    iPageCount = iPage + 1
    while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages
      SetVar "NavigatorPageNumber", iPageCount
      SetVar "NavigatorPageNumberView", iPageCount
      Parse "AfgemeldNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
      iPageCount = iPageCount + 1
    wend
    if bEof then
      SetVar "AfgemeldNavigatorLastPage", "_"
    else
      SetVar "NextPage", (iPage + 1)
    end if
    if iPage = 1 then
      SetVar "AfgemeldNavigatorFirstPage", "_"
    else
      SetVar "PrevPage", (iPage - 1)
    end if
    SetVar "AfgemeldCurrentPage", iPage
    Parse "AfgemeldNavigator", False
  end if
'-------------------------------
' Afgemeld Navigation end
'-------------------------------

'-------------------------------
' Finish form processing
'-------------------------------
  set rs = nothing
  SetVar "AfgemeldNoRecords", ""
  Parse "FormAfgemeld", False

'-------------------------------
' Afgemeld Close Event begin
' Afgemeld Close Event end
'-------------------------------
End Sub
'===============================

%>