COMPILE FUNCTION Comm_RDS_Ship(Method, Parm1, Parm2)

/*
	Commuter module for existing RDS... windows.
	Used for added functionality in the RDS Mess.
	
	09/17/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg, Security_Err_Msg
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg, Start_Window, End_Window, obj_WO_Step
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Send_Message, Popup, obj_RDS_Makeup, Msg, obj_RDS
DECLARE FUNCTION Security_Check,obj_WO_Step


EQU CRLF$	TO \0D0A\

$INSERT APPCOLORS
$INSERT MSG_EQUATES
$INSERT RDS_EQU
$INSERT POPUP_EQUATES

$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU

ErrTitle = 'Error in Comm_RDS'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'				; GOSUB Create
	CASE Method = 'Clear'				; GOSUB Clear
	CASE Method = 'Refresh'				; GOSUB Refresh
	CASE Method = 'LURds'				; GOSUB LURds
	CASE Method = 'ClearShipment'		; GOSUB ClearShipment
	
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


* * * * * * *
Create:
* * * * * * *



IF NOT(Security_Check('COC',READ$)) THEN
	Security_Err_Msg('COC',READ$)
	End_Window(@WINDOW)
	RETURN
END


obj_Appwindow('Create')



Def = ""
Def<MTEXT$> = "Enter Shipment Number to clear:"
Def<MTYPE$> = "RCE"
Def<MICON$> = "?"

ShipNo = Msg(@window, Def)

IF ShipNo = CHAR(27) OR ShipNo = '' THEN 
	Send_Event(@WINDOW,'CLOSE')
	RETURN
END

ShipRec = XLATE('COC',ShipNo,'','X')
IF ShipRec = '' THEN
	ErrMsg('Invalid Shipment Number')
	*Send_Event(@WINDOW,'CLOSE')
	*RETURN
END

Set_Property(@WINDOW,'@SHIP_NO',ShipNo)

GOSUB Refresh

RETURN




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


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

RETURN


* * * * * * *
LURds:
* * * * * * *

WONo = Get_Property(@Window:'.WO', 'TEXT')

WONo    = Get_Property(@Window:'.WO', 'TEXT')
RDSKeys = Dialog_Box('NDW_RDS_QUERY', @Window, WONo : @FM : 'quick')

CONVERT @FM TO @VM IN RDSKeys

TypeOver = ''
TypeOver<PDISPLAY$> = RDSKeys

NewRdsNos = Popup(@WINDOW,TypeOver,'WO_LOG_RTS')

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

IF INDEX(NewRdsNos,@VM,1) THEN
	Send_Event(@WINDOW,'QBFINIT')
	Set_Property(@WINDOW,'QBFLIST',NewRdsNos)
	Send_Event(@WINDOW,'QBFFIRST')
END ELSE
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:NewRdsNos)		;* Load key into form and triggers READ event or places focus on 1st empty key field.
END
RETURN


* * * * * * *
ClearShipment:
* * * * * * *

ShipNo = Get_Property(@WINDOW,'@SHIP_NO')

RDSShipNo = Get_Property(@WINDOW:'.SHIP_NO','TEXT')
RDSNo = Get_Property(@WINDOW:'.RDS_NO','TEXT')

IF Get_Property(@WINDOW,'QBFLIST') NE '' THEN QBFActive = 1 ELSE QBFActive = 0

IF RDSShipNo = ShipNo OR RDSShipNo = '' THEN
	Set_Property(@WINDOW:'.SHIP_NO','DEFPROP','')
	Set_Property(@WINDOW:'.SHIP_DATE','DEFPROP','')
	Set_Property(@WINDOW:'.SHIP_TIME','DEFPROP','')
	
	Set_Property(@WINDOW:'.STATUS','VALUE','R')
	
	Send_Event(@WINDOW,'WRITE')
	
	RDSRec = XLATE('RDS',RDSNo,'','X')
	WOStepKey = RDSRec<RDS_WO_STEP_KEY$>
	IF WOStepKey NE '' THEN
		CurrStatus = obj_RDS('CurrStatus',RDSNo:@RM:RDSRec)
		obj_WO_Step('RDSStatus',WOStepKey:@RM:RDSNo:@RM:CurrStatus)
	END
	
	
	IF QBFActive = 1 THEN
		Send_Event(@WINDOW,'QBFNEXT')
	END
END ELSE
	IF QBFActive = 1 THEN
		Send_Event(@WINDOW,'QBFNEXT')
	END ELSE
		Send_Event(@WINDOW,'CLEAR')
	END
END
	
RETURN:

