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

/*
	Commuter module for NOTES_ATTACH collector window
	
	11/16/2009 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, obj_Appwindow
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Start_Window, Create_Note

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Notes_Comm
DECLARE FUNCTION Send_Message, Msg, Security_Check


$INSERT MSG_EQUATES
$INSERT APPCOLORS

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


ErrTitle = 'Error in Notes_Attach commuter'
ErrorMsg = ''

Result = ''


BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			
			CASE Event = 'CREATE' 			; GOSUB Create
			
		END CASE
		
	CASE EntID = 'NOTES_ATTACH.SAVE_BUTTON' AND Event = 'CLICK' 			; GOSUB Save
		
	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',@WINDOW)

AttachWindow = FIELD( Parm1, '*',1)
AttachId     = FIELD( Parm1, '*',2)
*AttachQBF    = FIELD( Parm1, '*',3)

CONVERT '_' TO '*' IN AttachID

Set_Property( @WINDOW, '@AttachWindow', AttachWindow )
Set_Property( @WINDOW, '@AttachID', AttachID )
*Set_Property( @WINDOW, '@AttachQBF', AttachQBF )


FirstChar = AttachWindow[1,1]
RestChars = AttachWindow[2,999]

CONVERT @UPPER_CASE TO @LOWER_CASE IN RestChars

AttachWindow = FirstChar:RestChars

Set_Property(@WINDOW:'.ATTACHMENT','TEXT','Attachment: ':AttachWindow:' ':AttachID)


RETURN


* * * * * * *
Save:
* * * * * * *

To      = Notes_Comm( 'STRIP_DUPS' )							; * all users and groups
Group   = Get_Property(@WINDOW:'.SEND_TO_GROUP_INT','ARRAY')

From    = @USER4

Subject = Get_Property(@WINDOW:'.SUBJECT','TEXT')
Message = Get_Property(@WINDOW:'.MESSAGE','TEXT')

AttachWindow	= Get_Property(@WINDOW, '@AttachWindow' )
AttachId		= Get_Property( @WINDOW, '@AttachID' )


IF To AND Subject THEN

	obj_Notes('Create',To:@RM:From:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachID:@RM:Group)
	
	
    End_Dialog(@WINDOW,'')
    
END ELSE

	MsgInfo = ''
	MsgInfo<micon$> = 'H'
	MsgInfo<mtext$> = 'You must enter a send to person(s) and a subject...' 
	MSG( '',MsgInfo)
	
END

RETURN





