COMPILE FUNCTION React_Item(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for REACT_ITEM window
	
	01/13/2014 - John C. Henry, J.C. Henry & Co., Inc. cloned from Graphite
*/

DECLARE SUBROUTINE Set_Property, ErrMsg, obj_Appwindow, Btree.Extract, Send_Event, Post_Event, obj_React_Item
DECLARE FUNCTION Get_Property, Send_Message, NextKey, Popup, obj_Calendar, Printer_Select
DECLARE FUNCTION Set_Printer, obj_Install, Start_Window, obj_React_Item_Hist, obj_React_Item, Dialog_Box


$INSERT REACT_ITEM_EQUATES
$INSERT REACT_ITEM_HIST_EQUATES
$INSERT APPCOLORS
$INSERT POPUP_EQUATES

EQU COL$REACT_NO			TO 1
EQU COL$SVC_HRS				TO 2
EQU COL$SVC_WFRS			TO 3
EQU COL$RDS_WAFER_COUNT		TO 4
EQU COL$PCRC				TO 5
EQU COL$INST_DTM			TO 6
EQU COL$INST_REACT_HRS		TO 7
EQU COL$INST_REACT_WFRS		TO 8
EQU COL$INST_RL_ID			TO 9
EQU COL$REM_DTM				TO 10
EQU COL$REM_REACT_HRS		TO 11
EQU COL$REM_REACT_WFRS		TO 12
EQU COL$REM_RL_ID			TO 13

EQU SPECIAL_BLUE$	TO 227 + (253*256) + (248*65536)
EQU CRLF$			TO \0D0A\


EQU PI$LEFT		TO	1
EQU PI$TOP		TO  2
EQU PI$RIGHT	TO	3
EQU PI$BOTTOM	TO	4
EQU PI$WIDTH	TO 	5
EQU PI$HEIGHT	TO	6
EQU PI$SIZE		TO	7


ErrTitle = 'Error in React_Item'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'READ'				; GOSUB Read
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.REACT_NO'
	
		BEGIN CASE
			CASE Event = 'DBLCLK'			; GOSUB ReactDC
			
		END CASE
		
	CASE EntID = @WINDOW:'.LU_RI_NO' AND Event = 'CLICK'	 		; GOSUB LUReactItem
	CASE EntID = @WINDOW:'.NEW' AND Event = 'CLICK'					; GOSUB New
	CASE EntID = @WINDOW:'.LU_MFR_CD' AND Event = 'CLICK'			; GOSUB LUMfrCd
	CASE EntID = @WINDOW:'.LU_RI_TYPE' AND Event = 'CLICK'			; GOSUB LURIType
	CASE EntID = @WINDOW:'.LU_PART_TYPE' AND Event = 'CLICK'		; GOSUB LUPartType
	CASE EntID = @WINDOW:'.LU_TUBE_STYLE' AND Event = 'CLICK'		; GOSUB LUTubeStyle			;* Added by dkk 12/1/14
	CASE EntID = @WINDOW:'.LU_SUSC_SIZE' AND Event = 'CLICK'		; GOSUB LUSuscSize
	CASE EntID = @WINDOW:'.LU_PKT_SIZE' AND Event = 'CLICK'			; GOSUB LUPktSize
	CASE EntID = @WINDOW:'.LU_PKT_QTY' AND Event = 'CLICK'			; GOSUB LUPktQty
	CASE EntID = @WINDOW:'.RETIRE_BUTTON' AND Event = 'CLICK'		; GOSUB RetireItem
	CASE EntID = @WINDOW:'.PRINT_LABEL' AND Event = 'CLICK'			; GOSUB PrintLabel

	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:
* * * * * * *

obj_Appwindow('Create',@WINDOW)


RETURN



* * * * * * *
New:
* * * * * * *

RINo = Get_Property(@WINDOW:'.REACT_ITEM','DEFPROP')

IF RINo = '' THEN
	NextRINo = NextKey('REACT_ITEM')
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:NextRINo)
END

EnterBy = Get_Property(@WINDOW:'.ENTER_BY','DEFPROP')

