Function NDW_AUDIT_REPORT_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 Audit Report Events

    Description :
    
	Tags		:	[SRP]

    Parameters  :

    History (Date, Initials, Notes)
        11/10/10	fjt     Initial development

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

$insert SRP_APP_INSERTS
$insert SRP_EVENT_SETUP

Declare subroutine Btree.Extract, SRP_Show_Window, SRP_Redirect_OLE_Events, Update_Index

Begin Case

	Case Event EQ "OnClick"
		Begin Case
			Case Control EQ "PUB_REFRESH"		; GoSub OnClick.PUB_REFRESH
		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 -------------------------------------------------------------------------------------------


OnClick.PUB_REFRESH:
	GoSub Set_List
return


Window.CREATE:
	rv = ""
	rv<01> = "Appt"    :@VM: "Number" :@VM: "050" :@VM:1:@VM:1
	rv<02> = "User"    :@VM: "Text"   :@VM: "080" :@VM:1:@VM:1
	rv<03> = "Station" :@VM: "Text"   :@VM: "080" :@VM:1:@VM:1
	rv<04> = "Date"    :@VM: "Date"   :@VM: "070" :@VM:1:@VM:1
	rv<05> = "Time"    :@VM: "Time"   :@VM: "050" :@VM:1:@VM:1
	rv<06> = "Reactor" :@VM: "Number" :@VM: "040" :@VM:1:@VM:1
	rv<07> = "WO"      :@VM: "Number" :@VM: "050" :@VM:1:@VM:1
	rv<01,12> = "##0"
	rv<04,12> = "mm/dd/yyy"
	rv<05,12> = "hh:mm"
	rv<06,12> = "#0"
	rv<07,12> = "##0"
	Set_Property(@Window:".RPT_LIST", "OLE.ColumnList", rv)

	// Reactor dropdown
	rv = ""
	For i = 20 to 69
		rv := i :@FM
	Next i
	rv[-1,1] = ""
	Set_Property(@Window:".COB_REACTOR", "LIST", "<all>":@FM:rv)
	Set_Property(@Window:".COB_REACTOR", "TEXT", "<all>")
	
	// Initial Date Range
	Set_Property(@Window:".EDL_DATEF", "INVALUE", Date()-7)
	Set_Property(@Window:".EDL_DATET", "INVALUE", Date()-0)
	
	// Initial load
	GoSub Set_List

	SRP_Redirect_OLE_Events()
	SRP_Show_Window(@Window, "", "C", "C", 1)
return


Set_List:
	DateF = Get_Property(@Window:".EDL_DATEF", "INVALUE")
	DateT = Get_Property(@Window:".EDL_DATET", "INVALUE")
	
	List  = ""
	Table = "AUDIT_WO_MAST_SCHED"
	Field = "DATE_IN"
	Update_Index(Table, Field, No$, True$)
	
	Open Table to hTable else null
	
	Valid  = DateF and DateT
	Valid += DateT GE DateF
	Valid  = Valid EQ 2
	
	If Valid then
		Stmt  = "SELECT ":Table:" BY DATE_IN WITH DATE_IN FROM "
		Stmt := DateF:" TO "
		Stmt := DateT
		Call Rlist(Stmt, 5, "", "", "")
		
		EOL = No$
		Loop
			Readnext Key else EOL = Yes$
		Until EOL
			
			MV  = Key<0,2>
			Key = Key<0,1>
			Read Rec from hTable, Key then
				Row = ""
				Row<01> = Key
				Row<02> = Rec<3,MV>
				Row<03> = Rec<4,MV>
				Row<04> = Rec<1,MV>
				Row<05> = Rec<2,MV>
				Row<06> = Xlate("WO_MAST_SCHED", Key, "REACT_NO", "X")
				Row<07> = Xlate("WO_MAST_SCHED", Key, "WO_NO", "X")
				Convert @FM to @VM in Row
				List := Row :@FM
			end
		Repeat
	end
	
	If List[-1,1] EQ @FM then List[-1,1] = ""
	Set_Property(@Window:".RPT_LIST", "OLE.List", List)
return


