function wo_daily_sched_all_comm(Branch,CurrParm)
/***********************************************************************************************************************

    Name        :   wo_daily_sched_all_comm

    History     :   (Date, Initials, Notes)
        04/20/21    djs     Updated Form_Create GoSub to use PickPlace instead of Dedicated and Non-Dedicated
                            reactor assignments for form color purposes.

***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler

declare function set_property, fieldcount, get_property, msg, dialog_box, security_check, Reactor_Log_Services
declare function send_message, utility, key_sort, start_window, entid, repository, Nica_Orders_Services
declare function relational_call, memberof, get_mode_icon, Database_Services, Reactor_Services
declare subroutine extract_si_keys, end_dialog, make.list, security_err_msg, Set_Property, SRP_Stopwatch, Dialog_Box
Declare subroutine Send_Message

$INSERT APPCOLORS
$INSERT MSG_EQUATES
$INSERT LSL_USERS_EQU
$INSERT RDS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT LOGICAL
$INSERT POPUP_EQUATES
$INSERT REACT_MODE_EQU
$INSERT WO_LOG_EQUATES
$INSERT WO_DAILY_SCHED_EQU
$INSERT WO_MASTER_SCHED_EQU
$INSERT REACTOR_EQUATES
$INSERT REACT_MODE_EQUATES
$INSERT REACT_STATUS_EQUATES
$INSERT REACT_LL_EQUATES
$Insert PS_EQUATES
$INSERT REACTOR_LOG_EQUATES
$INSERT REACT_MODE_NG_EQUATES
$INSERT REACTOR_CHILD_KEY_IDS_EQUATES

Equ CRLF$		to \0D0A\
EQU APPBRED$	TO 255 + (  0*256) + (  0*65536)
EQU APPRED$		TO 220 + (192*256) + (192*65536)
EQU APPPINK$    TO 220 + (192*256) + (192*65536)
EQU APPGREEN$	TO 192 + (220*256) + (192*65536)
EQU APPGREY$	TO 192 + (192*256) + (192*65536)
EQU APPYELLOW$	TO 255 + (255*256) + (202*65536)
EQU APPDKRED$	TO 128 + (  0*256) + (  0*65536)
EQU APPBLUE$	TO   0 + (  0*256) + (255*65536)
EQU APPGANBLUE$	TO 181 + (235*256) + (251*65536)	;* Added GaN blue background to ID GaN reactors - dkk 6/6/16
ForceModeChange	= FALSE$ ;* flag set to true when changing work order stamp
ReturnVar		= 0
Branches		= 'FORM_CREATE,REACT_DETAIL,IQSViolButton,ChecklistButton'

CONVERT ',' TO @FM IN Branches

LOCATE Branch IN Branches USING @FM SETTING Bpos THEN
	ON Bpos gosub FORM_CREATE, REACT_DETAIL, IQSViolButton, ChecklistButton
END ELSE
	Void = msg( '', 'Invalid Branch ':Bpos:' passed to wo_daily_sched_comm' )
END

RETURN ReturnVar


*===============================================================================================*
ChecklistButton:

	Message       = ''
	ReactorNo     = CurrParm[-1, 'B_']
	
	Status_0311 = XLATE('REACTOR', ReactorNo, REACTOR_0311_ACTIVE$, 'X')
	
	If Status_0311 EQ '' then Status_0311 = False$

	CurrModeKey       = Xlate('REACTOR_CHILD_KEY_IDS_NG', ReactorNo, REACTOR_CHILD_KEY_IDS_REACT_MODE_KEY_IDS$, 'X')
	CurrRLKey         = Xlate('REACT_MODE_NG', CurrModeKey, REACT_MODE_NG_START_RL_ID$, 'X')
	ReactorNicaOrders = Nica_Orders_Services('GetActiveOrders', 'REACTOR', ReactorNo)
	ReactorPmOrderIds = Nica_Orders_Services('GetActiveOrders', 'REACTOR_LOG', CurrRlKey)
	
	ChecklistInfo = 'The following checklist(s) are active: '
	
	If Status_0311 then ChecklistInfo<-1> = '0311 OCAP'
	
	If ReactorPmOrderIds NE '' then
		For each ReactorPmOrderId in ReactorPmOrderIds using @VM setting vPos
		    ProgressPercentage = Xlate('NICA_ORDERS', ReactorPmOrderId, 'PROGRESS_PERCENTAGE', 'X')
			ChecklistInfo<-1> = Xlate('NICA_ORDERS', ReactorPmOrderId, 'ORDER_TYPE', 'X') : ' - ' : ProgressPercentage :'% Complete.'
		Next RlPmType
	end
	
	If ReactorNicaOrders NE '' then
		For each NicaOrderId in ReactorNicaOrders using @VM
		    ProgressPercentage = Xlate('NICA_ORDERS', NicaOrderId, 'PROGRESS_PERCENTAGE', 'X')
			ChecklistInfo<-1> = Xlate('NICA_ORDERS', NicaOrderId, 'ORDER_TYPE', 'X') : ' - ' : ProgressPercentage :'% Complete.'
		Next NicaOrderId
	end

	Swap @FM with CRLF$ in ChecklistInfo
	
	MsgOverride         = ''
	MsgOverride<MICON$> = '!'
	Msg(@Window, MsgOverride, 'IQS_BOX', '', 'R': ReactorNo : ' Checklist Info' : @FM : ChecklistInfo)
	
return

*===============================================================================================*
IQSViolButton:
	Message       = ''
	ReactorNo     = CurrParm[-1, 'B_']
	CurrIQSData   = Database_Services('ReadDataRow', 'CONFIG', 'IQS_VIOL_DATA')
	ViolationInfo = ''
	for ViolRow = 1 to DCount(CurrIQSData<1>, @VM)
		ViolReactNo = CurrIQSData<1, ViolRow>
		If ViolReactNo EQ ReactorNo then
			ViolationInfo<-1> = CurrIQSData<2, ViolRow> : ' - ' : CurrIQSData<8,ViolRow>
		end
	Next ViolRow
	Swap @FM with CRLF$ in ViolationInfo
	Msg(@Window, '', 'IQS_BOX', '', 'R': ReactorNo : ' Violation Info' : @FM : ViolationInfo)
return

FORM_CREATE:
	
	CurSize = Get_Property(@Window, "SIZE")
	MinW    = CurSize<3>
	MinH    = CurSize<4>
	MaxW    = CurSize<3>
	MaxH    = CurSize<4>
	Set_Property(@Window,"TRACKINGSIZE",MinW:@FM:MinH:@FM:MaxW:@FM:MaxH)
	
	IF Assigned(CurrParm) AND CurrParm NE '' THEN
		Window = CurrParm
	END ELSE
		Window = @WINDOW
	END
	
	IF Window = 'WO_DAILY_SCHED_ALL' OR Window = 'REACT_STATUS_ODD' THEN
		StartReact = 21
		EndReact = 79
	END ELSE
		StartReact = 20
		EndReact = 78
	END
	Qualifier = ''
	Qualifier<1> = 1
	Qualifier<4> = 0 ; * process synchronously (i.e. immediately)
	
	For I = StartReact To EndReact STEP 2
		IQSPicControl = Window : '.OLE_PIC_IQS_': i
		Qualifier      = 1: @fm: 2: "*": @appid<1>: "*OMNIEVENT*":  Window : "."
		EventQualified = Send_Message(IQSPicControl,  'QUALIFY_EVENT', 'OLE.OnClick', Qualifier)
		
		ChecklistPicControl = Window : '.OLE_PIC_' : i
		EventQualified      = Send_Message(ChecklistPicControl, 'QUALIFY_EVENT', 'OLE.OnClick', Qualifier)
	Next I
	
	IQSData = Database_Services('ReadDataRow', 'CONFIG', 'IQS_VIOL_DATA')
	
	FOR I = StartReact TO  EndReact STEP 2

		ReactRec         = Xlate('REACTOR',I,'','X')
		LLDisabled		 = ReactRec<REACTOR_LL_DISABLED$>
		ReactAssign      = ReactRec<REACTOR_REACT_ASSIGNMENT$>
		PickPlace        = ReactRec<REACTOR_PICK_PLACE$>
		ReactType        = ReactRec<REACTOR_REACT_TYPE$>
		NotRepairable    = ReactRec<REACTOR_NOT_REPAIRABLE$>
		EpiPro           = (ReactType EQ 'EPP')
		EscElapsedTime   = OCONV(XLATE('REACTOR',I,'ACT_ESC_HRS','X'),'MD2')
		OutOfProdDTM     = Xlate('REACT_STATUS',I,REACT_STATUS_OUT_OF_PROD_DTM$,'X')
		
		BEGIN CASE
			CASE EscElapsedTime NE ''	         ; BackColor = APPYELLOW$		;* Reactor in escalation
			CASE ReactAssign = 'G'		         ; BackColor = APPGANBLUE$		;* Added GaN blue background to ID GaN reactors - dkk 6/6/16
			CASE ReactAssign = 'O'               ; BackColor = APPGREY$         ;* Out of service
			CASE Not(NotRepairable)
				
				ReactorLoaded = Reactor_Services('IsReactorLoaded', I)
				TimeSinceLastUnload = Reactor_Services('GetReactorTimeSinceUnload', I) 
				CurrMode      = Reactor_Services('GetReactCurrModeName', I)
				E10State      = Xlate('REACTOR_MODES', CurrMode, 'E10_STATE', 'X')
				Productive    = (E10State EQ 'Productive')
				If Productive and Not(ReactorLoaded) and TimeSinceLastUnload GE 30  then
					BackColor = APPRED$
				end else
					BackColor = APPGREEN$
				end
				*		CASE ReactAssign = 'M'		         ; BackColor = APPRED$          ;* M = Dedicated
			CASE NotRepairable                   ; BackColor = LTORANGE$
			CASE 1						         ; BackColor = APPGREY$
		END CASE
		Set_Property(Window:'.RPANEL':I,'BACKCOLOR',BackColor)
		Set_Property(Window:'.RWO':I,'BACKCOLOR',BackColor)
		Set_Property(Window:'.RCUST':I,'BACKCOLOR',BackColor)
		Set_Property(Window:'.TIM':I,'BACKCOLOR',BackColor)
		Set_Property(Window:'.ESC':I,'BACKCOLOR',BackColor)
		
		RMId = 'REACT_MODE':I
		
		CurrDTM	= ICONV(OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTHS'),'DT')		;* Current Date-Time in internal format
		
		CurrModeRec = XLATE('CONFIG',RMId,'','X')
		CurrMode		= CurrModeRec<Mode$>
		
		ModeStartDt	= CurrModeRec<Date$>
		ModeStartTm	= CurrModeRec<Time$>
		
		StartDTM	= ICONV(ModeStartDt:' ':ModeStartTm,'DT')
		
		TimeInMode = OCONV(ICONV((CurrDTM - StartDTM)*24,'MD1'),'MD1')
		TimeOutOfProd = OCONV(ICONV((CurrDTM - OutOfProdDTM)*24,'MD1'),'MD1')
		IF CurrMode THEN
			Icon = Get_Mode_Icon( CurrMode, Mode$ )	  
			Extension = '.BMP'        
			DosBmp = 'BMPS\':Icon:Extension
			Void = Set_Property( Window:'.RMODE':I, 'BITMAP', DosBmp )
		END
		
		DailySchedName = 'WO_DAILY_SCHED':I
		DSR = XLATE( 'CONFIG', DailySchedName, '', 'X' )
		WOCust = DSR<WOCust$>
		WO   = FIELD( WOCust, ' ', 1 )
		Cust = FIELD( WOCust, ' ', 2, 999 )
		
		Size = Xlate('REACTOR', I, REACTOR_SUSC_POCKET_SIZE$, 'X')
		Size = Field(Size, ' ' , 3, 2)
		
		CONVERT ' ' TO '' IN Size
		
		WONo = WO[1,'.']
		
		ActiveReactLLKey = XLATE('REACTOR',I, REACTOR_ACTIVE_LL_DISABLED$, 'X' )			;* Drive asterisk from new field ACTIVE_LL_DISABLED
		
		IF ActiveReactLLKey NE '' THEN
			LLDisabled = XLATE('REACT_LL',ActiveReactLLKey,REACT_LL_DISABLED$,'X')
			
			IF LLDisabled = 'L' THEN WO = '*  ':WO
			IF LLDisabled = 'R' THEN WO = WO:'  *'
		END
		
		RPanelTitle = 'R':I:' - ':Size
		If PickPlace = 1 Then
			RPanelTitle := ' - PP'
		END
		
		Status_ProveIn = Xlate('REACTOR', I, REACTOR_PROVE_IN_ACTIVE$, 'X')
		
		Status_0311 = XLATE('REACTOR', I, REACTOR_0311_ACTIVE$, 'X')
		
		IF Status_0311 EQ '' THEN Status_0311 = FALSE$
		
		Set_Property(Window:'.RPANEL':I, 'TEXT', RpanelTitle )				;* Display Wafer Size in inches
		Set_Property(Window:'.RWO':I, 'TEXT', WO )							;* Display WO #
		Set_Property(Window:'.RCUST':I, 'TEXT', Cust )						;* Display Customer Name
		
		If Status_ProveIn EQ True$ then
			Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveProveIn.png')
		end

		If Status_0311 EQ True$ then
			Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\Active_0311.png')
		end

		CurrModeKey            = Xlate('REACTOR_CHILD_KEY_IDS_NG', I, 'REACT_MODE_KEY_IDS', 'X')
		CurrModeKey            = CurrModeKey[-1, 'B':@VM]
		CurrRLKey              = Xlate('REACT_MODE_NG', CurrModeKey, 'START_RL_ID', 'X')
		Status_ReactorPM       = Xlate('REACTOR_LOG', CurrRLKey, REACTOR_LOG_CHECKLIST_ACTIVE$, 'X')
		
		If Status_ReactorPM EQ '' then Status_ReactorPM = False$
		
		If Status_ReactorPM EQ True$ then
			Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveReactorPM.png')
		end
		
		Status_HgCV_Alarm      = Xlate('REACTOR', I, REACTOR_HGCV_CHECKLIST_ACTIVE$, 'X')
		Status_Intrusive_Maint = Xlate('REACTOR', I, REACTOR_INTRUSIVE_MAINT_CHECKLIST_ACTIVE$, 'X')
		Status_Abort_Alarm     = Xlate('REACTOR', I, REACTOR_ABORT_ALARM_CHECKLIST_ACTIVE$, 'X')
		If Status_HgCV_Alarm or Status_Intrusive_Maint or Status_Abort_Alarm then
			Set_Property(Window:'.OLE_PIC_':I, 'OLE.Image', '.\BMPS\ActiveProveIn.png')
		end
		
		OlePicVisible = ( Status_ProveIn or Status_0311 or Status_ReactorPM or Status_HgCV_Alarm or Status_Intrusive_Maint or Status_Abort_Alarm )
		Set_Property(Window:'.OLE_PIC_':I,'VISIBLE', OlePicVisible)
		
		IQSPicControl             = @Window : '.OLE_PIC_IQS_': i
		Locate I in IQSData<1> using @VM setting vPos then
			Set_Property(IQSPicControl,'VISIBLE', 1)
			Set_Property(IQSPicControl, 'OLE.Image', '.\BMPS\IQS.PNG')
		end else
			Set_Property(IQSPicControl,'VISIBLE', 0)
		end
		WOLogRow    = Database_Services('ReadDataRow', 'WO_LOG', WONo)
		HotLot      = WOLogRow<WO_LOG_HOT_FLAG$>
		
		IF HotLot THEN
			Set_Property(Window:'.RWO':I, 'FORECOLOR',APPBRED$)				;* Hot Lots font is red 
		END ELSE
			Set_Property(Window:'.RWO':I, 'FORECOLOR',APPBLUE$)
		END
		
		ProdModes  = 'Production':@VM
		ProdModes := 'Production (incr sampling)':@VM
		ProdModes := 'UP_WITH_RESTRICTIONS':@VM
		ProdModes := 'UP':@VM
		ProdModes := 'UP_WITH_INCREASED_SAMPLING':@VM
		ProdModes := 'UP_WITH_INCREASED_SAMPLING_SURFACE':@VM
		ProdModes := 'UP_WITH_INCREASED_SAMPLING_METROLOGY':@VM
		ProdModes := 'UP_NOT_RUNNING'
		
		LOCATE CurrMode IN ProdModes USING @VM SETTING DUMMY THEN
			Set_Property(Window:'.TIM':I,'TEXT',TimeInMode)
			Set_Property(Window:'.TIM':I,'FORECOLOR',APPBLUE$)
		END ELSE
			IF TimeOutOfProd > '99999.0' THEN TimeOutOfProd = '****'
			Set_Property(Window:'.TIM':I,'TEXT',TimeOutOfProd)
			Set_Property(Window:'.TIM':I,'FORECOLOR',APPDKRED$)
		END
		
		Skip:
	NEXT I
	
RETURN

*===============================================================================================*
REACT_DETAIL:
	Void = start_window( 'WO_DAILY_SCHED_SINGLE', @window, CurrParm:'*CENTER', '', '' )
return
*===============================================================================================*


