Function RDS_PRE_EPI_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        :   RDS_Pre_Epi_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)
        08/13/19    djs     Created initial commuter module and began moving script evebts into commuter module.
        06/13/24	djm		Add new stage-specific supplement system.
                            

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

#pragma precomp SRP_PreCompiler
#Window RDS_PRE_EPI

$insert APP_INSERTS
$insert EVENT_SETUP
$insert MSG_EQUATES
$insert RDS_EQUATES
$insert LSL_USERS_EQUATES
$insert PROD_SPEC_EQUATES
$insert WO_MAT_EQUATES
$insert SURFACE_SCAN_EQUATES
$insert REACTOR_EQUATES
$insert PRS_STAGE_EQUATES
$insert COMPANY_EQUATES
$insert WO_MAT_QA_EQUATES
$insert REACT_STATUS_EQUATES
$insert SUPPL_INFO_ARRAY_EQU
$insert CLEAN_INSP_EQUATES

EQU READONLY_GREEN$ TO 192 + (220*256) + (192*65536)

Equ COL$LOG_FILE        to 1
Equ COL$LOG_DTM         to 2
Equ COL$ACTION          to 3
Equ COL$WH_CD           to 4
Equ COL$LOC_CD          to 5
Equ COL$WO_NOS          to 6
Equ COL$CASS_NOS        to 7
Equ COL$USER_ID         to 8
Equ COL$TAGS            to 9
Equ COL$TOOL_ID         to 10

Declare subroutine ErrMsg, Set_Status, obj_WO_Mat, obj_WO_Mat_Log, obj_RDS, Set_Property, Send_Event, Database_Services
Declare subroutine Qa_Services, RDS_Services, Dialog_Box
Declare function   Dialog_Box, Msg, MemberOf, obj_WO_Mat, Database_Services, Get_Property, obj_React_Status, Get_Status
Declare function   QA_Services, Database_Services, Supplement_Services

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)

end event


Event WINDOW.READ()
    // Disable reactor edit line control if the RDS has been loaded.
    RDSNo = Get_Property(@Window:'.RDS_NO', 'TEXT')
    If RDSNo NE '' then
        LoadSig = Xlate('RDS', RDSNo, 'OPERATOR_IN', 'X')
        If LoadSig NE '' then
            Set_Property(@Window:'.REACTOR', 'ENABLED', False$)
            Set_Property(@Window:'.REACTOR', 'BACKCOLOR', READONLY_GREEN$)
        end
    end
end event


Event WINDOW.CLOSE(CancelFlag)
    
end event


Event WINDOW.CLEAR(bSaveKey, bSuppressWarning, bMaintainFocus, CtrlIDFocus)

end event


Event SUPPL_BUTTON.CLICK()
    
    RDSNo = Get_Property(@Window:'.RDS_NO', 'TEXT')
    Dialog_Box('NDW_RDS_SUPP_SIG', @Window, RDSNo :@FM: 'VER' :@FM: FALSE$)
    
end event


Event PUB_SIGN.CLICK()

    RDSNo            = Get_Property(@Window:'.RDS_NO'    ,'DEFPROP')
    WfrQty           = Get_Property(@Window:'.VERIFY_QTY','TEXT')
    Reactor          = Get_Property(@Window:'.REACTOR'   ,'TEXT')
    PREInstAckReq    = Xlate('RDS', RDSNo, 'PRE_INST_ACK_REQ', 'X')
    PreAuthenticated = FALSE$
    If PreInstAckReq EQ True$ then
        RDS_Services('RDSVerifyInst', RDSNo, 'PRE')
    end
    SupplAckReq = Supplement_Services('UnacknowledgedSupplementCheck', 'RDS', RDSNo, 'VER')
	IF (SupplAckReq NE FALSE$) then
		Response = Dialog_Box('NDW_RDS_SUPP_SIG', @Window, RDSNo :@FM: 'VER' :@FM: FALSE$)
		If Response EQ False$ then
			return
		end else
			PreAuthenticated = TRUE$
		end
	end
    ReadyToSign = QA_Services('PreEpiSignatureReady', RDSNo, @User4, WfrQty, Reactor)
    If (ReadyToSign EQ True$) then
    	If PreAuthenticated EQ FALSE$ then
        Response    = Dialog_Box('NDW_VERIFY_USER', @WINDOW)
        Valid       = Response<1>
        If (Valid EQ True$) then
				QA_Services('SignPreEpiStage', RDSNo, @USER4, WfrQty, Reactor) 
			end
		end else
			QA_Services('SignPreEpiStage', RDSNo, @USER4, WfrQty, Reactor) 
        end
    end
    If Error_Services('HasError') then
        ErrorMsg = Error_Services('GetMessage')
        ErrMsg(ErrorMsg)
    end
    Set_Property(@Window, 'SAVEWARN', False$)
    Set_Status(0)
    Send_Event(@Window, 'READ')
    
end event


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

