Compile function PROVE_IN_OVERRIDE_EVENTS(CtrlEntId, Event, @PARAMS)
#pragma precomp SRP_PreCompiler
#window PROVE_IN_OVERRIDE

$Insert APP_INSERTS
$Insert REACTOR_EQUATES
$insert Message_Box_Equates

Declare subroutine Placedialog, Message_Box

GoToEvent Event for CtrlEntId else
    // Event not implemented
end

Return EventFlow or 1

//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------

Event WINDOW.CREATE(CreateParam)
	ReactNo = CreateParam
	
    Placedialog(-2, -2)
    
    ProveInTypes = Xlate('REACTOR', ReactNo, REACTOR_PROVE_IN_TYPE$, 'X')
    for each ProveInType in ProveInTypes using @VM setting dummy
    	Begin Case
    		Case ProveInType _EQC 'changeover'
    			Set_Property(@Window:'.CHB_CHANGEOVER', 'ENABLED', True$)
    		Case ProveInType _EQC 'initiate_idle'
    			Set_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'ENABLED', True$)
    		Case ProveInType _EQC 'idle'
    			Set_Property(@Window:'.CHB_IDLE_STARTUP', 'ENABLED', True$)
    		Case ProveInType _EQC 'intrusive_maint'
    			Set_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'ENABLED', True$)
    		Case Otherwise$
    			Null
    	End Case
    Next ProveInType
End Event

Event PUB_SUBMIT.CLICK()
	OverrideData = ''
	
	SelectedTypes = ''
	If Get_Property(@Window:'.CHB_CHANGEOVER', 'CHECK') then
		SelectedTypes = "CHANGEOVER"
	end		
	If Get_Property(@Window:'.CHB_IDLE_SHUTDOWN', 'CHECK') then
		If SelectedTypes NE '' then
			SelectedTypes := @VM
		end
		SelectedTypes := 'INITIATE_IDLE'
	end	
	If Get_Property(@Window:'.CHB_IDLE_STARTUP', 'CHECK') then
		If SelectedTypes NE '' then
			SelectedTypes := @VM
		end
		SelectedTypes := 'IDLE'
	end		
	If Get_Property(@Window:'.CHB_INTRUSIVE_MAINT', 'CHECK') then
		If SelectedTypes NE '' then
			SelectedTypes := @VM
		end
		SelectedTypes := 'INTRUSIVE_MAINT'
	end
	
	If SelectedTypes EQ '' then
		Message_Box(@Window, "You must select at least one prove in type!", "Error", MSG_ICON_EXCLAM$)
		return
	end else
		OverrideData<1, 1> = SelectedTypes
	end
	
	OverrideData<2, 1> = Get_Property(@Window:'.EDB_COMMENT', 'TEXT')
	
	If OverrideData<2, 1> EQ '' or Len(OverrideData<2, 1>) LT 4 then
		Message_Box(@Window, "Your comment must be at least 4 characters!", "Error", MSG_ICON_EXCLAM$)
		return
	end	
	
	End_Dialog(@Window, OverrideData)
end event

Event PUB_CANCEL.CLICK()
	End_Dialog(@Window, '')
end event


