          SUBROUTINE (OID,GEN,QSIGN,LOG.MV,PRC.KEY,LDID.LIST)
** Version# 28.0001[2] - 09/07/2016 - 12:48pm - TSMITH - eclipse
*** V28.0001 Change - Custom Coding . - 09/07/2016 - TSMITH - eclipse

*** Subroutine - OE.ITEM.PRICING.OVRD
*-------------------------------------------------------------------------*
*** This routine displays a screen that allow the user to change the price
*** and/or cost for the line items displayed on the screen Job Bid
*** Subtotal Maintenance Screen (OE.LOT.SUBTOLS).
*-------------------------------------------------------------------------*
*** OID        - Order Id                                            [IN]
*** GEN        - Generation                                          [IN]
*** QSIGN     - Qsign                                                [IN]
*** LOG.MV    - The list of gens to apply change log comments.   (IN/OUT)
*** PRC.KEY   - Flag set if user is able to edit cost/price          [IN]
*** LDID.LIST - List of LDID's we are working with                   [IN]
*-------------------------------------------------------------------------*
*** COMMON: LED, LD
*-------------------------------------------------------------------------*

          CHECK.KEY 'OE.PRICE.CLASS.LEVEL',,PC.LVL
          IF NOT(PC.LVL) AND PRC.KEY <> 1 THEN PRINT BELL:; RETURN

          SCREEN

          GOSUB INIT
          GOSUB DISPLAY
          MESS 2,3,"Use F10 To Select A Range Of Items."
*-------------------------------------------------------------------------*
IN.APP:   INP APPLY.TO,15,1,9,V_"D:":APP.OPTS
          IF F12 THEN GOTO FILEIT
          IF CHANGED THEN
             GOSUB SET.PDATE
             GOSUB DISPLAY
          END
          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.APP, IN.APP, IN.APP, IN.APP
*-------------------------------------------------------------------------*
IN.PDATE: * Check for Date change authorization before allowing change
INDATE:   INP PDATE,15,2,10,'D4/'
          IF F12 THEN GOTO FILEIT
          IF PDATE='' THEN PRINT BELL:; GOTO IN.PDATE
          IF CHANGED THEN
             IF APPLY.TO = "Price" THEN
                BEGIN CASE
                CASE PCD.LVL = 1
                   IF PDATE < ORIG.PDT THEN
                      PRINT BELL:
                      PRINT @(15,1):OCONV(LED(22)<1,GEN>,'D4/')"L#10"
                      GOTO IN.PDATE
                   END
                CASE PCD.LVL >= 2; * Auth for any price change
                CASE OTHERWISE
                   PRINT BELL:
                   PRINT @(15,2):OCONV(ORIG.PDT,'D4/')"L#10"
                   GOTO IN.PDATE
                END CASE
                PRC.DATE = PDATE
                LED(22)<1,GEN>   = PRC.DATE
             END ELSE
                CST.DATE = PDATE
                LED(38)<1,GEN,3> = CST.DATE
             END
          END

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.PDATE, IN.PDATE, IN.APP, IN.PDATE
*-------------------------------------------------------------------------*
IN.LDS:   INPWP LINE.NOS,1,4,38,2,99,'0101'
          IF HELP THEN
             VERF.OE.LINE.ITEM 0,0,0,LINE.NOS,ORN
             TEMP.LN = LINE.NOS
             LINE.NOS = FOLDCHAR(TEMP.LN,30,,',')
             GOTO IN.LDS
          END
          IF QUIT THEN GOTO FILEIT

          IF MOVE=2 THEN
             GOTO IN.PDATE
          END ELSE IF MOVE=4 THEN
             GOTO IN.BASE
          END ELSE
             GOTO IN.LDS
          END
*-------------------------------------------------------------------------*
IN.BASE:  TYPE = 1
          IF APPLY.TO = "Comm Cost" THEN TYPE = 25
          COST.INFO = MODE:'~':LED(2)<1,GEN,2>:'~':LED(6)<1,GEN>:'~':TYPE:'~':GLOBAL.BASE:'~':GEN:'~':1:'~':0
          IF APPLY.TO[1,1] = 'C' THEN
