Compile Function NDW_RDS_Query_Events(CtrlEntId, Event, @PARAMS)
/***********************************************************************************************************************

    This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
    permission from Infineon.

    Name        :   NDW_RDS_Query_Events

    Description :   This function acts as a commuter module for all events related to this window.

    Notes       :   Commuter Modules are automatically called from the Promoted_Events function which is called by the
                    application-specific promoted event handler. This makes it possible to add QuickEvents that need to
                    execute Basic+ logic without having use the Form Designer to make the association, although this is
                    limited to the events which are currently promoted.

                    If the form needs to call the commuter module directly then the QuickEvent parameters should be
                    formatted like this:
`
                        '@SELF','@EVENT',['@PARAM1','@PARAMx']

    Parameters  :
        CtrlEntId   [in] -- The fully qualified name of the control calling the promoted event
        Event       [in] -- The event being executed. See the Notes section regarding "PRE" events
        Param1-15   [in] -- Additional event parameter holders
        EventFlow  [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
                            EVENT_SETUP insert

    History     :   (Date, Initials, Notes)
        09/08/22    djs     Created initial commuter module.
        11/10/23    djs     Added supplement column. Consolidated NDW_RDS_QUICK_QUERY and NDW_RDS_QUERY into
                            NDW_RDS_QUERY. Removed NDW_RDS_QUICK_QUERY. 

***********************************************************************************************************************/

#pragma precomp SRP_PreCompiler
#Window NDW_RDS_QUERY

$insert APP_INSERTS
$insert EVENT_SETUP
$insert WO_MAT_EQUATES
$insert MSG_EQUATES
$insert SUPPLEMENTS_EQUATES

equ WOCust$ to 2

Declare subroutine  SRP_Show_Window, Rds_Services, ErrMsg, Start_Window, Placedialog, Supplement_Services, Hold_Services
Declare subroutine Labeling_Services
Declare function    Database_Services, Material_Services, Rds_Services, RGB, SRP_Array, MemberOf, Supplement_Services
Declare function	Hold_Services, Datetime, Printer_Select

CRLF = \0D0A\ 

SubclassInfo    = Form_Services('FindSubclassControl')
Subclass        = SubclassInfo<1>

// Update the arguments so that the OpenInsight OLE event will treate the ActiveX event as a native event handler.
If Event EQ 'OLE' then
    Transfer Event to OIEvent
    Transfer Param1 to Event
    Transfer Param2 to Param1
    Transfer Param3 to Param2
    *    Transfer Param4 to Param3
    *    Transfer Param5 to Param4
    *    Transfer Param6 to Param5
    *    Transfer Param7 to Param6
    *    Transfer Param8 to Param7
end

GoToEvent Event for CtrlEntID

Return EventFlow else EVENT_CONTINUE$


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Event WINDOW.CREATE(CreateParam)
    
    KeyList = CreateParam<1>
    View    = CreateParam<2>
    View    = OConv(View, 'MCT')
    Swap @VM with @FM in KeyList
    Begin Case
        Case RowExists('WO_LOG', KeyList)
            ThisWorkOrderNo = KeyList
            RDSOverrideList = ''
        Case RowExists('RDS', KeyList)
            ThisWorkOrderNo = ''
            RDSOverrideList = KeyList
    End Case
    
    If View NE '' then
        Set_Property(@Window:'.RAG_VIEW', 'VALUE', View)
    end
    
    GoSub GetRdsColumns
    
    RDSList         = RDS_Services('GetRDSData', ThisWorkOrderNo, RDSColumns, True$, RDSOverrideList)   
    RDSRptCtrl      = @Window : '.OLE_RPT_RDS_LIST'
    
    OrigSize = Get_Property(@Window, 'SIZE')
    Set_Property(@Window, '@ORIG_SIZE', OrigSize)
    
    GoSub Setup_OLE_Controls
    
    // Turn off AutoPopulate for performance reasons
    Set_Property(RDSRptCtrl, 'OLE.AutoPopulate', False$)
    
    Set_Property(@Window:'.EDL_SEARCH', 'TEXT', ThisWorkOrderNo)
    
    // Turn AutoPopulate back on
    Set_Property(RDSRptCtrl, 'OLE.AutoPopulate', True$)
    Set_Property(RDSRptCtrl, "OLE.AlwaysShowSelection", True$)
    Send_Message(RDSRptCtrl, "OLE.UnselectAll")
    Send_Message(@Window, "SET_ZORDER", '')
    
    SRP_Show_Window(@Window, 'SYSTEM', 'C', 'C', False$, '', False$, False$, FormSize)
    // Show the form in the center of the screen
    Placedialog(-2, -2)
    
