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

/*
	Commuter module for CUST_EPI_PART window TABLE
	
	05/31/2011 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status,obj_Tables, 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, obj_Tables
DECLARE FUNCTION Send_Message, Msg, Security_Check, NextKey



$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT EPI_PART_EQUATES
$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT RTI_STYLE_EQUATES
$INSERT PART_EQUATES


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

EQU COL$STEP		TO 1
EQU COL$STEP_PSN	TO 2
EQU COL$STEP_DESC	TO 3
EQU COL$PSN_STATUS	TO 4
EQU COL$REACT_TYPE	TO 5
EQU COL$TARG_THICK	TO 6
EQU COL$PRE_CLEAN	TO 7
EQU COL$POST_CLEAN	TO 8
EQU COL$TYPE		TO 9
EQU COL$MAKEUPS		TO 10


ErrTitle = 'Error in CUST_EPI_PART 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 = 'WRITE'			; GOSUB Write
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.LU_PROD_VER' 	AND Event = 'CLICK'	 	; GOSUB LUProdVer
	CASE EntID = @WINDOW:'.LU_EPI_PART_NO'	AND Event = 'CLICK'		; GOSUB LUEpiPartNo
	CASE EntID = @WINDOW:'.TABCONTROL'		AND Event = 'CLICK'		; GOSUB Page
	CASE EntID = @WINDOW:'.SHIP_PARTIAL'	AND Event = 'CLICK'		; GOSUB Refresh
	CASE EntID = @WINDOW:'.TR_SRP'			AND Event = 'CLICK'		; GOSUB Refresh
	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)

obj_Appwindow('SetDropDowns')

* Set result table special styles (Dropdowns)

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



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

GOSUB Refresh

RETURN


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

Forward_Event()

RETURN 0


* * * * * * *
Page:
* * * * * * *

IF Parm1 NE '' THEN
	Page = Parm1
END ELSE
	Page = Get_Property(@WINDOW:'.TABCONTROL','VALUE')
END

Set_Property(@WINDOW,'VPOSITION',Page)


RETURN


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

ShipPartial = Get_Property(@WINDOW:'.SHIP_PARTIAL','CHECK')

Ctrls  = @WINDOW:'.SHIP_FULL_TYPE':@RM				; Props  = 'VISIBLE':@RM
Ctrls := @WINDOW:'.SHIP_FULL_TYPE_LABEL':@RM		; Props := 'VISIBLE':@RM
Ctrls := @WINDOW:'.SHIP_FULL_TYPE_LABEL1'			; Props := 'VISIBLE'

IF ShipPartial THEN
	Vals = 0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1
END


Set_Property(Ctrls,Props,Vals)

SRPReq = Get_Property(@WINDOW:'.TR_SRP','CHECK')

IF SRPReq THEN
	Set_Property(@WINDOW:'.TR_SRP_WWAFER','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.TR_SRP_WWAFER','CHECK',0)
	Set_Property(@WINDOW:'.TR_SRP_WWAFER','VISIBLE',0)
END



* 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 Line
NEXT I


EpiPartNo = Get_Property(@Window:'.EPI_PN', 'TEXT')
ReactTypes = Xlate('EPI_PART', EpiPartNo, 'REACT_TYPE', 'X')
NumTypes = DCount(ReactTypes, @VM)
If ReactTypes<0, NumTypes> EQ 'GAN' then
    Set_Property(@Window:'.GRP_REACT_TYPE', 'TEXT', 'GaN')
    Set_Property(@Window:'.EPIPRO_GROUP', 'VISIBLE', False$)
end


RETURN


* * * * * * *
LUProdVer:
* * * * * * *

* Doesn't seem to be used JCH 7/18/2011

EpiPartNo = Get_Property(@WINDOW:'.EPI_PART_NO','DEFPROP')

TypeOver = ''

IF EpiPartNo NE '' THEN
	ProdVerNos = XLATE('EPI_PART',EpiPartNo,EPI_PART_PROD_VER_NO$,'X')
	
	TypeOver<PMODE$>	= 'K'
	TypeOver<PDISPLAY$>	= ProdVerNos
END

Set_Status(0)
ProdVerNos = Popup(@WINDOW,TypeOver,'PROD_VER')
errCode    = ''
IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	RETURN
END

IF ProdVerNos NE '' THEN
	IF INDEX(ProdVerNos,@VM,1) THEN
		Send_Event(@WINDOW,'QBFINIT')
		Set_Property(@WINDOW,'QBFLIST',ProdVerNos)
		Send_Event(@WINDOW,'QBFFIRST')
	END ELSE
		obj_AppWindow('LoadFormKeys',@WINDOW:@RM:ProdVerNos)
	END
END

RETURN





* * * * * * *
LUEpiPartNo:
* * * * * * *

TypeOver = ''
TypeOver<PSELECT$> = 1	;* Single selection

EpiPartNo = Popup(@WINDOW,TypeOver,'EPI_PART_NOS')

IF EpiPartNo NE '' THEN
	obj_Appwindow('LUValReturn',EpiPartNo:@RM:@WINDOW:'.EPI_PART_NO':@RM:'')
END

RETURN



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

obj_Appwindow('DetailReturn')

RETURN






