Function RDS_Post_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_Post_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)
        04/11/18    dmb     Created initial commuter module.
        06/13/18    djs     Added Verify Wafer Quantity section within Sign Button click event. This section of code
                            checks to see if the quantities of Wafers Out and Scheduled Wafers are equal. If not,
                            then a member of the group 'LEAD' or group 'SUPERVISOR' must override the discrepancy.
                            Updated Sign Button click event to use the current user verification form, NDW_VERIFY_USER,
                            instead of QUOTE_SIG_PWD_ENTRY which has been deprecated.
        09/19/18    djs     Added an ROTR check to verify that the total quantity of NCR wafers is greater than or equal
                            to the quantity of wafers above the USL threshold. (In development wrapper)
        01/22/19    djs     Added a simple check to verify that metrology data exists in order to allow FQA signature.
                            See "Verify RDS_TEST record has measurement data" section.
        06/13/24	djm		Add new stage-specific supplement system.
        02/13/25    djm     Removed override requirement for makeup boxes to resolve ADO item 255463.  
                            

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

#pragma precomp SRP_PreCompiler
#Window RDS_POST_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 WAFER_COUNTER_EQUATES


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

Equ COL$MET_TEST        to 1    ; // QA Metrology control on RDS_UNLOAD & RDS_POST_EPI windows
Equ COL$MET_TEST_DESC   to 2
Equ COL$MET_SLOT        to 3
Equ COL$MET_SLOT_DESC   to 4
Equ COL$MET_WFR_QTY     to 5
Equ COL$MET_MIN         to 6
Equ COL$MET_MAX         to 7
Equ COL$MET_RESULT      to 8
Equ COL$MET_STD_MAX     to 9
Equ COL$MET_STD_RESULT  to 10
Equ COL$MET_SIG         to 11
Equ COL$MET_SIG_DTM     to 12

EQU APPGREEN$  TO 192 + (220*256) + (192*65536)
EQU APPRED$    TO 255 + (128*256) + (128*65536)
EQU APPORANGE$ TO 255 + (176*256) + (0*65536)

Declare subroutine  ErrMsg, Set_Status, obj_WO_Mat, obj_WO_Mat_Log, obj_RDS, RDS_Services, Signature_Services, obj_Notes
Declare subroutine  Comm_RDS, WO_Mat_QA_Services, Wafer_Counter_Services, Dialog_Box, Lot_Event_Services
Declare function    Dialog_Box, Msg, MemberOf, obj_WO_Mat, Database_Services, QA_Services, Signature_Services
Declare function    RDS_Services, Wafer_Counter_Services, Datetime, 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)
    
    GoSub Setup_OLE_Controls

    SRP_Show_Window(@Window, '', 'C', 'C', 1, '', False$, False$)

end event


Event WINDOW.READ()

end event


Event WINDOW.CLOSE(CancelFlag)

end event


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

    Set_Property(@Window, '@ORIG_WFR_CTR_QTY', '')
	Set_Property(@WINDOW:'.EDL_WAFER_COUNTER_QTY','BACKCOLOR', APPGREEN$)

end event


Event WINDOW.WRITE()

end event


