Function NDW_Scheduler_Test_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 Infineon.

    Name        :   NDW_Scheduler_Test_Events

    Description :   This function acts as a commuter module for all events related to this window.

    Notes       :   Commuter Modules are automatically called from the Promoted_Events function which is called by the
                    application-specific promoted event handler. This makes it possible to add QuickEvents that need to
                    execute Basic+ logic without having use the Form Designer to make the association, although this is
                    limited to the events which are currently promoted.

                    If the form needs to call the commuter module directly then the QuickEvent parameters should be
                    formatted like this:

                        '@SELF','@EVENT',['@PARAM1','@PARAMx']

    Parameters  :
        CtrlEntId   [in] -- The fully qualified name of the control calling the promoted event
        Event       [in] -- The event being executed. See the Notes section regarding "PRE" events
        Param1-15   [in] -- Additional event parameter holders
        EventFlow  [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
                            EVENT_SETUP insert

    History     :   (Date, Initials, Notes)
        08/26/2021   djs     Created initial commuter module.

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

#pragma precomp SRP_PreCompiler
#Window NDW_SCHEDULER_TEST

$insert APP_INSERTS
$insert EVENT_SETUP

Equ LightGrey$ TO 239 + (239*256) + (239*65536)
EQU LTORANGE$  TO 255 + (220*256) + (128*65536)

Declare function    SRP_Array, SRP_JSON, Database_Services
Declare subroutine  SRP_JSON, Database_Services

SubclassInfo    = Form_Services('FindSubclassControl')
Subclass        = SubclassInfo<1>

// Update the arguments so that the OpenInsight OLE event will treate the ActiveX event as a native event handler.
If Event EQ 'OLE' then
    Transfer Event to OIEvent
    Transfer Param1 to Event
    Transfer Param2 to Param1
    Transfer Param3 to Param2
    Transfer Param4 to Param3
    Transfer Param5 to Param4
    Transfer Param6 to Param5
    Transfer Param7 to Param6
    Transfer Param8 to Param7
end

GoToEvent Event for CtrlEntID

Return EventFlow else EVENT_CONTINUE$


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Event WINDOW.CREATE(CreateParam)

    Set_Property(@Window, 'VISIBLE', 3)

 	GoSub Setup_OLE_Controls

end event


Event WINDOW.CLOSE(CancelFlag)

    
end event


Event OLE_DATEPICKER.OnSelChange(FirstDate)

    SelectedDate    = Get_Property(CtrlEntId, 'OLE.Selection')
    Set_Property(@Window : '.OLE_SCHEDULE', 'OLE.Date', SelectedDate)
    Send_Event(@Window : '.OLE_SCHEDULE', 'OLE', 'OnDateChange', SelectedDate)

end event


Event OLE_PUB_REFRESH_SCHEDULE.OnClick(Point, Button, Shift, Ctrl)

    // The ShowWaitMessage gosub hides the schedule control and displays the picture contorl with the indicated caption.
    Caption     = 'Please wait...refreshing schedule'
    GoSub ShowWaitMessage
    GoSub UpdateAppointmentList
    GoSub HideWaitMessage

end event


Event OLE_SUBCLASS.OnOptionClick(CtrlId)

    Send_Event(CtrlId, 'OPTIONS')

end event


Event OLE_SUBCLASS.OnComboClick(CtrlId)

    Send_Event(CtrlId, 'LOSTFOCUS')

end event


Event WINDOW.OMNIEVENT(Message, Param1, Param2, Param3, Param4)
    
    Sender     = Param1
    If ( (Message EQ 'RefreshSchedule') and (Sender NE @User4) ) then
        Caption = 'Please wait...refreshing schedule'
        GoSub ShowWaitMessage
        GoSub UpdateAppointmentList
        GoSub HideWaitMessage
    end

end event


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Setup_OLE_Controls:

    Ctrl        = @Window : '.OLE_PICTURE'
    Set_Property(Ctrl, 'OLE.BackgroundColor', 'Vertical(Gradient(LightSteelBlue L=90, LightSteelBlue L=80, 30%), Gradient(LightSteelBlue L=75, LightSteelBlue L=80), Border(LightSteelBlue L=50, LightSteelBlue L=50, LightSteelBlue L=50, LightSteelBlue L=50))')
    Set_Property(Ctrl, 'OLE.Font', SystemTypeface$ : @SVM : 30 : @SVM : 700)

    // The ShowWaitMessage gosub hides the schedule control and displays the picture contorl with the indicated caption.
    GoSub ShowWaitMessage
    Ctrl        = @Window : '.OLE_SCHEDULE'

    // Setup the inital date range during the 'Create'
    StartDate   = Date() - 120
    EndDate     = Date() + 120
    DateList    = ''
    For Date = StartDate to EndDate
        DateList   := Date : @FM
    Next Date
    DateList[-1, 1] = ''
    Set_Property(Ctrl, '@DATE_LIST', DateList)
    Set_Property(Ctrl, 'OLE.Border', 'XP Flat')
 	Set_Property(Ctrl, 'OLE.View', 'MultiDayHorz')			    ; // Landscape mode
 	Set_Property(Ctrl, 'OLE.DateHeaderFormat', 'DDDD  -  mmm DD, YYYY')
 	Set_Property(Ctrl, 'OLE.CurrentTimeColor', 'Blue')
 	Set_Property(Ctrl, 'OLE.ShowCalendar', False$)
 	Set_Property(Ctrl, 'OLE.ShowTree', False$)
 	Set_Property(Ctrl, 'OLE.AllowLeadTime', False$)
 	Set_Property(Ctrl, 'OLE.AllowTrailTime', False$)
 	Set_Property(Ctrl, 'OLE.EnableLeadTrailDisplay', Trail$)
 	Set_Property(Ctrl, 'OLE.AppointmentMetrics', 4 : @FM : 4)
 	Set_Property(Ctrl, 'OLE.Interval', 60)						; // Number of minutes per interval

    ZoomPercent = '100%'
    Set_Property(@Window:'.LBL_ZOOM_PERCENT', 'TEXT', ZoomPercent)

    IntervalSize = 11

 	Set_Property(Ctrl, 'OLE.IntervalSize', IntervalSize)	; // Space (width) for each time increment (in pixels)
 	Set_Property(Ctrl, 'OLE.TimeRange', 0 :@FM: 24 :@FM: 4)		; // <3> is hour display increment
    Fonts         = ''
    Fonts<1>      = 'Segoe UI' : @SVM : '10'                 ; // Column Hours
    Fonts<2>      = 'Segoe UI' : @SVM : '6'                  ; // Column Minutes
    Fonts<3>      = 'Segoe UI' : @SVM : '12' : @SVM : '700'  ; // Reactor No
    Fonts<4>      = 'Segoe UI' : @SVM : '8'                  ; // Reactor Meta
    Fonts<5>      = 'Segoe UI' : @SVM : '12' : @SVM : '700'  ; // Column Date and Day
    Set_Property(Ctrl, 'OLE.ScheduleFonts', Fonts)
    // Setup the initial reactors list. This populates the EntityList variable.
    GoSub GetReactorEntities
    Set_Property(Ctrl, 'OLE.EntityList', EntityList)
    Set_Property(Ctrl, 'OLE.AutoSize', 0)
    Set_Property(Ctrl, 'OLE.EntitySize[All]', 75)
 	Set_Property(Ctrl, 'OLE.Date', Date()-1)
 	Layout        = ''
 	Layout<1, 1>  = 'APPTDATA'
 	Layout<1, 2>  = 0 : @SVM : 0 : @SVM : -1 : @SVM : -1
 	Layout<1, 3>  = 'NAME'
 	Layout<1, 4>  = ''
 	Layout<1, 5>  = 'Segoe UI' : @SVM : 9 : @SVM : 700
 	Layout<1, 6>  = 'Center'
 	Layout<1, 7>  = 'Center'
 	Layout<1, 8>  = 0
 	Layout<1, 10> = 1
 	Layout<2, 1>  = 'APPTDATA'
 	Layout<2, 2>  = 0 : @SVM : 0 : @SVM : -1 : @SVM : -1
 	Layout<2, 3>  = 'DESC'
 	Layout<2, 4>  = ''
 	Layout<2, 6>  = 'Center'
 	Layout<2, 7>  = 'Bottom'
 	Layout<2, 8>  = 1
 	Layout<2, 10> = 0
 	Layout<3, 1>  = 'FLAGS'
 	Layout<3, 2>  = 0 : @SVM : 0 : @SVM : -1 : @SVM : -1
 	Layout<3, 3>  = 'bmps\scheduler.png'
 	Layout<3, 4>  = 4 : @SVM : @SVM : 0
 	Layout<3, 6>  = 'Right'
 	Layout<3, 7>  = ''
 	Layout<3, 8>  = ''
 	Layout<3, 10> = 0
 	Set_Property(Ctrl, 'OLE.Layout', Layout)
 	// The GetScheduleAppointments gosub populates the AppointmentList, AppointmentKeys, and AppointmentFlags variables.
    GoSub GetScheduleAppointments
    Set_Property(Ctrl, 'OLE.AppointmentList', AppointmentList)
    // The SetScheduleFlags gosub loops through the AppointmentKeys array and parses the AppointmentFlags
    // array for the ApptFlags property.
    GoSub SetScheduleFlags
 	Qualify       = ''
 	Qualify<1>    = 1
    Qualify<4>    = 0
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnApptClick', Qualify)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnApptDblClick', Qualify)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnScheduleClick', Qualify)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnContextMenuClick', Qualify)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnApptHover', Qualify)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnScheduleMouseMove', Qualify)
 	Set_Property(Ctrl, "OLE.EnableMouseMoveEvent", True$)
 	Send_Message(@Window:'.OLE_PUB_ZOOM_IN', 'QUALIFY_EVENT', 'OLE.OnClick', Qualify)
 	Send_Message(@Window:'.OLE_PUB_ZOOM_OUT', 'QUALIFY_EVENT', 'OLE.OnClick', Qualify)
 	
 	Qualify<4> = 1
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnDateChange', Qualify)
    Qualify<4> = 0
    GoSub HideWaitMessage

    Ctrl    = @Window : '.OLE_DATEPICKER'
    Set_Property(Ctrl, 'OLE.Border', 'XP Flat')
    Set_Property(Ctrl, 'OLE.Font', 'Segoe UI' : @SVM : '9')
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnSelChange', 1)

    Ctrl        = @Window : '.OLE_SUBCLASS'
    EditLine    = @Window : '.EDL_REACTOR_FILTER'
    Set_Property(EditLine, 'TEXT', 'Reactor Type')
    Post_Event(EditLine, 'LOSTFOCUS')
    Handle      = Get_Property(EditLine, 'HANDLE')
    Send_Message(Ctrl, 'OLE.Subclass', Handle, EditLine)
    EditLine    = @Window : ';EDL_REACTOR_FILTER'
    FilterTypes = 'Reactor Type' : @STM : 'Reactor Assignment' : @STM : 'Wafer Size' : @STM : 'Cleanroom Area'
    Combo       = ''
    Combo<1>    = 1
    Combo<2, 1> = ''
    Combo<2, 2> = 'L' : @STM : 'DYN'
    Combo<2, 3> = FilterTypes
    Combo<2, 4> = 1
    Combo<2, 5> = 1
    Combo<2, 6> = 0
    Combo<2, 9> = 1
    Combo<2,11> = 0
    Set_Property(Ctrl, 'OLE.Combo[' : EditLine : ']', Combo)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnOptionClick', 1)
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnComboClick', 1)

    EditLine    = @Window : '.EDL_WORK_ORDER_SEARCH'
    Handle      = Get_Property(EditLine, 'HANDLE')
    Send_Message(Ctrl, 'OLE.Subclass', Handle, EditLine)
    EditLine    = @Window : ';EDL_WORK_ORDER_SEARCH'
    ApptIDs     = AppointmentArray<2>
    WorkOrders  = Xlate('SCHED_DET_NG', ApptIDs, 'WO_NO', 'X')
    Convert @VM to @FM in WorkOrders
    Convert '*' to @VM in WorkOrders
    WorkOrders  = SRP_Array('Rotate', WorkOrders, @FM, @VM)
    WorkOrders  = WorkOrders<1>
    Convert @VM to @FM in WorkOrders
    WorkOrders  = SRP_Array('Clean', WorkOrders, 'TrimAndMakeUnique', @FM)
    WorkOrders  = SRP_Array('SortRows', WorkOrders, 'AR1', 'LIST', @FM, @VM)
    Convert @FM to @STM in WorkOrders
    Combo       = ''
    Combo<1>    = 1
    Combo<2, 1> = ''
    Combo<2, 2> = 'L' : @STM : 'DYN'
    Combo<2, 3> = WorkOrders
    Combo<2, 4> = 1
    Combo<2, 5> = 1
    Combo<2, 6> = 0
    Combo<2, 9> = 1
    Combo<2,10> = 0
    Combo<2,11> = 0
    Set_Property(Ctrl, 'OLE.Combo[' : EditLine : ']', Combo)

    EditLine = @Window : '.EDL_EPI_PART_SEARCH'
    Handle   = Get_Property(EditLine, 'HANDLE')
    Send_Message(Ctrl, 'OLE.Subclass', Handle, EditLine)
    EditLine = @Window : ';EDL_EPI_PART_SEARCH'
    Convert @STM to @VM in WorkOrders
    EpiParts = Xlate('WO_LOG', WorkOrders, 'EPI_PART_NO', 'X')
    Convert @VM to @FM in EpiParts
    Convert '*' to @VM in EpiParts
    EpiParts = SRP_Array('Rotate', EpiParts, @FM, @VM)
    Convert @VM to @FM in EpiParts
    EpiParts = SRP_Array('Clean', EpiParts, 'TrimAndMakeUnique', @FM)
    EpiParts = SRP_Array('SortRows', EpiParts, 'AR1', 'LIST', @FM, @VM)

    Convert @FM to @STM in EpiParts
    Combo       = ''
    Combo<1>    = 1
    Combo<2, 1> = ''
    Combo<2, 2> = 'L' : @STM : 'DYN'
    Combo<2, 3> = EpiParts
    Combo<2, 4> = 1
    Combo<2, 5> = 1
    Combo<2, 6> = 0
    Combo<2, 9> = 1
    Combo<2,10> = 0
    Combo<2,11> = 0
    Set_Property(Ctrl, 'OLE.Combo[' : EditLine : ']', Combo)

    Ctrl    = @Window : '.OLE_TRE_REACTOR_FILTER_OPTIONS'
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnItemCheck', 1)
 	Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnApptDblClick', 1)

    Ctrls   = 'OLE_PUB_UPDATE_ASM_UTILIZATION,OLE_PUB_UPDATE_ASM_PLUS_UTILIZATION,OLE_PUB_UPDATE_HTR_UTILIZATION,OLE_PUB_UPDATE_EPIPRO_UTILIZATION,OLE_PUB_UPDATE_GAN_UTILIZATION'
    For Each ButtonCtrl in Ctrls using ','
        Ctrl    = @Window : '.' : ButtonCtrl
        Set_Property(Ctrl, 'OLE.Icon', '.\BMPS\Save.png')
        Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnClick', 1)
    Next ButtonCtrl

    Ctrl    = @Window : '.OLE_PUB_REFRESH_SCHEDULE'
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnClick', 1)

    Ctrl    = @Window : '.OLE_POPUP'
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnItemClick', 1)
    Send_Message(Ctrl, 'QUALIFY_EVENT', 'OLE.OnHide', 1)
    GoSub EnableZoomButtons

