COMPILE FUNCTION COMM_REACTOR_LOG(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)
#pragma precomp SRP_PreCompiler
/*
	Commuter module for COMM_REACTOR_LOG (Reactor_Log) window
	
	09/9/2013 - John C. Henry, J.C. Henry & Co., Inc.
*/
Declare Subroutine Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event, Set_List_Box_Data
Declare Subroutine obj_Tables, Print_RootCause_Analysis, Database_Services, obj_React_Reads, obj_React_Event
Declare Subroutine ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, Dialog_Box, Yield
Declare Subroutine obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, obj_Reactor_Log, obj_Post_Log
Declare Subroutine Reactor_Log_Events, Reactor_Log_Services, Error_Services, React_Servs_Services, Reactor_Services
Declare Subroutine Override_Log_Services, SRP_List, Nica_Orders_Services
Declare Function Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, EntID, Repository, NextKey
Declare Function Send_Message, Msg, Security_Check, obj_React_Item, Select_Into, MemberOf, Create_Dialog, obj_Calendar
Declare Function GetAsyncKeyState, obj_Tables, MemberOf, Environment_Services, Database_Services, Rds_Services
Declare Function Reactor_Services, Error_Services, React_Servs_Services, Reactor_Log_Services, Send_Event, SRP_List
Declare Function Nica_Orders_Services, SRP_Date, React_Item_Services, SRP_Datetime, Datetime
$Insert MSG_EQUATES
$Insert APPCOLORS
$Insert LSL_USERS_EQU
$Insert SECURITY_RIGHTS_EQU
$Insert POPUP_EQUATES
$Insert RTI_STYLE_EQUATES
$Insert RLIST_EQUATES
$Insert REACT_SERVS_EQUATES
$Insert REACT_PROB_CAT_EQUATES
$Insert REACTOR_LOG_EQUATES
$Insert REACT_SERV_CAT_EQUATES
$Insert REACT_ITEM_EQUATES
$Insert REACT_INJECTOR_EQUATES
$Insert REACT_STATE_EQUATES
$Insert EXCEL_EQU
$Insert REACTOR_PM_EQUATES
$Insert REACTOR_EQUATES
$Insert RDS_EQUATES
$Insert LOGICAL
Equ WM_USER$			to 1024
Equ DTM_EDITCURCELL$	to WM_USER$ + 95
Equ DT_BEGINEDIT$		to 1
Equ DT_ENDEDIT$			to 2
Equ DT_ABORTEDIT$		to 3
Equ CRLF$	to \0D0A\
Equ TAB$	to \09\
Equ POPUP_WHITE$         to 15400411
Equ POPUP_GREEN$         to 16777215
Equ COL$PROB_CAT      to 1		;* Used in .SERV_INFO
Equ COL$PROB_CAT_DESC to 2
Equ COL$SERV_ID       to 3
Equ COL$SERV_ID_DESC  to 4
Equ COL$SCHED         to 5
Equ COL$ITEM_TYPE     to 6
Equ COL$ITEM_ID       to 7
Equ COL$ITEM_RI_NO    to 8
Equ COL$MFR_PART_NO   to 9
Equ COL$REV			  to 10
Equ COL$SERIAL_NO	  to 11
Equ COL$RI_NO          to 1		;* Used in .REM_RI_NO and .INST_RI_NO
Equ COL$RI_SERIAL      to 2
Equ COL$RI_TYPE        to 3
Equ COL$RI_PART_NO     to 4
Equ COL$RI_PART_REV    to 5
Equ COL$RI_SERIAL_NO   to 6
Equ COL$RI_DISP        to 7
Equ COL$RI_DISPOSITION to 8
Equ COL$RI_INST_RL_ID  to 9
Equ COL$INST_DTM	   to 10
Equ COL$INST_RIH_KEY   to 11
Equ COL$INST_RHI_KEY	to 7
Equ COL$REM_RHI_KEY		to 9
Equ COL$CURR_RI_NO		to 1		;* Used in .CURR_REACT_ITEMS
Equ COL$CURR_SERIAL		to 2
Equ COL$CURR_RI_TYPE	to 3
Equ COL$CURR_INST_DTM	to 4
Equ COL$CURR_DESC		to 5
Equ COL$CURR_RL_ID		to 6
LastServCol = COL$ITEM_ID
Equ COL$SIG			to 1
Equ COL$SIG_DTM		to 2
Equ COL$SIG_NOTE	to 3
Equ HIDDEN$		to 32
Equ SKIPPED$	to 4100
ErrTitle = 'Error in Reactor_Log'
ErrorMsg = ''
Result = ''
Begin Case
	Case EntID = @Window
		Begin Case
			Case Event = 'CREATE' 			; GoSub Create
			Case Event = 'CLEAR'			; GoSub Clear
			Case Event = 'CLOSE'			; GoSub Close
			Case Event = 'WRITE'			; GoSub Write
			Case Event = 'READ'				; GoSub Read
			Case Event = 'PAGE'				; GoSub Page
			Case Event = 'VSCROLL'			; GoSub VScroll
			Case Event = 'DELETE'			; GoSub Delete
			Case Event[1,3] = 'QBF'			; GoSub Refresh
				
		End Case
		
	Case EntID = @Window:'.LOTO'                and Event = 'CLICK'		; GoSub LOTOClick
	Case EntID = @Window:'.LO_NA'               and Event = 'CLICK'	    ; GoSub Refresh
	Case EntID = @Window:'.LO_REVIEWED'         and Event = 'CLICK'		; GoSub Refresh
	Case EntID = @Window:'.LU_RL_NO'            and Event = 'CLICK'		; GoSub LURLNo
	Case EntID = @Window:'.NEW_BUTTON'          and Event = 'CLICK'		; GoSub New
	Case EntID = @Window:'.TAB'                 and Event = 'CLICK'		; GoSub Page
	Case EntID = @Window:'.ADD_BUTTON'          and Event = 'CLICK'		; GoSub CopyRemove
	Case EntID = @Window:'.POST_BUTTON'         and Event = 'CLICK'		; GoSub PostItems
	Case EntID = @Window:'.TECH_SIGN'           and Event = 'CLICK'		; GoSub TechSign
	Case EntID = @Window:'.REACT_WAFER_CNT'     and Event = 'LOSTFOCUS'	; GoSub Refresh
	Case EntID = @Window:'.INJ_SETTING'         and Event = 'LOSTFOCUS'	; GoSub SettingLF
    Case EntID = @Window:'.EDT_NEW_RATIOS'      and Event = 'LOSTFOCUS'	; GoSub RatioSettingLF
	Case EntID = @Window:'.INJ_SETTING_HIST'    and Event = 'CLICK'		; GoSub InjHistory
    Case EntID = @Window:'.PUB_RATIO_HISTORY'   and Event = 'CLICK'     ; GoSub RatioHistory
	Case EntID = @Window:'.PRINT_ROOT_CAUSE'    and Event = 'CLICK'		; GoSub PrintRootCause
		
	Case EntID = @Window:'.SERV_INFO'
		Begin Case 
			Case Event = 'POSCHANGED'		; GoSub SvcsPC
			Case Event = 'OPTIONS'			; GoSub SvcsOptions
			Case Event = 'GOTFOCUS'			; GoSub SvcsGF
			Case Event = 'LOSTFOCUS'        ; GoSub SvcsLF
			Case Event = 'DBLCLK'			; GoSub SvcsDC
		End Case
		
	Case EntID = @Window:'.SHIFT_SIG'
		Begin Case
			Case Event = 'POSCHANGED'		; GoSub ShiftSigPC
			Case Event = 'DBLCLK'			; GoSub ShiftSigDC
		End Case
		
	Case EntID = @Window:'.REM_RI_NO'
		
		Begin Case
			Case Event = 'DBLCLK'			; GoSub RemRIDC
			Case Event = 'OPTIONS'			; GoSub RemOptions
				
		End Case
		
	Case EntID = @Window:'.CURR_REACT_ITEMS'
		
		Begin Case
			Case Event = 'DBLCLK'			; GoSub CurrRIDC
		End Case
		
	Case 1
		
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
End Case
If ErrorMsg NE '' then
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
end
return Result
* * * * * * *
Create:
* * * * * * *
	
	If NOT(MemberOf(@User4,'MAINTENANCE')) and NOT(MemberOf(@User4,'SUPERVISOR')) then
		ErrMsg('Please contact the System Administrator if you require access to this window')
		Send_Event(@Window,'CLOSE')
		return
	end
	
	obj_Appwindow('Create',@Window)
	
	Reactor_Log_Events(@Window, 'CREATE')
	
	If MemberOf(@User4, 'OI_SUPERUSER') then
		Set_Property(@Window:'.TEMP_INJ_POST','VISIBLE',1)
		
	end else
		Set_Property(@Window:'.TEMP_INJ_POST','VISIBLE',0)
	end
	
	Keys = Field( Parm1, '*', 1 )
	If LEN(Keys) then
		If INDEX(Keys,@VM,1) then
			Set_Property(@Window,'QBFLIST',Keys)
		end else
			obj_AppWindow('LoadFormKeys',@Window:@RM:Keys)
		end
	end
	
	If Security_Check( 'Reactor Log', Read$ ) then
		Set_List_Box_Data( @Window )
	end else
		Security_Err_Msg( 'Reactor Log', Read$ )
		Send_Event(@Window,'CLOSE')
		return
	end
	
	If NOT(Security_Check( 'Reactor Log', Edit$ )) then
		Security_Err_Msg( 'Reactor Log', Edit$ )
	end
	
	If NOT(MemberOf( @User4, 'MAINTENANCE' )) then
		Set_Property(@Window:'.SERV_BUTTON_MULTI', 'VISIBLE', 0 )
	end
	
	col1Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$PROB_CAT,0)
	col1Style = bitor(col1Style,DTCS_OPTIONSBUTTON$)
	col1Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$PROB_CAT,0,col1Style)
	
	col3Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$SERV_ID,0)
	col3Style = bitor(col3Style,DTCS_OPTIONSBUTTON$)
	col3Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$SERV_ID,0,col3Style)
	
	col8Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$ITEM_ID,0)
	col8Style = bitor(col8Style,DTCS_OPTIONSBUTTON$)
	col8Style = Send_Message(@Window:'.SERV_INFO','STYLE_BY_POS',COL$ITEM_ID,0,col8Style)
	
	colStyle = Send_Message(@Window:'.REM_RI_NO','STYLE_BY_POS',COL$RI_DISP,0)
	colStyle = bitor(colStyle,DTCS_OPTIONSBUTTON$)
	colStyle = Send_Message(@Window:'.REM_RI_NO','STYLE_BY_POS',COL$RI_DISP,0,colStyle)
	
	ReactorType = Get_Property(@Window:'.REACT_TYPE','TEXT')
	If ReactorType = 'EPP' then
		Set_Property(@Window:'.CHB_WAFERS_REMOVED', 'VISIBLE', False$)
	end
	