end event


Event WINDOW.CLOSE(CancelFlag)
    
    Result = ''
    // Perhaps add a savewarn prompt if list has been edited.
    End_Dialog(@Window, Result)
    
end event


Event PUB_OK.CLICK()
    
    SelRDSList = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
    SelRDSList = SRP_Array('Rotate', SelRDSList, @FM, @VM)
    RDSKeys    = SelRDSList<4>
    End_Dialog(@Window, RDSKeys)
    
end event


Event PUB_CANCEL.CLICK()
    
    Result = ''
    // Perhaps add a savewarn prompt if list has been edited.
    End_Dialog(@Window, Result)
    
end event


Event PUB_SELECT_ALL.CLICK()
    
    Send_Message(@Window : '.OLE_RPT_RDS_LIST', "OLE.SelectAll")
    Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.Focus', True$)
    
end event


Event PUB_CLEAR.CLICK()
    
    Send_Message(@Window : '.OLE_RPT_RDS_LIST', "OLE.UnselectAll")
    
end event


Event PUB_ENG_OPTIONS.CLICK()
    
    SelOpt = Popup(@Window, '', 'ENG_OPTIONS')
    
    If SelOpt NE '' then
        
        SelRDSList = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
        SelRDSList = SRP_Array('Rotate', SelRDSList, @FM, @VM)
        SelWO      = SelRDSList<2>
        SelCass    = SelRDSList<6>
        WOMatKeys  = ''
        If SelWO NE '' then
            For each WONo in SelWO using @VM setting vPos
                WOMatKeys<0, -1> = WONo:'*':SelCass<0 , vPos>
            Next WONo
        end
        
        NumRows = DCount(WOMatKeys, @VM)
        
        Begin Case
            
            Case SelOpt EQ 'CLEAN_INSP'
                
                Caption        = "Updating Clean & Insp specs for selected RDS cassettes..."
                ServiceModules = 'CLEAN_INSP_SERVICES'
                Services       = 'UpdateAllCleanInsp'
                
            Case SelOpt EQ 'QA_MET'
                
                Caption        = "Updating QA Metrology specs for selected RDS cassettes..."
                ServiceModules = 'WO_MAT_QA_SERVICES'
                Services       = 'UpdateQAMet'
                
            Case SelOpt EQ 'CLEAN_INSP':@VM:'QA_MET'
                Caption        = "Updating Clean & Insp and QA Metrology specs for selected RDS cassettes..."
                ServiceModules = 'CLEAN_INSP_SERVICES':@VM:'WO_MAT_QA_SERVICES'
                Services       = 'UpdateAllCleanInsp':@VM:'UpdateQAMet'
                
        End Case
        
        If ServiceModules NE '' then
            Def              = ""
            Def<MCAPTION$>   = Caption
            Def<MTYPE$>      = "GC"
            Def<MEXTENT$>    = NumRows
            Def<MTEXTWIDTH$> = 600
            MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
            For each WOMatKey in WOMatKeys using @VM setting vPos
                Running = Msg(@WINDOW, MsgUp, vPos, MSGINSTUPDATE$) ;* Update gas guage
                For each ServiceModule in ServiceModules using @VM setting sPos
                    Service = Services<0, sPos>
                    Ans     = Function(@ServiceModule(Service, WOMatKey))
                    If Error_Services('HasError') then
                        Error_Services('DisplayError')
                    end
                Next ServiceModule
            Next WOMatKey
            Msg(@WINDOW,MsgUp) ;* Take gas guage down
        end
        
        If Error_Services('NoError') then
            Def            = ""
            Def<MICON$>    = '*'
            Def<MCAPTION$> = 'Success'
            Def<MTEXT$>    = "Update complete!"
            Def<MTYPE$>    = "BO"
            MsgUp          = Msg(@window, Def)
        end
    end
    