INBASE1:     INP GLOBAL.BASE,10,7,10,V_'S:VERF.COST.GLVL,':COST.INFO
             IF CHANGED THEN
                PRINT @(10,7):GLOBAL.BASE"L#10"
                IF GLOBAL.BASE = '' THEN
                   GLOBAL.BASN=''
                   GLOBAL.FORM=''
                   PRINT @(24,7):''"L#15"
                   GOTO IN.BASE
                END ELSE
                   LOCATE GLOBAL.BASE IN GBASIS SETTING GLOBAL.BASN THEN
                      IF GLOBAL.BASN < 19 THEN
                         GLOBAL.BASN += 2
                      END
                   END ELSE
                      GLOBAL.BASN = ''
                      GLOBAL.FORM = ''
                      PRINT @(10,7):GLOBAL.BASE"L#10"
                      PRINT @(24,7):''"L#15"
                      GOTO IN.BASE
                   END
                END
             END
          END ELSE
INBASE2:     INP GLOBAL.BASE,10,7,10
             IF CHANGED OR HELP THEN
                IF GLOBAL.BASE = '' AND NOT(HELP) THEN
                   GLOBAL.BASN=''
                   GLOBAL.FORM=''
                   PRINT @(24,7):''"L#15"
                END ELSE
                   OE.SELECT.GBASIS OID,GLOBAL.BASE,GLOBAL.BASN
                   IF (GLOBAL.BASN < 19) THEN
                      GLOBAL.BASN += 2
                   END

                   IF GLOBAL.BASN = '' THEN
                      PRINT @(10,7):BELL:GLOBAL.BASE"L#10"
                      GOTO IN.BASE
                   END
                   PRINT @(10,7):GLOBAL.BASE"L#10"
                END
             END
          END
          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.BASE, IN.BASE, IN.LDS, IN.FORM, IN.OVR
*-------------------------------------------------------------------------*
IN.FORM:  IF GLOBAL.BASN#'' THEN
IN.FORM2:    INP GLOBAL.FORM,24,7,15
             PARSE.FORMULA GLOBAL.FORM,MULT,CONST,EFLAG
             IF EFLAG THEN PRINT BELL:; GOTO IN.FORM
             IF QUIT THEN GOTO FILEIT
             ON MOVE+1 GOTO IN.FORM, IN.BASE, IN.LDS, IN.FORM
          END
*-------------------------------------------------------------------------*
IN.OVR:   INP REP.OVR,28,9,1,'YN'
          IF QUIT THEN GOTO FILEIT
          IF GLOBAL.BASN#'' THEN
             ON MOVE+1 GOTO IN.OVR, IN.OVR, IN.FORM, IN.OVR, IN.OVR, FILEIT
          END ELSE
             ON MOVE+1 GOTO IN.OVR, IN.OVR, IN.BASE, IN.OVR, IN.OVR, FILEIT
          END
          GOTO IN.OVR
*-------------------------------------------------------------------------*
INIT:     * Initialize variables in use for this routine
          MODE = OID[1,1]
*** Check Date change auth level for use in date logic PCD.LVL
          CHECK.KEY 'OE.PRICE.DATE.EDIT',,PCD.LVL
          CHECK.KEY MODE:'OE.COST.EDIT',COST.OK
          ORD.STAT = LED(6)<1,GEN>
          IF ORD.STAT='D' THEN
          CHECK.KEY 'SOE.COST.EDIT.DIRECT',COST.OK
          END

          IF NOT(COST.OK) THEN
             IF LED(6)<1,GEN> = 'B' THEN
                CHECK.KEY MODE:'OE.BID.COST.EDIT',COST.OK
             END
          END

          REP.OVR  = NO
          APPLY.TO = "Price"
          APP.OPTS = "Price"
          ORIG.PDT = LED(22)<1,GEN>
          ORIG.CDT = LED(38)<1,GEN,3>
          PRC.DATE = ORIG.PDT
          CST.DATE = ORIG.CDT
          PDATE    = PRC.DATE
          GLOBAL.BASN = ''