return


ShowWaitMessage:

    Set_Property(@Window : '.OLE_PICTURE', 'OLE.Caption', Caption)
    Set_Property(@Window : '.OLE_PICTURE', 'VISIBLE', 1)
    Set_Property(@Window : '.OLE_SCHEDULE', 'VISIBLE', 0)
    Set_Property(@Window, 'REDRAW', 0)

return


HideWaitMessage:

    Set_Property(@Window : '.OLE_SCHEDULE', 'VISIBLE', 1)
    Set_Property(@Window : '.OLE_PICTURE', 'OLE.Caption', '')
    Set_Property(@Window : '.OLE_PICTURE', 'VISIBLE', 0)
    Set_Property(@Window, 'REDRAW', 1)

return


GetScheduleAppointments:

    Ctrl             = @Window : '.OLE_SCHEDULE'
    AppointmentList  = ''
    AppointmentKeys  = ''
    AppointmentFlags = ''
    StartDate        = Date() - 60
    EndDate          = Date() + 60
    AppointmentList  = Database_Services('ReadDataRow', 'SYSLISTS', 'PREV_APPT_DATA')
    Set_Property(@Window, '@APPT_LIST', AppointmentList)
    AppointmentArray = SRP_Array('Rotate', AppointmentList, @FM, @VM)
    AppointmentKeys  = AppointmentArray<2>
    Convert @VM to @FM in AppointmentKeys
    AppointmentFlags = AppointmentArray<19>
    Convert @VM to @FM in AppointmentFlags
    
    DateList = Get_Property(@Window, '@DATE_LIST')
    For Date = StartDate to EndDate
    Locate Date in DateList using @FM setting fPos else
        DateList    = Insert(DateList, fPos, 0, 0, Date)
    end
    Next Date
    Set_Property(CtrlEntId, '@DATE_LIST', DateList)