return
* * * * * * *
Clear:
* * * * * * *
	
	Page = 1
	
	Send_Event(@Window,'VSCROLL',Page)
	Send_Event(@Window,'PAGE',Page)
	
	Reactor_Log_Events(@Window, 'CLEAR')
	
return
* * * * * * *
Page:
* * * * * * *
	
	Page = Get_Property(@Window:'.TAB', 'VALUE')
	Set_Property(@Window,'VPOSITION', Page)
	
return
* * * * * * *
VScroll:
* * * * * * *
	
	Page = Parm1
	Set_Property(@Window:'.TAB','VALUE', Page)
	
return
* * * * * * *
New:
* * * * * * *
	
	RLId = Get_Property(@Window:'.REACTOR_LOG_NO','DEFPROP')
	
	If RLId = '' then
		NextRLId = NextKey('REACTOR_LOG')
		obj_Appwindow('LoadFormKeys',@Window:@RM:NextRLId)
	end
	
	GoSub Refresh
	
return
* * * * * * *
Close:
* * * * * * *
	
	ParentWindow = Get_Property(@Window,'@PARENT')
	
	If ParentWindow = 'REACT_MODE_CHG' Then
		Send_Event(ParentWindow:'.CANCEL','CLICK')
	end
	
return
* * * * * * *
Write:
* * * * * * *
	RLId      = Get_Property(@Window:'.REACTOR_LOG_NO','DEFPROP')
	ReactNo   = Get_Property(@Window:'.REACTOR','DEFPROP')
	InjRlId   = Xlate('REACT_STATE', ReactNo, REACT_STATE_CURR_INJ_RL_ID$, 'X')
	RatioRlId = Xlate('REACT_STATE', ReactNo, REACT_STATE_CURR_RATIO_RL_ID$, 'X')
	
	// Check Injector Settings and Reactor Ratios for required values or changes to post
	ErrMsg     = ''
    ServArray  = Get_Property(@Window:'.SERV_INFO', 'ARRAY')
    ServIds    = ServArray
    InjDataReq = Sum(Xlate('REACT_SERVS', ServIds, REACT_SERVS_REQ_INJECTOR_DATA$, 'X'))
    
    If (InjDataReq and (RlId NE InjRlId) ) then
        
        // One of the performed services requires all new injector setting values
        CurrInjSettings  = Get_Property(@Window:'.CURR_INJ_SETTINGS', 'ARRAY')
        NewInjSettings   = Get_Property(@Window:'.INJ_SETTING', 'ARRAY')
        MissingInjValues = ''
        For each InjSetting in NewInjSettings using @VM setting vPos
            If InjSetting EQ '' then MissingInjValues<0, -1> = vPos
        Until ErrMsg NE '' 
        Next InjSetting
        If MissingInjValues NE '' then
            Convert @VM to ',' in MissingInjValues
            ErrMsg = 'Injector setting(s) ':MissingInjValues:' are missing a value.'            
        end
        
    end	
	
	If ErrMsg EQ '' then
	    
	    InjServFlag    = Sum(Xlate('REACT_SERVS', ServIds, REACT_SERVS_INJECTOR_CHANGE$, 'X'))
	    RatioServFlag  = Sum(Xlate('REACT_SERVS', ServIds, REACT_SERVS_RATIO_SERVICE$, 'X'))
	    NewInjSettings = ''
	    
	    If (RlId NE InjRlId) then
            CurrInjSettings  = Get_Property(@Window:'.CURR_INJ_SETTINGS', 'ARRAY')
            InjSettings      = Get_Property(@Window:'.INJ_SETTING', 'ARRAY')
            NumInjSetChanges = 0
            TestInjSettings  = InjSettings
            Convert @VM to '' in TestInjSettings
            If TestInjSettings NE '' then
                // At least one injector setting has been entered. Carry over other values
                // and record them.
                For each InjSetting in InjSettings using @VM setting vPos
                    If InjSetting NE '' then
                        NewInjSettings<0, vPos> = InjSetting
                        If InjSetting NE CurrInjSettings<0, vPos> then NumInjSetChanges += 1
                    end else
                        // Carry over the current injector setting
                        NewInjSettings<0, vPos> = CurrInjSettings<0, vPos>
                    end
                Next InjSetting
                If InjServFlag and NumInjSetChanges EQ 0 then ErrMsg = 'At least one injector setting change is required.'
                If ErrMsg EQ '' then Set_Property(@Window:'.INJ_SETTING', 'ARRAY', NewInjSettings)
            end else
                If InjServFlag then ErrMsg = 'At least one injector setting change is required.'
            end	        
	    end
        
        If ErrMsg EQ '' then 
        
            NewRatios       = ''
            If (RlId NE RatioRlId) then
                CurrRatios      = Get_Property(@Window:'.EDT_CURR_RATIOS', 'ARRAY')
                Ratios          = Get_Property(@Window:'.EDT_NEW_RATIOS', 'ARRAY')
                NumRatioChanges = 0
                TestRatios      = Ratios
                Convert @VM to '' in TestRatios
                If TestRatios NE '' then
                    // At least one ratio has been entered. Carry over other values
                    // and record them.
                    For each Ratio in Ratios using @VM setting vPos
                        If Ratio NE '' then
                            NewRatios<0, vPos> = Ratio
                            If Ratio NE CurrRatios<0, vPos> then NumRatioChanges += 1
                        end else
                            // Carry over the current injector setting
                            NewRatios<0, vPos> = CurrRatios<0, vPos>
                        end
                    Next Ratio
                    If RatioServFlag and (NumRatioChanges EQ 0) then ErrMsg = 'At least one ratio change is required.'
                    If ErrorMsg EQ '' then Set_Property(@Window:'EDT_NEW_RATIOS', 'ARRAY', NewRatios)
                end else
                    If RatioServFlag then ErrMsg = 'At least one ratio change is required.'
                end
            end
        end
    end
    
    If ErrMsg EQ '' then
        
        If NewInjSettings NE '' then
            If CurrInjSettings NE NewInjSettings then
                Reactor_Services('SetNewInjectorSettings', ReactNo, IConv(NewInjSettings, 'MD3'))
                If Error_Services('HasError') then ErrMsg = Error_Services('GetMessage')
            end
        end
        
        If NewRatios NE '' then
            If CurrRatios NE NewRatios then
                Reactor_Services('SetNewRatios', ReactNo, IConv(NewRatios, 'MD3'))
                If Error_Services('HasError') then ErrMsg = Error_Services('GetMessage')
            end	
        end        
        
        Notes         = Get_Property(@Window:'.NOTES','DEFPROP')
        ChangeDt      = Get_Property(@Window:'.END_DATE','TEXT')
        ChangeTm      = Get_Property(@Window:'.END_TIME','TEXT')
        ReactWaferCnt = Get_Property(@Window:'.REACT_WAFER_CNT','DEFPROP')
        
        If ChangeDt NE '' and ChangeTm NE '' then
            
            ChangeDTM = ChangeDt:' ':ChangeTm
            EnteredBy = @User4
            
            * Log new Reactor Read if the EndDate and EndTime if this record is newer than the last one logged for the reactor
            
            If ReactWaferCnt NE '' and ReactNo NE '0' then
                thisChangeDTM = ICONV(ChangeDTM,'DT')
                LastWfrReadDTM = XLATE('REACTOR',ReactNo,REACTOR_LAST_READ_WFRS_DTM$,'X')
                If thisChangeDTM > LastWfrReadDTM then
                    obj_React_Reads('Create',ReactNo:@RM:EnteredBy:@RM:ChangeDTM:@RM:ReactWaferCnt)
                    errCode = ''
                    If Get_Status(errCode) then
                        ErrMsg(errCode)
                    end
                end
            end
            
            * Log Maintenance event in Reactor Event
            
            oREParms  = ReactNo:@RM
            oREParms := ChangeDTM:@RM
            oREParms := 'MTC':@RM
            oREParms := EnteredBy:@RM
            oREParms := Notes:@RM
            oREParms := '':@RM											;* Not a mode change
            oREParms := XLATE('REACTOR',ReactNo,'CURR_MODE','X')		;* Curr reactor mode
            
            obj_React_Event('Create',oREParms)
            
        end	;* End of check for ChangeDt and ChangeTm filled in
        
        ROTRCheckStatus = Get_Property(@Window:'.CHECK_BOX_ROTR', 'CHECK')
        If ROTRCheckStatus EQ False$ then
            // Prompt user whether or not maintenance event is ROTR related
            MsgHead	= 'ROTR Reminder'
            MsgText	= 'Is this maintenance ROTR related?'
            
            Response = Msg(@Window,'','YESNO','',MsgHead:@FM:MsgText)
            
            If Response EQ True$ then
                Set_Property(@Window:'.CHECK_BOX_ROTR', 'CHECK', True$)
            end
        end        
        
        IOOptions    = Get_Property(@Window, 'IOOPTIONS')
        IOOptions<6> = True$
        Set_Property(@Window, 'IOOPTIONS', IOOptions)	
        Reactor_Log_Events(@Window, 'WRITE')
        Reactor_Log_Events(@Window, 'READ')
        Result = 1
        
    end else
        
        MsgHead	= 'Process Error'
		MsgText	= ErrMsg
		Response = Msg(@Window,'','OK','',MsgHead:@FM:MsgText)
        Error_Services('Add', ErrMsg)
        Set_Property(@Window,'REDRAW', False$)
        Begin Case
            Case IndexC(ErrMsg, 'injector', 1)
				Set_Property(@Window:'.TAB','VALUE',4)
				Send_Event(@Window:'.TAB','CLICK')
				Set_Property(@Window:'.INJ_SETTING','FOCUS',1)
				Set_Property(@Window:'.INJ_SETTING','SELPOS',1:@FM:1)
				hTable = Get_Property(@Window:'.INJ_SETTING','HANDLE')
				If NOT(hTable) then 
					ErrMsg('Problem Getting the handle to the INJ_SETTINGS control.')
					return
				end
				void = Send_Message(hTable,DTM_EDITCURCELL$,DT_BEGINEDIT$,0)                
                
            Case IndexC(ErrMsg, 'ratio', 1)
				Set_Property(@Window:'.TAB','VALUE',6)
				Send_Event(@Window:'.TAB','CLICK')
				Set_Property(@Window:'.EDT_NEW_RATIOS','FOCUS',1)
				Set_Property(@Window:'.EDT_NEW_RATIOS','SELPOS',1:@FM:1)
				hTable = Get_Property(@Window:'.EDT_NEW_RATIOS','HANDLE')
				If NOT(hTable) then 
					ErrMsg('Problem Getting the handle to the EDT_NEW_RATIOS control.')
					return
				end
				void = Send_Message(hTable,DTM_EDITCURCELL$,DT_BEGINEDIT$,0)                
        End Case
        Set_Property(@Window,'REDRAW', True$)
    end
    
