Compile function NDW_PRINT_REACTOR_LABELS_EVENTS(CtrlEntId, Event, @PARAMS)
/***********************************************************************************************************************

    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_Print_Reactor_Labels_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)
        01/13/25    djs     Created initial commuter module.

***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
#window NDW_PRINT_REACTOR_LABELS

$Insert APP_INSERTS
$Insert EVENT_SETUP
$Insert MSG_EQUATES

Declare function   Reactor_Services, Labeling_Services, Printer_Select
Declare subroutine PlaceDialog, Labeling_Services

GoToEvent Event for CtrlEntId else
    // Event not implemented
end

Return EventFlow or 1

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

Event WINDOW.CREATE(CreateParam)
    
    ReactNos      = Reactor_Services('GetReactorNumbers')
    Set_Property(@Window:'.COB_REACTOR', 'LIST', ReactNos)
    LoadLockSides = 'Left,Right,Both'
    Convert ',' to @FM in LoadLockSides
    Set_Property(@Window:'.COB_LOAD_LOCK_SIDE', 'LIST', LoadLockSides)
    PlaceDialog(-2, -2)
    
End Event


Event COB_REACTOR.CHANGED(NewData)
	
	GoSub EnablePrintButton
	
end event


Event COB_LOAD_LOCK_SIDE.CHANGED(NewData)
	
	GoSub EnablePrintButton
	
end event


Event PUB_PRINT.CLICK()
	
	ErrorMsg    = ''
	ReactNo     = Get_Property(@Window:'.COB_REACTOR', 'TEXT')
	LLSide      = Get_Property(@Window:'.COB_LOAD_LOCK_SIDE', 'TEXT')
	ReactorZpl  = Labeling_Services('GetReactorLabelZPL', ReactNo, LLSide)
	If Error_Services('NoError') then
		PrintPath	= Printer_Select()
		If PrintPath NE '' then
			Def         = ""
			Def<MTEXT$> = "Printing label..."
			Def<MTYPE$> = "U"
			MsgUp       = Msg(@window, Def)   ;* display the processing message
			Msg(@window, MsgUp)         ;* take down the processing message
			Labeling_Services('PrintLabel', ReactorZpl, PrintPath)
			If Error_Services('HasError') then
				ErrorMsg = Error_Services('GetMessage')
			end
		end
	end else
		ErrorMsg = Error_Services('GetMessage')
	end
	
	If ErrorMsg NE '' then
		Msg(@Window, '', 'OK', '', 'Print Error':@FM:ErrorMsg)
	end
	
end event

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

EnablePrintButton:
	
	ReactNo = Get_Property(@Window:'.COB_REACTOR', 'TEXT')
	LLSide  = Get_Property(@Window:'.COB_LOAD_LOCK_SIDE', 'TEXT')
	Set_Property(@Window:'.PUB_PRINT', 'ENABLED', ( (ReactNo NE '') and (LLSide NE '') ) )	
	
return

