function reactor_log_comm(Branch)

declare function msg, get_property, entid, key_sort, repository, fieldcount, set_property, send_message
declare subroutine extract_si_keys, make.list

$insert reactor_log_equ
$insert react_servs_equ

$insert msg_equates
$insert logical
$insert popup_equates

* THIS IS EQUATED TO THE ID OF THE TUBE CHANGE SERVICE
* DEFINED IN THE REACT_SERVS DATABASE

EQU COL$PROB_CAT			TO 1
EQU COL$PROB_CAT_DESC		TO 2
EQU COL$SERV_ID				TO 3
EQU COL$SERV_ID_DESC		TO 4
EQU COL$SERV_CAT_ID			TO 5
EQU COL$SERV_CAT_ID_DESC	TO 6
EQU COL$SCHED				TO 7
EQU COL$SN_REQ				TO 8
EQU COL$ITEM_ID				TO 9


equ TubeChangeService$ to 240

equ Hidden$ to 32
equ White$  to 16777215
equ Gray$   to 12632256
equ Black$  to 1

ReturnVar = 0
Branches = 'CHECK_SERVICES,ITEM_SN_CHECK'
convert ',' to @fm in Branches

locate Branch in Branches using @fm setting Bpos then
   on Bpos gosub CHECK_SERVICES, ITEM_SN_CHECK
end else
   Void = msg( '', 'Invalid Branch ':Bpos:' passed to reactor_log_comm' )
end

