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

/*
	Commuter module for WO_GAN_DISPO window
	
	07/18/2016 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status,obj_WO_Wfr, obj_WO_Wfr_Wip, Post_Event
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, obj_AppWindow, 
DECLARE SUBROUTINE End_Window,obj_React_Reads, obj_WO_Mat_Log, obj_WO_Mat, obj_Appwindow

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals, obj_WO_Mat_QA, obj_Appwindow
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_WO_Log, WO_Purge, Set_Property, Create_Dialog, obj_WO_Mat_Gan
DECLARE FUNCTION obj_WO_Mat_Wfr

$INSERT REACT_RUN_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT WO_MAT_WFR_EQUATES
$INSERT WO_WFR_EQUATES
$INSERT LSL_USERS_EQUATES
$INSERT POPUP_EQUATES
$INSERT TOOL_CLASS_EQUATES
$INSERT RTI_STYLE_EQUATES

$INSERT MSG_EQUATES
$INSERT APPCOLORS

EQU COL$WO_MAT_KEY	TO 1

EQU COL$SLOT_NO			TO 1
EQU COL$WFR_ID			TO 2
EQU COL$CARR_SLOT_ID	TO 3
EQU COL$GAN_WFR_ID		TO 4
EQU COL$SCRIBE			TO 5
EQU COL$GRADE			TO 6


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



ErrTitle = 'Error in WO_GaN_Dispo commuter module'
ErrorMsg = ''

Result = ''

BEGIN CASE

	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'DELETE'			; GOSUB Delete
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
		
		END CASE
		
	
	CASE EntID = @WINDOW:'.ADD_WAFERS' AND Event = 'CLICK'		; GOSUB AddWafers
	CASE EntID = @WINDOW:'.WO_MAT_KEY' AND Event = 'CLICK'		; GOSUB WOMatSelect
	

	
	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)
	
GOSUB Refresh

RETURN
	


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

GOTO Refresh

RETURN



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


RETURN

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

Result = 0

RETURN
				
				
		
		

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

GOSUB Refresh

RETURN



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


RETURN


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

* 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


* * * * * * *
AddWafers:
* * * * * * *

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

WfrData = obj_WO_Mat_GaN('GetManifestWfrs',WONo)

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


IF WfrData = '' THEN

 	Msg(@WINDOW,'','NO_SHIPPABLE')
 	RETURN
 END

CONVERT @VM:@FM TO @SVM:@VM IN WfrData

TypeOver = ''
TypeOver<PDISPLAY$> = WfrData

SelWfrs = Popup(@WINDOW,TypeOver,'WO_WFRS')

* obj_WO_Wfr('AddEvent' goes here

RETURN



* * * * * * *
WOMatSelect:
* * * * * * *

CtrlEntID = @WINDOW:'.WO_MAT_KEY'

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

WfrList		= Get_Property(CtrlEntID,'LIST')
WOMatKey	= WfrList<CurrRow,COL$WO_MAT_KEY>

BEGIN CASE
	CASE CurrCol = COL$WO_MAT_KEY
	
		WONo	= WOMatKey[1,'*']
		CassNo	= WOMatKey[COL2()+1,'*']
		
		OutWfrIDs = XLATE('WO_MAT_WFR',WOMatKey,WO_MAT_WFR_OUT_WFR_ID$,'X')
		OutSlotNos = XLATE('WO_MAT_WFR',WOMatKey,'OUT_SLOT_NO','X')
		
		IF OutSlotNos = '' THEN
			WfrQty = XLATE( 'WO_MAT' , @ID , WO_MAT_CASS_SHIP_QTY$  , 'X' )

			IF WfrQty = '' THEN WfrQty = XLATE( 'WO_MAT' , @ID ,  WO_MAT_WAFER_QTY$ , 'X' )
			IF WfrQty = '' THEN WfrQty = 25

			OutSlotNos = ''
			FOR I = 1 TO WfrQty
			     OutSlotNos<1,I> = I
			NEXT I
		END
		
		
		sCnt = COUNT(OutSlotNos , @VM ) + ( OutSlotNos NE '' )
		
		SlotArray = ''
		
		FOR I = 1 TO sCnt
			SlotArray<COL$SLOT_NO,I>		= OutSlotNos<1,I>
			SlotArray<COL$WFR_ID,I>			= OutWfrIDs<1,I>
			SlotArray<COL$CARR_SLOT_ID,I>	= XLATE('WO_WFR',OutWfrIDs<1,I>,'CARR_SLOT_ID','X')
			SlotArray<COL$GAN_WFR_ID,I>		= XLATE('WO_WFR',OutWfrIDs<1,I>,'GAN_WFR_ID','X')
			SlotArray<COL$SCRIBE,I>			= XLATE('WO_WFR',OutWfrIDs<1,I>,12,'X')
			SlotArray<COL$GRADE,I>			= ''
			
			
		NEXT I
		
		IF SlotArray NE '' THEN
			Set_Property(@WINDOW:'.CURR_CASS_LOAD','DEFPROP',SlotArray)
		END
		
END CASE






RETURN

































