COMPILE FUNCTION Comm_Coa(Instruction, Parm1)

/*
	Commuter module for Coawindow
	
	04/18/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window,Print_Vend_CofA
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Center_Window, Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message

$INSERT POPUP_EQUATES
$INSERT APPCOLORS

EQU CRLF$	TO \0D0A\

ErrTitle = 'Error in Comm_Coa'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Instruction = 'Create' 			; GOSUB Create
	CASE Instruction = 'Refresh'			; GOSUB Refresh
	CASE Instruction = 'Write'				; GOSUB Write
	CASE Instruction = 'Delete'				; GOSUB Delete
	CASE Instruction = 'Print'				; GOSUB Print
	CASE Instruction = 'LUCompNo'			; GOSUB LUCompNo
	CASE Instruction = 'LotNoGF'			; GOSUB LotNoGF
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine.'
		ErrMsg(ErrorMsg)
END CASE

RETURN Result



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

Center_Window(@WINDOW)

IF Parm1 NE '' THEN
	obj_AppWindow('LoadFormKeys',@WINDOW:@RM:Parm1)
END

GOSUB Refresh


RETURN


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

RETURN

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

ErrMsg('Records may not be modified.')

Result = 0	;* No Writes

RETURN

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

ErrMsg('Records may not be modified.')

Result = 0	;* No Deletes

RETURN


* * * * * * *
LUCompNo:
* * * * * * *

CompKeys = Collect.IXVals('COA', 'COMP_NO')

CONVERT @FM TO @VM IN CompKeys

PopOver = ''
PopOver<PDISPLAY$> = CompKeys

CompanyKey = Popup(@WINDOW,PopOver,'COMPANY_COA')

IF CompanyKey NE '' THEN
	obj_AppWindow('LUValReturn',CompanyKey:@RM:@WINDOW:'.COMP_NO')
END

RETURN


* * * * * * *
LotNoGF:
* * * * * * *

CompNo = Get_Property(@WINDOW:'.COMP_NO','INVALUE')
LotNo = Get_Property(@WINDOW:'.LOT_NO','TEXT')

IF CompNo NE '' AND LotNo = '' THEN
	OPEN 'DICT.COA' TO DictCOA THEN
		SearchString = 'COMP_NO':@VM:CompNo:@FM
		Btree.Extract(SearchString, 'COA', DictCOA, COAKeys, '', '')
		
		IF COAKeys = '' THEN RETURN
		
		COAKeys := @VM
		CONVERT @VM TO @RM IN COAKeys
		CALL V119('S','','D','R',COAKeys,'')
		IF Get_Status(errCode) THEN DEBUG
		CONVERT @RM TO @VM IN COAKeys
		COAKeys[-1,1] = ''					;* Strip trailing delimiter

		PopOver = ''
		PopOver<PDISPLAY$> = COAKeys
		
		COAKey = Popup(@WINDOW,PopOver,'COA')
		
		IF COAKey NE '' THEN
			LotNo = FIELD(COAKey,'*',2)
			obj_AppWindow('LUValReturn',LotNo:@RM:@WINDOW:'.LOT_NO')
		END
	END
END

RETURN


* * * * * * * 
Print:
* * * * * * *

CoaID = Get_Property(@WINDOW,'ID')

IF CoaID = '' THEN RETURN

Print_Vend_CofA( CoaID, PDFPath )

RETURN