return
* * * * * * *
Delete:
* * * * * * *
	
	* Pre-Event called from DELETE event handler on window
	
	If Security_Check( 'Reactor Log', Delete$ ) then
		Result = 1
	end else
		Security_Err_Msg( 'Reactor Log', Delete$ )
		Result = 0
	end
	
return
* * * * * * *
Read:
* * * * * * *
	
	* Check for and Set Entry data if null *
	
	EntryID = Get_Property(@Window:'.ENTRY_ID','DEFPROP')
	
	If EntryID = '' then
		Set_Property(@Window:'.ENTRY_ID','INVALUE',@User4)
		Set_Property(@Window:'.ENTRY_DATE','DEFPROP',OCONV(Date(),'D4/'))
	end
	
	* Check for and Set Start data if null *
	
	If Get_Property(@Window:'.START_DATE','DEFPROP') = '' then
		
		Set_Property(@Window:'.START_DATE','DEFPROP',OCONV(Date(),'D4/'))
		Set_Property(@Window:'.START_TIME','DEFPROP',OCONV(Time(),'MTS'))
		
	end
	
	* Check for any pending Reactor PM records *
	
	
	ReactNo = Get_Property(@Window:'.REACTOR','DEFPROP')
	
	If RowExists('REACTOR',ReactNo) then
		
		TechSig = Get_Property(@Window:'.TECH_SIG','TEXT')
		EndDate = Get_Property(@Window:'.END_DATE','TEXT')
		IDs = ''
		
		If ReactNo NE '' and EndDate = '' then
			
			* Check for PM's due
			
			ReactPMIds			= ''
			Today				= Date()
			AWeekAndADayFromNow = OCONV(Today + 8, 'D2/' )
			
			Statement  = 'SELECT REACTOR_PM WITH COMPLETE_DATE = ""'
			Statement := ' AND WITH NEXT_DONE < ':QUOTE( AWeekAndADayFromNow )
			Statement := ' AND WITH REACTOR = ':ReactNo
			Statement := ' BY NEXT_DONE'
			
			RList( Statement, TARGET_ACTIVELIST$, '', '', '' )
			
			@RN.COUNTER = 0
			
			Done = 0
			Loop
				ReadNext ReactPMId else Done = 1
			Until Done
				ReactPMIds<-1> = ReactPMId
			Repeat
			
			If ReactPMIds NE '' then
				Dialog_Box( 'REACTOR_LOG_TODO', @Window, ReactPMIds:CHAR(245):ReactNo)
			end
		end	;* End of check for ReactNo and no End Date)
		
		
	end
	
	GoSub CalcRIHKeys
	
	Reactor_Log_Events(@Window, 'READ')
	
	