IF EnterBy = '' THEN
	Set_Property(@WINDOW:'.ENTER_BY','INVALUE',@USER4)
	Set_Property(@WINDOW:'.ENTER_DTM','DEFPROP',obj_Calendar('CurrDTM'))
END

GOSUB Refresh

RETURN


* * * * * * *
Close:
* * * * * * *

*DEBUG

obj_Appwindow('CardReturn',@WINDOW)

RETURN



* * * * * * *
Read:
* * * * * * *





GOSUB Refresh

RETURN

* * * * * * *
Write:
* * * * * * *

Parent = Get_Property(@WINDOW,'PARENT')

IF Parent = 'REACTOR_LOG' OR Parent = 'REACT_STATE' THEN
	Post_Event(@WINDOW,'CLOSE')
END

RETURN


* * * * * * *
Clear:
* * * * * * *

*Send_Event(@WINDOW,'PAGE',1)



* * * * * * *
Refresh:
* * * * * * *

Ctrls  = @WINDOW:'.ENTER_BY':@RM		; Props  = 'TEXT':@RM
Ctrls := @WINDOW:'.ENTER_DTM'			; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

EnterBy		= Vals[1,@RM]
EnterDTM	= Vals[COL2()+1,@RM]

IF EnterBy	= '' THEN Vals  = 1:@RM ELSE Vals  = 0:@RM
IF EnterDTM = '' THEN Vals := 1		ELSE Vals := 0

Props = 'ENABLED':@RM:'ENABLED'

Set_Property(Ctrls,Props,Vals)

* 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<Line,1> 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

*/



ETCtrl = @WINDOW:'.REACT_NO'
ETList = Get_Property(ETCtrl,'LIST')
ListCnt = COUNT(ETList,@FM) + (ETList NE '')


FOR Line = 1 TO ListCnt
	
	IF MOD(Line,2) THEN
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$REACT_NO,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$SVC_HRS,Line,VL_YELLOW$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$SVC_WFRS,Line,VL_YELLOW$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$RDS_WAFER_COUNT,Line,VL_YELLOW$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$PCRC,Line,VL_YELLOW$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$INST_DTM,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$INST_REACT_HRS,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$INST_REACT_WFRS,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$INST_RL_ID,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$REM_DTM,Line,SPECIAL_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$REM_REACT_HRS,Line,RCV_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$REM_REACT_WFRS,Line,RCV_BLUE$)
		stat = Send_Message(ETCtrl,'COLOR_BY_POS',COL$REM_RL_ID,Line,RCV_BLUE$)
		
	END ELSE
		FOR N = 1 TO 11
			stat = Send_Message(ETCtrl,'COLOR_BY_POS',N,Line,WHITE$)
		NEXT N
	END
NEXT Line

RETURN


* * * * * * *
RetireItem:
* * * * * * *

Ctrls  = @WINDOW:'.RETIRE_DT':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.RETIRE_BY'			; Props := 'INVALUE'

Vals = Get_Property(Ctrls,Props)

RetDt = Vals[1,@RM]
RetBy = Vals[COL2()+1,@RM]

IF RetBy NE '' THEN RETURN		;* Nothing to do

Vals  = OCONV(Date(),'D4/'):@RM
Vals := @USER4

Set_Property(Ctrls,Props,Vals)

GraphNo = Get_Property(@WINDOW:'.GR_NO','DEFPROP')

Send_Event(@WINDOW,'WRITE')

obj_AppWindow('LoadFormKeys',@WINDOW:@RM:GraphNo)

RETURN


* * * * * * *
ReactDC:
* * * * * * *

