COMPILE FUNCTION Comm_Dialog_Hold(Method, Parm1, Parm2)

/*
	Commuter module for Dialog_Hold window.
	
	06/09/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, Send_Message

EQU CRLF$	TO \0D0A\

$INSERT POPUP_EQUATES
$INSERT APPCOLORS
$Insert LOGICAL


ErrTitle = 'Error in Comm_Dialog_Hold'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
	CASE Method = 'OK'				; GOSUB OK
	CASE Method = 'Cancel'			; GOSUB Cancel
	CASE Method = 'Close'			; GOSUB Close
	CASE Method = 'Refresh'			; GOSUB Refresh
	CASE Method = 'LU_UserID'		; GOSUB LU_UserID
	CASE Method = 'UserIDLF'		; GOSUB UserIDLF
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


* * * * * * *
Create:
* * * * * * *
	
	obj_AppWindow('Create')
	
	Transition	= Parm1<1>
	TableName	= Parm1<2>
	HoldType	= Parm1<3>
	Stage       = Parm1<4>
	Interrupted = Parm1<5>
	
	IF HoldType = '' THEN HoldType = 'HOLD'
	
	BEGIN CASE
		CASE Transition = False$ AND HoldType = 'HOLD'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Hold On')
			WinText = 'Hold Change'
			Set_Property(@Window : '.RAD_STAGE', 'ENABLED', True$)
			Set_Property(@Window : '.CHK_INTERRUPTED', 'ENABLED', True$)
			
		CASE Transition = True$ AND HoldType = 'HOLD'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Hold Off')
			WinText = 'Hold Change'
			Set_Property(@Window : '.RAD_STAGE', 'VALUE', Stage)
			Set_Property(@Window : '.CHK_INTERRUPTED', 'CHECK', Interrupted)
			
		CASE Transition = False$ AND HoldType = 'SHOLD'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Ship Hold On')
			WinText = 'Ship Hold Change'
			Set_Property(@Window : '.RAD_STAGE', 'ENABLED', True$)
			Set_Property(@Window : '.CHK_INTERRUPTED', 'ENABLED', True$)
			
		CASE Transition = True$ AND HoldType = 'SHOLD'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Ship Hold Off')
			WinText = 'Ship Hold Change'
			Set_Property(@Window : '.RAD_STAGE', 'Value', Stage)
			Set_Property(@Window : '.CHK_INTERRUPTED', 'CHECK', Interrupted)
			
		CASE Transition = 'ESC'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Start Escalation')
			WinText = TableName:' Escalation Change'
			
		CASE Transition = 'D-ESC'
			Set_Property(@WINDOW:'.WINDOW_LABEL_FIX','TEXT','Stop Escalation')
			WinText = TableName:' Escalation Change'
	END CASE
	
	Set_Property(@WINDOW,'TEXT',WinText)	; * Window title in top bar
	
	UserName = OCONV(@USER4,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')
	
	Set_Property(@WINDOW:'.USER_ID','DEFPROP',@USER4)
	Set_Property(@WINDOW:'.USER_NAME','DEFPROP',UserName)
	Set_Property(@WINDOW:'.REASON','FOCUS',1)
	
RETURN



* * * * * * *
LU_UserID:
* * * * * * *
	
	TypeOver = ''
	TypeOver<PSELECT$>	= 1
	TypeOver<PDISPLAY$>	= 'BY LAST_FIRST'
	
	UserID = Popup(@WINDOW,TypeOver,'SHOW_USERS')
	
	IF UserID NE '' THEN
		Set_Property(@WINDOW:'.USER_ID','DEFPROP',UserID)
	END ELSE
		RETURN
	END
	
	
* * * * * * *
UserIDLF:
* * * * * * *
	
	UserID = Get_Property(@WINDOW:'.USER_ID','DEFPROP')
	
	UserName = OCONV(UserID,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')
	Set_Property(@WINDOW:'.USER_NAME','DEFPROP',UserName)
	
RETURN


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


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


* * * * * * *
OK:
* * * * * * *
	
	StageEnabled = Get_Property(@WINDOW:'.RAD_STAGE','ENABLED')
	Stage = Get_Property(@WINDOW:'.RAD_STAGE','VALUE')
	If (Stage NE '') OR (StageEnabled EQ False$) then
		UserID   = Get_Property(@WINDOW:'.USER_ID','DEFPROP')
		Reason   = Get_Property(@WINDOW:'.REASON','DEFPROP')
		Extended = Get_Property(@WINDOW:'.HOLD_EXTENDED','CHECK')
		Interrupted = Get_Property(@WINDOW:'.CHK_INTERRUPTED','CHECK')
		If (Reason NE '') then
			Result   = UserID:@FM:Reason:@FM:Extended:@FM:Stage:@FM:Interrupted
			End_Dialog(@WINDOW,Result)
		end else
			Errmsg('A reason is required to change hold status.')
		end
	end else
		Errmsg('Please select either PRE or POST.')
	end
	
RETURN