* * * * * * *
Refresh:
* * * * * * *
    ReactNo     = Get_Property(@Window:'.REACTOR', 'TEXT')
    If ReactNo NE '' then 
        // Populate Current Injector Settings and Current Reactor Ratios
        InjSettings = OConv(Reactor_Services('GetCurrentInjectorSettings', ReactNo), 'MD3,')
        Set_Property(@Window:'.CURR_INJ_SETTINGS', 'ARRAY', InjSettings)
        Ratios      = OConv(Reactor_Services('GetCurrentRatios', ReactNo), 'MD3,')
        Set_Property(@Window:'.EDT_CURR_RATIOS', 'ARRAY', Ratios)
        NumRatios   = Reactor_Services('GetNumRatios', ReactNo)
        If Error_Services('NoError') then
            Set_Property(@Window:'.EDT_CURR_RATIOS', 'MINROWLIMIT', NumRatios)
            Set_Property(@Window:'.EDT_CURR_RATIOS', 'MAXROWLIMIT', NumRatios)
            Set_Property(@Window:'.EDT_NEW_RATIOS', 'MINROWLIMIT', NumRatios)
            Set_Property(@Window:'.EDT_NEW_RATIOS', 'MAXROWLIMIT', NumRatios)
        end
        ThisRlId      = Get_Property(@Window:'.REACTOR_LOG_NO', 'TEXT')
        CurrInjRlId   = Xlate('REACT_STATE', ReactNo, REACT_STATE_CURR_INJ_RL_ID$, 'X')
        If ThisRlId EQ CurrInjRlId then Set_Property(@Window:'.INJ_SETTING', 'ARRAY', InjSettings)
        CurrRatioRlId = Xlate('REACT_STATE', ReactNo, REACT_STATE_CURR_RATIO_RL_ID$, 'X')        
        If ThisRlId EQ CurrRatioRlId then Set_Property(@Window:'.EDT_NEW_RATIOS', 'ARRAY', Ratios)
	end
	
	LOReviewed	= Get_Property(@Window:'.LO_REVIEWED','CHECK')
	LONotApp	= Get_Property(@Window:'.LO_NA','CHECK')
	
	If LOReviewed OR LONotApp then
		Set_Property(@Window:'.TECH_SIGN','ENABLED',1)
	end else
		Set_Property(@Window:'.TECH_SIGN','ENABLED',0)
	end
	
	TechSig = Get_Property(@Window:'.TECH_SIG','DEFPROP')
	PostSig = Get_Property(@Window:'.RI_POST_BY','DEFPROP')
	
	If TechSig NE '' OR PostSig NE '' then
		Set_Property(@Window:'.REACTOR','ENABLED',0)
	end else
		Set_Property(@Window:'.REACTOR','ENABLED',1)
	end
	
	If PostSig = '' then
		RemText		= 'Items Being Removed'
		InstText	= 'Items Being Installed'
		ButtonText	= 'Post Items'
	end else
		RemText		= 'Items Removed'
		InstText	= 'Items Installed'
		ButtonText	= 'Unpost Items'
	end
	
	Ctrls  = @Window:'.POST_BUTTON':@RM		; Props  = 'TEXT':@RM		; Vals  = ButtonText:@RM
	Ctrls := @Window:'.REMOVE_GROUP':@RM	; Props := 'TEXT':@RM		; Vals := RemText:@RM
	Ctrls := @Window:'.INST_GROUP'			; Props := 'TEXT'			; Vals := InstText
	
	Set_Property(Ctrls,Props,Vals)
	* Load ReactWfrCntEnd value  ***************************************************
	
	ItemArray = Get_Property(@Window:'.SERV_INFO','DEFPROP')
	ItemTypes = ICONV(ItemArray,'[CONV_CODE_DESC,REACT_ITEM_TYPE]')
	
	StartWfrCnt = Get_Property(@Window:'.REACT_WAFER_CNT','DEFPROP')
	
	If INDEX(ItemTypes,'T',1) then
		EndWfrCnt = 0				;* Tube being installed
		Set_Property(@Window:'.RESET_REMINDER','VISIBLE',1)
	end else
		EndWfrCnt = StartWfrCnt		;* No tube change -> no reset
		Set_Property(@Window:'.RESET_REMINDER','VISIBLE',0)
	end
	
	Set_Property(@Window:'.REACT_WFR_CNT_END','DEFPROP',EndWfrCnt)	;* New tubes start with zero wafers
	* QBF buttons
	
	Ctrls  = @Window:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
	Ctrls := @Window:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
	Ctrls := @Window:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
	Ctrls := @Window:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
	Ctrls := @Window:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
	Ctrls := @Window:'.QBF_STOP_FIX'			; Props := 'ENABLED'
	
	If Get_Property(@Window,'QBFLIST') = '' then
		Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
	end else
		Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
	end
	
	Set_Property(Ctrls,Props,Vals)
	
	* Turn edit table symbolic column backgrounds to green *
	
	ETSymbolics = Get_Property(@Window,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow
	
	ETCtrls	= ETSymbolics<1>
	ETCols	= ETSymbolics<2>
	
	For I = 1 to COUNT(ETCtrls,@VM) + (ETCtrls NE '')
		ETCtrl	= ETCtrls<1,I>
		ETList = Get_Property(ETCtrl,'LIST')
		For Line = 1 to COUNT(ETList,@FM) + (ETList NE '')
			If ETList NE '' then
				For N = 1 to COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
					stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
				Next N
			end
		Next I
	Next I
	
	* CurrItems Flagged for removal
	
	If Get_Property(@Window:'.RI_POST_BY','DEFPROP') ='' then
		
		RemRINos = Get_Property(@Window:'.REM_RI_NO','ARRAY')
		
		If RemRINos NE '' then
			CurrRINos = Get_Property(@Window:'.CURR_REACT_ITEMS','ARRAY')
			
			RemCnt = COUNT(RemRINos,@VM) + (RemRINos NE '')
			
			For I = 1 to RemCnt
				RemRINo = RemRINos<1,I>
				Locate RemRINo in CurrRINos using @VM setting Pos then
					For N = 1 to COL$CURR_RL_ID
						stat = Send_Message(@Window:'.CURR_REACT_ITEMS','COLOR_BY_POS',N,Pos,YELLOW$)
					Next N	
				end
				
			Next I
		end	;* End of check for RemRINos
	end	;* End of check for RI Posted signature
	
	GoSub FillServInfoCalcCols
	GoSub ColorRemRiTable
	
	Reactor_Log_Events(@Window, 'OMNIEVENT')
	
return
* * * * * * *
LURLNo:
* * * * * * *
	
	FocusControl	= Parm1
	FocusPos 		= Parm2
	
	RetVal = Dialog_Box('REACTOR_LOG_QUERY',@Window,'')
	
	If RetVal = '' then return
	
	Convert @FM to @VM IN RetVal
	
	TypeOver = ''
	TypeOver	= 'K'
	TypeOver = RetVal
	
	RetVal = Popup( @Window , TypeOver , 'REACTOR_LOG_QUERY' )
	
	If RetVal = '' then return
	
	If INDEX(RetVal,@VM,1) then
		Set_Property(@Window,'QBFLIST',RetVal)
	end else
		oaParms = RetVal:@RM:@Window:'.':FocusControl
		obj_Appwindow('LUValReturn',oaParms)
	end
	
	GoSub Refresh
	
return
* * * * * * *
TechSign:
* * * * * * *
	Action = Get_Property(@Window:'.TECH_SIGN', 'TEXT')
	ErrMsg = ''
	If Action EQ 'Sign' then
		TechSig = Get_Property(@Window:'.TECH_SIG','DEFPROP')
		
		If TechSig NE '' then
			ErrMsg('Application Message':@SVM:'This log has already been signed.')
			return
		end
		
		AtRecord	= Get_Property(@Window,'ATRECORD')
		ReactNo		= AtRecord
		
        WafersRemoved = Get_Property(@Window:'.CHB_WAFERS_REMOVED', 'CHECK')
        If WafersRemoved EQ True$ then
            RdsKeys = Reactor_Services('GetLoadedRds', ReactNo)
            SelectedRdsKeys = ''
            Begin Case
                Case ((RdsKeys<1> NE '') and (RdsKeys<2> NE ''))
                    SelectedLoadLocks = Dialog_Box("NDW_WAFERS_REMOVED_RDS_PROMPT", @Window)
                    For each SelectedLoadLock in SelectedLoadLocks using @VM
                        For Idx = 1 to 2
                            rdsLoadLockSide = Xlate('RDS', RdsKeys, RDS_LOAD_LOCK_SIDE$, 'X')
                            If (rdsLoadLockSide _EQC SelectedLoadLock) then
                                If (SelectedRdsKeys NE '') then SelectedRdsKeys := @VM
                                SelectedRdsKeys := RdsKeys
                            end
                        Next Idx
                    Next SelectedLoadLock
                Case RdsKeys<1> NE ''
                    SelectedRdsKeys = RdsKeys<1>
                Case RdsKeys<2> NE ''
                    SelectedRdsKeys = RdsKeys<2>
            End Case
            Set_Property(@Window:'.EDL_WAFERS_REMOVED_RDS', 'TEXT', SelectedRdsKeys)
        end
        
        PrevOptions   = Get_Property(@Window, 'IOOPTIONS')
        NewOptions    = PrevOptions
        NewOptions<6> = True$ ; // Do not clear the form on write
        Set_Property(@Window, 'IOOPTIONS', NewOptions)
        Send_Event(@Window, 'WRITE')
        Set_Property(@Window, 'IOOPTIONS', PrevOptions)
        If Error_Services('HasError') then return
        ReactorlogNo =  Get_Property(@Window:'.REACTOR_LOG_NO', 'TEXT')
        
        Response = Dialog_Box('NDW_VERIFY_USER', @Window, @User4)
        Valid    = Response<1>
        
        If Valid then
            Def            = ""
            Def = "Signing Reactor Log..."
            Def     = -2
            Def     = -2
            Def    = "U"
            MsgUp          = Msg(@window, Def)
            
            SuccessfulSign = Reactor_Log_Services('SignReactorLog', ReactorLogNo, @User4)
            
            Msg(@window, MsgUp)         ;* take down the message
            
            If Not(SuccessfulSign) then
                Error_Services('DisplayError')
                ActiveRlNicaOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', ReactorLogNo)
                ActiveChecklist      = (ActiveRlNicaOrderIds NE '')
                If ActiveChecklist then
                    OverrideGroups    = 'MAINTENANCE':@VM:'SUPERVISOR'
                    UserMsg           = "Reactor Log PM must be processed in NICA. Override required from a member of "
                    UserMsg          := "the MAINTENANCE or SUPERVISOR groups to bypass NICA."
                    UserVerification  = Dialog_Box('NDW_VERIFY_USER', @Window, @User4:@FM:OverrideGroups:@FM:'':@FM:UserMsg)
                    Override          = UserVerification<1>
                    If Override EQ True$ then
                        ResponseComment = Dialog_Box('NDW_ADD_COMMENT', @Window)<2>
                        ResponseComment        = ''
                        ActiveRlNicaOrderTypes = Xlate('NICA_ORDERS', ActiveRlNicaOrderIds, 'ORDER_TYPE', 'X')
                        For each ActiveRlNicaOrderId in ActiveRlNicaOrderIds using @VM setting Idx
                            Nica_Orders_Services('CancelOrder', ActiveRlNicaOrderId)
                            If ResponseComment NE '' then ResponseComment := ', '
                            ResponseComment := ActiveRlNicaOrderTypes<0, Idx>
                        Next ActiveRlNicaOrderId
                        
                        Override_Log_Services('Create', 'REACTOR_LOG', ReactorLogNo, UserVerification<2>, ResponseComment, 'REACTOR_LOG_PM')
                        
                        SuccessfulSign = Reactor_Log_Services('SignReactorLog', ReactorLogNo, @User4)
                        If Not(SuccessfulSign) then Error_Services('DisplayError')
                            
                        SRP_List('Release', PmOrderList)
                        SRP_List('Release', PmTypeList)
                    end
                end
                Send_Event(@Window, 'READ')
                return
            end
            Send_Event(@Window, 'READ')
        end else
            ErrMsg('Application Message':@SVM:'Invalid user password.')
        end
		
	end else
		
		// Unsign the reactor log
		RLKey = Get_Property(@Window:'.REACTOR_LOG_NO', 'TEXT')
		If RLKey NE '' then
			Set_Property(@Window, 'SAVEWARN', False$)
			
			Def            = ""
			Def = "Unsigning Reactor Log..."
			Def     = -2
			Def     = -2
			Def    = "U"			
			MsgUp          = Msg(@window, Def)			
			
			Reactor_Log_Services('ClearSignature', RLKey)
			
			Msg(@window, MsgUp)         ;* take down the message
			
			If Error_Services('NoError') then
				Post_Event(@Window, 'READ')
			end else
				Error_Services('DisplayError')
			end
		end
	end
	
return
* * * * * * *
SvcsGF:
* * * * * * *
	
	ReactNo = Get_Property(@Window:'.REACTOR','DEFPROP')
	
	If ReactNo = '' then
		ErrMsg('Application Message':@SVM:'Reactor No is required')
		Set_Property(@Window:'.REACTOR','FOCUS',1)
	end
	
return
* * * * * * *
SvcsPC:
* * * * * * *
	
	GoSub FillServInfoCalcCols
	
	CtrlEntID = 'REACTOR_LOG.SERV_INFO'
	
	PrevSelPos = Get_Property(CtrlEntID,'PREVSELPOS')
	PrevCol = PrevSelPos<1>
	PrevRow = PrevSelPos<2>
	
	SelPos	= Get_Property(CtrlEntID,'SELPOS')
	CurCol	= SelPos<1>
	CurRow	= SelPos<2>
	
	ListData = Get_Property(CtrlEntID,'LIST')
	ArrayData = Get_Property(CtrlEntID,'DEFPROP')
	
	CurRowData	= ListData
	
	* Move Up to non-empty row or first row *
	
	TestRow = CurRowData
	Convert @VM to '' IN TestRow
	
	If TestRow = '' then
		CurLine = CurRow
		Loop
			Col1Val = ListData
		Until Col1Val NE '' OR CurLine = 1
			CurLine -=1
		Repeat
		Set_Property(CtrlEntId,"SELPOS",1:@FM:CurLine)
		
	end else
		BadCol = ''
		Mesg = ''
		
		Begin Case
			
			Case CurCol > COL$PROB_CAT and CurRowData<1,COL$PROB_CAT> = ''
				Mesg = 'Please fill in the Prob Cat column.'
				BadCol = COL$PROB_CAT
				
			Case CurCol > COL$SERV_ID and CurRowData<1,COL$SERV_ID> = ''
				Mesg = 'Please fill in the Serv ID column.'
				BadCol = COL$SERV_ID
				
			Case CurCol > COL$SCHED and CurRowData<1,COL$SCHED> = ''
				Mesg = 'Please fill in the Sched column.'
				BadCol = COL$SCHED
				
		End Case
		
		
		If BadCol then
			Msg('',Mesg)
			Set_Property(CtrlEntID,'SELPOS',BadCol:@FM:CurRow)
			return
		end
	end
	
	CurrWindow = CtrlEntID[1,'.']
	
	If PrevCol = COL$PROB_CAT then
		ProbCat = CurRowData<1,PrevCol>
		
		If ProbCat = 44 Then		;* Added by dkk 4/8/15
			
			NotesRequired = XLATE('REACT_PROB_CAT',ProbCat,REACT_PROB_CAT_NOTES$,'X')
			
			If NotesRequired then
				Notes = Get_Property(@Window:'.NOTES','DEFPROP')
				Notes = TRIM(Notes)
				
				If Notes = '' then
					MsgInfo = ''
					MsgInfo = 'Notes required when #44 - Problem ID not found.'
					MsgInfo = 'H'
					Void = Msg( '', MsgInfo )
					Set_Property( @Window:'.NOTES', "FOCUS", 1 )
					Post_Event( @Window:'.NOTES', 'GOTFOCUS' )
				end
			End							;* Added by dkk 4/8/15
			
		end
	end
	
	
	If PrevCol = COL$SERV_ID then
		
		If CurRowData<1,COL$SERV_ID> NE '' then
			
			ReactServsRec	= XLATE('REACT_SERVS',CurRowData<1,COL$SERV_ID>,'','X')
			InjectorFlag	= ReactServsRec
			NotesRequired	= ReactServsRec
			
			If InjectorFlag then
				Set_Property(CurrWindow:'.TAB','VALUE',4)
				Send_Event(CurrWindow:'.TAB','CLICK')
				Set_Property(CurrWindow:'.INJ_SETTING','FOCUS',1)
				Set_Property(CurrWindow:'.INJ_SETTING','SELPOS',1:@FM:1)
				hTable = Get_Property(CurrWindow:'.INJ_SETTING','HANDLE')
				If NOT(hTable) then 
					ErrMsg('Problem Getting the handle to the INJ_SETTINGS control.')
					return
				end
				void = Send_Message(hTable,DTM_EDITCURCELL$,DT_BEGINEDIT$,0)
				return
			end
			
			RatioFlag = ReactServsRec
			If RatioFlag then
				Set_Property(CurrWindow:'.TAB','VALUE',6)
				Send_Event(CurrWindow:'.TAB','CLICK')
				Set_Property(CurrWindow:'.EDT_NEW_RATIOS','FOCUS',1)
				Set_Property(CurrWindow:'.EDT_NEW_RATIOS','SELPOS',1:@FM:1)
				hTable = Get_Property(CurrWindow:'.EDT_NEW_RATIOS','HANDLE')
				If NOT(hTable) then 
					ErrMsg('Problem Getting the handle to the EDT_NEW_RATIOS control.')
					return
				end
				void = Send_Message(hTable,DTM_EDITCURCELL$,DT_BEGINEDIT$,0)
				return			    
			end
			
			If NotesRequired then
				
				Notes = Get_Property(@Window:'.NOTES','DEFPROP')
				Notes = TRIM(Notes)
				
				If Notes = '' then
					MsgInfo = ''
					MsgInfo = 'Notes required when no Service ID is found.'
					MsgInfo = 'H'
					Void = Msg( '', MsgInfo )
					Set_Property( @Window:'.NOTES', "FOCUS", 1 )
					Post_Event( @Window:'.NOTES', 'GOTFOCUS' )
				end
				
			end
			
		end 
	end
	
	If PrevCol = COL$ITEM_ID then
		CurrWindow = CtrlEntID[1,'.']
		
		If CurRowData<1,COL$ITEM_TYPE> = 'Tube' then
			RINo = CurRowData<1,COL$ITEM_RI_NO>
			
			If RINo NE '' then
				obj_AppWindow('ViewRelated','REACT_ITEM':@RM:RINo)
				Set_Property('REACT_ITEM.TUBE_GRADE','FOCUS',1)
			end
			
		end	;* End of check for Tube Change
		
		GoSub VerifyReactItems
		
	end
	* Skip calculated columns *
	
	If CurCol = COL$PROB_CAT_DESC then
		Set_Property(CtrlEntId,'SELPOS',COL$SERV_ID:@FM:CurRow)
	end
	
	If CurCol = COL$SERV_ID_DESC then
		Set_Property(CtrlEntId,'SELPOS',COL$SCHED:@FM:CurRow)
	end
	
	If CurCol = COL$ITEM_TYPE then
		Set_Property(CtrlEntId,'SELPOS',COL$ITEM_ID:@FM:CurRow)
	end
	
	If PrevCol = COL$ITEM_ID then GoSub CalcRIHKeys
	
return
* * * * * * *
SettingLF:
* * * * * * *
	Settings = Get_Property(EntId, 'ARRAY')
    Convert @VM to '' in Settings
    If Settings NE '' then Set_Property(@Window, 'SAVEWARN', True$)	
	
return
* * * * * * *
RatioSettingLF:
* * * * * * *
    Ratios = Get_Property(EntId, 'ARRAY')
    Convert @VM to '' in Ratios
    If Ratios NE '' then Set_Property(@Window, 'SAVEWARN', True$)
    
return
* * * * * * *
InjHistory:
* * * * * * * 
	
	ReactNo = Get_Property(@Window:'.REACTOR','DEFPROP')
	If ReactNo NE '' then
		
		TypeOver            = ''
		TypeOver = 'WITH REACTOR_NO = ':ReactNo:' BY-DSND INJ_SET_DTM'
		
		void = Popup(@Window,TypeOver,'REACT_INJ_SETTINGS')
		
	end
	
return
* * * * * * *
RatioHistory:
* * * * * * *
    ReactNo = Get_Property(@Window:'.REACTOR','DEFPROP')
    If ReactNo NE '' then
        NumRatios = Reactor_Services('GetNumRatios', ReactNo)
        If Error_Services('NoError') then 
            DisplayText               = 'WITH REACTOR_NO EQ ':ReactNo:' BY-DSND RATIO_SET_DTM':@vm:''
            PopupRec                 = ""
            PopupRec         = "REACTOR_RATIOS"
            PopupRec      = DisplayText
            PopupRec       = 'REACTOR_NO':@svm:'6':@svm:'C':@svm:'C':@svm:'MD0':@svm:'Reactor No'
            PopupRec   = 'RATIO_SET_DTM':@svm:'16':@svm:'C':@svm:'C':@svm:'DT/^S':@svm:'Ratio Set Dtm'
            For RatioIndex = 1 to NumRatios
                PopupRec   = 'RATIO_':RatioIndex:@svm:'7':@svm:'C':@svm:'C':@svm:'MD3,':@svm:'Ratio ':RatioIndex
            Next RatioIndex
            PopupRec          = 'T'
            PopupRec        = True$
            PopupRec         = 'Reactor Ratios'
            PopupRec         = True$
            PopupRec          = "F"
            PopupRec        = True$
            PopupRec        = True$
            PopupRec        = True$
            PopupRec         = True$
            PopupRec         = True$
            PopupRec        = True$
            PopupRec        = True$
            PopupRec     = False$
            PopupRec        = False$
            PopupRec          = False$
            PopupRec          = False$
            PopupRec   = False$
            PopupRec     = True$
            PopupRec     = False$
            PopupRec    = False$
            PopupRec      = True$
            PopupRec   = POPUP_WHITE$
            PopupRec  = POPUP_GREEN$
            Response                  = Popup(@Window, PopupRec, '')
        end else
            Error_Services('DisplayError')
        end
    end else
        Error_Services('Add', "Reactor number is missing")
        Error_Services('DisplayError')
    end
    
return
* * * * * * *
SvcsOptions:
* * * * * * *
	
	SelPos = Get_Property(@Window:'.SERV_INFO','SELPOS')
	CurCol = SelPos<1>
	CurRow = SelPos<2>
	CurrArray = Get_Property(@Window:'.SERV_INFO','ARRAY')
	
	Begin Case
		Case CurCol = COL$PROB_CAT
			
			ProbCat = Popup(@Window,'','SHOW_REACT_PROB_CAT')
			
			If ProbCat NE '' then
				obj_AppWindow('LUValReturn',ProbCat:@RM:@Window:'.SERV_INFO':@RM:SelPos)
			end
			
			
		Case CurCol = COL$SERV_ID
			
			ReactServ = Popup(@Window,'','SHOW_REACT_SERVS')
			
			If ReactServ NE '' then
				obj_AppWindow('LUValReturn',ReactServ:@RM:@Window:'.SERV_INFO':@RM:SelPos)
			end
			
			
		Case CurCol = COL$ITEM_ID
			
			ItemType = Get_Property(@Window:'.SERV_INFO','DEFPROP',COL$ITEM_TYPE:@FM:CurRow)
			
			If ItemType NE '' then
				
				RetVal = ''
				ItemType = ICONV(ItemType,'[CONV_CODE_DESC,REACT_ITEM_TYPE]')
				
				RIKeys   = React_Item_Services('GetReactItems', ItemType, 'N,U')
				
				If Error_Services('NoError') then
				    
                    TypeOver            = ''
                    TypeOVer    = 'K'
                    TypeOver = RIKeys
                    RetVal              = Popup(@Window,TypeOver,'REACT_ITEM')
                    
                    If RetVal NE '' then
                        obj_AppWindow('LUValReturn',RetVal:@RM:@Window:'.SERV_INFO':@RM:SelPos)
                        
                        RIRec = XLATE('REACT_ITEM',RetVal,'','X')
                        
                        If RIRec = 'T' then
                            CardWindow	= 'REACT_ITEM'
                            CardKey		= RetVal
                            DefaultRec	= ''
                            NewCardCtrl	= ''
                            RecalcCtrl	= @Window:'.SERV_INFO'
                            RecalcPos	= SelPos
                            RetCtrl		= @Window:'.SERV_INFO'
                            RetPos		= SelPos
                            
                            oAParms = CardWindow:@RM:CardKey:@RM:DefaultRec:@RM:NewCardCtrl:@RM:RecalcCtrl:@RM:RecalcPos:@RM:RetCtrl:@RM:RetPos
                            
                            obj_AppWindow('ViewNewCard',oAParms)
                            
                            Set_Property('REACT_ITEM.TUBE_GRADE','FOCUS',1)
                            
                            If Get_Status(errCode) then
                                ErrMsg(errCode)
                            end
                        end
                        
                        GoSub Refresh
                    end				    
				end else
				    Error_Services('DisplayError')
				end
				
			end	;* End of check for null SNReq
			
	End Case
	
	GoSub Refresh
	
	
return
* * * * * * *
SvcsDC:
* * * * * * * 
	
	CurrPos = Get_Property(EntID,'SELPOS')
	CurrCol = CurrPos<1>
	CurrRow = CurrPos<2>
	
	CurrList = Get_Property(EntID,'LIST')
	
	Begin Case
		Case CurrCol = COL$ITEM_RI_NO
			RINo = CurrList
			If RINo NE '' then
				obj_AppWindow('ViewRelated','REACT_ITEM':@RM:RINo)
			end
			
	End Case
	
return
* * * * * * *
ShiftSigPC:
* * * * * * *
	CtrlEntID = EntID
	
	PrevSelPos = Get_Property(CtrlEntID,'PREVSELPOS')
	PrevCol = PrevSelPos<1>
	PrevRow = PrevSelPos<2>
	
	SelPos	= Get_Property(CtrlEntID,'SELPOS')
	CurCol	= SelPos<1>
	CurRow	= SelPos<2>
	
	ListData = Get_Property(CtrlEntID,'LIST')
	ArrayData = Get_Property(CtrlEntID,'DEFPROP')
	
	CurRowData = ListData
	
	* Move Up to non-empty row or first row *
	
	TestRow = CurRowData
	Convert @VM to '' IN TestRow
	
	If TestRow = '' then
		CurLine = CurRow
		Loop
			Col1Val = ListData
		Until Col1Val NE '' OR CurLine = 1
			CurLine -=1
		Repeat
		Set_Property(CtrlEntId,"SELPOS",1:@FM:CurLine)
		
	end
	
	If CurRow NE PrevRow then
		* check last field in prev row
		
		If ListData NE '' then
			If ListData = '' then
				Msg('','Please fill in the Item SN column.')
				Set_Property(CtrlEntID,'SELPOS',COL$ITEM_ID:@FM:PrevRow)
			end
		end
		
	end	;* End of check for row change
	
	
return
* * * * * * *
ShiftSigDC:
* * * * * * *
	
	CurrPos = Get_Property(EntID,'SELPOS')
	CurrCol = CurrPos<1>
	CurrRow = CurrPos<2>
	
	CurrList = Get_Property(EntID,'LIST')
	
	Note = CurrList
	
	DialogResult = Dialog_Box("DIALOG_ZOOM",@Window,Note)
	
	If DialogResult = 'Cancel' then return
	
	If DialogResult NE ''  then
		Set_Property(EntID,'CELLPOS',@User4,COL$SIG:@FM:CurrRow)
		Set_Property(EntID,'CELLPOS',obj_Calendar('CurrDTM'),COL$SIG_DTM:@FM:CurrRow)
		Set_Property(EntID,'CELLPOS',DialogResult,COL$SIG_NOTE:@FM:CurrRow)
	end
	
return
* * * * * *
CurrRIDC:
* * * * * *
	
	CurrPos = Get_Property(EntID,'SELPOS')
	CurrCol = CurrPos<1>
	CurrRow = CurrPos<2>
	
	CurrList = Get_Property(EntID,'LIST')
	
	Begin Case
		Case CurrCol = COL$CURR_RI_NO
			RINo = CurrList
			If RINo NE '' then
				obj_AppWindow('ViewRelated','REACT_ITEM':@RM:RINo)
			end
			
			
	End Case
	
return
* * * * * * *
RemOptions:
* * * * * * *
	
	
	SelPos = Get_Property(@Window:'.REM_RI_NO','SELPOS')
	CurCol = SelPos<1>
	CurRow = SelPos<2>
	CurrArray = Get_Property(@Window:'.REM_RI_NO','ARRAY')
	
	Begin Case
		Case CurCol = COL$RI_DISP
			
			RetVal = Popup(@Window,'','REACT_ITEM_DISP')
			
			If RetVal NE '' then
				obj_AppWindow('LUValReturn',RetVal:@RM:@Window:'.REM_RI_NO':@RM:SelPos)
			end
			
	End Case
	
	GoSub Refresh
	
return
* * * * * * * * 
CalcRIHKeys:
* * * * * * * *
	
	ReactNo	= Get_Property(@Window:'.REACTOR','DEFPROP')
	PostDTM	= Get_Property(@Window:'.POST_DTM','INVALUE')
	
	AtRecord = Get_Property(@Window,'ATRECORD')
	
	RawReactItemIds = AtRecord
	rawCnt = COUNT(RawReactItemIds,@VM) + (RawReactItemIds NE '')
	
	InstRINos = ''
	
	For I = 1 to rawCnt
		If RawReactItemIds<1,I> NE '' then
			InstRINos<1,-1> = obj_React_Item('Serial_RINo',RawReactItemIds<1,I>)
		end
	Next I
	
	InstRIData    = ''
	InstRIData<1> = InstRINos
	InstRIData<2> = XLATE('REACT_ITEM', InstRINos, 17, 'X')
	InstRIData<3> = OConv(XLATE('REACT_ITEM',InstRINos,11,'X'), '[RI_TYPE_CONV]')
	InstRIData<4> = XLATE('REACT_ITEM',InstRINos,8,'X')
	InstRIData<5> = XLATE('REACT_ITEM',InstRINos,9,'X')
	InstRIData<6> = XLATE('REACT_ITEM',InstRINos,10,'X')
	InstRIData<7> = XLATE('REACT_ITEM',InstRINos,10,'X')
	
	Set_Property(@Window:'.INST_RI_NO', 'DEFPROP', InstRIData)
	
	GoSub ColorInstRiTable
	
	* Remove Calculation
	
	PostedBy    = Get_Property(@Window:'.RI_POST_BY','DEFPROP')
	NewRITypes  = XLATE('REACT_ITEM',InstRINos,REACT_ITEM_RI_TYPE$,'X')
	CurrRIArray = Get_Property(@Window:'.CURR_REACT_ITEMS','ARRAY')
	CurrRITypes = CurrRIArray
	CurrRITypes = ICONV(CUrrRITypes,'[CONV_CODE_DESC,REACT_ITEM_TYPE]')
	
	nRICnt = COUNT(NewRITypes,@VM) + (NewRITypes NE '')
	cRICnt = COUNT(CurrRITypes,@VM) + (CurrRITypes NE '')
	
	RemRINos = ''
	RemHistKeys = ''
	
	For J = 1 to nRICnt
		NewRIType = NewRITypes<1,J>
		For K = 1 to cRICnt
			CurrRIType = CurrRITypes<1,K>
			If CurrRIType[1,1] = NewRIType[1,1] then
				RemNo		= CurrRIArray
				RemInstDTM	= ICONV(CurrRIArray,'DT')
				RemHistKey	= ReactNo:'*':RemNo:'*':RemInstDTM
				
				Locate RemNo IN RemRINos using @VM setting Pos else
					RemRINos = INSERT(RemRINos,1,Pos,0,RemNo)
					RemHistKeys = INSERT(RemHistKeys,1,Pos,0,RemHistKey)
				end
			end
		Next K	;* End of Curr Loop
	Next J	;* End of New Loop
	
	RemArray     = Get_Property(@Window:'.REM_RI_NO', 'ARRAY')
	
	RemArray<1>  = RemRINos
	RemArray<2>  = Xlate('REACT_ITEM', RemRINos, 17, 'X')
	RemArray<3>  = OConv(Xlate('REACT_ITEM', RemRINos, 11, 'X'), '[RI_TYPE_CONV]')
	RemArray<4>  = Xlate('REACT_ITEM', RemRINos, 8, 'X')
	RemArray<5>  = Xlate('REACT_ITEM', RemRINos, 9, 'X')
	RemArray<6>  = XLATE('REACT_ITEM', RemRINos, 10, 'X')
	RemArray<8>  = OConv(RemArray<7>, '[CONV_CODE_DESC,REACT_ITEM_DISP]')
	RemArray<9>  = Xlate('REACT_ITEM_HIST', RemHistKeys, 1, 'X')
	
	KeyList = RemHistKeys
	kCnt    = COUNT(KeyList,@VM) + (KeyList NE '')
	Dtms    = ''
	For I = 1 to kCnt
		 Dtms<1,I> = FIELD(KeyList<1,I>,'*',3)
	Next I
	RemArray<10> = OConv(Dtms, 'DT4/^S')
	RemArray<11> = RemHistKeys
	
	Set_Property(@Window:'.REM_RI_NO', 'DEFPROP', RemArray)
	
	GoSub ColorRemRiTable
	GoSub Refresh
	
return
* * * * * * *
CopyRemove:
* * * * * * *
	
return
	EntID      = @Window:'.CURR_REACT_ITEMS'
	CurrRIList = Get_Property(EntID,'LIST')
	CurrRISelection	= Get_Property(EntID,'SELPOS')
	SelectedRows	= CurrRISelection<2>
	Convert @VM to @FM in SelectedRows
	SelCnt		= COUNT(SelectedRows,@FM) + (SelectedRows NE '')
	If SelCnt	= 0 then
		ErrMsg('You must select at least one row in order to copy to the Remove list.')
		return
	end
	CopyRINos = 0
	CopyRICnt = 0
	For I = 1 to SelCnt
		If CurrRIList,COL$CURR_RI_NO> NE '' then
			CopyRICnt += 1
			CopyRINos<1,CopyRICnt> 	=CurrRIList,COL$CURR_RI_NO>
		end
	Next I
	Set_Property(EntID,'SELPOS',SlotSelection)	;* Toggle WM_IN select off
return
* * * * * * *
PostItems:
* * * * * * *
	
	RemList    = Get_Property(@Window:'.REM_RI_NO','LIST')
	
	CurrWindow = @Window
	
	rlCnt = COUNT(RemList,@FM) + (RemList NE '')
	
	For I = 1 to rlCnt
		RINo = RemList
	Until RINo = ''
		
		If RemList = '' then
			
			* RINo without associated Disposition Code entered
			
			ErrMsg('Application Message':@SVM:'Disposition for items being removed has not been completed.')
			
			Set_Property(CurrWindow:'.TAB','VALUE',3)
			Send_Event(CurrWindow:'.TAB','CLICK')
			
			
			Set_Property(CurrWindow:'.REM_RI_NO','FOCUS',1)
			Set_Property(CurrWindow:'.REM_RI_NO','SELPOS',COL$RI_DISP:@FM:I)
			
			hTable = Get_Property(CurrWindow:'.REM_RI_NO','HANDLE')
			
			If NOT(hTable) then 
				ErrMsg('Problem Getting the handle to the REM_RI_NO control.')
				return
			end
			
			void = Send_Message(hTable,DTM_EDITCURCELL$,DT_BEGINEDIT$,0)
			
			return
			
		end	;* End of check for missing Disposition code on line with RI No 
		
	Next I
	
	Ctrls  = @Window:'.REACTOR_LOG_NO':@RM			; Props  = 'DEFPROP':@RM
	Ctrls := @Window:'.RI_POST_BY':@RM				; Props := 'DEFPROP':@RM
	Ctrls := @Window:'.RI_POST_DTM'					; Props := 'DEFPROP'
	
	Vals = Get_Property(Ctrls,Props)
	
	RLNo	= Vals[1,@RM]
	PostBy	= Vals[COL2()+1,@RM]
	PostDTM	= Vals[COL2()+1,@RM]
	Reactor_Log_Events(@Window, 'WRITE')
	CurrRLRec = Get_Property (@Window, "ATRECORD")
	Database_Services('WriteDataRow', 'REACTOR_LOG', RLNo, CurrRLRec, 1, 0, 1)
	Set_Property(@Window, 'SAVEWARN', 0)
	If PostBy = '' then
		obj_Reactor_Log('PostReactItems',RLNo)
	end else
		obj_Reactor_Log('UnpostReactItems',RLNo)
	end
	
	If Error_Services('HasError') then
		ErrorMessage = Error_Services('GetMessage')
		ErrMsg('Application Message':@SVM:ErrorMessage)
	end
	
	obj_Appwindow('LoadFormKeys','REACTOR_LOG':@RM:RLNo)
	
	Send_Event(@Window, 'READ')	
	
return
* * * * * * *
RemRIDC:
* * * * * * *
	
	CurrPos = Get_Property(EntID,'SELPOS')
	CurrCol = CurrPos<1>
	CurrRow = CurrPos<2>
	
	CurrList = Get_Property(EntID,'LIST')
	
	Begin Case
		Case CurrCol = COL$RI_NO
			RINo = CurrList
			If RINo NE '' then
				obj_AppWindow('ViewRelated','REACT_ITEM':@RM:RINo)
			end
			
	End Case
	
return
* * * * * * *
PrintRootCause:
* * * * * * *
	
	ReactLogNo 	= Get_Property(@Window:'.REACTOR_LOG_NO','DEFPROP')
	ReactNo		= Get_Property(@Window:'.REACTOR','DEFPROP')
	ServInfo	= Get_Property(@Window:'.SERV_INFO','DEFPROP')
	
	InitProbCat = ServInfo<1,1>  ;* 1st line, 1st column is Init Prob Cat
	
	Print_RootCause_Analysis(ReactLogNo,ReactNo,InitProbCat)
	
return
* * * * * * *
LOTOClick:
* * * * * * *
	
	xlApp = OleCreateInstance("excel.Application")
	
	OlePutProperty(XlApp, 'Visible', xlSheetVisible)
	
	If OleStatus() then
		GOTO HadError
		return
	end
	
	xlWorkBooks = OleGetProperty(xlApp, "Workbooks")
	
	If OleStatus() then
		GOTO HadError
		return
	end
	
	xlWkb = OleCallMethod(xlWorkbooks,"Open",Environment_Services('GetUserDataRootPath') : "\Facilities\DeptData\LOTO Procedures\LOTO Master List App.xlsm")
	
	If OleStatus() then
		GOTO HadError
		return
	end
	
	xdummy = OleCallMethod(xlWkb, "RunAutoMacros", xlAutoOpen )
	
	If OleStatus() then
		GOTO HadError
		return
	end
	
	Set_Property(@Window:'.LO_REVIEWED','CHECK',1)
	
	GoSub Refresh
	
	
return
* * * * * * *
HadError:
* * * * * * *
	
	status = OleStatus()
	
	If Status then
		ErrMsg('OLE Error Code ':Status)
	end
	
	xlChart = ''
	Charts = ''
	range = ''
	xlSht = ''
	xlWkb=''
	xlWorkBooks = ''
	x = OleCallMethod(xlApp, 'Quit')
	
return 
SvcsLF:
	
	GoSub VerifyReactItems
	
return
VerifyReactItems:
	
	GoSub CalcRIHKeys
	SvcsList      = Get_Property(@Window:'.SERV_INFO', 'LIST')
	Done          = False$
	BadRow        = False$
	BadRowMessage = ''
	For each Row in SvcsList using @FM setting RowPos
		ReactItem       = Row<0, COL$ITEM_ID>
		ServiceItem     = Row<0, COL$SERV_ID>
		ServiceItemType = XLATE('REACT_SERVS', ServiceItem, REACT_SERVS_GRAPHITE_OR_TUBE$, 'X')
		If ReactItem NE '' then
			If RowExists('REACT_ITEM', ReactItem) EQ False$ then
				Msg(@Window, '', 'OK', '', 'Invalid React Item':@FM:'React Item ':ReactItem:' does not exist!')
				BadRow = RowPos
			end else
				RIRec     = Database_Services('ReadDataRow', 'REACT_ITEM', ReactItem)
				RIType    = RIRec
				TypeMatch = (RIType EQ ServiceItemType) OR ServiceItemType EQ ''
				Retired   = RIRec NE ''
				If Retired then
					BadRowMessage := 'Invalid React Item':@FM:'React Item ':ReactItem:' is retired' : CRLF$
					BadRow         = RowPos
				end
				If Not(TypeMatch) then
					BadRowMessage := 'Invalid React Item':@FM:'React Item ':ReactItem:' is the incorrect type' : CRLF$
					BadRow         = RowPos
				end
				If BadRow NE False$ then
					Msg(@Window, '', 'OK', '', BadRowMessage)
					BadRow = RowPos
				end
			end
		end
	Until Done
	Next Row
	
	If BadRow then
		SvcsList = ''
		Set_Property(@Window:'.SERV_INFO', 'LIST', SvcsList)
	end
	
return
FillServInfoCalcCols:
	
	ServInfo     = Get_Property(@Window:'.SERV_INFO', 'ARRAY')
	CatIds       = ServInfo
	ServIds      = ServInfo
	ReactItemIds = ServInfo
	
	CatDescs      = Xlate('REACT_PROB_CAT', CatIds , REACT_PROB_CAT_REACTOR_PROBLEM_CATEGORY$, 'X')
	ServDescs     = Xlate('REACT_SERVS', ServIds, REACT_SERVS_DESCRIPTION$, 'X')
	convert @fm to @vm in ServDescs
	ServItemTypes = OConv(Xlate('REACT_SERVS', ServIds, REACT_SERVS_REACT_ITEM_TYPE$, 'X'), '[CONV_CODE_DESC,REACT_ITEM_TYPE]')
	
	RINos      = obj_React_Item('Serial_RINo', ReactItemIds)
	MfrPartNos = Xlate('REACT_ITEM', RINos, REACT_ITEM_MFR_PART_NO$, 'X')
	Revs       = Xlate('REACT_ITEM', RINos, REACT_ITEM_MFR_PART_NO_REV$, 'X')
	SerialNos  = Xlate('REACT_ITEM', RINos, REACT_ITEM_SERIAL_NO$, 'X')
	
	ServInfo = CatDescs
	ServInfo  = ServDescs
	ServInfo     = ServItemTypes
	ServInfo    = RINos
	ServInfo   = MfrPartNos
	ServInfo           = Revs
	ServInfo     = SerialNos
	Set_Property(@Window:'.SERV_INFO', 'ARRAY', ServInfo)
	
	For each CatId in CatIds using @VM setting vPos
		If CatId NE '' then
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$PROB_CAT_DESC, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$SERV_ID_DESC, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$ITEM_TYPE, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$ITEM_RI_NO, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$MFR_PART_NO, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$REV, vPos ,GREEN$)
			stat = Send_Message(@Window:'.SERV_INFO', 'COLOR_BY_POS', COL$SERIAL_NO, vPos ,GREEN$)
		end
	Next CatId
	
