Function NDW_COPY_APPT_EVENTS(CtrlEntId, Event, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15)

/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to
    be copied without written permission from SRP Computer Solutions, Inc.

    Name        :   NDW Copy Appt Events

    Description :
    
	Tags		:	[SRP]

    Parameters  :

    History (Date, Initials, Notes)
        12/23/09    fjt     Initial development

********************************************************************************************************/

$insert SRP_APP_INSERTS
$insert SRP_EVENT_SETUP

Equ Metrics$ to	26:@FM:20:@FM:3:@FM:3:@FM:4:@FM:4

Declare subroutine SRP_Show_Window, SRP_Redirect_OLE_Events
Declare function   SVC_Option_Button

Begin Case
	
	Case Event EQ "CLICK"
		Begin Case
			Case Control EQ "PUB_CANCEL"		; GoSub CLICK.PUB_CANCEL
			Case Control EQ "PUB_COPY"			; GoSub CLICK.PUB_COPY
		End Case
		
	Case Event _eqc "OnOptionClick"
		Control = Field(Param1, ".", 2)
		Begin Case
			Case Control EQ "EDL_DATE"			; GoSub OnOptionClick.EDL_DATE
		End Case

    Case Control EQ Window
        Begin Case
        	Case Event EQ "CREATE"              ; GoSub Window.CREATE
        End Case

End Case

If Assigned(Ans) else Ans = 1
Return Ans


!----- EVENTS -------------------------------------------------------------------------------------------


CLICK.PUB_CANCEL:
	End_Dialog(@Window, "")
	Ans = 0
return


CLICK.PUB_COPY:
	rv     = Get_Property(@Window:".EDL_APPT", "DEFPROP")
	rv<02> = Get_Property(@Window:".COB_REACTOR", "TEXT")
	rv<03> = Get_Property(@Window:".EDL_DATE", "INVALUE")
	
	Begin Case
		Case rv<02> EQ "" or rv<03> EQ ""
			Msg = "Copy Appointment" :@FM: "All information is required."
			Msg(@Window, "", "ERROR", "", Msg)
		Case Otherwise$
			End_Dialog(@Window, rv)
			Ans = 0
	End Case
return


OnOptionClick.EDL_DATE:
	GoSub Calendar
return


Window.CREATE:
	// Calendar dropdown
	rv = SVC_Option_Button("Add", @Window, "EDL_DATE", "bmps/dropcal.bmp")

	// Reactor dropdown
	rv = ""
	For i = 20 to 74
		rv := i :@FM
	Next i
	rv[-1,1] = ""
	Set_Property(@Window:".COB_REACTOR", "LIST", rv)
	
	// Passed in parameters
	If Param1 then Set_Property(@Window:".EDL_APPT", "DEFPROP", Param1)
	
	SRP_Redirect_OLE_Events()
	SRP_Show_Window(@Window, "", "C", "C", 1, Metrics$)
return


!----- INTERNAL ROUTINES --------------------------------------------------------------------------------


Calendar:
	Default	  = Iconv(Get_Property(Param1, "DEFPROP"), "D4/")
	WinPos	  = Get_Property(@Window, "SIZE")
	CtrlPos	  = Get_Property(Param1, "SIZE")
	InitParam = Default:@FM:@Window:@FM:(CtrlPos<1> + WinPos<1>) + 3 :@FM:(CtrlPos<2> + WinPos<2> + CtrlPos<4> + 30)
	Date	  = Dialog_Box("POPUP_MONTH", @Window, InitParam)
	If (Date) then
		Set_Property(Param1, "DEFPROP", Oconv(Date, "D4/"))
		Ans = 0
	end
return
