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

/*
	Commuter module for WO_Log_GaN (WO_LOG table) window
	GaN Work Order entry only.  WO_LOG2 window is used
	once the initial set-up is done
	
	04/14/2016 - John C. Henry, J.C. Henry & Co., Inc.
*/


DECLARE SUBROUTINE Set_Property, Set_Status, ErrMsg, obj_AppWindow
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, Create_Note, Post_Event


DECLARE FUNCTION Get_Property, Get_Status, Popup, dIALOG_bOX
DECLARE FUNCTION Send_Message, Msg, obj_AppWindow



$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT EPI_PART_EQUATES
$INSERT WO_LOG_EQUATES


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




ErrTitle = 'Error in CleanInsp'
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 = 'WRITE'			; GOSUB Write
			CASE Event = 'READ'				; GOSUB Read
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	
	CASE EntID = @WINDOW:'.NEW	'				AND Event = 'CLICK'	 	; GOSUB NewWO
	CASE EntID = @WINDOW:'.LU_WO_NO'			AND Event = 'CLICK'	 	; GOSUB LU_WONo
	CASE EntID = @WINDOW:'.LU_EPI_PN'			AND Event = 'CLICK'	 	; GOSUB LU_EpiPN
	CASE EntID = @WINDOW:'.LU_SUB_PART_NO'		AND Event = 'CLICK'	 	; GOSUB LU_SubPN
	Case EntID = @WINDOW:'.LU_EXP_VEND_CD'		AND Event = 'CLICK'		; GOSUB LU_ExpVendCd
	Case EntID = @WINDOW:'.LU_PROMISE_SHIP_DT'	AND Event = 'CLICK'		; GOSUB LU_Dt
	
	
	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','WO_LOG_GAN')

WONo = Parm1

obj_AppWindow('LoadFormKeys','WO_LOG_GAN':@RM:WONo)

IF Get_Status(errCode) THEN DEBUG

RETURN


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

GOSUB Refresh

RETURN





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

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

NewForm = Xlate('APP_INFO', 'NEW_WO_FORM', '', 'X')
If NewForm then
    Form = 'NDW_WO_LOG'
end else
    Form = 'WO_LOG2'
end

Set_Property(Form:'.WO_NO','DEFPROP',WONo)

Post_Event(@WINDOW,'CLOSE')

Result = 1

RETURN



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

NewForm = Xlate('APP_INFO', 'NEW_WO_FORM', '', 'X')
If NewForm then
    Form = 'NDW_WO_LOG'
end else
    Form = 'WO_LOG2'
end
Post_Event(Form,'READ')

RETURN



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

EntryID = Get_Property(@WINDOW:'.ENTRY_ID','DEFPROP')


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

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

RETURN


* * * * * * *
NewWO:
* * * * * * *



RETURN


* * * * * * *
LU_WONo:
* * * * * * *


RETURN



* * * * * * *
LU_EpiPN:
* * * * * * *

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


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

IF EpiPartNo NE '' THEN
	obj_Appwindow('LUValReturn',EpiPartNo:@RM:@WINDOW:'.EPI_PART_NO')
	
	EpiPartRec = XLATE('EPI_PART',EpiPartNo,'','X')
	
	EpiPartSubPartNos = EpiPartRec<EPI_PART_SUB_PART_NO$>
	
	IF NOT(INDEX(EpiPartSubPartNos,@VM,1)) THEN
		IF EpiPartSubPartNos NE '' THEN
			obj_AppWindow('LUValReturn',EpiPartSubPartNos:@RM:@WINDOW:'.ORD_SUB_PART_NO')
			obj_AppWindow('LUValReturn',EpiPartRec<EPI_PART_SUB_PART_REV$>:@RM:@WINDOW:'.ORD_SUB_PART_REV')
		END
	END
	
END


RETURN


* * * * * * *
LU_SubPN:
* * * * * * *

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

IF EpiPN NE '' THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = EpiPN
	
	SubData = Popup(@WINDOW,TypeOver,'EPI_PART_SUBSTRATES')
	
	IF SubData NE '' THEN
	
		SubPartNo = SubData<1,1>
		SubPartRev = SubData<1,2>
		
		obj_AppWindow('LUValReturn',SubPartNo:@RM:@WINDOW:'.ORD_SUB_PART_NO')
		obj_AppWindow('LUValReturn',SubPartRev:@RM:@WINDOW:'.ORD_SUB_PART_REV')
		
	END
	
END

RETURN


* * * * * * *
LU_ExpVendCd:
* * * * * * *

VendCode = Popup(@WINDOW,'','SEMI_VEND_CODE')

IF VendCode NE '' THEN
	obj_Appwindow('LUValReturn',VendCode:@RM:@WINDOW:'.EXP_VEND_CD')
END

RETURN


* * * * * * *
LU_Dt:
* * * * * * *

ReturnCtrl = Parm1[1,@RM]

IF ReturnCtrl = '' THEN ReturnCtrl = Get_Property(@WINDOW,'FOCUS')

DateSelected =  Dialog_Box('POPUP_YEAR',@WINDOW)

RetVal = OCONV(DateSelected, 'D4/')


obj_Appwindow('LUValReturn',RetVal:@RM:ReturnCtrl)



RETURN









