COMPILE FUNCTION Comm_Order_Det(Instruction, Parm1,Parm2)

/*
	Commuter module for Order Detail (Order Detail) window
	
	01/16/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Send_Event, Post_Event, Start_Window
DECLARE SUBROUTINE Btree.Extract, Extract_SI_Keys, obj_Notes, Security_Err_Msg, End_Window, obj_Order_Det, ErrMsg
DECLARE SUBROUTINE obj_WO_Log, Forward_Event, obj_Prod_Ver, obj_Post_Log

DECLARE FUNCTION Get_Property, Get_Status, Popup, Send_Message, Msg, obj_Order, Utility, obj_WO_Log, Security_Check
DECLARE FUNCTION obj_Quote, Dialog_Box

$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT ORDER_EQU
$INSERT ORDER_DET_EQU
$INSERT QUOTE_EQU
$INSERT WO_LOG_EQUATES
$INSERT PROD_SPEC_EQU
$INSERT QUOTE_SIGS_EQU
$INSERT NOTIFICATION_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT ANNUAL_CONTRACTS_EQU
$INSERT EPI_PART_EQUATES
$INSERT PROD_VER_EQUATES
$INSERT CUST_EPI_PART_EQUATES

EQU CRLF$	TO \0D0A\

EQU COL$DESC		TO 1
EQU COL$EPI_PN		TO 2
EQU COL$SETUP_CHG	TO 3
EQU COL$SRP_CHG		TO 4
EQU COL$PER_WAFER	TO 5

EQU COL$CUST_LOT_NO		TO 1
EQU COL$CUST_LOT_QTY	TO 2

ErrTitle = 'Error in Comm_Order_Det'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Instruction = 'Create' 			; GOSUB Create
	CASE Instruction = 'Refresh'			; GOSUB Refresh
	CASE Instruction = 'Read'				; GOSUB Read
	CASE Instruction = 'Write'				; GOSUB Write
	CASE Instruction = 'Clear'				; GOSUB Clear
	CASE Instruction = 'Close'				; GOSUB Close
	CASE Instruction = 'Cancel'				; GOSUB Cancel
	CASE Instruction = 'Delete'				; GOSUB Delete
	CASE Instruction = 'LUOrder'			; GOSUB LUOrder
	CASE Instruction = 'LUItemNo'			; GOSUB LUItemNo
	CASE Instruction = 'ItemNoGF'			; GOSUB ItemNoGF
	CASE Instruction = 'LUQuote'			; GOSUB LUQuote
	CASE Instruction = 'QuoteGF'			; GOSUB QuoteGF
	CASE Instruction = 'QuoteLF'			; GOSUB QuoteLF
	CASE Instruction = 'LUEpiPartNo'		; GOSUB LUEpiPartNo
	CASE Instruction = 'LUProdVerNo'		; GOSUB LUProdVerNo
	CASE Instruction = 'LUInboundPartNo'	; GOSUB LUInboundPartNo
	CASE Instruction = 'LUCustSubNo'		; GOSUB LUCustSubNo
	CASE Instruction = 'ViewCustEpiPart'	; GOSUB ViewCustEpiPart
	CASE Instruction = 'ViewQuote'			; GOSUB ViewQuote
	CASE Instruction = 'ViewEpiPN'			; GOSUB ViewEpiPN
	CASE Instruction = 'EpiPnGF'			; GOSUB EpiPnGF
	CASE Instruction = 'NewViewWO'			; GOSUB NewViewWO
	CASE Instruction = 'QuoteChgDC'			; GOSUB QuoteChgDC
	CASE Instruction = 'LUCustPN'			; GOSUB LUCustPN
	CASE Instruction = 'CustPNGF'			; GOSUB CustPNGF
	CASE Instruction = 'CustPNLF'			; GOSUB CustPNLF
	CASE Instruction = 'LUSubPartNo'		; GOSUB LUSubPartNo
	CASE Instruction = 'SubPartNoGF'		; GOSUB SubPartNoGF
	CASE Instruction = 'SubPartNoLF'		; GOSUB SubPartNoLF
	CASE Instruction = 'ShipDC'				; GOSUB ShipDC
	CASE Instruction = 'CustLotNoPC'		; GOSUB CustLotNoPC
	CASE Instruction = 'LUItemDesc'			; GOSUB LUItemDesc
	CASE Instruction = 'CustLotsLF'			; GOSUB CustLotsLF
	CASE Instruction = 'ItemDescGF'			; GOSUB ItemDescGF
	CASE Instruction = 'ExpRxDtLF'			; GOSUB ExpRxDtLF
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine'
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result


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

IF NOT(Security_Check('Order',READ$)) THEN
	Security_Err_Msg('Order',READ$)				;* Uses same security as the Order table
	End_Window(@WINDOW)
	RETURN
END

obj_Appwindow('Create',@WINDOW)

* Provides compatibility with the existing messaging attachment system

IF Parm1 NE '' THEN
	PassedKeys = FIELD(Parm1,'*',1)
	obj_Appwindow('ViewRelated',@WINDOW:@RM:PassedKeys)
END

IOOptions = Get_Property(@WINDOW,'IOOPTIONS')
IOOptions<10> = 1	;* Check for required fields on WRITE event
IOOptions<11> = 1	;* Create READ event on QBF load

Set_Property(@WINDOW,'IOOPTIONS',IOOptions)


GOSUB Refresh

RETURN


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

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')

IF RowExists('ORDER_DET',OrderNo:'*':ItemNo) THEN
	IF NOT(Security_Check('Order',EDIT$)) THEN
		obj_AppWindow('ReadOnly',@WINDOW)				;* disable all database controls
		Set_Property(@WINDOW,'@READONLY',1)
	END
END ELSE
	IF NOT(Security_Check('Order',WRITE$)) THEN
		Send_Event(@WINDOW,'CLEAR')
		Security_Err_Msg('Order',WRITE$)
		RETURN
	END
END


IF Get_Property(@WINDOW:'.QUOTE_NO','DEFPROP') = '' THEN
	Set_Property(@WINDOW:'.QUOTE_NO','ENABLED',1)
	Set_Property(@WINDOW:'.LU_QUOTE','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.QUOTE_NO','ENABLED',-1)
	Set_Property(@WINDOW:'.LU_QUOTE','ENABLED',-1)
END


GOSUB Refresh

RETURN


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

OrderDetKey = Get_Property(@WINDOW,'ID')

Ctrls  = @WINDOW:'.EPI_PN':@RM					; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.CUST_PN':@RM					; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.PROD_VER_NO':@RM				; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CUST_PART_NO_INBOUND':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CUST_SUB_PART_NO':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CUST_SUB_MFR':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_NO'						; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

EpiPartNo 		= Vals[1,@RM]
CustPartNo		= Vals[COL2()+1,@RM]
ProdVerNo		= Vals[COL2()+1,@RM]
CustPNInbound	= Vals[COL2()+1,@RM]
CustSubPN		= Vals[COL2()+1,@RM]
CustSubMfr		= Vals[COL2()+1,@RM]
WONo			= Vals[COL2()+1,@RM]

IF WONo NE '' THEN


	Fields  = WO_LOG_CUST_PART_NO$:@VM			; Values  = CustPartNo:@VM
	Fields := WO_LOG_EPI_PART_NO$:@VM			; Values := EpiPartNo:@VM
	Fields := WO_LOG_PROD_VER_NO$:@VM			; Values := ProdVerNo:@VM
	Fields := WO_LOG_CUST_PART_INBOUND$:@VM		; Values := CustPNInbound:@VM
	Fields := WO_LOG_CUST_SUB_PART_NO$:@VM		; Values := CustSubPN:@VM
	Fields := WO_LOG_CUST_SUB_MFR$ 				; Values := CustSubMfr
	
	
	oblParms  = 'WO_LOG':@RM
	oblParms := WONo:@RM
	oblParms := Fields:@RM
	oblParms := Values

	obj_Post_Log('Create',oblParms)
	

END

Forward_Event()					;* Write the record

Post_Event(@WINDOW,'CLOSE')		;* Close the window when the dust settles

Result = 0

RETURN


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

obj_AppWindow('ReadOnly',@RM:1)					;* Reenables data bound controls
Set_Property(@WINDOW,'@READONLY',0)				;* Clear flag on window
Set_Property(@WINDOW:'.QUOTE_NO','ENABLED',1)
Set_Property(@WINDOW:'.LU_QUOTE','ENABLED',1)


GOTO Refresh

RETURN


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

obj_Appwindow('DetailReturn')

RETURN


* * * * * * *
Cancel:
* * * * * * *

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')

IF RowExists('ORDER_DET',OrderNo:'*':ItemNo) THEN
	
	IF Security_Check('Order',Delete$) THEN
		Send_Event(@WINDOW,'WRITE')
		obj_Order_Det('Cancel',OrderNo:@RM:ItemNo)
		IF Get_Status(errCode) THEN ErrMsg(errCode)
	END ELSE
		Security_Err_Msg('Order',DELETE$)
	END
	
	obj_Appwindow(LoadFormKeys,@WINDOW:@RM:OrderNo:'*':ItemNo)

	GOSUB Refresh
	
END

RETURN


* * * * * * *
Delete:
* * * * * * *

IF NOT(Security_Check('Order',DELETE$)) THEN
	Security_Err_Msg('Order',DELETE$)
	RETURN
END

Forward_Event()

obj_AppWindow('ReadOnly',@WINDOW:@RM:1)		;* Clear Read Only

Result = 0

RETURN



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

WONo = Get_Property(@WINDOW:'.WO_NO','TEXT')

IF WONo = '' THEN
	Set_Property(@WINDOW:'.VIEW_WO','ENABLED','0')
END ELSE
	Set_Property(@WINDOW:'.VIEW_WO','ENABLED','1')
END

ItemQty = Get_Property(@WINDOW:'.ITEM_QTY','DEFPROP')
CustLotTotal = Get_Property(@WINDOW:'.CUST_LOT_TOTAL','DEFPROP')

IF ItemQty NE '' THEN

	IF CustLotTotal NE ItemQty THEN
		Set_Property(@WINDOW:'.CUST_LOT_TOTAL','BACKCOLOR',RED$)
		Set_Property(@WINDOW:'.CUST_LOT_TOTAL2','BACKCOLOR',RED$)
		Set_Property(@WINDOW:'.CUST_LOT_NO','BACKCOLOR',YELLOW$)
	END ELSE
		Set_Property(@WINDOW:'.CUST_LOT_TOTAL','BACKCOLOR',GREEN$)
		Set_Property(@WINDOW:'.CUST_LOT_TOTAL2','BACKCOLOR',GREEN$)
		Set_Property(@WINDOW:'.CUST_LOT_NO','BACKCOLOR',GREEN$)
	END
END ELSE
	Set_Property(@WINDOW:'.CUST_LOT_NO','BACKCOLOR',WHITE$)
END

Ctrls  = @WINDOW:'.LU_ORDER':@RM				; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.LOOKUP_ITEM':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.VIEW_QUOTE':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.LU_QUOTE':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.LU_CUST_PART':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.LU_EPI_PART_NO':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.LU_SUB_PART_NO':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.LU_ITEM_DESC':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.VIEW_WO'						; Props := 'ENABLED'

IF Get_Property(@WINDOW,'@READONLY') THEN
	Vals = STR('0':@RM,9)					;* ReadOnly mode - kill the buttons
END ELSE
	Vals = STR('1':@RM,9)					;* Normal mode - enable the buttons
END

Vals[-1,1] = ''

Set_Property(Ctrls,Props,Vals)				;* Kill the function buttons when in view only mode

* 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

RETURN



* * * * * * *
LUOrder:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Set_Status(0)

OrderKeys = obj_Order('Find')	

IF Get_Status(errCode) THEN ErrMsg(ErrCode)

IF INDEX(OrderKeys,@VM,1) THEN
	TypeOver = ''
	TypeOver<PMODE$>	= 'K'
	TypeOver<PDISPLAY$> = OrderKeys
	TypeOver<PSELECT$>	= 1				;* Single selection only
	OrderKey = Popup(@WINDOW,TypeOver,'ORDER_QUERY')
END ELSE
	OrderKey = OrderKeys
END

IF OrderKey NE '' THEN
	obj_Appwindow('LUValReturn',OrderKey:@RM:FocusControl)
END

RETURN



* * * * * * *
ItemNoGF:
* * * * * * *

OrderNo	= Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')

IF OrderNo = '' THEN RETURN
IF ItemNo NE '' THEN RETURN


* * * * * * *
LUItemNo:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')

IF OrderNo = '' THEN RETURN

OrderDetKeys = XLATE('ORDER',OrderNo,ORDER_ORDER_DET_KEY$,'X')

IF OrderDetKeys = '' THEN
	ErrMsg('No Order Detail Items on file for this Order.')
	RETURN
END

IF INDEX(OrderDetKeys,@VM,1) THEN

	TypeOver = ''
	TypeOver<PFIELD$> = 'ITEM_NO'
	TypeOver<PDISPLAY$> = OrderDetKeys

	ItemNo = Popup(@WINDOW,TypeOver,'ORDER_DETAIL')
	
END ELSE
	ItemNo = FIELD(OrderDetKeys,'*',2)
END

obj_Appwindow('LUValReturn',ItemNo:@RM:@WINDOW:'.ITEM_NO')

RETURN


* * * * * * *
LUQuote:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo NE '' THEN RETURN

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
IF OrderNo = '' THEN RETURN

CustNo = XLATE('ORDER',OrderNo,ORDER_CUST_NO$,'X')

IF CustNo = '' THEN
	ErrMsg('No Customer No found on Order!')
	RETURN
END


OPEN 'DICT.QUOTE' TO DictVar THEN
	SearchString  = 'CUST_NO':@VM:CustNo:@FM	;* Select not closed quotes for this customer
	SearchString := 'STATUS':@VM:'O':@FM

	Cursor = Utility( 'CURSOR', 'H' )
	    
	Btree.Extract( SearchString, 'QUOTE', DictVar, QuoteNos, '', Flag )
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		Void = Utility('CURSOR',Cursor)
		RETURN
	END
	Void = Utility('CURSOR',Cursor)
END ELSE
	ErrMsg('Unable to Open DICT.QUOTE in COMM_ORDER_DET.')
	RETURN
END

IF QuoteNos = '' THEN RETURN

TypeOver = ''
TypeOver<PDISPLAY$> = QuoteNos
TypeOver<PSELECT$>	= 1			;* Single select
TypeOver<PMODE$>	= 'K'		;* Keylist
    
QuoteNo = Popup(@WINDOW,TypeOver,'QUOTES_QUERY')

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	RETURN
END

IF QuoteNo = '' THEN RETURN

obj_AppWindow('LUValReturn',QuoteNo:@RM:@WINDOW:'.QUOTE_NO')

RETURN



* * * * * * *
QuoteGF:
* * * * * * *

Ctrls = @WINDOW:'.ORDER_NO':@RM:@WINDOW:'.ITEM_NO':@RM:@WINDOW:'.QUOTE_NO'
Props = 'TEXT':@RM:'TEXT':@RM:'TEXT'
Vals = Get_Property(Ctrls,Props)

OrderNo	= Vals[1,@RM]
ItemNo	= Vals[COL2()+1,@RM]
QuoteNo	= Vals[COL2()+1,@RM]

IF QuoteNo NE '' THEN RETURN
IF OrderNo = '' THEN RETURN
IF ItemNo = 1 THEN RETURN

PrevItemNo = ItemNo - 1
PrevQuoteNo = XLATE('ORDER_DET',OrderNo:'*':PrevItemNo,ORDER_DET_QUOTE_NO$,'X')

IF PrevQuoteNo NE '' THEN
	Set_Property(@WINDOW:'.QUOTE_NO','TEXT',PrevQuoteNo)
	Set_Property(@WINDOW:'.QUOTE_NO','SELECTION',1:@FM:65534)
END

RETURN


* * * * * * *
QuoteLF:
* * * * * * *

Ctrls  = @WINDOW:'.QUOTE_NO':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.ORDER_NO':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.ITEM_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.EPI_PN'				; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

QuoteNo = Vals[1,@RM]
OrderNo = Vals[COL2()+1,@RM]
ItemNo	= Vals[COL2()+1,@RM]
WONo	= Vals[COL2()+1,@RM]
EpiPN	= Vals[COL2()+1,@RM]

IF QuoteNo NE '' AND OrderNo NE '' THEN
	ACNo = XLATE('ORDER',OrderNo,ORDER_AC_ID$,'X')
	IF ACNo NE '' THEN
		ACQuotes = XLATE('ANNUAL_CONTRACTS',ACNo,ANNUAL_CONTRACTS_QUOTE_NO$,'X')
		LOCATE QuoteNo IN ACQuotes USING @VM SETTING Pos THEN
			QuoteStatus = XLATE('QUOTE',QuoteNo,10,'X')
			IF QuoteStatus NE 'O' THEN
				ErrMsg('Quote No: ':QUOTE(QuoteNo):' is not Open and may not be used.')
				Set_Property(@WINDOW:'.QUOTE_NO','FOCUS',1)
				Set_Property(@WINDOW:'.QUOTE_NO','TEXT','')
				RETURN
			END
		END ELSE
			ErrMsg('Quote No: ':QUOTE(QuoteNo):' is not on the Annual Contract referenced by this Order.')
			Set_Property(@WINDOW:'.QUOTE_NO','FOCUS',1)
			Set_Property(@WINDOW:'.QUOTE_NO','TEXT','')
			RETURN
		END
		
		TestQuote = XLATE('QUOTE',QuoteNo,'','X')
		IF TestQuote = '' THEN
			ErrMsg('Quote No: ':QUOTE(QuoteNo):' is not on file in the Quote Table.')
			Set_Property(@WINDOW:'.QUOTE_NO','FOCUS',1)
			Set_Property(@WINDOW:'.QUOTE_NO','TEXT','')
			RETURN
		END
	END
END

OrgQuote = XLATE('ORDER_DET',OrderNo:'*':ItemNo,ORDER_DET_QUOTE_NO$,'X')

IF QuoteNo NE '' THEN

	PSNo		= XLATE('QUOTE',QuoteNo,QUOTE_PROC_STEP_PSN$,'X')<1,1>		;* Field is multivalued - take the first one
	SuppliedBy	= XLATE('PROD_SPEC',PSNo,'SUB_SUPPLIED_BY','X')
	Set_Property(@WINDOW:'.SUPPLIED_BY','TEXT',SuppliedBy)

	RelStamp = XLATE('WO_LOG',WONo,'REL_STAMP','X')<1>
	
	IF RelStamp = '' THEN
		IF QuoteNo NE OrgQuote AND OrgQuote NE '' THEN
		
			IF WONo NE '' THEN
				obj_WO_Log('QuoteChange',QuoteNo:@RM:WONo)
				IF Get_Status(errCode) THEN
					ErrMsg(errCode)
					Set_Property(@WINDOW:'.QUOTE_NO','DEFPROP',OrgQuote)
				END
			END
		END
	END ELSE
		IF QuoteNo NE OrgQuote AND OrgQuote NE '' THEN
			ErrMsg('Work Order has been released to production.':CRLF$:'The Quote No may not be changed.')
			Set_Property(@WINDOW:'.QUOTE_NO','DEFPROP',OrgQuote)
		END
	END
END

IF QuoteNo NE OrgQuote OR QuoteNo = '' THEN
	Set_Property(@WINDOW:'.CUST_PN','DEFPROP','')
	Set_Property(@WINDOW:'.CUST_PN','GOTFOCUS_VALUE','')
	Set_Property(@WINDOW:'.SUB_PART_NO','DEFPROP','')
	Set_Property(@WINDOW:'.SUB_PART_NO','GOTFOCUS_VALUE','')
	Set_Property(@WINDOW:'.EPI_PN','DEFPROP','')
	Set_Property(@WINDOW:'.EPI_PN','GOTFOCUS_VALUE','')
END

IF OrderNo NE '' AND EpiPN = '' THEN
	Captive = XLATE('ORDER',OrderNo,ORDER_CAPTIVE$,'X')
	IF NOT(Captive) AND QuoteNo NE '' THEN
		EpiPN = 'EPI':FMT(QuoteNo,'R(0)#5')
		Set_Property(@WINDOW:'.EPI_PN','DEFPROP',EpiPN)
	END
END



RETURN



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

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteRec = XLATE('QUOTE',QuoteNo,'','X')

EpiPartNos	= QuoteRec<QUOTE_EPI_PART_NO$>
Details		= QuoteRec<QUOTE_DETAIL$>

Display = ''
LineCnt = 1

DetCnt = COUNT(Details,@VM) + (Details NE '')

FOR I = 1 TO DetCnt
	EpiPartNo	= EpiPartNos<1,I>
	Detail		= Details<1,I>
	IF EpiPartNos NE '' THEN
		Display<1,LineCnt> = EpiPartNo:@SVM:Detail
		LineCnt += 1
	END
NEXT I

IF Display = '' THEN
	ErrMsg('No EPI Part Numbers have been entered on Quote ':QUOTE(QuoteNo):'.')
	RETURN
END

IF INDEX(Display,@VM,1) THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = Display
	
	EpiPN = Popup(@WINDOW,TypeOver,'QUOTE_EPI_PARTS')
END ELSE
	EpiPN = Display<1,1,1>
END

IF EpiPN NE '' THEN
	Set_Property(@WINDOW:'.EPI_PN','DEFPROP',EpiPN)
END

RETURN


* * * * * * *
ViewCustEpiPart:
* * * * * * *

CustNo	= Get_Property(@WINDOW:'.CUST_NO','DEFPROP')
EpiPN	= Get_Property(@WINDOW:'.EPI_PN','DEFPROP')

IF CustNo = '' THEN RETURN
IF EpiPN = '' THEN RETURN	

obj_AppWindow('ViewRelated','CUST_EPI_PART':@RM:CustNo:'*':EpiPN)

RETURN



* * * * * * *
ViewQuote:
* * * * * * *

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

obj_AppWindow('ViewRelated','QUOTE2':@RM:QuoteNo)

RETURN


* * * * * * *
ViewEpiPN:
* * * * * * *

EpiPN = Get_Property(@WINDOW:'.EPI_PN','TEXT')

IF EpiPN = '' THEN RETURN

obj_AppWindow('ViewRelated','EPI_PN':@RM:EpiPN)

RETURN


* * * * * * *
EpiPnGF:
* * * * * * *

Ctrls  = @WINDOW:'.ORDER_NO':@RM				; Props  = 'TEXT':@RM
Ctrls := @WINDOW:'.CUST_PN':@RM					; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.EPI_PN':@RM					; Props := 'TEXT':@RM		
Ctrls := @WINDOW:'.ENGINEERING_PART':@RM		; Props := 'CHECK':@RM
Ctrls := @WINDOW:'.QUOTE_NO'					; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

OrderNo			= Vals[1,@RM]
CustPN			= Vals[COL2()+1,@RM]
EpiPN			= Vals[COL2()+1,@RM]
EngineeringPart	= Vals[COL2()+1,@RM]
QuoteNo			= Vals[COL2()+1,@RM]

IF OrderNo = '' OR CustPN = '' OR EpiPN NE '' OR QuoteNo = '' THEN RETURN

Captive = XLATE('ORDER',OrderNo,ORDER_CAPTIVE$,'X')

IF Captive AND NOT(EngineeringPart) THEN
	BEGIN CASE
		CASE CustPN[1,10] Matches "'W'6N'IRE'"
			EpiPN = CustPN[1,10]
			
		CASE CustPN[1,12] Matches "'WEP'6N'IRE'"
			EpiPN = CustPN[1,12]	
		
		CASE CustPN[1,6] Matches "6N"
			EpiPN = CustPN[1,6]
			
		CASE 1
			EpiPN = 'EPI':FMT(QuoteNo,"R(0)#5")
			
	END CASE
	
END	ELSE
	EpiPN = 'EPI':FMT(QuoteNo,"R(0)#5")
END

IF EpiPN NE '' THEN
	obj_Appwindow('LUValReturn',EpiPN:@RM:@WINDOW:'.EPI_PN')
END

RETURN


* * * * * * *
LUProdVerNo:
* * * * * * *

EpiPN		= Get_Property(@WINDOW:'.EPI_PN','DEFPROP')
ProdVerNo	= Get_Property(@WINDOW:'.PROD_VER_NO','DEFPROP')

QuoteProcStepPSNs = Get_Property(@WINDOW:'.QUOTE_PROC_STEP','DEFPROP')<2>

LOOP
	LastStepPSN = QuoteProcStepPSNs[-1,'B':@VM]
UNTIL LastStepPSN NE ''
	QuoteProcStepPSNs[COL1(),99] = ''
REPEAT

PsnID = QuoteProcStepPSNs

CONVERT @VM TO '.' IN PsnID

IF EpiPN NE '' AND ProdVerNo = '' THEN
	ProdVerNo = Dialog_Box('PROD_VER_SELECT',@WINDOW,EpiPN:@VM:PsnID)
	
	IF ProdVerNo NE '' AND ProdVerNo NE 'Cancel' THEN
		Set_Property(@WINDOW:'.PROD_VER_NO','DEFPROP',ProdVerNo)
		Send_Event(@WINDOW:'.PROD_VER_NO','LOSTFOCUS')
		
		ProdVerRec = XLATE('PROD_VER',ProdVerNo,'','X')
		
		SubPartNo = ProdVerRec<PROD_VER_SUB_PART_NO$>
		
		IF Get_Property(@WINDOW:'.SUB_PART_NO','DEFPROP') = '' AND SubPartNo NE '' THEN
			Set_Property(@WINDOW:'.SUB_PART_NO','DEFPROP',SubPartNo)
		END
		
		ProdVerDesc = ProdVerRec<PROD_VER_DESC$>
		
		IF Get_Property(@WINDOW:'.ITEM_DESC','DEFPROP') = '' AND ProdVerDesc NE '' THEN
			Set_Property(@WINDOW:'.ITEM_DESC','DEFPROP',ProdVerDesc)
		END
	END
END

RETURN


* * * * * * *
LUInboundPartNo:
* * * * * * *

EpiPN		= Get_Property(@WINDOW:'.EPI_PN','DEFPROP')
CustNo		= Get_Property(@WINDOW:'.CUST_NO','DEFPROP')
CustPartNo	= Get_Property(@WINDOW:'.CUST_PN','DEFPROP')

IF EpiPN = '' THEN RETURN
IF CustNo = '' THEN RETURN
IF CustPartNo = '' THEN RETURN

CustEpiPartRec = XLATE('CUST_EPI_PART',CustNo:'*':EpiPN,'','X')

CustPartNos			= CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO$>
CustPartRevs		= CustEpiPartRec<CUST_EPI_PART_CUST_PART_REV$>
CustPartDescs		= CustEpiPartRec<CUST_EPI_PART_CUST_PART_DESC$>
CustPartInboundNos	= CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO_INBOUND$>


LOCATE CustPartNo IN CustPartNos USING @VM SETTING Pos THEN
	CustPartInboundNo	= CustPartInboundNos<1,Pos>
END ELSE
	
	PopDisplay = ''
	
	PNCnt = COUNT(CustPartNos,@VM) + (CustPartNos NE '')
	
	FOR I = 1 TO PNCnt
		PopDisplay<1,I> = CustPartNos<1,I>:@SVM:CustPartRevs<1,I>:@SVM:CustPartDescs<1,I>:@SVM:CustPartInboundNos<1,I>
	NEXT I
	
	TypeOver = ''
	TypeOver<PDISPLAY$> = PopDisplay
	CustPartInboundNo = Popup(@WINDOW,TypeOver,'CUST_EPI_CUST_PARTS')<1,4>

END

IF CustPartInboundNo NE '' THEN
	Set_Property(@WINDOW:'.CUST_PART_NO_INBOUND','DEFPROP',CustPartInboundNo)
END


RETURN


* * * * * * *
LUCustSubNo:
* * * * * * *

EpiPN		= Get_Property(@WINDOW:'.EPI_PN','DEFPROP')
CustNo		= Get_Property(@WINDOW:'.CUST_NO','DEFPROP')

IF EpiPN = '' THEN RETURN
IF CustNo = '' THEN RETURN

CustEpiPartRec = XLATE('CUST_EPI_PART',CustNo:'*':EpiPN,'','X')

SubPartNos	= CustEpiPartRec<CUST_EPI_PART_SUBSTRATE_PART_NO$
SubPartMfrs	= CustEpiPartRec<CUST_EPI_PART_SUBSTRATE_MFR$>

SubPNCnt = COUNT(SubPartNos,@VM) + (SubPartNos NE '')

PopDisplay = ''

FOR I = 1 TO SubPNCnt
	PopDisplay<1,I> = SubPartNos<1,I>:@SVM:SubPartMfrs<1,I>
NEXT I

TypeOver = ''
TypeOver<PDISPLAY$> = PopDisplay

CustSubstrate = Popup(@WINDOW,TypeOver,'CUST_EPI_CUST_SUBSTRATES')

SubPartNo = CustSubstrate<1,1>
SubMfr	= CustSubstrate<1,2>

IF SubPartNo NE '' THEN
	Set_Property(@WINDOW:'.SUBSTRATE_PART_NO','DEFPROP',SubPartNo)
	Set_Property(@WINDOW:'.SUBSTRATE_MFR','DEFPROP',SubMfr)
END

RETURN




* * * * * * *
NewViewWO:
* * * * * * *

WONo = Get_Property(@WINDOW:'.WO_NO','TEXT')

If WONo = '' Then
	* Create a new WO_LOG record and WO_STEP record(s)
		
	Ctrls  = @WINDOW:'.ORDER_NO':@RM	; Props  = 'TEXT':@RM
	Ctrls := @WINDOW:'.ITEM_NO':@RM		; Props := 'TEXT':@RM
	Ctrls := @WINDOW:'.QUOTE_NO'		; Props := 'TEXT'
	
	
	Vals = Get_Property(Ctrls,Props)
	
	OrderNo		= Vals[1,@RM]
	OrderItem	= Vals[COL2()+1,@RM]
	QuoteNo		= Vals[COL2()+1,@RM]
	
	IF OrderNo NE '' AND OrderItem NE '' AND QuoteNo NE '' THEN
		WONo = obj_WO_Log('Create',OrderNo:@RM:OrderItem:@RM:QuoteNo)
		IF Get_Status(errCode) THEN
			ErrMsg(errCode)
			RETURN
		END
		IF WONo NE '' THEN
			obj_AppWindow('LUValReturn',WONo:@RM:@WINDOW:'.WO_NO')
		END
	END
	
End Else
    NewForm = Xlate('APP_INFO', 'NEW_WO_FORM', '', 'X')
    If NewForm then
        Start_Window('NDW_WO_LOG', @Window, WONo)
    end else
        obj_Appwindow('ViewRelated','WO_LOG2':@RM:WONo)
    end
End

RETURN


* * * * * * * 
QuoteChgDC:
* * * * * * *

Ctrls = @WINDOW:'.ITEM_DESC':@RM:@WINDOW:'.UNIT_PRICE':@RM:'EPI_PN'
Props = 'TEXT':@RM:'TEXT'

Vals = Get_Property(Ctrls,Props)

ItemDesc	= Vals[1,@RM]
UnitPrice	= Vals[COL2()+1,@RM]
EpiPN		= Vals[COL2()+1,@RM]

IF ItemDesc = '' AND UnitPrice = '' THEN

	CtrlEntID = @WINDOW:'.QUOTE_CHG_DESC'
	
	CurrPos = Get_Property(CtrlEntID,'SELPOS')
	CurrCol = CurrPos<1>
	CurrRow = CurrPos<2>
	
	ChargeDesc	= Get_Property(CtrlEntID,'CELLPOS',COL$DESC:@FM:CurrRow)
	ChargeAmt	= Get_Property(CtrlEntID,'CELLPOS',CurrCol:@FM:CurrRow)
	EpiPN		= Get_Property(CtrlEntID,'CELLPOS',COL$EPI_PN:@FM:CurrRow)

	Vals = ChargeDesc:@RM:ChargeAmt:@RM:EpiPN
	Set_Property(Ctrls,Props,Vals)
END

RETURN


* * * * * * *
CustPNGF:
* * * * * * *

CustPN = Get_Property(@WINDOW:'.CUST_PN','TEXT')

IF CustPN NE '' THEN RETURN


* * * * * * *
LUCustPN:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1

Set_Status(0)

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteStepPSNs = XLATE('QUOTE',QuoteNo,QUOTE_PROC_STEP_PSN$,'X')

ShipPSN = QuoteStepPSNs[-1,'B':@VM]

CustPartNos = XLATE('PROD_SPEC',ShipPSN,PROD_SPEC_CUST_PART_NO$,'X')

IF Get_Status(errCode)	THEN ErrMsg(ErrCode)
IF CustPartNos = '' 	THEN
	Resp= Msg(@WINDOW,'','NO_PART_NUMBERS')
	IF Resp THEN
		CustPartNos = 'Q':QuoteNo
	END ELSE
		RETURN
	END
END

IF INDEX(CustPartNos,@VM,1) THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = ShipPSN
	TypeOver<PSELECT$>	= 1				;* Single selection only
	CustPartNo = Popup(@WINDOW,TypeOver,'CUST_PART_NO')
END ELSE
	CustPartNo = CustPartNos
END

IF CustPartNo NE '' THEN
	obj_Appwindow('LUValReturn',CustPartNo:@RM:FocusControl)
END

RETURN


* * * * * * *
CustPNLF:
* * * * * * *

OriginalVal = Get_Property(@WINDOW:'.CUST_PN','GOTFOCUS_VALUE')
CurrentVal	= Get_Property(@WINDOW:'.CUST_PN','TEXT')
WONo		= Get_Property(@WINDOW:'.WO_NO','DEFPROP')

IF CurrentVal NE OriginalVal AND OriginalVal NE '' THEN

	Send_Event(@WINDOW:'.CUST_PN_DESC','CALCULATE')
	Send_Event(@WINDOW:'.CUST_PN_INBOUND','CALCULATE')	

	QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')
	
	QuoteStepPSNs = XLATE('QUOTE',QuoteNo,QUOTE_PROC_STEP_PSN$,'X')

	ShipPSN = QuoteStepPSNs[-1,'B':@VM]

	CustPartNos = XLATE('PROD_SPEC',ShipPSN,PROD_SPEC_CUST_PART_NO$,'X')

	IF Get_Status(errCode)	THEN ErrMsg(ErrCode)
	IF CustPartNos = '' 	THEN CustPartNos = 'Q':QuoteNo
	
	LOCATE CurrentVal IN CustPartNos USING @VM SETTING Pos ELSE
		ErrMsg('Invalid Customer Part Number')
		Set_Property(@WINDOW:'.CUST_PN','FOCUS',1)
		Set_Property(@WINDOW:'.CUST_PN','SELECTION',1:@FM:65534)
		RETURN
	END
	
	MsgResult = Msg(@WINDOW,'','PART_NO_CHANGE','',OriginalVal:@FM:CurrentVal)	;* Warn user about change to Part No
	
	IF MsgResult = CHAR(27) THEN
		Set_Property(@WINDOW:'.CUST_PN','DEFPROP',OriginalVal)					;* User bailed on continuing
		RETURN
	END
	
	IF WONo NE '' THEN
		Def = ''
		Def<MTEXT$> = 'Posting New Part Number to WO_MAT and RDS records...'
		Def<MTYPE$> = 'U'
		
		MsgUp = Msg(@WINDOW,Def)
		
		
		obj_WO_Log('SetPartNo',WONo:@RM:CurrentVal:@RM:OriginalVal)					;* Change WO_Mat (and RDS) records to new P/N
		
		IF Get_Status(errCode) THEN
		
			* Error updating dependent records
			
			ErrMsg(errCode)
			
			Set_Property(@WINDOW:'.CUST_PN','DEFPROP',OriginalVal)
			RETURN
		END
		
		Msg(@WINDOW,MsgUp)
	END
END

RETURN


* * * * * * *
SubPartNoGF:
* * * * * * *

SubPartNo = Get_Property(@WINDOW:'.SUB_PART_NO','TEXT')

IF SubPartNo NE '' THEN RETURN



RETURN


* * * * * * *
LUSubPartNo:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1

Set_Status(0)

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteStepPSNs = XLATE('QUOTE',QuoteNo,QUOTE_PROC_STEP_PSN$,'X')

IF Get_Status(errCode)	THEN ErrMsg(ErrCode)
IF QuoteStepPSNs = '' 	THEN RETURN

SubSuppliedBy = XLATE('PROD_SPEC',QuoteStepPSNs<1,1>,'SUB_SUPPLIED_BY','X')

SubPartNos 	= XLATE('PROD_SPEC',QuoteStepPSNs<1,1>,PROD_SPEC_SUB_PART_NUMS$,'X')
SubMfgs		= XLATE('PROD_SPEC',QuoteStepPSNs<1,1>,PROD_SPEC_SUB_WAFER_MFG$,'X')

IF SubPartNos = '' THEN
	ErrMsg('No Substrate Part Numbers specified in PSN ':QuoteStepPSNs<1,1>)
	RETURN
END

PDisplay = ''
FOR I = 1 TO COUNT(SubPartNos,@VM) + (SubPartNos NE '')
	PDisplay<1,I> = SubPartNos<1,I>:@SVM:SubMfgs<1,I>
NEXT I

TypeOver = ''
TypeOver<PDISPLAY$> = PDisplay

IF SubSuppliedBy = 'C' THEN
	*TypeOver<PTYPE$> = 'R'
END

SubPartNo = PopUp(@WINDOW,TypeOver,'SUBSTRATE_PART_NO')


IF SubPartNo NE '' THEN
	obj_Appwindow('LUValReturn',SubPartNo:@RM:FocusControl)
END

RETURN


* * * * * *
SubPartNoLF:
* * * * * *

SubPartNo = Get_Property(@WINDOW:'.SUB_PART_NO','TEXT')

IF SubPartNo = '' THEN RETURN

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteStepPSNs = XLATE('QUOTE',QuoteNo,QUOTE_PROC_STEP_PSN$,'X')

IF Get_Status(errCode)	THEN ErrMsg(ErrCode)
IF QuoteStepPSNs = '' 	THEN RETURN

SubSuppliedBy = XLATE('PROD_SPEC',QuoteStepPSNs<1,1>,'SUB_SUPPLIED_BY','X')

SubPartNos 	= XLATE('PROD_SPEC',QuoteStepPSNs<1,1>,PROD_SPEC_SUB_PART_NUMS$,'X')

LOCATE SubPartNo IN SubPartNos USING @VM SETTING Dummy ELSE
	ErrMsg('Substrate Part No: ':QUOTE(SubPartNo):' is not found on the Prod Spec for Quote ':QuoteNo)
	
	Set_Property(@WINDOW:'.SUB_PART_NO','FOCUS',1)
	Set_Property(@WINDOW:'.SUB_PART_NO','SELECTION',1:@FM:65534)
END


RETURN



* * * * * * *
ShipDC:
* * * * * * *

CtrlEntID = @WINDOW:'.SHIP_NO'

CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

ShipNo = Get_Property(CtrlEntID,'CELLPOS',1:@FM:CurrRow)	;* Ship No is in column 1

IF ShipNo NE '' THEN
	obj_AppWindow('ViewRelated','SHIPMENT':@RM:ShipNo)
END

RETURN


* * * * * * *
CustLotNoPC:
* * * * * * *

CtrlEntID = @WINDOW:'.CUST_LOT_NO'

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')

OrderDetKey = OrderNo:'*':ItemNo

PrevSelPos	= Get_Property(CtrlEntId,"PREVSELPOS")
PrevCol 	= PrevSelPos<1>
PrevRow 	= PrevSelPos<2>

CurrPos = Get_Property(CtrlEntId,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

ListData	= Get_Property(CtrlEntId,'LIST')

ColCnt = 2		;* Number of columns in the edit table

IF ListData<CurrRow,CurrCol> = '' THEN
	
	ColPointer = CurrCol
	LinePointer = CurrRow
	
	* Find the first non-empty cell
	
	LOOP
		Test = ListData<LinePointer,(ColPointer) >
	UNTIL Test NE '' OR (LinePointer = 0 AND ColPointer = 1)
		ColPointer -= 1
		IF ColPointer = 0 THEN
			ColPointer = ColCnt
			LinePointer -= 1
		END
	REPEAT
	
	* Move one past the non empty cell
	
	BEGIN CASE
		CASE LinePointer = 0 
			* Empty Table
			LinePointer = 1
			CoilPointer = 1
			
		CASE ColPointer = ColCnt
			LinePointer += 1
			ColPointer = 1
			
		CASE 1
			ColPointer += 1
			
	END CASE
	Set_Property(CtrlEntId,"SELPOS",ColPointer:@FM:LinePointer)
END

IF ListData<PrevRow,PrevCol> NE '' THEN

	IF PrevCol = COL$CUST_LOT_NO THEN
			
		LotNo = ListData<PrevRow,PrevCol>
		
		IF INDEX(LotNo,' ',1) THEN
			ListData<PrevRow,PrevCol> = TRIM(LotNo)
			Set_Property(CtrlEntId,'LIST',ListData)
			LotNo = TRIM(LotNo)
		END
		Extract_SI_Keys('ORDER_DET','CUST_LOT_NO',LotNo,OrderDetKeys)	;* Check for previous use of customer lot number in new data structure
		
		IF OrderDetKeys NE '' THEN
		
			LOCATE OrderDetKey IN OrderDetKeys USING @VM SETTING FPos THEN
				OrderDetKeys = DELETE(OrderDetKeys,1,FPos,0)					;* Exclude the current Order Item from this check
			END
		
			IF OrderDetKeys NE '' THEN
				SWAP @VM WITH ', ' IN OrderDetKeys
				
				Message  = 'Lot No ':QUOTE(LotNo):' has been used in Order Item(s) |':OrderDetKeys:'||'
				Message := 'Do you wish to use this duplicate Lot Number?|'
				
				MsgInfo = ''
				MsgInfo<MTEXT$> = Message
				
				Resp = Msg( @WINDOW, MsgInfo,'CUST_LOT_USED' )
				IF Resp = CHAR(27) THEN
					Set_Property(CtrlEntId,'CELLPOS','',PrevSelPos)
					Set_Property(CtrlEntId,"SELPOS",PrevSelPos)	
				END

			END
		END	ELSE
		
			* Try looking in the old format Orders
			
			Extract_SI_Keys('ORDER','LOT_NUM',LotNo,OrderNos)				;* Check for previous use of customer lot number in old data structure	
			IF OrderNos NE '' THEN
			
				LOCATE OrderNo IN OrderNos USING @VM SETTING FPos THEN
					OrderNos = DELETE(OrderNos,1,FPos,0)					;* Exclude the current Order No from this check
				END
			
				IF OrderNos NE '' THEN
					SWAP @VM WITH ', ' IN OrderNos
					
					Message  = 'Lot No ':QUOTE(LotNo):' has been used in Order Number |':OrderNos:'||'
					Message := 'Do you wish to use this duplicate Lot Number?|'
						
					MsgInfo = ''
					MsgInfo<MTEXT$> = Message
					
					Resp = Msg( @WINDOW, MsgInfo,'CUST_LOT_USED' )
					IF Resp = CHAR(27) THEN
						Set_Property(CtrlEntId,'CELLPOS','',PrevSelPos)
						Set_Property(CtrlEntId,"SELPOS",PrevSelPos)	
					END

				END
			END	
		END	;* End of checks for Lot Nos used elswhere
			
	END 
		
END	 ;* End of check for Previous Cell NE Null

GOSUB Refresh

RETURN


* * * * * * *
LUItemDesc:
* * * * * * *

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1

Set_Status(0)

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteItemDesc = XLATE('QUOTE',QuoteNo,QUOTE_PROC_DESC$,'X')
QuoteDetail = XLATE('QUOTE',QuoteNo,QUOTE_DETAIL$,'X')

TypeOver = ''
TypeOver<PDISPLAY$> = QuoteItemDesc:@VM:QuoteDetail

IF TypeOver = '' THEN
	ErrMsg('No item descriptions found on Quote')
	RETURN
END

Desc = Popup(@WINDOW,TypeOver,'QUOTE_DETAIL')

IF Get_Status(errCode) THEN 
	ErrMsg(errCode)
END


IF Desc NE '' THEN
	obj_Appwindow('LUValReturn',Desc:@RM:FocusControl)
END

RETURN


* * * * * * *
CustLotsLF:
* * * * * * *

CustLotTotal = Get_Property(@WINDOW:'.CUST_LOT_TOTAL','TEXT')
OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')

IF CustLotTotal = ''	THEN RETURN
IF OrderNo = ''			THEN RETURN
IF ItemNo = ''			THEN RETURN

OrgCustLotTotal = XLATE('ORDER_DET',OrderNo:'*':ItemNo,'CUST_LOT_TOTAL','X')

IF CustLotTotal NE OrgCustLotTotal AND OrgCustLotTotal NE '' THEN

	Recipients		= XLATE('NOTIFICATION','WO_ENTRY',NOTIFICATION_USER_ID$,'X')
	SentFrom		= @USER4
	Subject			= 'Expected Wafers Quantity Change ':OrderNo:'*':ItemNo
	Message			= 'Expected Wafer Quantity was changed on this order item.'
	AttachWindow	= 'ORDER_DET'
	AttachKey		= OrderNo:'*':ItemNo    
	SendToGroup		= ''   

	Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
	obj_Notes('Create',Parms)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
	END
END


RETURN


* * * * * * *
ExpRxDtLF:
* * * * * * *

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')
ItemNo	= Get_Property(@WINDOW:'.ITEM_NO','TEXT')
ExpRxDt = Get_Property(@WINDOW:'.EXP_RX_DT','TEXT')

IF OrderNo = ''			THEN RETURN
IF ItemNo = ''			THEN RETURN

IF ExpRxDt NE '' THEN
	thisRxDt = ICONV(ExpRxDt,'D')
	IF thisRxDt = '' THEN
		ErrorMsg ='Invalid ExpRxDt ':QUOTE(ExpRxDt):' passed to routine.'
		RETURN
	END
END ELSE
	thisRxDt = ''
END

OrgRxDt = XLATE('ORDER_DET',OrderNo:'*':ItemNo,'EXP_RX_DT','X')

IF thisRxDt NE OrgRxDt AND OrgRxDt NE '' THEN

	Recipients		= XLATE('NOTIFICATION','WO_ENTRY',NOTIFICATION_USER_ID$,'X')
	SentFrom		= @USER4
	Subject			= 'Expected Material Receipt Date Change':OrderNo:'*':ItemNo
	Message			= 'Expected Wafer Receipt Date was changed from ':OCONV(OrgRxDt,'D4/'):' to ':ExpRxDt:'.'
	AttachWindow	= 'ORDER_DET'
	AttachKey		= OrderNo:'*':ItemNo    
	SendToGroup		= ''   

	Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
	obj_Notes('Create',Parms)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
	END
END

RETURN




* * * * * * *
ItemDescGF:
* * * * * * *

ItemDesc = Get_Property(@WINDOW:'.ITEM_DESC','TEXT')

IF ItemDesc NE '' THEN  RETURN

QuoteNo = Get_Property(@WINDOW:'.QUOTE_NO','TEXT')

IF QuoteNo = '' THEN RETURN

QuoteItemDesc = XLATE('QUOTE',QuoteNo,QUOTE_PROC_DESC$,'X')

Set_Property(@WINDOW:'.ITEM_DESC','TEXT',QuoteItemDesc)
Set_Property(@WINDOW:'.ITEM_DESC','SELECTION',1:@FM:65534)

RETURN


















