w3Admin.w3Config.process

subroutine w3Admin.w3Config.process

***********************************************************************

* w3Admin.w3Config.process: Process a submitted w3Admin.w3Create

*                           web page. Redisplay page when done.

*                           Show any errors.

***********************************************************************

* [00] 18Sep00 jr Initial creation

*

Include wbp w3Include                   

Include bp w3Admin.Include

CRT "w3Admin.w3Config.process"

ids = ""

call w3GetVal(ids, "ID")

convert "~" to @am in ids

messages = ""

ok       = w3_OK

skipEntries = ""      ;* If deleting an entry has an error, then

*                        don't show it on a error refresh. This is

*                        the means used to remove unwanted, invalid

*                        entries.

rows = dcount(ids, @am)

for i = 1 to rows

    id     = ""

    delete = ""

    change = ""

    status = ""

    call w3GetVal(id, "ID":i)

    hostOriginal = field(id, "#", 1)

    poolOriginal = field(id, "#", 2)

    call w3GetVal(change, "Change":i)

    if change="Delete" then

       call w3Config.process("Delete", poolOriginal, hostOriginal, "", "", "", "", "", "", "", status)

       if status # "" then

          skipEntries<-1> = i

       end

    end else                 

*      check if changed, compare value on file with submitted value

       status = w3_OK

       oMax       = ""

       oMin       = ""

       oMaxFree   = ""

       oMinFree   = ""

       oPort      = ""

       oFrequency = ""

       oHb        = ""

       call w3Config.process("Read", poolOriginal, hostOriginal, oMax, oMin, oMinFree, oMaxFree, oPort, oFrequency, oHb, Status)

       host      = ""

       pool      = ""

       max       = ""

       min       = ""

       maxFree   = ""

       minFree   = ""

       port      = ""

       frequency = ""

       hb        = ""

       call w3GetVal(host, "host":i)

       call w3GetVal(pool, "pool":i)

       call w3GetVal(max, "max":i)

       call w3GetVal(min, "min":i)

       call w3GetVal(maxFree, "maxFree":i)

       call w3GetVal(minFree, "minFree":i)

       call w3GetVal(port, "port":i)

       call w3GetVal(hb, "hb":i)

       call w3GetVal(frequency, "freq":i)

 

       changed = 0

       if host # hostOriginal then changed = 1

       if Pool # poolOriginal then changed = 1

       if max # omax then changed = 1

       if min # omin then changed = 1

       if MaxFree # oMaxFree then changed = 1

       if MinFree # oMinFree then changed = 1

       if port # oport then changed = 1

       if hb # ohb then changed = 1

       if frequency # ofrequency then changed = 1

*      change = delete + add/update

       if changed then

          call w3Config.process("Delete", poolOriginal, hostOriginal , max, min, minFree, maxFree, port, frequency, hb, Status)

          status = ""

          call w3Config.process("Update", pool, host, max, min, minFree, maxFree, port, frequency, hb, Status)

          if status # "" then

             ok = w3_Error

             lineCnt = dcount(status, @am)

             for xy = 1 to lineCnt

                 messages<-1> = "Line ":i:" ":status<xy>

             next xy

          end   ;* error on update

      end  ;* changed

    end   ;* delete

next i

*   check for add

rows += 1      

i     = rows

host      = ""

pool      = ""

max       = ""

min       = ""

maxFree   = ""

minFree   = ""

port      = ""

frequency = ""

hb        = ""

call w3GetVal(host, "host":i)

call w3GetVal(pool, "pool":i)

call w3GetVal(max, "max":i)

call w3GetVal(min, "min":i)

call w3GetVal(maxFree, "maxFree":i)

call w3GetVal(minFree, "minFree":i)

call w3GetVal(port, "port":i)

call w3GetVal(hb, "hb":i)

call w3GetVal(frequency, "freq":i)

if host # "" and pool # "" then

   call w3Config.process("Update", pool, host, max, min, minFree, maxFree, port, frequency, hb, Status)

   if status # "" then

      ok = w3_Error

       lineCnt = dcount(status, @am)

       for xy = 1 to lineCnt

           messages<-1> = "Line ":i:@am:status<xy>

       next xy

   end                      

end

if ok = w3_OK then

   call w3Admin.w3Config.create      ;* create from filed data

end else

*  create the page to update w/ error messages

 

  pools = ""

  i = 1

  for indx = 1 to rows     ;* already incremented to pick up add

      locate(indx, skipEntries; loc; "ar") else

         status = w3_OK

         host      = ""

         pool      = ""

         max       = ""

         min       = ""

         maxFree   = ""

         minFree   = ""

         port      = ""

         frequency = ""

         hb        = ""

         call w3GetVal(id, "ID":indx)

         call w3GetVal(host, "host":indx)

         call w3GetVal(pool, "pool":indx)

         call w3GetVal(max, "max":indx)

         call w3GetVal(min, "min":indx)

         call w3GetVal(maxFree, "maxFree":indx)

         call w3GetVal(minFree, "minFree":indx)

         call w3GetVal(port, "port":indx)

         call w3GetVal(hb, "hb":indx)

         call w3GetVal(frequency, "freq":indx)

 

*        include the add line if required fields are provided

         if host # "" and pool # "" or indx # rows then

            pools<1, i> = pool

            pools<2, i> = host

            pools<3, i> = min

            pools<4, i> = max

            pools<5, i> = maxFree

            pools<6, i> = minFree

            pools<7, i> = frequency

            pools<8, i> = port

            pools<9, i> = hb

            i += 1

         end   ;* insert add option

      end   ;* skipEntries

    next indx

    call w3Admin.w3Config.form(pools, messages)

end

return