return


GetNewScheduleAppointments:

    Ctrl             = @Window : '.OLE_SCHEDULE'
    AppointmentList  = ''
    AppointmentKeys  = ''
    AppointmentFlags = ''
    StartDate        = Date() - 60
    EndDate          = Date() + 60
    AppointmentList  = Database_Services('ReadDataRow', 'SYSLISTS', 'NEW_APPT_DATA')
    Set_Property(@Window, '@APPT_LIST', AppointmentList)
    AppointmentArray = SRP_Array('Rotate', AppointmentList, @FM, @VM)
    AppointmentKeys  = AppointmentArray<2>
    Convert @VM to @FM in AppointmentKeys
    AppointmentFlags = AppointmentArray<19>
    Convert @VM to @FM in AppointmentFlags
    
    DateList = Get_Property(@Window, '@DATE_LIST')
    For Date = StartDate to EndDate
    Locate Date in DateList using @FM setting fPos else
        DateList    = Insert(DateList, fPos, 0, 0, Date)
    end
    Next Date
    Set_Property(CtrlEntId, '@DATE_LIST', DateList)

return


SetScheduleFlags:

    Ctrl    = @Window : '.OLE_SCHEDULE'
    For Each AppointmentKey in AppointmentKeys using @FM setting fPos
        Flags    = AppointmentFlags<fPos>
        If Sum(Flags) GT 0 then
            Convert @SVM to @FM in Flags
            Set_Property(Ctrl, 'OLE.ApptFlags[' : AppointmentKey : ']', Flags)
        end
    Next AppointmentKey

