COMPILE FUNCTION Comm_Location(Instruction, Parm1,Parm2)

/*
	Commuter module for LOCATION (Inventory Location ) window
	
	10/19/2006 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Send_Message 
DECLARE SUBROUTINE Btree.Extract, Send_Event, Security_Err_Msg, Print_Loc_Label, Print_Small_Loc_Label
DECLARE FUNCTION Get_Property, Get_Status, Popup, Send_Message, Msg, Security_Check, Dialog_Box


$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT WAREHOUSE_EQUATES
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU

EQU CRLF$	TO \0D0A\


ErrTitle = 'Error in Comm_Location'
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 = 'Delete'				; GOSUB Delete
	CASE Instruction = 'Close'				; GOSUB Close
	CASE Instruction = 'LUWhCd'				; GOSUB LUWhCd
	CASE Instruction = 'LULocCd'			; GOSUB LULocCd
	CASE Instruction = 'PrintLabel'			; GOSUB PrintLabel
	CASE Instruction = 'PrintSmallLabel'	; GOSUB PrintSmallLabel
	CASE Instruction = 'LocCdGF'			; GOSUB LocCdGF
	
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine'
END CASE

RETURN Result


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

obj_Appwindow('Create',@WINDOW)

GOSUB Refresh

RETURN


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


GOSUB Refresh

RETURN


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

RETURN


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


GOTO Refresh

RETURN


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

RETURN



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


RETURN 


* * * * * * *
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>
	IF ETCtrl NE @WINDOW:'.CASSETTES' THEN
		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
	END
NEXT I

RETURN


* * * * * * *
LUWhCd:
* * * * * * *

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


WHCd = Popup(@WINDOW,'','WAREHOUSE')
IF WHCd NE '' THEN
	obj_Appwindow('LUValReturn',WHCd:@RM:FocusControl:@RM:FocusPos)
END

RETURN


* * * * * * *
PrintLabel:
* * * * * * *

WHCd	= Get_Property(@WINDOW:'.WH_CD','DEFPROP')
LocCd	= Get_Property(@WINDOW:'.LOC_CD','DEFPROP')


IF WHCd NE '' AND LocCd NE '' THEN
	Print_Loc_Label(WHCd,LocCd)	
END

RETURN



* * * * * * *
PrintSmallLabel:
* * * * * * *

WHCd	= Get_Property(@WINDOW:'.WH_CD','DEFPROP')
LocCd	= Get_Property(@WINDOW:'.LOC_CD','DEFPROP')

IF WHCd NE '' AND LocCd NE '' THEN
	Print_Small_Loc_Label(WHCd,LocCd)	
END

RETURN


* * * * * * *
LULocCD:
* * * * * * *

WhCd = Get_Property(@WINDOW:'.WH_CD','DEFPROP')
LocCd = Get_Property(@WINDOW:'.LOC_CD','DEFPROP')


IF WhCd = '' THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = 'BY @ID'
	TypeOver<PMODE$> = 'T'
	TypeOVer<PTYPE$> = 'K'
	
	LocKey = Popup(@WINDOW,TypeOver,'LOCATIONS')
	
	IF LocKey NE '' THEN
		obj_Appwindow('LoadFormKeys',@WINDOW:@RM:LocKey)
	END
END ELSE
	
	LocCds = XLATE('WAREHOUSE',WhCd,WAREHOUSE_LOC_KEY$,'X')
	
	IF LocCds NE '' THEN
		TypeOver = ''
		TypeOver<PDISPLAY$> = LocCds
		TypeOver<PTITLE$> = 'Locations in Warehouse ':WhCd
		
		LocCd = Popup(@WINDOW,TypeOver,'LOCATIONS')
		
		IF LocCd NE '' THEN
		
			IF INDEX(LocCd,@VM,1) THEN
				lCnt = COUNT(LocCd,@VM) + (LocCd NE '')
				KeyList = ''
				
				FOR I = 1 to lCnt
					KeyList<1,I> = WhCd:'*':LocCd<1,I>
				NEXT I
				
				Set_Property(@WINDOW,'QBFLIST',KeyList)
		
			END ELSE
				obj_Appwindow('LUValReturn',LocCd:@RM:@WINDOW:'.LOC_CD')
			END
		END
	END

END

RETURN


* * * * * * * 
LocCdGF:
* * * * * * *


RETURN

WhCd = Get_Property(@WINDOW:'.WH_CD','DEFPROP')
LocCd = Get_Property(@WINDOW:'.LOC_CD','DEFPROP')

IF WhCd NE '' AND LocCd = '' THEN
	LocCds = XLATE('WAREHOUSE',WhCd,WAREHOUSE_LOC_KEY$,'X')
	IF LocCds NE '' THEN
		TypeOver = ''
		TypeOver<PDISPLAY$> = LocCds
		TypeOver<PTITLE$> = 'Locations in Warehouse ':WhCd
		LocCd = Popup(@WINDOW,TypeOver,'LOCATIONS')
		IF LocCd NE '' THEN
			obj_Appwindow('LUValReturn',LocCd)
		END
	END
END

RETURN












