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

/*
	Commuter module for SCHED_DET (Reactor Schedule Detail) window
	
	06/30/2014 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status,ErrMsg, obj_Appwindow

DECLARE FUNCTION Msg, obj_Appwindow, Get_Property, Check_Notes, Post_Event, Popup, obj_WO_Log

$INSERT APPCOLORS
$INSERT SCHED_EQUATES
$INSERT SCHED_DET_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT POPUP_EQUATES

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



ErrTitle = 'Error in Sched Detail (SCHED_DET) Commuter'
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_PRE'		; GOSUB Write_Pre
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'READ'				; GOSUB Read
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	
	CASE EntID = @WINDOW:'.LU_WO_NO' AND Event = 'CLICK'	 		; GOSUB LUWONo
	CASE EntID = @WINDOW:'.WO_STEP' AND Event = 'GOTFOCUS'			; GOSUB WOStepGF
	
	
		
	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)
If Parm1 NE '' then
    Set_Property(@Window, '@SCHEDULE_ID', Parm1)
    ReactNo     = Field(Parm1, '*', 3, 1)
    SchedDt     = Parm1[Col2() + 1, '*']
    SeqNo       = Parm1[Col2() + 1, '*']
    Set_Property(@Window : '.REACT_NO', 'TEXT', ReactNo)
    Set_Property(@Window : '.SCHED_DT', 'INVALUE', SchedDt)
    Set_Property(@Window : '.SCHED_SEQ', 'TEXT', SeqNo)
    Send_Event(@Window : '.SCHED_SEQ', 'LOSTFOCUS')
end

RETURN


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


RETURN



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

RETURN


* * * * * * *
Write_Pre:
* * * * * * *
If Get_Property('SCHEDULER', 'HANDLE') then
    ScheduleID  = Get_Property(@Window, '@SCHEDULE_ID')
    Description = Get_Property(@Window : '.DESC', 'TEXT')
    If Description EQ '' then Description = ' '
    Appt        = Get_Property('SCHEDULER.OLE_SCHEDULE', 'OLE.Appt[' : ScheduleID : ']')
    Appt<7>     = Description
    Set_Property('SCHEDULER.OLE_SCHEDULE', 'OLE.Appt[' : ScheduleID : ']', Appt)
end

Result  = 1
RETURN 1


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

void = Post_Event(@WINDOW,'CLOSE')

RETURN 1


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

obj_Appwindow('DetailReturn')

Void = Check_Notes()

RETURN


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


RETURN


* * * * * * *
WOStepGF:
* * * * * * *

WONo = Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStepNo  = Get_Property(@WINDOW:'.WO_STEP','DEFPROP')

IF WONo = '' OR WOStepNo NE '' THEN RETURN


WOStepKeys = XLATE('WO_LOG',WONo,WO_LOG_WO_STEP_KEY$,'X')

IF INDEX(WOStepKeys,@VM,1) THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = WOStepKeys
	WOStepNo = Popup(@WINDOW,TypeOver,'WO_STEP_SELECT')
END ELSE
	WOStepNo = 1
END

Set_Property(@WINDOW:'.WO_STEP','DEFPROP',WOStepNo)

RETURN


* * * * * * *
LUWONo:
* * * * * * *

OpenWONo = obj_WO_Log('OpenWONos','')

IF OpenWONo NE '' THEN
	obj_AppWindow('LUValReturn',OpenWONo:@RM:@WINDOW:'.WO_NO':@RM)
END


RETURN






