COMPILE FUNCTION Comm_Dialog_Passdown(Method, Parm1, Parm2)

/*
	Commuter module for Dialog_React_Event window.
	
	01/10/2007 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg, RList, Obj_React_Event
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Btree.Extract, Msg, Send_Info
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Send_Message, Popup, Collect.IXVals, Msg


$INSERT APPCOLORS
$INSERT MSG_EQUATES
$INSERT RLIST_EQUATES
$INSERT POPUP_EQUATES


EQU CRLF$	TO \0D0A\

EQU COL$REACT_NO		TO 1
EQU COL$REACT_TYPE		TO 2
EQU COL$RED_PRESS		TO 3
EQU COL$WAFER_SIZE		TO 4
EQU COL$TOOL_LOC		TO 5
EQU COL$ASSIGNMENT		TO 6
EQU COL$ESC_HOURS		TO 7

ErrTitle = 'Error in Comm_Dialog_Passdown'
ErrorMsg = ''
ErrCode = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
	CASE Method = 'LUReactor'		; GOSUB LUReactor
	CASE Method = 'Cancel'			; GOSUB Cancel
	CASE Method = 'PostEntries'		; GOSUB PostEntries
	CASE Method = 'ReactNoGF'		; GOSUB ReactNoGF
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE

RETURN Result


* * * * * * *
Create:
* * * * * * *
	
	obj_AppWindow('Create')
	
	Set_Property(@WINDOW,'STATUSLINE',@WINDOW:'.STATUSLINE_FIX')
	
	GOSUB Refresh
	
RETURN


* * * * * * *
Refresh:
* * * * * * *
	
RETURN


* * * * * * *
ReactNoGF:
* * * * * * *
	
* Don't add a return here

* * * * * * *
LUReactor:
* * * * * * *
	
	IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
	IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2
	
	Set_Status(0)
	
	TypeOver = ''
	TypeOver<PSELECT$>	= '2'		;* Multiple Select
	TypeOver<PTYPE$> 	= 'E'		;* Return entire row
	
	ReactData = Popup(@WINDOW,TypeOver,'REACTORS')
	
	IF ReactData = '' THEN RETURN
	
	Set_Property(@WINDOW:'.REACT_NO','LIST',ReactData)
	
	LineCnt = COUNT(ReactData,@FM) + (ReactData NE '')
	ColCnt = 7
	
	FOR Line = 1 TO LineCnt
		FOR Column = 2 TO ColCnt
			stat = Send_Message(@WINDOW:'.REACT_NO','COLOR_BY_POS',Column,Line,GREEN$)
		NEXT Column
	NEXT Line
	
RETURN


* * * * * * *
Cancel:
* * * * * * *
	
	End_Dialog(@WINDOW,'')
	
RETURN


* * * * * * *
PostEntries:
* * * * * * *
	
	ReactNos	= Get_Property(@WINDOW:'.REACT_NO','ARRAY')<COL$REACT_NO>
	Comment		= Get_Property(@WINDOW:'.COMMENT','DEFPROP')
	
	LOOP
		TestChar = ReactNos[-1,1]
	UNTIL TestChar NE @VM OR ReactNos = ''
		ReactNos[-1,1] = ''
	REPEAT
	
	EventKeys = ''		;* Keys to return to the REACT_EVENT window for a browse of the newly created records
	
	IF ReactNos NE '' AND Comment NE '' THEN
		
		EventDTM	= OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')	;* Same DTM for all new records
		EventType	= 'PD'											;* Passdown
		LoggedBy	= @USER4
		
		ReactCnt = COUNT(ReactNos,@VM) + (ReactNos NE '')
		
		FOR I = 1 TO ReactCnt
			ReactNo		= ReactNos<1,I>
			CurrMode	= XLATE('REACTOR',ReactNo,'CURR_MODE','X')
			
			obj_React_Event('Create',ReactNo:@RM:EventDTM:@RM:EventType:@RM:LoggedBy:@RM:Comment:@RM:@RM:CurrMode)
			
			ErrCode = ''
			If Get_Status(ErrCode) then
				Msg(@Window, '', 'OK', '', 'Process Error':@FM:'Error posting entries. ':ErrCode)
			end else
				Set_Property(@Window:'.REACT_NO', 'LIST', '')
				Set_Property(@Window:'.COMMENT', 'TEXT', '')
			end
			
			EventKeys<I> = ReactNo:'*':ICONV(EventDTM,'DT')
		NEXT I
		
	END else
		Msg(@Window, '', 'OK', '', 'Process Error':@FM:'React No(s) and Comment must not be null!')
	end
	
RETURN