Event SIGN_BUTTON.CLICK()
	
	RDSNo            = Get_Property(@Window:'.RDS_NO', 'TEXT')
	Valid            = ''    
	CurRdsNo         = Get_Property(@WINDOW:'.RDS_NO',      'DEFPROP')
	WONo             = Get_Property(@WINDOW:'.WO',          'DEFPROP')
	CassNo           = Get_Property(@WINDOW:'.CASS_NO',     'DEFPROP')
	WOStep           = Get_Property(@WINDOW:'.WO_STEP',     'DEFPROP')
	ReactorType      = Get_Property(@WINDOW:'.REACTOR_TYPE','DEFPROP')
	PreAuthenticated = FALSE$
	
	If RDSNo NE '' then
        SigReady = QA_Services('PostEpiSignatureReady', RDSNo, @User4)
        If Not(SigReady) then
            Error_Services('DisplayError')
            return
        end
	end
	
	******************************************
	* Update the form with signature, if any *
	******************************************
	CurrSig  = ''
	CurrDTM  = ''
	CurrDate = ''
	CurrTime = ''
	
	
	*********************************************
	* Verify if the FQA has already been signed *
	*********************************************
	IF Not(MemberOf(@USER4,'BYPASS')) THEN
		IF (CurrSig NE '') THEN
			ErrMsg('Supervisor Verification for this material has already been signed.')
			RETURN
		END
	END
	
	***************************************
	* Verify Metrology has been completed *
	***************************************
	Set_Status(0)
	obj_WO_Mat('MQAComp',WONo:'*':CassNo:@RM:WOStep:@RM:'QA')
	errCode = ''
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END
	
	***********************************************
	* Verify RDS_TEST record has measurement data *
	***********************************************
	ThickAvg = Xlate('RDS', CurRdsNo, 'TTHICK_AVG_ALL', 'X')
	If ThickAvg EQ '' then
		ErrMsg('RDS metrology measurement data is missing. FQA cannot be signed.')
		Return
	end
	ResAvg = Xlate('RDS', CurRdsNo, 'TRES_AVG_ALL', 'X')
	If ResAvg EQ '' then
		ErrMsg('RDS Resistivity measurement data is missing. FQA cannot be signed.')
		Recipients     = XLATE('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
		SentFrom       = 'OI Admin'
		Subject        = 'Missing Resistivity Avg data'
		Message        = CurRdsNo: ' failed FQA due to missing resistivity average data.'
		AttachWindow   = ''
		AttachKey      = ''   
		SendToGroup    = ''   
		Parms          = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
		obj_Notes('Create',Parms) 
		Return
	end

	************************************************
	* Verify QA Supplement has been fulfilled *
	************************************************
	
	SupplAckReq = Supplement_Services('UnacknowledgedSupplementCheck', 'RDS', RDSNo, 'QA')
	IF (SupplAckReq NE FALSE$) then
		Response = Dialog_Box('NDW_RDS_SUPP_SIG', @Window, RDSNo :@FM: 'QA' :@FM: FALSE$)
		If Response EQ False$ then
			return
		end else
			PreAuthenticated = TRUE$
		end
	end
	************************************************
	* Verify Signatures Profile has been fulfilled *
	************************************************
	
	WOMatKey = WONo:'*':CassNo
	Signature_Services('CheckSigOrder', WOMatKey, 'QA')
	If Error_Services('HasError') then            
		ErrMsg(Error_Services('GetMessage'))
		return 0
	end
	
	
	Signature_Services('FQAReady', WOMatKey)
	If Error_Services('HasError') then
		ErrMsg(Error_Services('GetMessage'))
		Return 0
	end   
	
	RDSNo          = Get_Property(@Window : '.RDS_NO','DEFPROP')
	****************************************
	* Verify the Wafer Counter information *
	****************************************
	WafersOut       = Get_Property(@WINDOW:'.WAFERS_OUT','TEXT')        
	WaferCounterQty = Get_Property(@WINDOW:'.EDL_WAFER_COUNTER_QTY','DEFPROP')
	
	*************************************
	* Wafer Counter -  Quantity Section *
	*************************************
	If (WaferCounterQty NE '') then
		If (WaferCounterQty NE WafersOut) then
			ErrMsg('Unable to sign FQA because Wafer Counter and Wafers Out quantities do not match.')
			RETURN 0
		end
	end else
		ErrMsg('Unable to sign FQA because the Wafer Counter quantity is missing.')
		RETURN 0
	end
	
	***********************************
	* Verify Scheduled Wafer Quantity *
	***********************************
	CassSchedWafers = Get_Property(@Window : '.WAFERS_SCHEDULED', 'TEXT')
	WafersOut       = Get_Property(@Window : '.WAFERS_OUT', 'TEXT')
	MakeupBox       = Xlate('RDS', RDSNo, 'MAKEUP_BOX', 'X')
	
	If ( (MakeupBox NE True$) and (CassSchedWafers NE WafersOut) ) then
		Title     = 'Process Error'
		ErrorMsg  = 'Scheduled Wafers Quantity does not equal the Wafers Out Quantity.'
		Response  = Msg(@Window, '', 'OK', '', Title:@FM:ErrorMsg)
		return
	end
	
	*********************************
	* Verify NCR total >= USL Fails *
	*********************************
	ReactorNo   = Get_Property(@Window : '.REACTOR', 'TEXT')
	ROTREnabled = Xlate('REACTOR', ReactorNo, 'ENABLE_ROTR', 'X')
	If (ROTREnabled EQ True$) then
		RDSKey        = Get_Property(@Window : '.RDS_NO', 'TEXT')
		// Backlog Req 731 - ROTR POST Stage Supercede
		// If POST surfscan ROTR is passing, then use the number of failed wafers from that result
		// as the min number of NCRd wafers required to FQA the cassette.
		LWICIKey      = Xlate('RDS', RDSKey, 'LWI_CI_NO', 'X')
		PostSupercede = Xlate('RDS', RDSKey, 'POST_SUPERCEDE', 'X')
		CIKey         = LWICIKey
		If PostSupercede then 
			PostCIKey     = Xlate('RDS', RDSKey, 'POST_CI_NO', 'X')
			If PostCIKey NE '' then
				CIKey = PostCIKey
			end
		end else
			CIKey = LWICIKey
		end
		
		NumUSLFailValues  = Xlate('CLEAN_INSP', CIKey, 'NUM_FAILED_WAFERS', 'X')
		NumUSLFailCount   = COUNT(NumUSLFailValues,@VM) + (NumUSLFailValues NE '')
		NumUSLFail        = NumUSLFailValues<1,NumUSLFailCount>
		If NumUSLFail EQ '' then NumUSLFail = 0
		TotalNCR    = Xlate('RDS', RDSKey, 'TOT_REJ', 'X')
		If TotalNCR EQ '' then TotalNCR = 0
		
		If NumUSLFail GT TotalNCR then
			Message     = 'Unable to sign FQA because the total quantity of NCR wafers':CRLF$:'is less than the '|
			: 'number of wafers above the USL threshold.' : CRLF$ : 'A lead or supervisor must override.'
			LeadMessage = 'Total quantity of NCR wafers is less than the number of wafers above the USL threshold.'
			
			If NOT( MemberOf(@USER4, 'LEAD') OR MemberOf(@USER4, 'SUPERVISOR') ) then
				Response = Msg(@Window, '', 'POST_EPI_WAFER_OUT', '', Message)
			end else
				Response = Msg(@Window, '', 'POST_EPI_WAFER_OUT', '', LeadMessage)
			end
			
			Begin Case
				Case Response EQ 1
					Response = True$        ; // User Clicked Override
				Case Response EQ 2
					Response = False$       ; // User Clicked Cancel
				Case Response EQ char(27)
					Response = False$       ; // User Pressed Escape Key
			End Case            
			
			If Response EQ True$ then
				Response    = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:'LEAD':@VM:'SUPERVISOR':@VM:'ENGINEER')
				Valid       = Response<1>
				If NOT(Valid) then Return
			end else
				Return
			end
		end
	end
	
	
	********************************************
	* Verify NCR wafer qty >= Failed wafer qty *
	********************************************
	
	NCRReq = QA_Services('GetNCRRequired', WOMatKey)
	If NCRReq then
		Message     = 'Unable to sign FQA because the total quantity of NCR wafers':CRLF$:'is less than the '|
		: 'number of wafers that failed surfscan.' : CRLF$ : 'A lead or supervisor must override.'
		LeadMessage = 'Total quantity of NCR wafers is less than the number of wafers that failed surfscan.'
		
		If NOT( MemberOf(@USER4, 'LEAD') OR MemberOf(@USER4, 'SUPERVISOR') ) then
			Response = Msg(@Window, '', 'POST_EPI_WAFER_OUT', '', Message)
		end else
			Response = Msg(@Window, '', 'POST_EPI_WAFER_OUT', '', LeadMessage)
		end
		
		Begin Case
			Case Response EQ 1
				Response = True$        ; // User Clicked Override
			Case Response EQ 2
				Response = False$       ; // User Clicked Cancel
			Case Response EQ char(27)
				Response = False$       ; // User Pressed Escape Key
		End Case            
		
		If Response EQ True$ then
			Response    = Dialog_Box('NDW_VERIFY_USER', @WINDOW, @USER4:@FM:'LEAD':@VM:'SUPERVISOR':@VM:'ENGINEER')
			Valid       = Response<1>
			If NOT(Valid) then Return 0
		end else
			Return
		end
	end
	
	
	*************************
	* Verify if Shift exist *
	*************************
	IF (Get_Property(@WINDOW:'.SHIFT','DEFPROP') = '') THEN
		ErrMsg('Process Error':@SVM:'Shift is required before signing.')
		RETURN
	END
	
	****************************
	* Verify if lot is on Hold *
	****************************
	WOMatCurrStatus = obj_WO_Mat('CurrStatus',WONo:'*':CassNo)
	IF WOMatCurrStatus = 'HOLD' THEN
		ErrMsg('Process Error':@SVM:'Cassette is on Hold and may not be signed off.':CRLF$:CRLF$)
		RETURN
	END
	
	**********************
	* Check ROTR Failure *
	**********************
	ROTRAction  = Get_Property(@Window : '.ROTR_ACTION', 'INVALUE')
	If (ROTRAction NE 'Passed') AND (ROTRAction NE 'Accepted') AND (ROTRAction NE '') then
		ErrMsg('Process Error':@SVM:'ROTR does not meet all requirements.':CRLF$:CRLF$)
		return
	end
	
	***************************************
	* Verify Metrology has been completed *
	***************************************
    // Added QA met sig check to ensure it matches the user attempting to sign FQA.
    // If it does not match, then clear the QA met signatures to force QA metrology to be re-verified.
    
    CtrlName = @WINDOW:'.MET_TEST'
    MetList = Get_Property(CtrlName,'LIST')
    MLCnt = COUNT(MetList,@FM) + (MetList NE '')
    FOR Line = 1 TO MLCnt
        IF MetList<Line,COL$MET_TEST> NE '' THEN
            BEGIN CASE
                Case ( ( MetList<Line,COL$MET_SIG> NE '') and (MetList<Line,COL$MET_SIG> NE @User4) )
                    ErrMsg('Process Error':@SVM:'QA Metrology results were signed by another technician. QA Metrology results must be signed by FQA technician.')
                    WO_Mat_QA_Services('ClearResultsByStage', WONo:'*':CassNo, 'QA')
                    Post_Event(@Window, 'READ')
                    RETURN                    
                CASE ((MetList<Line,COL$MET_MIN> = '') AND (MetList<Line,COL$MET_MAX> = ''))
                    NULL
                CASE (MetList<Line,COL$MET_RESULT> = '')
                    ErrMsg('Process Error':@SVM:'Required QA Metrology results have not been entered.')
                    RETURN
                CASE ((MetList<Line,COL$MET_RESULT> < MetList<Line,COL$MET_MIN>) OR (MetList<Line,COL$MET_RESULT> > MetList<Line,COL$MET_MAX>))
                    ErrMsg('Process Error':@SVM:'One or more QA Metrology results is out of specification.')
                    RETURN
                CASE ((MetList<Line,COL$MET_RESULT> NE '') AND (MetList<Line,COL$MET_SIG> = ''))
                    ErrMsg('Process Error':@SVM:'One or more QA Metrology results are not signed off.')
                    RETURN
            END CASE
        END    ;* End of check for a test requirement on the line
    NEXT Line
    
    ******************************************
    * Verify Unload Stage QA Metrology Tests *
    ******************************************
	WONo        = Get_Property(@WINDOW:'.WO','DEFPROP')
	CassNo      = Get_Property(@WINDOW:'.CASS_NO','DEFPROP')
	WOMatQAKey  = WONo : '*' : CassNo
	WOMatQARec  = Database_Services('ReadDataRow', 'WO_MAT_QA', WOMatQAKey)
	OutOfSpec   = WOMatQARec<WO_MAT_QA_OUT_OF_SPEC$>
	OutOfSpec   = Sum(OutOfSpec)
	If OutOfSpec GT 0 then
		FailReasons = WOMatQARec<WO_MAT_QA_FAIL_REASON$>
		ErrorMsg = 'Process Error':@SVM
		For each FailReason in FailReasons using @VM
			ErrorMsg := FailReason:CRLF$
		Next FailReason
		ErrMsg(ErrorMsg)
		Return
	end

    *******************************************
    * Verify if all steps have been completed *
    *******************************************
    PsnNo     = Get_Property(@WINDOW:'.PSN','TEXT')
    CurRdsNo  = Get_Property(@WINDOW:'.RDS_NO','TEXT')
    WONo      = Get_Property(@WINDOW:'.WO','TEXT')
    WOStep    = Get_Property(@WINDOW:'.WO_STEP','TEXT')
    CassNo    = Get_Property(@WINDOW:'.CASS_NO','TEXT')
    Reactor   = Get_Property(@WINDOW:'.REACTOR','DEFPROP')
    WOMatRec  = XLATE('WO_MAT',WONo:'*':CassNo,'','X')
    RDSNos    = WOMatRec<WO_MAT_RDS_NO$>
    MakeupBox = WOMatRec<WO_MAT_MAKEUP_BOX$>

    LOCATE CurRdsNo IN RDSNos USING @VM SETTING Pos THEN
        NextRDS = RDSNos<1,Pos+1>
    END ELSE
        NextRDS = ''
    END
            
    IF (WOMatCurrStatus NE 'QA' AND WOMatCurrStatus NE 'PSTI' AND WOMatCurrStatus NE 'COMP') AND (NextRDS NE '' AND WOMatCurrStatus NE 'VER') THEN
        ErrorMessage  = 'Process Error':@SVM:'Run is not ready for final QA.':CRLF$:CRLF$
        ErrorMessage := 'The ':OCONV(WOMatCurrStatus,'[WO_MAT_CURR_STATUS_CONV]'):' step is not complete.'
        ErrMsg(ErrorMessage)
        RETURN
    END
        
    IF NOT(MemberOF( @USER4, 'SUPERVISOR' ) OR MemberOf( @user4, 'LEAD' ) OR MemberOf( @USER4, 'FINAL_QA' ) ) THEN
        ErrMsg('Process Error':@SVM:'You must be a supervisor to verify this RDS.')
        RETURN
    END
        
    ************************************************************************
    * Prompt user to validate the Process Specification Stage Instructions *
    ************************************************************************
    PSNo = Get_Property(@WINDOW:'.PSN','TEXT')
    VerInst = XLATE('PRS_STAGE',PSNo:'*QA',PRS_STAGE_INST$,'X')
    VerInst = TRIM(VerInst)
    IF LEN(VerInst) > 5 THEN
        Yes = Dialog_Box( 'RDS_VER', @WINDOW, VerInst )
        IF NOT(Yes) THEN
            RETURN
        END
    END

	************************************************************************
	* Pop-up read only supplement screen for review *
	************************************************************************
	RDSNo      = Get_Property(@Window:'.RDS_NO', 'TEXT')
	SuppStages = Supplement_Services('GetStagesWithSupplements', 'RDS', RDSNo)
	
	If SuppStages NE FALSE$ AND SuppStages  NE 'QA' then
		Dialog_Box('NDW_RDS_SUPP_SIG', @Window, RDSNo :@FM: '' :@FM: TRUE$)
	end
	
    **************************
    * Verify user's password *
    **************************
    
    // Check if user has already been verified above to avoid prompting for password twice
	
	If Valid EQ '' Then
		If PreAuthenticated EQ FALSE$ then
			Response    = Dialog_Box('NDW_VERIFY_USER', @WINDOW)
			Valid       = Response<1>
		end else
			Valid = TRUE$
		end
	end       

    IF (Valid) THEN
        
        Signature_Services('SignPostEpiStage', RDSNo, @User4)
        If Error_Services('NoError') then
            SigDt         = OCONV( Date(), 'D2/' )
            SigTm         = Time()
            SigTmPlusOne  = OCONV(SigTm + 1, 'MTS' )
            SigTmPlusTwo  = OCONV(SigTm + 2, 'MTS' )
            SigTmPlusFive = OCONV(SigTm + 5, 'MTS' )
            SigTmPlusTen  = OCONV(SigTm + 10, 'MTS' )
            SigTm         = OCONV(SigTm,'MTS')
            SigBy         = @USER4
            WOStep        = Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
            PostLPDs      = Get_Property(@WINDOW:'.LPD_POSTCLEAN','DEFPROP')
            Brightlight   = Get_Property(@WINDOW:'.BRIGHTLIGHT','CHECK')
            Microscope    = Get_Property(@WINDOW:'.MICROSCOPE','CHECK')
            EventParms    = ''
            EventCnt      = 1
                              
            IF ReactorType NE 'EPP' THEN
            
                ToolID = ''
                WHCd   = 'CR'
                LocCD  = 'QA'
                Tag    = ''

                EventParms<COL$LOG_FILE> = 'WO_MAT'
                EventParms<COL$LOG_DTM>  = SigDt:' ':SigTm
                EventParms<COL$ACTION>   = WOStep:'QA'
                EventParms<COL$WH_CD>    = 'CR'
                EventParms<COL$LOC_CD>   = 'QA'
                EventParms<COL$WO_NOS>   = WONo
                EventParms<COL$CASS_NOS> = CassNo
                EventParms<COL$USER_ID>  = @USER4
                EventParms<COL$TAGS>     = ''
                EventParms<COL$TOOL_ID>  = ''
                
                CONVERT @FM TO @RM IN EventParms
                
                obj_WO_Mat_Log('Create',EventParms)        ;* * * * * INV EVENT LOG * * * * *
                
                IF Get_Status(errCode) THEN
                    CALL ErrMsg(ErrCode)
                    RETURN
                END
                
                IF MakeupBox = 1 THEN
                    
                    EventParms<COL$LOG_FILE> = 'WO_MAT'
                    EventParms<COL$LOG_DTM>  = SigDt:' ':SigTmPlusTwo
                    EventParms<COL$ACTION>   = 'RTU'
                    EventParms<COL$WH_CD>    = 'CR'
                    EventParms<COL$LOC_CD>   = 'MU'
                    EventParms<COL$WO_NOS>   = WONo
                    EventParms<COL$CASS_NOS> = CassNo
                    EventParms<COL$USER_ID>  = @USER4
                    EventParms<COL$TAGS>     = ''
                    EventParms<COL$TOOL_ID>  = ''
                    
                    CONVERT @FM TO @RM IN EventParms
                    
                    obj_WO_Mat_Log('Create',EventParms)        ;* * * * * INV EVENT LOG * * * * *
                    
                    IF Get_Status(errCode) THEN
                        CALL ErrMsg(ErrCode)
                        RETURN
                    END
                END
            END    ;* End of check for non EpiPRO reactor

            Set_Property(@Window : '.POST_EPI_SUP_SIG', 'TEXT', @User4)
            Set_Property(@Window : '.POST_EPI_SUP_SIG_NAME', 'TEXT', OConv(@User4, '[XLATE_CONV,LSL_USERS*FIRST_LAST]'))
            Set_Property(@Window : '.POST_EPI_SUP_SIG_DATE', 'TEXT', SigDt)
            Set_Property(@Window : '.POST_EPI_SUP_SIG_TIME', 'TEXT', SigTmPlusOne)
            
            ** Create LOT_EVENT **
			Lot_Event_Services('CreateLotEvent', RDSNo, Datetime(), 'SIGN_FQA', '', '', @USER4, True$, 'RDS')
            
            /* Sync up the RDS record with WO_MAT */
            IOOptions = Get_Property(@Window, 'IOOPTIONS')
            IOOptions<6> = True$
            Set_Property(@Window, 'IOOPTIONS', IOOptions)
            Send_Event(@Window, 'WRITE')
            IOOptions<6> = False$
            Set_Property(@Window, 'IOOPTIONS', IOOptions)
            
            WOMatKey = WONo:'*':CassNo
            WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
            WMRDSNos = WOMatRec<WO_MAT_RDS_NO$>
                            
            LOCATE CurRdsNo IN WMRDSNos USING @VM SETTING Pos THEN
                NextRDSNo = WMRDSNos<1,Pos+1>
                                
                IF NextRDSNo NE '' THEN
                    CurrWfrQty = obj_WO_Mat('CurrWaferCnt',WOMatKey:@RM:WOMatRec)
                    Set_Status(0)
                    obj_RDS('SetSchedWfrQty',NextRDSNo:@RM:CurrWfrQty)
                    IF Get_Status(errCode) THEN ErrMsg(errCode)
                END
            END
                
            * Added 08/05/2013 JCH
            
            WOMatKey    = WONo:'*':CassNo
            OrgMUPart    = XLATE('WO_MAT',WOMatKey,'MU_PART_NO','X')
            
            NewMUPart = XLATE('WO_MAT',WOMatKey,'MU_PART_NO','X')
            
            IF NewMUPart NE OrgMUPart THEN

                IndexTransactionRow = 'MU_PART_NO':@FM:WOMatKey:@FM:OrgMUPart:@FM:NewMUPart:@FM
                
                OPEN "!WO_MAT" TO BangTable THEN

                    LOCK BangTable, 0 THEN

                        READ PendingTrans FROM BangTable, 0 ELSE PendingTrans = '0':@FM
                        
                        PendingTrans := IndexTransactionRow
                        
                        WRITE PendingTrans ON BangTable, 0 ELSE
                            ErrMsg('Unable to write index transaction to !WO_MAT. ':WOMatKey)
                        END
                        UNLOCK BangTable, 0 ELSE ErrMsg('Unable to Open !WO_MAT to add index transaction. ':WOMatKey)
                    END ELSE
                        ErrMsg('Unable to Lock !WO_MAT to add index transaction. ':WOMatKey)
                    END
                END ELSE
                    ErrMsg('Unable to Open !WO_MAT to add index transaction. ':WOMatKey)
                END
            END    ;* End of check for changed index value
        end else
            Error_Services('DisplayError')
        end
    END    ;* End of check for valid signature

end event


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

Event EDL_WAFER_COUNTER_QTY.CHANGED(NewData)
	
	QtyBackColor = APPGREEN$
	RDSNo        = Get_Property(@Window : '.RDS_NO','DEFPROP')
	If RDSNo NE '' then
		WafersOut       = Get_Property(@WINDOW:'.WAFERS_OUT','TEXT')
		WaferCounterQty = NewData
		If (WaferCounterQty NE '') then
			If (WaferCounterQty NE WafersOut) then QtyBackColor = APPRED$
		end else
			QtyBackColor = APPORANGE$
		end
		
		OrigWCQty = Get_Property(@Window, '@ORIG_WFR_CTR_QTY')
		OrigRec   = @Record
		CurrRec   = Get_Property(@Window, 'ATRECORD')
		Savewarn  = (OrigRec NE CurrRec) or (OrigWCQty NE WaferCounterQty)
		Set_Property(@Window, 'SAVEWARN', Savewarn)
	end
	Set_Property(@WINDOW:'.EDL_WAFER_COUNTER_QTY','BACKCOLOR', QtyBackColor)
	
end event


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

Setup_OLE_Controls:

return

