Function LSL2_MAIN_SCRIPT_CREATE(CtrlEntId, CtrlClassId, CreateParam)

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

    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        :   LSL2 Main Script Create

    Description :
    
	Tags		:	[SRP]

    Parameters  :

    History (Date, Initials, Notes)
        08/31/10	fjt     Initial development; moved from the window Create script event

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

$insert LOGICAL
$insert LSL_COMMON
$insert LSL_USERS_EQU
$INSERT QUOTE_SIGS_EQU
$INSERT NOTIFICATION_EQU
$INSERT ENVIRON_CONSTANTS

Declare function Get_Property, Set_Property
DECLARE FUNCTION start_window, findwindow, showwindow, Post_Event, Utility, obj_Notes_Sent, FindWindow
DECLARE FUNCTION log_check, send_event, set_printer, obj_Install, Get_Status, Show_Windows_Processes,GetEngineWindow, MemberOf
DECLARE SUBROUTINE Get_BMP_Info, Set_Property, Msg,	obj_Tables, ErrMsg, Set_Status, Post_Event, Utility, ErrMsg, obj_Appwindow
DECLARE SUBROUTINE ShowWindow, obj_Calib_List, Set_Env, Set_Property, Start_Window

Declare subroutine SRP_Show_Window

EQU X_OFF$	TO 1
EQU Y_OFF$	TO 2
EQU WIDTH$	TO 3
EQU HEIGHT$	TO 4

Process = 0
Loop
	Process += 1
	On Process GoSub Init, Graphic, Timer, Notes, Menus, Notify, Display, Done
Until (Err or Done)
Repeat

If Err then Ans = 0 else Ans = 1
Return Ans


!----- CREATE PROCESSES ---------------------------------------------------------------------------------


Init:
	Err = 0
	Done = 0
	Window = CtrlEntId

	IF @USERNAME = 'INDEXER' THEN
		Start_Window( 'IDXSVR', @window, '', '', '' )
		Err = Yes$
	END
	
	IF @USERNAME = 'VISION' THEN
		Start_Window( 'VISION_COMM', @WINDOW, '', '', '' )
		Err = Yes$
	END
	
	IF MemberOf(@USER4, 'OI_SUPERUSER') OR @USER4 = 'SRP_FRANK' THEN
		Set_Env(ENV_DEBUGGER_ENABLED$, 1, 1)
		Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$, '', 1)
	END ELSE
		Set_Env(ENV_DEBUGGER_ENABLED$, 2, 1)
		Set_Env(ENV_DEBUGGER_INTERCEPT_PROC$,'EPI_USER_DEBUG',1)
	END
return


Graphic:
	GraphicPath = obj_Install('Get_Prop','ColorBMP')
	* GraphicPath = "bmps/lsl2.jpg"
	Set_Property(Window:".OLE_PICTURE", "OLE.Image", GraphicPath)
return


Timer:
	Set_Property(CtrlEntId, "TIMER", 1000:@FM:1)
	Stat = Set_Property(@WINDOW, 'STATUSLINE', @WINDOW:'.STATUS_LINE')		;// Setup status line 
	
	if @user4 <> '' then
	   // THIS MEANS BRYCE IS IN DEVELOPMENT MODE AND HAS CHANGED THE USER ID SO LEAVE ALONE
	end else
	   @user4 = @username
	end
return


Notes:
	NotesSent = obj_Notes_Sent('GetUserKeys',@USER4)
	NewMessages = XLATE('NOTE_PTRS',@USER4,'NEW_MESSAGES','X')
	
	IF NotesSent NE '' OR NewMessages > 0 THEN
		Void = Start_Window( 'NOTE_PTRS', @WINDOW, '*CENTER', '', '' )
	END
return


Menus:
	IF @USERNAME = 'BRYCE_BARB' OR MemberOf(@USER4, 'OI_ADMIN')  OR @USERNAME = 'MIKE_MAY' THEN
		Set_Property(@WINDOW:'.MENU.ADMIN.MGMT','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.MENU.ADMIN.MGMT','ENABLED',0)
	END
	
	IF @USERNAME = 'BRYCE_BARB' OR MemberOf(@USER4, 'OI_ADMIN') OR MemberOf(@USER4, 'OI_SUPERUSER') THEN
		Set_Property(@WINDOW:'.MENU.PROD.REACTOR_RUN','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.MENU.PROD.REACTOR_RUN','ENABLED',0)
	END
return


Notify:
	CalDueRecipients = XLATE('NOTIFICATION','CALIB_DUE_NOTIFY',NOTIFICATION_USER_ID$,'X')
	LOCATE @USER4 IN CalDueRecipients USING @VM SETTING POS THEN
		obj_Calib_List('SendReminders')	;// New system added 3/18/2010 JCH
	END
return


Display:
	// Hide old controls
	Ctrls = "GROUP_1,CURRENT_USER,CURRENT_DATE,CURRENT_TIME"
	Convert "," to @FM in Ctrls
	For i = 1 to 4
		Set_Property(@Window:".":Ctrls<i>, "VISIBLE", No$)
	Next i
	
	// Show new controls
	Ctrls = "OLE_STATUS,OLE_PICTURE"
	Convert "," to @FM in Ctrls
	For i = 1 to 2
		Set_Property(@Window:".":Ctrls<i>, "VISIBLE", Yes$)
	Next i
	
	// Window Title
	Company = obj_Install('Get_Prop','Company')
	WinTitle = Get_Property(@WINDOW,'TEXT')
	Set_Property(@WINDOW,'TEXT',Company:' ':WinTitle)
	
	// Status
	Ctrl = Window:".OLE_STATUS"
	Set_Property(Ctrl, "OLE.PaneCaption[1]", 'User: ':oconv(@USER4, '[XLATE_CONV,LSL_USERS*FIRST_LAST]' ))
	Set_Property(Ctrl, "OLE.PaneCaption[2]", 'Date: ':oconv(Date(), 'D2/' ))
	
	// Finalize
	SRP_Show_Window(@Window, "", "C", "C", 1)
 	* obj_Appwindow('Create')
return


Done:
	IF @ADMIN < 2 THEN
		hWnd1% = FindWindow("RTI_OINSIGHT":\00\, "")
		hWnd2% = FindWindow("AREV":\00\, "")
		hWnd3% = FindWindow("PROGMAN":\00\, "")
		rv = ShowWindow(hWnd1%, 0)
		rv = ShowWindow(hWnd2%, 0)
		rv = ShowWindow(hWnd3%, 2)
	END

	*IF @ADMIN < 2 THEN ShowWindow(GetEngineWindow(),0)	;* Hide the OEngine ICON
	
	Done = Yes$
return 