end event


Event PUB_ON_HOLD.CLICK()
    
    SelPos           = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelPos')
    SelCount         = Dcount(SelPos, @VM)
    SelRDSList       = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
    SelRDSList       = SRP_Array('Rotate', SelRDSList, @FM, @VM)
    RDSKeys          = SelRDSList<4>
    Swap @VM with @FM in RDSKeys
    SelCount         = DCount(RDSKeys, @FM)
    WOMatKeys        = Xlate('RDS', RDSKeys, 'WO_MAT_KEY', 'X', '')
    Transition       = False$
    HoldEntity       = 'RDS' 
    HoldType         = 'HOLD'
    HoldData         = ''
    HoldData         = Dialog_Box('DIALOG_HOLD',@WINDOW,Transition:@FM:@FM:HoldType)
    If HoldData NE 'Cancel' then
        GoSub GetView
        Hold_Services('EnableMultipleHolds', WOMatKeys, HoldEntity, RDSKeys, 'NDW_RDS_QUERY', '', HoldData)
        IF Error_Services("HasError") THEN
            ErrCode = Error_Services("GetMessage")
            ErrMsg(errCode)
        end else
            MsgInfo = ''
            MsgInfo<MTYPE$> = 'BNY'
            MsgInfo<MTEXT$> = 'Hold Successful. Would you like to print label(s)?'
            MsgInfo<MICON$> = '!'
            PrintLabel = Msg(@WINDOW,MsgInfo,'')
            HoldBy = HoldData<1>
            Reason = HoldData<2>
            Stage = HoldData<4>
            Interrupted = HoldData<5>
            DTM = Datetime()
            If PrintLabel EQ True$ then
                PrinterId = Printer_Select(PrinterID)
            end
            For L = 1 to SelCount
                ThisPos = SelPos<L>
                If CurrentViewSelection _EQC 'quick' then
                    Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.ItemValue[16;' : ThisPos : ']', 'On Hold')
                end else
                    Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.ItemValue[19;' : ThisPos : ']', 'On Hold')
                end
                 PSN              = Xlate('RDS', RDSKeys<L>, 'PROD_SPEC_ID', 'X', '')
                 Reactor          = Xlate('RDS', RDSKeys<L>, 'REACTOR', 'X', '')
                 If PrintLabel EQ True$ then
                    Labeling_Services('PrintHoldLabel', HoldEntity, RDSKeys<L>, Stage, Reason, HoldBy, DTM, PSN, Reactor, Interrupted, PrinterId)
                 end
            Next L
            HoldOffFlag = True$
            HoldOnFlag  = False$
            Gosub CheckSelectedForHolds
        end
    end
    
end event


Event PUB_OFF_HOLD.CLICK()
    
    SelPos     = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelPos')
    SelCount   = Dcount(SelPos, @VM)
    SelRDSList = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
    SelRDSList = SRP_Array('Rotate', SelRDSList, @FM, @VM)
    RDSKeys    = SelRDSList<4>
    Swap @VM with @FM in RDSKeys
    SelCount   = DCount(RDSKeys, @FM)
    WOMatKeys  = Xlate('RDS', RDSKeys, 'WO_MAT_KEY', 'X', '')
    Transition = True$
    HoldType   = 'HOLD'
    HoldData   = ''
    HoldData   = Dialog_Box('DIALOG_HOLD',@WINDOW,Transition:@FM:@FM:HoldType)
    If HoldData NE 'Cancel' then
        GoSub GetView
        Hold_Services('DisableMultipleHolds', WOMatKeys, 'RDS', RDSKeys, 'NDW_RDS_QUERY', '', HoldData)
        For L = 1 to SelCount
            ThisPos = SelPos<L>
            If CurrentViewSelection _EQC 'quick' then
                Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.ItemValue[16;' : ThisPos : ']', 'Off Hold')
            end else
                Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.ItemValue[19;' : ThisPos : ']', 'Off Hold')
            end
        Next L
        HoldOffFlag = False$
        HoldOnFlag  = True$
        Gosub CheckSelectedForHolds
    end
    
end event


Event OLE_SUBCLASS.OnComboClick(CtrlId, Sel, Value)
    
    Send_Event(CtrlId, 'LOSTFOCUS')
    