return


GetReactorEntities:

    Ctrl       = @Window : '.OLE_SCHEDULE'
    EntityList = ''
    Reactors   = Database_Services('ReadDataRow', 'SYSLISTS', 'REACTOR_DATA')
    If SRP_JSON(objReactors, 'PARSE', Reactors) EQ '' then
        objReactorArray     = SRP_JSON(objReactors, 'GET', 'Reactors')
        objReactorList      = SRP_JSON(objReactorArray, 'GETELEMENTS')
        For Each objReactor in objReactorList using @FM
            ReactorNo     = SRP_JSON(objReactor, 'GETVALUE', 'ReactorNumber')
            Type          = SRP_JSON(objReactor, 'GETVALUE', 'TypeVerbose')
            Size          = SRP_JSON(objReactor, 'GETVALUE', 'SusceptorSize')
            Assignment    = SRP_JSON(objReactor, 'GETVALUE', 'AssignmentCode')
            SecondChamber = SRP_JSON(objReactor, 'GETVALUE', 'SecondChamber')
            PickPlace     = SRP_JSON(objReactor, 'GETVALUE', 'PickPlace')
            NotRepairable = SRP_JSON(objReactor, 'GETVALUE', 'NotRepairable')
            EpiPro        = (Type EQ 'EpiPro')
            Begin Case
                Case Assignment EQ 'G'
                    // GaN
                    Background  = 'SkyBlue'
                Case Assignment EQ 'O'
                    // Out-of-Service
                    Background  = 'Silver'
                Case Not(NotRepairable)
                    Background  = 'LightGreen'
                Case NotRepairable
                    Background = LTORANGE$
                Case Otherwise$
                    Background  = 'Silver'
            End Case
            If (Type NE 'EpiPro') OR (SecondChamber NE '') then
                EntityName  = ReactorNo
                If SecondChamber NE '' then EntityName := '/' : SecondChamber
                EntityList := 'ENT' : @VM : 1 : @VM : ReactorNo : @VM : EntityName : @VM : Type : CRLF$ : Size : @VM : 'Black' : @VM : Background : @FM
            end
            SRP_JSON(objReactor, 'RELEASE')
        Next objReactor
        EntityList[-1, 1]   = ''
        SRP_JSON(objReactorArray, 'RELEASE')
    end
    SRP_JSON(objReactors, 'RELEASE')

