          SUBROUTINE (WID,FORM.NAME,RESP)
** Version# 7.0002[7] - 08/05/2012 - 01:29pm - TSMITH - eclipse
*** V7.0002 Change - Custom Coding . - 08/05/2012 - TSMITH - eclipse
** Copied from BP WOE.GET.FORM.RESP Version# 7 - 09/04/2002 - 03:08pm - MIKER - develop

*** Subroutine: WOE.GET.FORM.RESP
*-------------------------------------------------------------------------*
*** This routine checks to see if the customer has any custom web pages
*** designed for them.  If they do that page will be displayed.  The
*** program first checks to see if the ship-to has a custom page. Then it
*** looks at the bill-to, company, and finally the eclipse set default.
*-------------------------------------------------------------------------*
*** WID       - session ID - if not logged in yet pass in the version [IN]
***           - valid options: level1 = 'A' level2 = 'B' Email = 'E'
*** FORM.NAME - the literal name of the html page we're looking for   [IN]
*** RESP      - the html response                                     [OUT]
*-------------------------------------------------------------------------*
          GOSUB OPEN.FILES             ;* open files
          GOSUB INIT                   ;* initialize variables
          GOSUB GET.FORM.ID            ;* gets the html ID
          GOSUB GET.CN.RESP            ;* get any custom html for this CN
          GOSUB GET.DEFAULT.RESP       ;* get the default html response

FINISH:   *** exit this routine
          IF OPEN.ERR = '' AND VER = 'A' THEN
             WOEA.GET.TOP.NAV RESP ;* fill in the top nav info if WOEA
          END

          RETURN
*-------------------------------------------------------------------------*
OPEN.FILES: *** open necessary files

          OPEN.ERR = ''; ERR.MSG = ''

          UT.OPEN.FILE 'WEB.FORMS',WFRFILE,ERR.MSG,YES
          IF ERR.MSG THEN
             CMD = 'CREATE-FILE WEB.FORMS 1 29,4,30'
             EXECUTE CMD CAPTURING MSG

             ERR.MSG = ''
             UT.OPEN.FILE 'WEB.FORMS',WFRFILE,ERR.MSG,YES
             OPEN.ERR<-1> = ERR.MSG
          END

          UT.OPEN.FILE 'CUS.FORMS',CWFRFILE,ERR.MSG,YES
          IF ERR.MSG THEN
             CMD = 'CREATE-FILE CUS.FORMS 1 29,4,30'
             EXECUTE CMD CAPTURING MSG

             ERR.MSG = ''
             UT.OPEN.FILE 'CUS.FORMS',CWFRFILE,ERR.MSG,YES
             OPEN.ERR<-1> = ERR.MSG
          END

          UT.OPEN.FILE 'CSUP.FORMS',CSPFILE,ERR.MSG,YES
          IF ERR.MSG THEN
             CMD = 'CREATE-FILE CSUP.FORMS 1 29,4,30'
             EXECUTE CMD CAPTURING MSG

             ERR.MSG = ''
             UT.OPEN.FILE 'CSUP.FORMS',CSPFILE,ERR.MSG,YES
             OPEN.ERR<-1> = ERR.MSG
          END
          IF OPEN.ERR THEN RETURN TO FINISH

          UT.OPEN.FILE 'WEB.TEMP',WTPFILE,ERR.MSG,YES
          IF ERR.MSG THEN
             CMD = 'CREATE-FILE WEB.TEMP 1 101,1,18'
             EXECUTE CMD CAPTURING MSG

             ERR.MSG = ''
             UT.OPEN.FILE 'WEB.TEMP',WTPFILE,ERR.MSG,YES
             OPEN.ERR<-1> = ERR.MSG
          END

          IF OPEN.ERR THEN
             CONVERT AM TO '<br>' IN OPEN.ERR
             RESP = 'The following error(s) occurred while trying to open the requested page:<br>':OPEN.ERR
             RETURN TO FINISH
          END

          RETURN
*-------------------------------------------------------------------------*
INIT:     *** Initialize all of the needed variables

          VER = ''; SKIP.CN = NO

          *** if we don't have a session ID yet, pass in A or B for WOE
          *** C for Customer Support or E for Outbound Email
          IF WID = 'A' OR WID = 'B' OR WID = 'C' OR WID = 'E' THEN
             VER = WID
             SKIP.CN = YES
             RETURN
          END

          READ HDR FROM WTPFILE,WID:'.HDR' ELSE
             RESP = 'The following error occurred while trying to locate your session ID:<br>Unable to find the HDR record'
             RETURN TO FINISH
          END

          BT  = HDR<2>
          ST  = HDR<3>
          VER = HDR<35>

          RETURN
*-------------------------------------------------------------------------*
GET.FORM.ID: *** gets the html ID for the page we're looking for

          *** read from the appropriate control rec
          BEGIN CASE
          CASE VER = 'A'
             READ DFLT.PAGES FROM CTRLFILE,'WOE.PAGES'   ELSE DFLT.PAGES=''
          CASE VER = 'B'
             READ DFLT.PAGES FROM CTRLFILE,'WOEB.PAGES'  ELSE DFLT.PAGES=''
          CASE VER = 'E'
             READ DFLT.PAGES FROM CTRLFILE,'EMAIL.PAGES.RED' ELSE DFLT.PAGES=''
          CASE VER = 'C'
             READ DFLT.PAGES FROM CTRLFILE,'CSUP.PAGES'  ELSE DFLT.PAGES=''
          CASE OTHERWISE
             READ DFLT.PAGES FROM CTRLFILE,'WOE.PAGES'   ELSE DFLT.PAGES=''
          END CASE

          FORM.ID = 'SOE Email Order RED'
          LOCATE FORM.NAME IN DFLT.PAGES<1> SETTING POS THEN
             FORM.ID = DFLT.PAGES<2,POS>
          END

          IF NOT(FORM.ID) THEN
             RESP = 'There was an error trying to locate the following page:<br>':FORM.NAME:'<br>Please try again.'
             RETURN TO FINISH
          END

          RETURN
*-------------------------------------------------------------------------*
GET.CN.RESP: *** checks custom html at the customer level

          IF SKIP.CN THEN RETURN

          READ RESP FROM CWFRFILE,ST:'~':FORM.ID:'~CUR' ELSE RESP = ''
          IF RESP THEN RETURN TO FINISH

          READ RESP FROM CWFRFILE,BT:'~':FORM.ID:'~CUR' ELSE RESP = ''
          IF RESP THEN RETURN TO FINISH

          RETURN
*-------------------------------------------------------------------------*
GET.DEFAULT.RESP: *** get the html for this site

          READ RESP FROM CWFRFILE,'DEFAULT~':FORM.ID:'~CUR' ELSE RESP = ''
          IF RESP THEN RETURN TO FINISH

          IF VER = 'C' THEN
             READ RESP FROM CSPFILE,FORM.ID ELSE RESP = ''
          END ELSE
             READ RESP FROM WFRFILE,FORM.ID ELSE RESP = ''
          END
          IF RESP THEN RETURN

          IF NOT(RESP) THEN
             RESP = 'The request for the following page does not exist:<br>':FORM.NAME:'<br>Please try again.'
          END

          RETURN
!TSMITH~08/05/12~13:29
