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

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


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


'===============================
' fac_authgroeprecord CustomSecurity Event begin
checkAutorisation("WEB_FACMSU")
' fac_authgroeprecord CustomSecurity Event end
'===============================

'===============================
' fac_authgroeprecord Open Event begin
if getParam("fac_functie_key") <> "" then
  fac_functie_key = getParam("fac_functie_key")
end if

if getParam("fac_functie_module") <> "" then
  fldFAC_GEBRUIKER_MODULE = getParam("fac_functie_module")
end if
' fac_authgroeprecord Open Event end
'===============================


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

' fac_authgroeprecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sFunctieRecordErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "FunctieRecord"
    FunctieRecordAction(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
'-------------------------------
FunctieRecord_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' fac_authgroeprecord Show end

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

' fac_authgroeprecord Close Event begin
' fac_authgroeprecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub FunctieRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKFAC_GROEPRECHTEN_KEY : pPKFAC_GROEPRECHTEN_KEY = ""
  Dim fldFAC_GROEP_KEY : fldFAC_GROEP_KEY = ""
  Dim fldFAC_FUNCTIE_KEY : fldFAC_FUNCTIE_KEY = ""
  Dim fldFAC_GEBRUIKER_PRS_LEVEL_READ : fldFAC_GEBRUIKER_PRS_LEVEL_READ = ""
  Dim fldFAC_GEBRUIKER_PRS_LEVEL_WRITE : fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = ""
  Dim fldFAC_GEBRUIKER_ALG_LEVEL_READ : fldFAC_GEBRUIKER_ALG_LEVEL_READ = ""
  Dim fldFAC_GEBRUIKER_ALG_LEVEL_WRITE : fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = ""
  Dim fldREADRIGHTS : fldREADRIGHTS = ""
  Dim fldWRITERIGHTS : fldWRITERIGHTS = ""
  Dim fldRIGHTS : fldRIGHTS = ""
  Dim fldFAC_FUNCTIE_MIN_LEVEL : fldFAC_FUNCTIE_MIN_LEVEL = ""
'-------------------------------

'-------------------------------
' FunctieRecord Action begin
'-------------------------------
  sActionFileName = "fac_authgroepgrid.asp"
  sParams = sParams & "FAC_GROEP_KEY=" & ToURL(GetParam("Trn_FAC_GROEP_KEY")) & "&"
  sParams = sParams & "FAC_FUNCTIE_MODULE=" & ToURL(GetParam("Trn_FAC_FUNCTIE_MODULE")) & "&"
  sParams = sParams & "sFAC_GROEP_UPPER=" & ToURL(GetParam("Trn_sFAC_GROEP_UPPER"))

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldFAC_FUNCTIE_KEY = GetParam("Rqd_FAC_FUNCTIE_KEY")
  fldFAC_GROEP_KEY = GetParam("FAC_GROEP_KEY")
  fldFAC_FUNCTIE_KEY = GetParam("FAC_FUNCTIE_KEY")
  fldFAC_GEBRUIKER_PRS_LEVEL_READ = GetParam("FAC_GEBRUIKER_PRS_LEVEL_READ")
  fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = GetParam("FAC_GEBRUIKER_PRS_LEVEL_WRITE")
  fldFAC_GEBRUIKER_ALG_LEVEL_READ = GetParam("FAC_GEBRUIKER_ALG_LEVEL_READ")
  fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = GetParam("FAC_GEBRUIKER_ALG_LEVEL_WRITE")
  fldREADRIGHTS = GetParam("READRIGHTS")
  fldWRITERIGHTS = GetParam("WRITERIGHTS")
  fldRIGHTS = GetParam("RIGHTS")
  fldFAC_FUNCTIE_MIN_LEVEL = GetParam("FAC_FUNCTIE_MIN_LEVEL")

'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' FunctieRecord Insert Event begin
select case fldFAC_FUNCTIE_MIN_LEVEL
case "0"
  prs_read  = fldRIGHTS
  prs_write = fldRIGHTS
  alg_read  = fldRIGHTS
  alg_write = fldRIGHTS
case "1"
  prs_read  = fldREADRIGHTS
  prs_write = "9"
  alg_read  = fldREADRIGHTS
  alg_write = "9"
case "3"
  prs_read = fldREADRIGHTS
  prs_write = fldWRITERIGHTS
  alg_read = fldREADRIGHTS
  alg_write = fldWRITERIGHTS
case "5"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = "9"
  alg_read  = "-1"
  alg_write = "-1"
case "7"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = fldFAC_GEBRUIKER_PRS_LEVEL_WRITE
  alg_read  = "-1"
  alg_write = "-1"
case "9"
  prs_read  = "-1"
  prs_write = "-1"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = "9"
case "11"
  prs_read  = "-1"
  prs_write = "-1"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = fldFAC_GEBRUIKER_ALG_LEVEL_WRITE
case "13"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = "9"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = "9"
case "15"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = fldFAC_GEBRUIKER_PRS_LEVEL_WRITE
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = fldFAC_GEBRUIKER_ALG_LEVEL_WRITE
case else
  'Voer geen actie uit
  sSql = "select 0,'' "&from_dual
end select

if sSql = "" then
  sSql = "insert into fac_groeprechten("&_
    "fac_functie_key," &_
    "fac_gebruiker_prs_level_read," &_
    "fac_gebruiker_prs_level_write," &_
    "fac_gebruiker_alg_level_read," &_
    "fac_gebruiker_alg_level_write," &_
    "fac_groep_key) " &_
    "values (" &_
    ToSQL(fldFAC_FUNCTIE_KEY,"Number") &"," &_
    ToSql(prs_read,"Number") & "," &_
    ToSql(prs_write,"Number") & "," &_
    ToSql(alg_read,"Number") & "," &_
    ToSql(alg_write,"Number") & "," &_
    ToSQL(fldFAC_GROEP_KEY,"Number") & ")"
end if
' FunctieRecord Insert Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "insert into FAC_GROEPRECHTEN (" & _
          "FAC_FUNCTIE_KEY," & _
          "FAC_GROEP_KEY," & _
          "FAC_FUNCTIE_KEY," & _
          "FAC_GEBRUIKER_PRS_LEVEL_READ," & _
          "FAC_GEBRUIKER_PRS_LEVEL_WRITE," & _
          "FAC_GEBRUIKER_ALG_LEVEL_READ," & _
          "FAC_GEBRUIKER_ALG_LEVEL_WRITE," & _
          "FAC_FUNCTIE_KEY)" & _
          " values (" & _
          ToSQL(fldFAC_FUNCTIE_KEY, "Number") & "," & _
          ToSQL(fldFAC_GROEP_KEY, "Number") & "," & _
          ToSQL(fldFAC_FUNCTIE_KEY, "Number") & "," & _
          ToSQL(fldFAC_GEBRUIKER_PRS_LEVEL_READ, "Number") & "," & _
          ToSQL(fldFAC_GEBRUIKER_PRS_LEVEL_WRITE, "Number") & "," & _
          ToSQL(fldFAC_GEBRUIKER_ALG_LEVEL_READ, "Number") & "," & _
          ToSQL(fldFAC_GEBRUIKER_ALG_LEVEL_WRITE, "Number") & "," & _
          ToSQL(fldFAC_FUNCTIE_MIN_LEVEL, "Number") & _
          ")"
      end if
    case "update"
'-------------------------------
' FunctieRecord Update Event begin
select case fldFAC_FUNCTIE_MIN_LEVEL
case "0"
  prs_read  = fldRIGHTS
  prs_write = fldRIGHTS
  alg_read  = fldRIGHTS
  alg_write = fldRIGHTS
case "1"
  prs_read  = fldREADRIGHTS
  prs_write = "9"
  alg_read  = fldREADRIGHTS
  alg_write = "9"
case "3"
  prs_read = fldREADRIGHTS
  prs_write = fldWRITERIGHTS
  alg_read = fldREADRIGHTS
  alg_write = fldWRITERIGHTS
case "5"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = "9"
  alg_read  = "-1"
  alg_write = "-1"
case "7"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = fldFAC_GEBRUIKER_PRS_LEVEL_WRITE
  alg_read  = "-1"
  alg_write = "-1"
case "9"
  prs_read  = "-1"
  prs_write = "-1"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = "9"
case "11"
  prs_read  = "-1"
  prs_write = "-1"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = fldFAC_GEBRUIKER_ALG_LEVEL_WRITE
case "13"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = "9"
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = "9"
case "15"
  prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
  prs_write = fldFAC_GEBRUIKER_PRS_LEVEL_WRITE
  alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
  alg_write = fldFAC_GEBRUIKER_ALG_LEVEL_WRITE
case else
  'Voer geen actie uit
  sSql = "select 0,'' "&from_dual
end select

if (sSql = "") then
  sSql = "update fac_groeprechten set " &_
         "fac_gebruiker_prs_level_read  = " & ToSql(prs_read,"Number")  & "," &_
         "fac_gebruiker_prs_level_write = " & ToSql(prs_write,"Number") & "," &_
         "fac_gebruiker_alg_level_read  = " & ToSql(alg_read,"Number")  & "," &_
         "fac_gebruiker_alg_level_write = " & ToSql(alg_write,"Number") &_
         " where " & sWhere
end if
' FunctieRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update FAC_GROEPRECHTEN set " & _
        "FAC_GROEP_KEY=" & ToSQL(fldFAC_GROEP_KEY, "Number") & _
        ",FAC_FUNCTIE_KEY=" & ToSQL(fldFAC_FUNCTIE_KEY, "Number") & _
        ",FAC_GEBRUIKER_PRS_LEVEL_READ=" & ToSQL(fldFAC_GEBRUIKER_PRS_LEVEL_READ, "Number") & _
        ",FAC_GEBRUIKER_PRS_LEVEL_WRITE=" & ToSQL(fldFAC_GEBRUIKER_PRS_LEVEL_WRITE, "Number") & _
        ",FAC_GEBRUIKER_ALG_LEVEL_READ=" & ToSQL(fldFAC_GEBRUIKER_ALG_LEVEL_READ, "Number") & _
        ",FAC_GEBRUIKER_ALG_LEVEL_WRITE=" & ToSQL(fldFAC_GEBRUIKER_ALG_LEVEL_WRITE, "Number") & _
        ",FAC_FUNCTIE_KEY=" & ToSQL(fldFAC_FUNCTIE_MIN_LEVEL, "Number")
      sSQL = sSQL & " where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' FunctieRecord BeforeExecute Event begin
' FunctieRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub FunctieRecord_Show()
'-------------------------------
' FunctieRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Autorisatie functie"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sFunctieRecordErr = "" then
    fldFAC_GROEP_KEY = GetParam("FAC_GROEP_KEY")
    fldFAC_FUNCTIE_KEY = GetParam("FAC_FUNCTIE_KEY")
    SetVar "Trn_FAC_GROEP_KEY", GetParam("FAC_GROEP_KEY")
    SetVar "Trn_FAC_FUNCTIE_MODULE", GetParam("FAC_FUNCTIE_MODULE")
    SetVar "Trn_sFAC_GROEP_UPPER", GetParam("sFAC_GROEP_UPPER")
    SetVar "Rqd_FAC_FUNCTIE_KEY", GetParam("FAC_FUNCTIE_KEY")
    pFAC_GROEPRECHTEN_KEY = GetParam("FAC_GROEPRECHTEN_KEY")
    SetVar "FunctieRecordError", ""
  else
    fldFAC_GROEPRECHTEN_KEY = GetParam("FAC_GROEPRECHTEN_KEY")
    fldFAC_GROEP_KEY = GetParam("FAC_GROEP_KEY")
    fldFAC_FUNCTIE_KEY = GetParam("FAC_FUNCTIE_KEY")
    fldFAC_GEBRUIKER_PRS_LEVEL_READ = GetParam("FAC_GEBRUIKER_PRS_LEVEL_READ")
    fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = GetParam("FAC_GEBRUIKER_PRS_LEVEL_WRITE")
    fldFAC_GEBRUIKER_ALG_LEVEL_READ = GetParam("FAC_GEBRUIKER_ALG_LEVEL_READ")
    fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = GetParam("FAC_GEBRUIKER_ALG_LEVEL_WRITE")
    fldFAC_FUNCTIE_MIN_LEVEL = GetParam("FAC_FUNCTIE_MIN_LEVEL")
    SetVar "Trn_FAC_GROEP_KEY", GetParam("Trn_FAC_GROEP_KEY")
    SetVar "Trn_FAC_FUNCTIE_MODULE", GetParam("Trn_FAC_FUNCTIE_MODULE")
    SetVar "Trn_sFAC_GROEP_UPPER", GetParam("Trn_sFAC_GROEP_UPPER")
    pFAC_GROEPRECHTEN_KEY = GetParam("PK_FAC_GROEPRECHTEN_KEY")
    SetVar "sFunctieRecordErr", sFunctieRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "FunctieRecordError", False
  end if
'-------------------------------

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

  fldFAC_GROEP_OMSCHRIJVING = GetParam("FAC_GROEP_OMSCHRIJVING")
  fldFAC_FUNCTIE_OMSCHRIJVING = GetParam("FAC_FUNCTIE_OMSCHRIJVING")
  fldFAC_FUNCTIE_INFO = GetParam("FAC_FUNCTIE_INFO")
  fldField1 = GetParam("Field1")
  fldField2 = GetParam("Field2")
  fldField3 = GetParam("Field3")
  fldREADRIGHTS = GetParam("READRIGHTS")
  fldWRITERIGHTS = GetParam("WRITERIGHTS")
  fldField4 = GetParam("Field4")
  fldRIGHTS = GetParam("RIGHTS")
'-------------------------------

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

  if IsEmpty(pFAC_GROEPRECHTEN_KEY) then bPK = False
  
  sWhere = sWhere & "FAC_GROEPRECHTEN_KEY=" & ToSQL(pFAC_GROEPRECHTEN_KEY, "Number")
  SetVar "PK_FAC_GROEPRECHTEN_KEY", pFAC_GROEPRECHTEN_KEY
'-------------------------------
'-------------------------------
' FunctieRecord Open Event begin
' FunctieRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldFAC_FUNCTIE_KEY = GetValue(rs, "FAC_FUNCTIE_KEY")
    fldFAC_FUNCTIE_MIN_LEVEL = GetValue(rs, "FAC_FUNCTIE_KEY")
    fldFAC_GROEP_KEY = GetValue(rs, "FAC_GROEP_KEY")
    fldFAC_GROEPRECHTEN_KEY = GetValue(rs, "FAC_GROEPRECHTEN_KEY")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sFunctieRecordErr = "" then
      fldFAC_GEBRUIKER_PRS_LEVEL_READ = GetValue(rs, "FAC_GEBRUIKER_PRS_LEVEL_READ")
      fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = GetValue(rs, "FAC_GEBRUIKER_PRS_LEVEL_WRITE")
      fldFAC_GEBRUIKER_ALG_LEVEL_READ = GetValue(rs, "FAC_GEBRUIKER_ALG_LEVEL_READ")
      fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = GetValue(rs, "FAC_GEBRUIKER_ALG_LEVEL_WRITE")
    end if
    SetVar "FunctieRecordDelete", ""
    SetVar "FunctieRecordInsert", ""
    Parse "FunctieRecordEdit", False
'-------------------------------
' FunctieRecord ShowEdit Event begin
' FunctieRecord ShowEdit Event end
'-------------------------------
  else
    if sFunctieRecordErr = "" then
      fldFAC_GROEP_KEY = ToHTML(GetParam("FAC_GROEP_KEY"))
      fldFAC_FUNCTIE_KEY = ToHTML(GetParam("FAC_FUNCTIE_KEY"))
      fldFAC_FUNCTIE_MIN_LEVEL = ToHTML(GetParam("FAC_FUNCTIE_KEY"))
      fldField1= "<b>"&FCLTLCL("Organisatie")&"</b>"
      fldField2= "<b>"&FCLTLCL("Plaats")&"</b>"
    end if
    SetVar "FunctieRecordEdit", ""
    Parse "FunctieRecordInsert", False
'-------------------------------
' FunctieRecord ShowInsert Event begin
' FunctieRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "FunctieRecordCancel", false

'-------------------------------
' Set default values
'-------------------------------
  fldField1= "<b>"&FCLTLCL("Organisatie")&"</b>"
  fldField2= "<b>"&FCLTLCL("Plaats")&"</b>"
  if sFunctieRecordErr = "" then
'-------------------------------
' FunctieRecord Show Event begin
'Laat de showEvent altijd plaatsvinden:
end if
if true then

sqlFunctie = "select fac_functie_min_level, fac_functie_omschrijving, fac_functie_info "&_
             "from fac_functie where fac_functie_key = " & ToSQL(fldFAC_FUNCTIE_KEY, "Number")
openrs rsFunctie,sqlFunctie
if not rsFunctie.EOF then
  fldFAC_FUNCTIE_MIN_LEVEL = getValue(rsFunctie,"fac_functie_min_level")
  fldFAC_FUNCTIE_OMSCHRIJVING = getValue(rsFunctie,"fac_functie_omschrijving")
  fldFAC_FUNCTIE_INFO = getValue(rsFunctie,"fac_functie_info")
end if
rsFunctie.Close


prs_read  = fldFAC_GEBRUIKER_PRS_LEVEL_READ
prs_write = fldFAC_GEBRUIKER_PRS_LEVEL_WRITE
alg_read  = fldFAC_GEBRUIKER_ALG_LEVEL_READ
alg_write = fldFAC_GEBRUIKER_ALG_LEVEl_WRITE
if (fldFAC_FUNCTIE_MIN_LEVEL = "") or isEmpty(fldFAC_FUNCTIE_MIN_LEVEL) or isNull(fldFAC_FUNCTIE_MIN_LEVEL) then
  'Fout! kan min_level niet bepalen.
  minlevel = -1
else
  minlevel = CDbl(fldFAC_FUNCTIE_MIN_LEVEL)
end if


' Bepaal welke radiobuttons wel en niet gebruikt mogen worden
if minlevel=0 then
  'Mode 0
  setvar "M1_READ_DISABLED","disabled"
  setvar "M1_WRITE_DISABLED","disabled"
  setvar "PRS_READ_DISABLED","disabled"
  setvar "PRS_WRITE_DISABLED","disabled"
  setvar "ALG_READ_DISABLED","disabled"
  setvar "ALG_WRITE_DISABLED","disabled"
  'Bepaal de waarde
  if prs_read="-1" and prs_write="-1" and alg_read="-1" and alg_write="-1" then
    fldRIGHTS = "-1"
  else
    fldRIGHTS = "9"
  end if
  fldFAC_GEBRUIKER_PRS_LEVEL_READ = ""
  fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = ""
  fldFAC_GEBRUIKER_ALG_LEVEL_READ = ""
  fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = ""
elseif (minlevel>=1) and (minlevel<=3) then
  'Mode 1
  setvar "M0_DISABLED","disabled"
  setvar "PRS_READ_DISABLED","disabled"
  setvar "PRS_WRITE_DISABLED","disabled"
  setvar "ALG_READ_DISABLED","disabled"
  setvar "ALG_WRITE_DISABLED","disabled"
  if (prs_read="9" or prs_read="") and (prs_read="9" or prs_write="") then
    fldREADRIGHTS = "9"
  elseif (prs_read="-1" and alg_read="-1") then
    fldREADRIGHTS = "-1"
  end if
  if (minlevel=1) then
    setvar "M1_WRITE_DISABLED","disabled"
    fldWRITERIGHTS = ""
  elseif (minlevel=2) then
    setvar "M1_READ_DISABLED","disabled"
    setvar "M1_WRITE_DISABLED","disabled"
    fldREADRIGHTS = ""
    fldWRITERIGHTS = ""
  else
    if (prs_write="9" or prs_write="") and (alg_write="9" or alg_write="") then
      fldWRITERIGHTS = "9"
    elseif prs_write="-1" and alg_write="-1" then
      fldWRITERIGHTS = "-1"
    end if
  end if
  fldFAC_GEBRUIKER_PRS_LEVEL_READ = ""
  fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = ""
  fldFAC_GEBRUIKER_ALG_LEVEL_READ = ""
  fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = ""
elseif (minlevel>=4) and (minlevel<=15) then
  'Mode 2
  setvar "M0_DISABLED","disabled"
  setvar "M1_READ_DISABLED","disabled"
  setvar "M1_WRITE_DISABLED","disabled"
  select case minlevel
  case 5
    setvar "PRS_WRITE_DISABLED","disabled"
    setvar "ALG_READ_DISABLED","disabled"
    setvar "ALG_WRITE_DISABLED","disabled"
  case 7
    setvar "ALG_READ_DISABLED","disabled"
    setvar "ALG_WRITE_DISABLED","disabled"
  case 9
    setvar "PRS_READ_DISABLED","disabled"
    setvar "PRS_WRITE_DISABLED","disabled"
    setvar "ALG_WRITE_DISABLED","disabled"
  case 11
    setvar "PRS_READ_DISABLED","disabled"
    setvar "PRS_WRITE_DISABLED","disabled"
  case 13
    setvar "PRS_WRITE_DISABLED","disabled"
    setvar "ALG_WRITE_DISABLED","disabled"
  case 15
  case else
    'disable alles
    setvar "PRS_READ_DISABLED","disabled"
    setvar "PRS_WRITE_DISABLED","disabled"
    setvar "ALG_READ_DISABLED","disabled"
    setvar "ALG_WRITE_DISABLED","disabled"
  end select
  if fldFAC_GEBRUIKER_PRS_LEVEL_READ = "" then
    fldFAC_GEBRUIKER_PRS_LEVEL_READ = "9"
  end if
  if fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = "" then
    fldFAC_GEBRUIKER_PRS_LEVEL_WRITE = "9"
  end if
  if fldFAC_GEBRUIKER_ALG_LEVEL_READ = "" then
    fldFAC_GEBRUIKER_ALG_LEVEL_READ = "9"
  end if
  if fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = "" then
    fldFAC_GEBRUIKER_ALG_LEVEL_WRITE = "9"
  end if
end if

sqlGroep = "select fac_groep_omschrijving from fac_groep where fac_groep_key = " & ToSQL(fldFAC_GROEP_KEY, "Number")
openrs rsGroep,sqlGroep
if not rsGroep.EOF then
  fldFAC_GROEP_OMSCHRIJVING = getValue(rsGroep,"fac_groep_omschrijving")
end if
rsGroep.Close
' FunctieRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "FAC_GROEPRECHTEN_KEY", ToHTML(fldFAC_GROEPRECHTEN_KEY)
      SetVar "FAC_GROEP_KEY", ToHTML(fldFAC_GROEP_KEY)
      SetVar "FAC_GROEP_OMSCHRIJVING", ToHTML(fldFAC_GROEP_OMSCHRIJVING)
      SetVar "FAC_FUNCTIE_KEY", ToHTML(fldFAC_FUNCTIE_KEY)
      SetVar "FAC_FUNCTIE_OMSCHRIJVING", ToHTML(fldFAC_FUNCTIE_OMSCHRIJVING)
      SetVar "FAC_FUNCTIE_INFO", ToHTML(fldFAC_FUNCTIE_INFO)
      SetVar "Field1", fldField1
      SetVar "FunctieRecordRLFAC_GEBRUIKER_PRS_LEVEL_READ", ""
    
      LOV = Split(""&buildORGRadioList&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldFAC_GEBRUIKER_PRS_LEVEL_READ) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLFAC_GEBRUIKER_PRS_LEVEL_READ", True
        next
      end if
    
      SetVar "FunctieRecordRLFAC_GEBRUIKER_PRS_LEVEL_WRITE", ""
    
      LOV = Split(""&buildORGRadioList&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldFAC_GEBRUIKER_PRS_LEVEL_WRITE) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLFAC_GEBRUIKER_PRS_LEVEL_WRITE", True
        next
      end if
    
      SetVar "Field2", fldField2
      SetVar "FunctieRecordRLFAC_GEBRUIKER_ALG_LEVEL_READ", ""
    
      LOV = Split(""&buildPOSRadioList&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldFAC_GEBRUIKER_ALG_LEVEL_READ) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLFAC_GEBRUIKER_ALG_LEVEL_READ", True
        next
      end if
    
      SetVar "FunctieRecordRLFAC_GEBRUIKER_ALG_LEVEL_WRITE", ""
    
      LOV = Split(""&buildPOSRadioList&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldFAC_GEBRUIKER_ALG_LEVEL_WRITE) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLFAC_GEBRUIKER_ALG_LEVEL_WRITE", True
        next
      end if
    
      SetVar "Field3", ToHTML(fldField3)
      SetVar "FunctieRecordRLREADRIGHTS", ""
    
      LOV = Split(""&FCLTLCL("-1;Ja;9;Nee")&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldREADRIGHTS) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLREADRIGHTS", True
        next
      end if
    
      SetVar "FunctieRecordRLWRITERIGHTS", ""
    
      LOV = Split(""&FCLTLCL("-1;Ja;9;Nee")&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldWRITERIGHTS) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLWRITERIGHTS", True
        next
      end if
    
      SetVar "Field4", ToHTML(fldField4)
      SetVar "FunctieRecordRLRIGHTS", ""
    
      LOV = Split(""&FCLTLCL("-1;Ja;9;Nee")&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldRIGHTS) then SetVar "Selected", "CHECKED" else SetVar "Selected", ""
          Parse "FunctieRecordRLRIGHTS", True
        next
      end if
    
      SetVar "FAC_FUNCTIE_MIN_LEVEL", ToHTML(fldFAC_FUNCTIE_MIN_LEVEL)
  Parse "FormFunctieRecord", False

'-------------------------------
' FunctieRecord Close Event begin
' FunctieRecord Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' FunctieRecord Show end
'-------------------------------
End Sub
'===============================
%>