return
ColorInstRiTable:
	
	InstRiArray = Get_Property(@Window:'.INST_RI_NO', 'ARRAY')
	InstRiKeys  = InstRiArray<1>
	If InstRiKeys NE '' then 
		For each InstRiKey in InstRiKeys using @VM setting vPos
			If InstRiKey NE '' then 
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_SERIAL, vPos ,GREEN$)
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_TYPE, vPos ,GREEN$)
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_PART_NO, vPos ,GREEN$)
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_PART_REV, vPos ,GREEN$)
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_SERIAL_NO, vPos ,GREEN$)
				stat = Send_Message(@Window:'.INST_RI_NO', 'COLOR_BY_POS', COL$RI_DISP, vPos ,GREEN$)
			end
		Next InstRiKey
	end
	
return
ColorRemRiTable:
	
	RemRiArray = Get_Property(@Window:'.REM_RI_NO', 'ARRAY')
	RemRihKeys = RemRiArray<11>
	If RemRihKeys NE '' then 
		For each RemRihKey in RemRihKeys using @VM setting vPos
			If RemRihKey NE '' then 
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_NO, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_SERIAL, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_TYPE, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_PART_NO, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_PART_REV, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_SERIAL_NO, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_DISPOSITION, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$RI_INST_RL_ID, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$INST_DTM, vPos ,GREEN$)
				stat = Send_Message(@Window:'.REM_RI_NO', 'COLOR_BY_POS', COL$INST_RIH_KEY, vPos ,GREEN$)
			end
		Next RemRihKey
	end
	
return