CurrPos = Get_Property(EntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

GRNo	= Get_Property(@WINDOW:'.GR_NO','DEFPROP')

IF GRNo = '' THEN RETURN

BEGIN CASE
	CASE CurrCol = COL$INST_RL_ID
		RLId = CurrRow<COL$INST_RL_ID>
		
	CASE CurrCol = COL$REM_RL_ID
		RLId = CurrRow<COL$INST_RL_ID>

END CASE

RLId = Get_Property(EntID,'CELLPOS',CurrCol:@FM:CurrRow)

IF RLId NE '' THEN
	Dummy = Start_Window( 'REACTOR_LOG', @WINDOW, RLId:'*CENTER', '', '' )
END

RETURN


* * * * * * *
LURIType:
* * * * * * *

RetVal = Popup(@WINDOW,'','REACT_ITEM_TYPE')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.RI_TYPE'
	obj_Appwindow('LUValReturn',oaParms)
END

RETURN


* * * * * * *
LUReactItem:
* * * * * * *

RetVal = Dialog_Box('DIALOG_REACT_ITEM_QUERY', @WINDOW)

Display = ''
Display<PDISPLAY$>	= RetVal
Display<PMODE$>		= 'K'

RetVal = Popup(@WINDOW,Display,'REACT_ITEM')

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

IF INDEX(RetVal,@VM,1) THEN
	Set_Property(@WINDOW,'QBFLIST',RetVal)
END ELSE
	obj_AppWindow('LoadFormKeys',@WINDOW:@RM:RetVal)
END
	
RETURN



* * * * * * *
LUPartType:
* * * * * * *


RetVal = Popup(@WINDOW,'','RI_PART_TYPE')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.PART_TYPE'
	obj_Appwindow('LUValReturn',oaParms)
END


RETURN


* * * * * * *
LUTubeStyle:							;* Added by dkk 12/1/14
* * * * * * *


RetVal = Popup(@WINDOW,'','TUBE_STYLE')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.TUBE_STYLE'
	obj_Appwindow('LUValReturn',oaParms)
END


RETURN



* * * * * * *
LUMfrCd:
* * * * * * * 

MfrCd = Popup(@WINDOW,'','REACT_VENDOR')

IF MfrCd NE '' THEN
	oaParms = MfrCd:@RM:@WINDOW:'.MFR_CD'
	obj_Appwindow('LUValReturn',oaParms)
END

RETURN


* * * * * * *
LUReactType:
* * * * * * *

RetVal = Popup(@WINDOW,'','REACTOR_TYPE')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.REACT_TYPE'
	obj_Appwindow('LUValReturn',oaParms)
END



RETURN

* * * * * * *
LUSuscSize:
* * * * * * *
RetVal = Popup(@WINDOW,'','WAFER_SIZES')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.SUSC_SIZE'
	obj_Appwindow('LUValReturn',oaParms)
END


RETURN


* * * * * * *
LUPktSize:
* * * * * * *

RetVal = Popup(@WINDOW,'','WAFER_SIZES')

IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.PKT_SIZE'
	obj_Appwindow('LUValReturn',oaParms)
END

RETURN


* * * * * * *
LUPktQty:
* * * * * * *

ReactType = Get_Property(@WINDOW:'.REACT_TYPE','INVALUE')

IF ReactType NE '' THEN

	AllDisplayData	= XLATE('SYSREPOSPOPUPS','LSL2**SUSCEPTOR_POCKETS',PDISPLAY$,'X')
	DisplayData		= ''
	TypeOver 		= ''
	
	DispCnt = COUNT(AllDisplayData,@VM) + (AllDisplayData NE '')
	
	FOR I = 1 TO DispCnt
		DisplayLine = AllDisplayData<1,I>
		IF DisplayLine<1,1,2> = ReactType THEN
			DisplayData<1,-1> = DisplayLine
		END
	NEXT I
	
	TypeOver<PDISPLAY$> = DisplayData
	
	RetVal = Popup(@WINDOW,TypeOver,'SUSCEPTOR_POCKETS')
	
END ELSE
	RetVal = Popup(@WINDOW,'','SUSCEPTOR_POCKETS')
END


IF RetVal NE '' THEN
	oaParms = RetVal:@RM:@WINDOW:'.PKT_QTY'
	obj_Appwindow('LUValReturn',oaParms)
END

RETURN


* * * * * * *
PrintLabel:
* * * * * * * 

Ctrls  = @WINDOW:'.RI_NO':@RM	; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW				; Props := 'ATRECORD'

Vals = Get_Property(Ctrls,Props)

RINo		= Vals[1,@RM]
CurrRec		= Vals[COL2()+1,@RM]

obj_React_Item('PrintLabel',RINo:@RM:CurrRec)

RETURN