*** If the user's authorized to edit cost add those options.
          IF COST.OK THEN
             APP.OPTS := ",Comm Cost,COGS"
          END
          CONVERT ',' TO VM IN APP.OPTS
          IF LED(8)<1,GEN> THEN GEN.ID = LED(8)<1,GEN> "R%3" ELSE
             GEN.ID = LED(12)<1,GEN> "R%4"
          END

          ORN            = OID:'.':GEN.ID
          GLOBAL.FORM    = ''
          MULT           = ''
          CONST          = ''
          GLOBAL.BASE    = ''

          READ GBASIS FROM CTRLFILE,'GLOBAL.BASIS' ELSE GBASIS=''
          GBASIS = RAISE(RAISE(GBASIS))
          GBASIS<21> = "Lnd Cost"
          GBASIS<22> = "Avg Lnd"
          GBASIS<25> = "Order COGS"
          GBASIS<28> = "Order Comm"

          GOSUB SET.LINES
          RETURN
*-------------------------------------------------------------------------*
SET.LINES:   * Based on the current gen and LDID.LIST setup line no array
          TMP.LINE = ''
          IF LED(8)<1,GEN> THEN
             LDIDS = RAISE(LED(48)<1,GEN>)
          END ELSE
             LDIDS = LED(49)<1>
          END
          LD.CT = DCOUNT(LDID.LIST,VM)
          FOR LDN = 1 TO LD.CT
             LDID = LDID.LIST<1,LDN>
             LOCATE LDID IN LDIDS<1> SETTING LINE.NO THEN
                TMP.LINE<1,-1> = LINE.NO
             END
          NEXT LDN
          LINE.NOS = VM.COMPRESS(TMP.LINE)
          TEMP.LN  = LINE.NOS
          LINE.NOS = FOLDCHAR(TEMP.LN,30,,',')

          RETURN
*-------------------------------------------------------------------------*
SET.PDATE:   * Set the price date dependant on the apply to mode
          BEGIN CASE
          CASE APPLY.TO[1,1] = 'P';  PDATE = PRC.DATE; * Price Date
          CASE APPLY.TO[1,1] = 'C';  PDATE = CST.DATE; * Cost Date
          CASE OTHERWISE
          END CASE
          RETURN
*-------------------------------------------------------------------------*
DISPLAY:  PRINT @(15,1):APPLY.TO
          PRINT @(15,2):OCONV(PDATE,'D4/')"L#10"
          PRINT @(1,4):LINE.NOS<1,1>
          PRINT @(1,5):LINE.NOS<1,2>
          PRINT @(10,7):GLOBAL.BASE"L#10"
          PRINT @(24,7):GLOBAL.FORM"L#15"
          PRINT @(28,9):YN[REP.OVR+1,1]
          RETURN
*-------------------------------------------------------------------------*
FILEIT:   IF F12 THEN
             CONFIRM.ABORT SURE
             IF NOT(SURE) THEN GOTO IN.APP
          END ELSE
             OE.CHECK.PRC.AUTH OID,GEN,LDID.LIST,CHG.PRC.OK
             IF CHG.PRC.OK THEN
                IF GLOBAL.BASN = '' THEN
                   GLOBAL.FORM = ''
                END
                CONVERT VM TO '' IN LINE.NOS
                LINE.IDS  = VM.EXPAND(LINE.NOS)
                OE.ITEM.PRICING.OVRD.UPD OID,GEN,QSIGN,LINE.IDS,LDIDS,APPLY.TO,PDATE,GLOBAL.BASN,GLOBAL.FORM,REP.OVR,LOG.MV
             END
          END
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
!TSMITH~09/07/16~12:48
