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

/*
	Commuter module for REACTOR_LOG (Reactor_Log) window
	
	09/9/2013 - John C. Henry, J.C. Henry & Co., Inc.
*/


* * *  V  O  I  D   * * *



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, 
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, EntID, Repository
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI, Select_Into, MemberOf


$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_EQU
$INSERT REACTOR_LOG_EQUATES
$INSERT REACT_SERV_CAT_EQUATES

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

EQU COL$PROB_CAT			TO 1		;* SERV_INFO control equates
EQU COL$PROB_CAT_DESC		TO 2
EQU COL$SERV_ID				TO 3
EQU COL$SERV_DESC			TO 4
EQU COL$SCHEDULED			TO 5
EQU COL$SERV_SN_TYPE		TO 6
EQU COL$ITEM_IDS			TO 7
EQU COL$RI_NO				TO 8
EQU COL$RI_MFR_PART_NO		TO 9
EQU COL$RI_MFR_PART_REV		TO 10
EQU COL$RI_MFR_SERIAL_NO	TO 11

EQU HIDDEN$		TO 32
EQU SKIPPED$	TO 4100

ErrTitle = 'Error in CleanInsp'
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[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	
	CASE EntID = @WINDOW:'.SERV_INFO'
		BEGIN CASE 
			CASE Event = 'POSCHANGED'		; GOSUB ServicesPC
			CASE Event = 'DBLCLK'			; GOSUB ServicesDC
		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:
* * * * * * *

obj_Appwindow('Create',@WINDOW)

RETURN


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


RETURN


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


RETURN



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

Ctrls  = @WINDOW:'.REACTOR_LOG_NO':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACTOR':@RM				; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.NOTES':@RM				; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACT_HRS_START':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.TECH_SIG':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.END_DATE':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.END_TIME':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SERV_INFO'				; Props := 'LIST'

Vals = Get_Property(Ctrls,Props)

RLNo			= Vals[1,@RM]
ReactNo			= Vals[COL2()+1,@RM]
Notes			= Vals[COL2()+1,@RM]
ReactHrsStart	= Vals[COL2()+1,@RM]
TechSig			= Vals[COL2()+1,@RM]
EndDt			= Vals[COL2()+1,@RM]
EndTm			= Vals[COL2()+1,@RM]
ServList		= Vals[COL2()+1,@RM]





RETURN



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



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


* * * * * * *
ServicesPC:
* * * * * * * 

PrevSelPos = Get_Property(@WINDOW:'.SERV_INFO','PREVSELPOS')
PrevCol = SelPos<1>
PrevRow = SelPos<2>
CurrList = Get_Property(@WINDOW:'.SERV_INFO','ARRAY')

BEGIN CASE
	CASE CurCol = COL$PROB_CAT
		
END CASE

RETURN




* * * * * * *
ServicesDC:
* * * * * * *

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
		
		RList('SELECT REACT_PROB_CAT BY REACTOR_PROBLEM_CATEGORY', TARGET_ACTIVELIST$, '', '', '' )
		
		IF @RECCOUNT THEN
			TypeOver = ''
			TypeOver<PSELECT$> = 2
		    ProbCatIDs = Popup(@WINDOW,TypeOver,'SHOW_REACT_PROB_CAT')

   		    CONVERT @FM TO @VM IN ProbCatIDs
			
			CurrArray = DELETE( CurrArray, COL$PROB_CAT, CurRow, 0 )					
			CurrArray = INSERT( CurrArray, COL$PROB_CAT, CurRow, 0, ProbCatIDs )
			Set_Property(@WINDOW:'.SERV_INFO','ARRAY',CurrArray)
			
			Set_Property(@WINDOW, 'RECORD', Record )
			
			Send_Event(@WINDOW, '.SERV_INFO','CALCULATE',COL$PROB_CAT_DESC)
			Send_Event(@WINDOW, '.SERV_INFO','CALCULATE',COL$SERV_DESC)	
			Set_Property(@WINDOW, '@NoTopPosServs', 1 )
		    Send_Event(@WINDOW:'.SERV_INFO', 'LOSTFOCUS' )	
			Set_Property(@WINDOW, '@NoTopPosServs', '' )   		    
		END 

   CASE CurCol = COL$SERV_ID
   
		RList('SELECT REACT_SERVS BY DESCRIPTION',TARGET_ACTIVELIST$,'','','')
		
		IF @RECCOUNT THEN
		
		    PopupRec = entid( @appid<1>, 'POPUP', '', 'SHOW_REACT_SERVS' )
		    OverRide = ''
		    OverRide<pselect$> = 2
		    OverRide<pselect$> = 2
		    Choosen = repository( 'EXECUTE', PopupRec, @window, OverRide )
		    convert @fm to @vm in Choosen
		    
			CurrArray = Get_Property(@WINDOW:'.SERV_INFO','ARRAY')
			
			CurrArray = DELETE( CurrArray, 3, CurRow, 0 )
			CurrArray = DELETE( CurrArray, 4, CurRow, 0 )
			CurrArray = DELETE( CurrArray, 5, CurRow, 0 )
			CurrArray = DELETE( CurrArray, 6, CurRow, 0 )
			CurrArray = insert( CurrArray, 3, CurRow, 0, Choosen )
			CatIds = xlate( 'REACT_SERVS', Choosen, REACT_SERVS_REACT_SERV_CAT_ID$, 'X' )
			CatDescs = xlate( 'REACT_SERV_CAT', CatIds, REACT_SERV_CAT_REACTOR_SERVICE_CATEGORY$, 'X' )	
			CurrArray = insert( CurrArray, 5, CurRow, 0, CatIds )
			CurrArray = insert( CurrArray, 6, CurRow, 0, CatDescs )
			
			Record = Get_Property(@WINDOW, 'RECORD' )
			
			Record = INSERT( Record, REACTOR_LOG_REACT_SERV_CAT_ID$, CurRow, 0, CatIds )
			
			Set_Property(@WINDOW:'.SERV_INFO','ARRAY',CurrArray)
			
			Set_Property(@WINDOW,'RECORD', Record )
			Send_Event(@WINDOW, '.SERV_INFO', 'CALCULATE', COL$PROB_CAT_DESC )			
			Send_Event(@WINDOW, '.SERV_INFO', 'CALCULATE', 4 )	
			
			Set_Property(@WINDOW, '@NoTopPosServs', 1 )
		    Send_Event(@WINDOW:'.SERV_INFO', 'LOSTFOCUS' )	
			Set_Property(@WINDOW, '@NoTopPosServs', '' )    
		end 
		
	CASE CurCol = COL$ITEM_IDS
	
		Stmt = 'SELECT REACT_ITEMS WITH STATUS = "A" BY DESCRIPTION'
		RList( Stmt, target_activelist$, '', '', '' )
		if @reccount then
		    PopupRec = entid( @appid<1>, 'POPUP', '', 'SHOW_REACT_ITEMS' )
		    OverRide = ''
		    Choosen = repository( 'EXECUTE', PopupRec, @window, OverRide )
		    convert @fm to @vm in Choosen
		    
			CurrArray = Get_Property(@WINDOW:'.SERV_INFO','ARRAY')
			
			CurrArray = DELETE( CurrArray, 8, CurRow, 0 )					
			CurrArray = insert( CurrArray, 8, CurRow, 0, Choosen )
			*CatIds = xlate( 'REACT_SERVS', Choosen, react_servs_react_serv_cat_id$, 'X' )
			*CatDescs = xlate( 'REACT_SERV_CAT', CatIds, react_serv_cat_reactor_service_category$, 'X' )	
			*Record = Get_Property(@WINDOW, 'RECORD' )
			*Record = insert( Record, reactor_log_react_serv_cat_id$, CurRow, 0, CatIds )
			
			Set_Property(@WINDOW:'.SERV_INFO','ARRAY',CurrArray)
			
			Set_Property(@WINDOW, 'RECORD', Record )
			Send_Event(@WINDOW, '.SERV_INFO', 'CALCULATE', COL$PROB_CAT_DESC )			
			Send_Event(@WINDOW, '.SERV_INFO', 'CALCULATE', 4 )	
			Set_Property(@WINDOW, '@NoTopPosServs', 1 )
		    Send_Event(@WINDOW:'.SERV_INFO', 'LOSTFOCUS' )	
			Set_Property(@WINDOW, '@NoTopPosServs', '' )    
		END	
	END CASE
RETURN


RETURN