end event


Event OLE_RPT_RDS_LIST.OnSelChange()
    
    If MemberOf(@User4, 'ENGINEERING') then
        SelRDSList = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
        Enabled    = (SelRDSList NE '')
        Set_Property(@Window:'.PUB_ENG_OPTIONS', 'ENABLED', Enabled)
    end
    HoldOnFlag  = False$
    HoldOffFlag = False$
    Gosub CheckSelectedForHolds
    
end event


Event PUB_RUN.CLICK()
    
    GoSub GetRdsColumns
    
    Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.List', '')
    Set_Property(@Window, '@OrigList', '')
    
    WoNo = ''
    
    SearchBy = Get_Property(@Window:'.RAG_SEARCH_BY', 'VALUE')
    SearchValue = Get_Property(@Window:'.EDL_SEARCH', 'TEXT')
    If SearchBy _EQC 'reactor' then
        ReactorConfigKey = 'WO_DAILY_SCHED':SearchValue
        WoNo = Field(Xlate('CONFIG', ReactorConfigKey, WOCust$, 'X'), ' ', 1)
    end
    
    If SearchBy _EQC 'wono' then
        WoNo = SearchValue
    end
    
    RDSList = ''
    If WoNo then
        RDSList = RDS_Services('GetRDSData', WoNo, RDSColumns, True$, '')
    end
    
    RDSRptCtrl      = @Window : '.OLE_RPT_RDS_LIST'
    
    GoSub Setup_OLE_Controls
    
    // Turn off AutoPopulate for performance reasons
    Set_Property(RDSRptCtrl, 'OLE.AutoPopulate', False$)
    
    SRP_Show_Window(@Window, 'SYSTEM', 'C', 'C', 1, '', False$, False$, FormSize)
    
    // Turn AutoPopulate back on
    Set_Property(RDSRptCtrl, 'OLE.AutoPopulate', True$)
    Set_Property(RDSRptCtrl, "OLE.AlwaysShowSelection", True$)
    Send_Message(RDSRptCtrl, "OLE.UnselectAll")
    Send_Message(@Window, "SET_ZORDER", '')
    
end event


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Setup_OLE_Controls:
    
    Qualify     = ''
    Qualify<1>  = 1
    Qualify<4>  = 0
    
    RDSRptCtrl          = @Window : '.OLE_RPT_RDS_LIST'
    RDSPicCtrl          = @Window : '.OLE_PIC_RDS_LIST_DIV'
    
    // Qualify OLE events that we want to intercept
    Qualifier = ''
    Qualifier<1> = 1
    Qualifier<4> = 0 ; * process synchronously (i.e. immediately)
    Send_Message(RDSRptCtrl, 'QUALIFY_EVENT', 'OLE.OnSelChange', Qualifier)
    
    GoSub GetColumnList
    
    Set_Property(RDSRptCtrl, 'OLE.ColumnList', ColumnList)
    Set_Property(RDSRptCtrl, 'OLE.MultiSelect', 2)  ; // 2 = Multiselect Toggle Mode
    
    NumCols = DCount(ColumnList, @FM)
    For ColIndex = 1 to NumCols
        Set_Property(RDSRptCtrl, "OLE.ColumnHeaderAlignment[":ColIndex:"]", 'C')
    Next ColIndex
    
    // Get the design time form size. This will be adjusted based on the number of RDS records.
    FormSize            = Get_Property(@Window, '@ORIG_SIZE')
    RDSRptCtrlSize      = Get_Property(RDSRptCtrl, 'SIZE')
    NumRDS              = DCount(RDSList, @FM)
    
    // Adjust the form and ReportTable control size based on the number of RDS records in the work order.
    AdditionalRowsAdj   = 0
    AdditionalRowsAdj += (NumRDS - 1) * 20
    
    // Ensure window and controls are sized within client machine's max resolution.
    ProposedNewHeight = FormSize<4> + AdditionalRowsAdj
    SystemWindowSize  = Get_Property('SYSTEM', 'SIZE')
    MaxClientHeight   = SystemWindowSize<4>
    If ProposedNewHeight > MaxClientHeight then
        FormSize<4> = Oconv(MaxClientHeight * '0.9', 'MD0')
    end else
        FormSize<4> = FormSize<4> + AdditionalRowsAdj
    end
    MaxClientWidth    = SystemWindowSize<3>
    If FormSize<3> > MaxClientWidth then
        FormSize<3> = Oconv(MaxClientWidth * '0.9', 'MD0')
    end
    Set_Property(@Window, '@ORIGSIZE', FormSize)
    GoSub GetExistingSupps
    // Pull then save original list after formatting for savewarn purposes
    Set_Property(RDSRptCtrl, 'OLE.List', RDSList)
    RDSList  = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.List')
    Set_Property(@Window, '@OrigList', RDSList)
    GoSub RefreshRowColors
    
