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

/*
	Commuter module for REACT_SHIFT_TARG (Reactor Shift Targets) window
	
	12/09/2013 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, RList 
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI



$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT REACT_SHIFT_TARG_EQUATES


EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\

EQU COL$REACT_NO	TO 1
EQU COL$TARGET		TO 2
EQU COL$NOTE		TO 3


ErrTitle = 'Error in React_Shift_Targ commuter module.'
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 = 'READ'				; GOSUB Read
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.REACT_NO' AND Event = 'DBLCLK'	; GOSUB ReactDC	
	CASE EntID = @WINDOW:'.TARG_DT' AND Event = 'GOTFOCUS'	; GOSUB TargDtGF
	
		
	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)

GOSUB Refresh

RETURN


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


IF Get_Property(@WINDOW,'@READONLY') THEN
	obj_AppWindow('ReadOnly',@RM:1)			;* Reenables data bound controls
	Set_Property(@WINDOW,'@READONLY',0)		;* Clear flag on window
END


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

* 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

RETURN





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

IF Get_Property(@WINDOW,'RECORD') = '' THEN
	* New Record

	OPEN 'REACTOR' TO ReactTable ELSE
		ErrMsg('Unable to open "REACTOR" table for read')
		RETURN
	END

	SELECT ReactTable

	ReactData = ''
	Done = 0

	LOOP
		READNEXT ReactNo ELSE Done = 1
	UNTIL Done
		LOCATE ReactNo IN ReactData<COL$REACT_NO>  BY 'AR' USING @VM SETTING Pos ELSE
			CurrMode = OCONV(XLATE('REACTOR',ReactNo,'CURR_MODE','X'),'[REACT_MODE_CONV]')
			
			ReactData = INSERT(ReactData,COL$REACT_NO,Pos,0,ReactNo)
			ReactData = INSERT(ReactData,COL$NOTE,Pos,0,CurrMode)
		END
	REPEAT

	Set_Property(@WINDOW:'.REACT_NO','DEFPROP',ReactData)
END

GOSUB Refresh

RETURN


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


RETURN


* * * * * * *
Delete:
* * * * * * *



RETURN

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

RETURN


* * * * * * *
TargDtGF:
* * * * * * * 

TargDt = Get_Property(@WINDOW:'.TARG_DT','DEFPROP')

IF TargDt = '' THEN
	TargDt = Date()
	Set_Property(@WINDOW:'.TARG_DT','INVALUE',TargDt)
	Send_Event(@WINDOW:'TARG_DT','LOSTFOCUS')
END

RETURN



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

CtrlEntID = @WINDOW:'.REACT_NO'

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

Note = Get_Property(CtrlEntID,'CELLPOS',COL$NOTE:@FM:CurrRow)

* * *   Open Dialog for Memo   * * *

DialogResult = Dialog_Box("DIALOG_ZOOM",@WINDOW,Note)

IF DialogResult = 'Cancel' THEN RETURN

IF DialogResult NE ''  THEN
	Set_Property(CtrlEntID,'CELLPOS',DialogResult,COL$NOTE:@FM:CurrRow)
END

RETURN