return ReturnVar
*===============================================================================================*
CHECK_SERVICES:
	* Dead 1/29/2014 JCH
   Visible = false$
   OrigServices = get_property( @window, '@OrigServs' )
   CurServices  = get_property( @window:'.SERV_INFO', 'ARRAY' )<COL$SERV_ID>
   if index( CurServices, TubeChangeService$, 1 ) then
      Visible = true$
   end
   if index( OrigServices, TubeChangeService$, 1 ) and not( index( CurServices, TubeChangeService$, 1 ) ) then
   
      * It was tube change and they are trying to change it 
      * must now verify that all flatness fields are blank
      * and if so we will allow them to change it
      
  		Str = get_property( @window:'.TOP_FLAT_IN', 'TEXT' )
  		Str:= get_property( @window:'.TOP_FLAT_OUT', 'TEXT' )
 		Str:= get_property( @window:'.LOW_BOTTOM_FLAT_IN', 'TEXT' )
      Str:= get_property( @window:'.LOW_BOTTOM_FLAT_OUT', 'TEXT' )
      
      if ( Str = '' ) then
         Visible = false$         
      end else
         Visible = true$
         MsgInfo = ''
         MsgInfo<mtext$> = 'You must blank out all flatness fields if you are removing the Tube Change Service.'
         MsgInfo<micon$> = 'H'
         Void = msg( '', MsgInfo )
      end 
      
   end
   
   
         
   *
   Void = set_property( @window:'.TOP_FLAT_PANEL', 'VISIBLE', Visible )
   Void = set_property( @window:'.LOW_BOTTOM_FLAT_PANEL', 'VISIBLE', Visible )
   Void = set_property( @window:'.TUBE_GRADE_PANEL', 'VISIBLE', Visible )   
   Void = set_property( @window:'.T_IN', 'VISIBLE', Visible )
   Void = set_property( @window:'.T_OUT', 'VISIBLE', Visible )
   Void = set_property( @window:'.B_IN', 'VISIBLE', Visible )
   Void = set_property( @window:'.B_OUT', 'VISIBLE', Visible )
   Void = set_property( @window:'.G_LABEL', 'VISIBLE', Visible )
   Void = set_property( @window:'.C_LABEL', 'VISIBLE', Visible )
   Void = set_property( @window:'.TOP_FLAT_IN', 'VISIBLE', Visible )
   Void = set_property( @window:'.TOP_FLAT_OUT', 'VISIBLE', Visible )
   Void = set_property( @window:'.LOW_BOTTOM_FLAT_IN', 'VISIBLE', Visible )
   Void = set_property( @window:'.LOW_BOTTOM_FLAT_OUT', 'VISIBLE', Visible )
   Void = set_property( @window:'.TUBE_GRADE', 'VISIBLE', Visible )
   *
   
   /*
   Void = set_property( @window:'.REACT_HRS_PANEL', 'VISIBLE', Visible )
   Void = set_property( @window:'.R_START', 'VISIBLE', Visible )
   Void = set_property( @window:'.R_END', 'VISIBLE', Visible )
   Void = set_property( @window:'.R_ELAPSED', 'VISIBLE', Visible )
   Void = set_property( @window:'.REACT_HRS_START', 'VISIBLE', Visible )
   Void = set_property( @window:'.REACT_HRS_END', 'VISIBLE', Visible )
   Void = set_property( @window:'.REACT_HRS_ELAPSED', 'VISIBLE', Visible )
   
   Void = set_property(@WINDOW:'.REACT_CYCLES_GROUP','VISIBLE',Visible)
   Void = set_property(@WINDOW:'.CYCLES_READ_LABEL','VISIBLE',Visible)
   Void = set_property(@WINDOW:'.REACT_CYCLES_READ','VISIBLE',Visible)
   
   */
   
         
   * NOW CHECK TO SEE IF THE SERVICE REQUIRES REACTOR HOURS
   
   * TUBE CHANGE IS THE ONLY SERVICE THAT WILL REQUIRE HOURS PLEASE CHANGE THE BELOW CODE
   
   
   * NEED TO FIX THIS CODE
   
   
   RequiresReactHrs = Visible ;* BASICALLY IF IT IS A TUBE CHANGE SERVICE THEN IT REQUIRES REACTOR HOURS
   OrigRequiresReactHrs = index( xlate( 'REACTOR_LOG', get_property( @window:'.REACTOR_LOG_NO', 'TEXT' ), reactor_log_react_serv_id$, 'X' ), TubeChangeService$, 1 )

   if Visible then
      ****
   end else
      if OrigRequiresReactHrs then
      
         * The service originally required reactor hours and they are changing it to one that does not
         
	      IF ROWEXISTS( 'REACTOR_LOG', get_property( @window:'.REACTOR_LOG_NO', 'TEXT' ) ) THEN
	      
	         * The record already exists and they are not allowed to modify the service code
	         
            Visible = true$
            MsgInfo = ''
            MsgInfo<mtext$> = 'You are not allowed to change or remove the tube change service because the reactor end hours have already been set for the last time this service was performed...If this is an error, then delete this reactor log entry and create a new one.'
            MsgInfo<micon$> = 'H'
                    
            Void = msg( '', MsgInfo )
            
	      END ELSE
	      
			   Str = get_property( @window:'.REACT_HRS_START', 'TEXT' )
			   Str:= get_property( @window:'.REACT_HRS_END', 'TEXT' )
			   
				IF ( Str = '' ) THEN
					Visible = false$         
				END ELSE
	         
					Visible = true$
					MsgInfo = ''
					MsgInfo<mtext$> = 'You must blank out the reactor hours if you are removing the tube change service.'
					MsgInfo<micon$> = 'H'

					void = msg( '', MsgInfo )
					
				END 
			END	            
		END
	END
   CurSize = get_property( @window:'.NOTES', 'SIZE' )
   if ( Visible = true$ ) then
      CurSize<3> = 313   
   end else
      CurSize<3> = 556
   end
   CurSize = set_property( @window:'.NOTES', 'SIZE', CurSize )      
return
*===============================================================================================*
ITEM_SN_CHECK:

RETURN

* 11/21/2013 JCH no longer used

	CurArray = get_property( @window:'.SERV_INFO', 'ARRAY' )
	ServIds = CurArray<COL$SERV_ID>
	SCnt = fieldcount( ServIds, @vm )
	
   for i = 1 to SCnt
   	if ( xlate( 'REACT_SERVS', ServIds<1,i>, react_servs_graphite_or_tube$, 'X' ) <> '' ) then
   		Void = send_message( @window:'.SERV_INFO', 'COLOR_BY_POS',COL$ITEM_ID, i, White$ )   	
   	end else
			Void = send_message( @window:'.SERV_INFO', 'COLOR_BY_POS',COL$ITEM_ID, i, Black$ )   	
   	end
   next i
return
*===============================================================================================*