return


RefreshRowColors:
    
    RDSRptCtrl  = @Window : '.OLE_RPT_RDS_LIST'
    NumRDS      = DCount(RDSList, @FM)
    
    // Fill report table with RDS data
    Set_Property(RDSRptCtrl, 'OLE.List', RDSList)
    
    // Color every other cell to increase row distinguishability
    Colors = ''
    If NumRDS GT 1 then
        For RowNo = 1 To NumRDS
            If Mod(RowNo, 2) EQ 1 then Colors<RowNo> = RGB(231, 243, 254) else Null ; // light blue       
        Next RowNo
        Set_Property(RDSRptCtrl, 'OLE.RecordColors', Colors)
    end
    
    // Clear any selected rows
    SelPos = ''
    Set_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelPos', SelPos)
    
return


GetRdsColumns:
    
    GoSub GetView
    
    If CurrentViewSelection _EQC 'quick' then
        RDSColumns        = ''
        RDSColumns<0, 1>  = 'ABBREV_OR_CO_NAME'
        RDSColumns<0, 2>  = 'WO'
        RDSColumns<0, 3>  = 'WO_STEP'
        RDSColumns<0, 4>  = 'SEQ'
        RDSColumns<0, 5>  = 'REACTOR'
        RDSColumns<0, 6>  = 'RUN_ORDER_NUM'
        RDSColumns<0, 7>  = 'UNLOAD_THICK_TEST'
        RDSColumns<0, 8>  = 'HGCV_TEST'
        RDSColumns<0, 9>  = 'DATE_IN'
        RDSColumns<0, 10> = 'TIME_IN'
        RDSColumns<0, 11> = 'DATE_OUT'
        RDSColumns<0, 12> = 'TIME_OUT'
        RDSColumns<0, 13> = 'PART_NUM'
        RDSColumns<0, 14> = 'LOT_NUM'
        RDSColumns<0, 15> = 'SUPPL_INST'
        RDSColumns<0, 16> = 'HOLD_STATUS'
    end else
        RDSColumns        = ''
        RDSColumns<0, 1>  = 'ABBREV_OR_CO_NAME'
        RDSColumns<0, 2>  = 'WO'
        RDSColumns<0, 3>  = 'WO_STEP'
        RDSColumns<0, 4>  = 'SEQ'
        RDSColumns<0, 5>  = 'REACTOR'
        RDSColumns<0, 6>  = 'RUN_ORDER_NUM'
        RDSColumns<0, 7>  = 'UNLOAD_THICK_TEST'
        RDSColumns<0, 8>  = 'HGCV_TEST'
        RDSColumns<0, 9>  = 'DATE_IN'
        RDSColumns<0, 10> = 'TIME_IN'
        RDSColumns<0, 11> = 'DATE_OUT'
        RDSColumns<0, 12> = 'TIME_OUT'
        RDSColumns<0, 13> = 'ELAPSED_HOURS'
        RDSColumns<0, 14> = 'PART_NUM'
        RDSColumns<0, 15> = 'LOT_NUM'
        RDSColumns<0, 16> = 'COMB_STATUS'
        RDSColumns<0, 17> = 'NCR_SUM'
        RDSColumns<0, 18> = 'NCR_REJ_CNT_SUM'
        RDSColumns<0, 19> = 'HOLD_STATUS'
        RDSColumns<0, 20> = 'SUPPL_INST'
    end
    
return


