COMPILE FUNCTION Comm_Dialog_Packed_Shipments(Method, Parm1)

/*
	Commuter module for Dialog_Packed_Shipments window.
	
	03/05/2005 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Btree.Extract, Msg, Send_Message
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Send_Message, Popup, Collect.IXVals, Msg

EQU CRLF$	TO \0D0A\

EQU COL$SHIP_NO		TO 1		;* Customer edit table column equates
EQU COL$CUST_NAME	TO 2
EQU COL$WO_NO		TO 3
EQU COL$TRACKING_NO	TO 4

$INSERT COC_EQU
$INSERT PS_EQUATES
$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES

ErrTitle = 'Error in Comm_Dialog_Packed_Shipments'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'				; GOSUB Create
	CASE Method = 'SelectShipments'		; GOSUB SelectShipments
	CASE Method = 'OK'					; GOSUB OK
	CASE Method = 'Cancel'				; GOSUB Cancel
	
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


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

obj_AppWindow('Create')



* * * * * * *
SelectShipments:
* * * * * * *


StartDt = Date() - 15

OPEN 'DICT.COC' TO DictVar THEN
	SearchString  = 'ENTRY_DATE':@VM:'>=':OConv(StartDt, 'D4/'):@FM
	SearchString := 'CURR_STATUS':@VM:'PACK':@FM
	
	Flag = ''
	Btree.Extract(SearchString, 'COC', DictVar, ShipKeys, '', Flag)
	IF Get_Status(errCode) THEN
		Msg(@window, MsgUp)
		ErrMsg(errCode)
		RETURN
	END
		
	IF ShipKeys = '' THEN
		ErrMsg("No Shipments (COC's) on file for last 5 days.")
		RETURN
	END
	
	OpenShipKeys = ''
	CurrStatuses = XLATE('COC',ShipKeys,'CURR_STATUS','X')
	FOR I = 1 TO COUNT(ShipKeys,@VM) + (ShipKeys NE '')
		IF CurrStatuses<1,I> NE 'COMP' THEN
			OpenShipKeys<1,-1> = ShipKeys<1,I>
		END
	NEXT I
				
	OpenShipKeys := @VM
	CONVERT @VM TO @RM IN OpenShipKeys
	CALL V119('S','','D','R',OpenShipKeys,'')
	IF Get_Status(errCode) THEN DEBUG
	CONVERT @RM TO @VM IN OpenShipKeys
	OpenShipKeys[-1,1] = ''					;* Strip trailing delimiter	
	
	TypeOver = ''
	TypeOver<PMODE$> 	= 'K'
	TypeOver<PDISPLAY$> = OpenShipKeys
	TypeOver<PSELECT$>	= 2						;* Multiple Select
	TypeOver<PTYPE$>	= 'E'
	ShipData = Popup(@WINDOW,TypeOver,'COC_QUERY')
	
	IF Get_Status(errCode) THEN
		ErrMsg(errCode) 
		RETURN
	END
	
	IF ShipData = '' THEN RETURN
	
	ArrayData = ''
	FOR I = 1 TO COUNT(ShipData,@FM) + (ShipData NE '')
		ArrayData<1,I> = ShipData<I,1>
		ArrayData<2,I> = ShipData<I,2>
		ArrayData<3,I> = ShipData<I,4>
		ArrayData<4,I> = ''
	NEXT I
	
	Set_Property(@WINDOW:'.SHIPMENTS','DEFPROP',ArrayData)
	
DEBUG
END

 
RETURN


* * * * * * *
OK:
* * * * * * *


RETURN



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

RETURN