return


ParseScheduleEvent:

    If Assigned(objScheduleEvent) else objScheduleEvent = ''
    If objScheduleEvent EQ '' then
        SRP_JSON(objScheduleEvent, 'PARSE', ScheduleEvent)
    end
    If objScheduleEvent GT 0 then
        ReactorNo           = SRP_JSON(objScheduleEvent, 'GETVALUE', 'Reactor.ReactorNumber')
        ReactorType         = SRP_JSON(objScheduleEvent, 'GETVALUE', 'Reactor.Type')
        SusceptorSize       = SRP_JSON(objScheduleEvent, 'GETVALUE', 'Reactor.SusceptorSize')
        ScheduleDate        = SRP_JSON(objScheduleEvent, 'GETVALUE', 'ScheduleDate')
        ScheduleDate        = Iconv(ScheduleDate, 'D')
        Sequence            = SRP_JSON(objScheduleEvent, 'GETVALUE', 'Sequence')
        BackColor           = SRP_JSON(objScheduleEvent, 'GETVALUE', 'BackColor')
        ForeColor           = SRP_JSON(objScheduleEvent, 'GETVALUE', 'ForeColor')
        ModifiedDTM         = SRP_JSON(objScheduleEvent, 'GETVALUE', 'ModifiedDTM')
        BlockOut            = Iconv(SRP_JSON(objScheduleEvent, 'GETVALUE', 'BlockOut'), 'BYes,No')
        BlockOutType        = SRP_JSON(objScheduleEvent, 'GETVALUE', 'BlockOutType')
        Description         = SRP_JSON(objScheduleEvent, 'GETVALUE', 'Note')
        objWorkOrder        = SRP_JSON(objScheduleEvent, 'GET', 'WorkOrder')
        WorkOrderNo         = SRP_JSON(objWorkOrder, 'GETVALUE', 'WorkOrderNumber')
        EpiPartNo           = SRP_JSON(objWorkOrder, 'GETVALUE', 'EpiPartNumber')
        PSN                 = SRP_JSON(objWorkOrder, 'GETVALUE', 'PSN')
        Recipe              = SRP_JSON(objWorkOrder, 'GETVALUE', 'Recipe')
        HotLot              = Iconv(SRP_JSON(objWorkOrder, 'GETVALUE', 'HotLot'), 'BYes,No')
        Closed              = Iconv(SRP_JSON(objWorkOrder, 'GETVALUE', 'Closed'), 'BYes,No')
        CustNameShort       = SRP_JSON(objWorkOrder, 'GETVALUE', 'Company.NameShort')
        SRP_JSON(objWorkOrder, 'RELEASE')
        If BackColor EQ '' then
            Begin Case
                Case BackColor NE ''
                    // Set in the schedule detail record. Use current color.
                Case HotLot
                    BackColor   = 'LightCoral'
                Case Closed
                    BackColor   = 'LightGray'
                Case BlockOut
                    BackColor   = 'Plum'
                Case Otherwise$
                    BackColor   = 'LightSteelBlue'
            End Case
        end
        Current = False$    ; // Assume false for now.
        If (ScheduleDate GE Date()) then
            If (ModifiedDTM NE '') then
                CurrentDTM  = Iconv(Oconv(Date(), 'D4/') : ' ' : Oconv(Time(), 'MTH'), 'DTM')
                ElapseTime  = (CurrentDTM - ModifiedDTM) * 24
                IF (ElapseTime LE 12) then
                    CurrentFlag = True$
                end
            end
        end
        If ForeColor EQ '' then ForeColor = 'Black'
        FirstSchedDetKeyID  = SRP_JSON(objScheduleEvent, 'GETVALUE', 'FirstSchedDetKeyID')
        FirstReactorNo      = FirstSchedDetKeyID[1, '*']
        FirstScheduleDate   = Oconv(FirstSchedDetKeyID[Col2() + 1, '*'], 'D4/')
        LastSchedDetKeyID   = SRP_JSON(objScheduleEvent, 'GETVALUE', 'LastSchedDetKeyID')
        LastReactorNo       = LastSchedDetKeyID[1, '*']
        LastScheduleDate    = Oconv(LastSchedDetKeyID[Col2() + 1, '*'], 'D4/')
        TotalScheduledDays  = SRP_JSON(objScheduleEvent, 'GETVALUE', 'TotalScheduledDays')
        TotalWafers         = SRP_JSON(objScheduleEvent, 'GETVALUE', 'WorkOrder.TotalWafers')
        WafersRemaining     = SRP_JSON(objScheduleEvent, 'GETVALUE', 'WorkOrder.WafersRemaining')
        PercentComplete     = SRP_JSON(objScheduleEvent, 'GETVALUE', 'WorkOrder.PercentComplete')
        ScheduleEvent       = SRP_JSON(objScheduleEvent, 'STRINGIFY', 'FAST')
        SRP_JSON(objScheduleEvent, 'RELEASE')
    end

return


EnableZoomButtons:
    
    Ctrl          = @Window : '.OLE_SCHEDULE'
    IntervalSize  = Get_Property(Ctrl, 'OLE.IntervalSize')
    Set_Property(@Window:'.OLE_PUB_ZOOM_OUT', 'ENABLED', (IntervalSize GT 9))
    Set_Property(@Window:'.LBL_ZOOM_OUT', 'ENABLED', (IntervalSize GT 9))
    Set_Property(@Window:'.OLE_PUB_ZOOM_IN', 'ENABLED', (IntervalSize LT 29))
    Set_Property(@Window:'.LBL_ZOOM_IN', 'ENABLED', (IntervalSize LT 29))
    
return


UpdateAppointmentList:

    CurrApptList = Get_Property(Ctrl, 'OLE.AppointmentList')   
    GoSub GetNewScheduleAppointments    
    Set_Property(Ctrl, 'OLE.AppointmentList', AppointmentList)
    
return