GetColumnList:
    
    GoSub GetView
    
    If CurrentViewSelection _EQC 'quick' then
        ColumnList     = ''
        ColumnList<1>  = 'Customer' : @VM : 'TEXT' : @VM : 120 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Left' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<2>  = 'WO No' : @VM : 'NUMBER' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Center' : @VM : @VM : '#######' : @VM : @VM : 'Segoe UI,9'
        ColumnList<3>  = 'Step' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : '##': @VM : @VM : 'Segoe UI,9'
        ColumnList<4>  = 'RDS' : @VM : 'NUMBER' : @VM : 60 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : '###' : @VM : @VM : 'Segoe UI,9'
        ColumnList<5>  = 'Rx' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Center' : @VM : @VM : '#######' : @VM : @VM : 'Segoe UI,9'
        ColumnList<6>  = 'Run' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 25 : @VM : 'Center' : @VM : @VM :'##': @VM : @VM : 'Segoe UI,9'
        ColumnList<7>  = 'UL Thk' : @VM : 'BOOL' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : 'Yes' : @VM : @VM : 'Segoe UI,9'
        ColumnList<8>  = 'HgCv' : @VM : 'BOOL' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : 'Yes' : @VM : @VM : 'Segoe UI,9'
        ColumnList<9>  = 'Date In' : @VM : 'DATE' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'MM/DD/YY' : @VM : @VM : 'Segoe UI,9'
        ColumnList<10> = 'Time In' : @VM : 'TIME' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'hh:mmAA' : @VM : @VM : 'Segoe UI,9'
        ColumnList<11> = 'Date Out' : @VM : 'DATE' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'MM/DD/YY': @VM : @VM : 'Segoe UI,9'
        ColumnList<12> = 'Time Out' : @VM : 'TIME' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'hh:mmAA': @VM : @VM : 'Segoe UI,9'
        ColumnList<13> = 'Cust Part No' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<14> = 'Lot Number' : @VM : 'TEXT' : @VM : 80 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<15> = 'Supplement' : @VM : 'P' : @VM : 160 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<16> = 'Hold Status' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
    end else
        ColumnList     = ''
        ColumnList<1>  = 'Customer' : @VM : 'TEXT' : @VM : 120 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Left' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<2>  = 'WO No' : @VM : 'NUMBER' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Center' : @VM : @VM : '#######' : @VM : @VM : 'Segoe UI,9'
        ColumnList<3>  = 'Step' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : '##': @VM : @VM : 'Segoe UI,9'
        ColumnList<4>  = 'RDS' : @VM : 'NUMBER' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : '###' : @VM : @VM : 'Segoe UI,9'
        ColumnList<5>  = 'Rx' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Center' : @VM : @VM : '#######' : @VM : @VM : 'Segoe UI,9'
        ColumnList<6>  = 'Run' : @VM : 'NUMBER' : @VM : 30 : @VM : @VM : @VM : @VM : @VM : @VM : 25 : @VM : 'Center' : @VM : @VM :'##': @VM : @VM : 'Segoe UI,9'
        ColumnList<7>  = 'UL Thk' : @VM : 'BOOL' : @VM : 55 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : 'Yes' : @VM : @VM : 'Segoe UI,9'
        ColumnList<8>  = 'HgCv' : @VM : 'BOOL' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : 'Yes' : @VM : @VM : 'Segoe UI,9'
        ColumnList<9>  = 'Date In' : @VM : 'DATE' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'MM/DD/YY' : @VM : @VM : 'Segoe UI,9'
        ColumnList<10> = 'Time In' : @VM : 'TIME' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'hh:mmAA' : @VM : @VM : 'Segoe UI,9'
        ColumnList<11> = 'Date Out' : @VM : 'DATE' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'MM/DD/YY': @VM : @VM : 'Segoe UI,9'
        ColumnList<12> = 'Time Out' : @VM : 'TIME' : @VM : 50 : @VM : @VM : @VM : @VM : @VM : @VM : 60 : @VM : 'Center' : @VM : @VM : 'hh:mmAA': @VM : @VM : 'Segoe UI,9'
        ColumnList<13> = 'Elapsed Hours' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 50 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<14> = 'Cust Part No' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<15> = 'Lot Number' : @VM : 'TEXT' : @VM : 100 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<16> = 'Combined Status' : @VM : 'TEXT' : @VM : 125 : @VM : @VM : @VM : @VM : @VM : @VM : 125 : @VM : 'Left' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<17> = 'NCR Status' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<18> = 'NCR Wfr Cnt' : @VM : 'NUMBER' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 30 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<19> = 'Hold Status' : @VM : 'TEXT' : @VM : 75 : @VM : @VM : @VM : @VM : @VM : @VM : 40 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
        ColumnList<20> = 'Supplement' : @VM : 'P' : @VM : 160 : @VM : @VM : @VM : @VM : @VM : @VM : 75 : @VM : 'Center' : @VM : @VM : @VM : @VM : 'Segoe UI,9'
    end
    
