COMPILE FUNCTION Comm_SAP_Log(Instruction, Parm1,Parm2)

/*
	Commuter module for SAP_Log () window (SAP Error Posting window)
	
	08/17/2005 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Set_List_Box_Data
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow,ErrMsg
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility,  Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message, Msg, Security_Check, RowExists, NextKey

$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT QUOTE_SIGS_EQU
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU


EQU CRLF$	TO \0D0A\


ErrTitle = 'Error in Comm_SAP_Log'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Instruction = 'Create' 		; GOSUB Create
	CASE Instruction = 'Refresh'		; GOSUB Refresh
	CASE Instruction = 'Read'			; GOSUB Read
	CASE Instruction = 'Clear'			; GOSUB Clear
	CASE Instruction = 'LULogNo'		; GOSUB LULogNo
	CASE Instruction = 'ViewOrder'		; GOSUB ViewOrder
		
	CASE 1
		ErrorMsg = 'Unknown Instruction ':QUOTE(Instruction):' passed to routine.'
		ErrMsg(ErrorMsg)
END CASE

RETURN Result


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

* Change the security tables to match the table names after conversion and take this note out

obj_Appwindow('Create',@WINDOW)

* Provides compatibility with the existing messaging attachment system

IF Parm1 NE '' THEN
	PassedKeys = FIELD(Parm1,'*',1)
	obj_Appwindow('ViewRelated',@WINDOW:@RM:PassedKeys)
END

*obj_AppWindow('ReadOnly',@WINDOW)			;* disable all database controls

GOSUB Refresh

RETURN


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

obj_AppWindow('ReadOnly',@RM:1)		;* Reenables data bound controls

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

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>
	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


* * * * * * *
LULogNo:
* * * * * * *

LogNos = Popup(@WINDOW,'','SAP_LOG')

IF LogNos = '' THEN RETURN


IF LogNos NE '' THEN obj_Appwindow('ViewRelated',@WINDOW:@RM:LogNos)		;* Loads form key or QBFList as required

*obj_AppWindow('LUValReturn',LogNo:@RM:@WINDOW:'.LOG_NO')

RETURN


* * * * * * *
ViewOrder:
* * * * * * *

OrderNo = Get_Property(@WINDOW:'.ORDER_NO','TEXT')

IF OrderNo = '' THEN RETURN

obj_AppWindow('ViewRelated','ORDER2':@RM:OrderNo)

RETURN

