return


GetView:
    
    CurrentViewSelection = Get_Property(@Window:'.RAG_VIEW', 'VALUE')
    
return


GetExistingSupps:
    
    Gosub GetView
    NumRDS        = DCount(RDSList, @FM)
    SuppsWithLots = Supplement_Services('GetLotsWithSupplements', 'RDS')
    For I = 1 to NumRDS
        RDSSupps  = ''
        ThisRDS   = RDSList<I, 4>
        If Count(SuppsWithLots, ThisRDS) NE 0 then
            SuppCheck = Supplement_Services('GetSupplementsForLot', 'RDS', ThisRDS)
            If SuppCheck NE '' AND SuppCheck NE False$ then
                SuppCount = DCount(SuppCheck, @FM)
                For J = 1 to SuppCount
                    CurrSuppStage = Xlate('SUPPLEMENTS', SuppCheck<J>, SUPPLEMENTS_STAGE$, 'X', '')
                    CurrSuppText  = Xlate('SUPPLEMENTS', SuppCheck<J>, SUPPLEMENTS_SUPPL_TEXT$, 'X', '')
                    If RDSSupps EQ '' then
                        RDSSupps = CurrSuppStage: ': ' : CurrSuppText
                    End else
                        RDSSupps := CRLF : CurrSuppStage: ': ' : CurrSuppText
                    end
                Next J
            end
            If RDSSupps NE '' then
                If CurrentViewSelection _EQC 'quick' then
                    RDSList<I,15> = RDSSupps
                end else
                    RDSList<I,20> = RDSSupps
                end
            end 
        End
    Next I
    
return


CheckSelectedForHolds:
    
    If Unassigned(HoldOnFlag) then  HoldOnFlag = False$
    If Unassigned(HoldOffFlag) then  HoldOffFlag = False$
    SelRDSList = Get_Property(@Window : '.OLE_RPT_RDS_LIST', 'OLE.SelList')
    If SelRDSList NE '' then
        SelRDSList = SRP_Array('Rotate', SelRDSList, @FM, @VM)
        RDSKeys    = SelRDSList<4>
        Swap @VM with @FM in RDSKeys
        SelCount   = DCount(RDSKeys, @FM)
        
        For K = 1 to SelCount
            WOMatKey  = Xlate('RDS', RDSKeys<K>, 'WO_MAT_KEY', 'X', '')
            HoldCheck = Hold_Services('CheckForHold', WOMatKey, '')
            If HoldCheck EQ True$ AND HoldOffFlag EQ False$ then
                HoldOffFlag = True$
            end
            If HoldCheck EQ False$ AND HoldOnFlag EQ False$ then
                HoldOnFlag = True$
            end
        Until HoldOnFlag EQ True$ and HoldOffFlag  EQ True$ 
        Next K
    end
    if MemberOf(@USER4, 'ENG_TECH') OR MemberOf(@USER4, 'LEAD') OR MemberOf(@USER4, 'SUPERVISOR') then
        // IF ANY SELECTED LOTS ARE ON HOLD, ENABLE PUB_OFF_HOLD
        Set_Property(@Window:'.PUB_OFF_HOLD', 'ENABLED', HoldOffFlag)
    end else
        Set_Property(@Window:'.PUB_OFF_HOLD', 'ENABLED', False$)
    end
    // IF ANY SELECTED LOTS ARE NOT ON HOLD, ENABLE PUB_ON_HOLD 
    Set_Property(@Window:'.PUB_ON_HOLD', 'ENABLED', HoldOnFlag)
    
return

