compile function RDS_RPT2()
begin condition
pre:
post:
end condition
declare function msg, utility, dialog_box
declare function set_printer, Printer_Select, obj_RDS
declare subroutine rlist

$insert rds_equ
$insert rlist_equates
$insert msg_equates
$insert logical
* IF THIS CODE IS EVER USED, IT MUST CHANGE THE MSG CALLS WITH MCOL=-2 MROW=-2

open 'DICT.RDS' to @dict else
    Void = msg( '', 'Unable to open DICT.RDS...' )
    return 0
end
Params = dialog_box( 'RDS_RPT2', @window, '*CENTER' )
if Params = 'CANCEL' or Params = '' then
    return 0
end
convert '*' to @fm in Params
DateInFrom   = Params<1>
DateInThru   = Params<2>
DirToPrinter = Params<3>
Custs        = Params<4>
Wos          = Params<5>
if DirToPrinter = 'Yes' then
    PrintMode = ''
end else
    PrintMode = 2 ;* 2 is for print preview
end
Stat = utility( 'CURSOR', 'H' )
Stmt = 'SELECT RDS BY CUST_NAME BY WO'
if DateInFrom then
    Stmt :=  " WITH DATE_IN GE ":QUOTE(DateInFrom)
end
if DateInThru then
    if DateInFrom then
        Stmt := ' AND WITH '
    end else
        Stmt := ' WITH '
    end
    Stmt := " DATE_IN LE ":QUOTE(DateInThru)
end
if Custs then
    swap @vm with "' '" in Custs
    Custs = "'":Custs:"'"
    if DateInFrom or DateInThru then
        Stmt := ' AND WITH'
    end else
        Stmd := ' WITH'
    end
    Stmt := ' CUST_NO = ':Custs
end
if Wos then
    swap @vm with "' '" in Wos
    Wos = "'":Wos:"'"
    if DateInFrom or DateInThru or Custs then
        Stmt := ' AND WITH'
    end else
        Stmt := ' WITH'
    end
    Stmt := ' WO = ':Wos
end
*ACTIVATE_SA
rlist( Stmt, target_activelist$, '', '', '' )
FirstRecord = true$
if @reccount then

	PrintPath = Printer_Select('',1)	;* Gets default printer path
	
    Void = set_printer( 'INIT', '', '', '', 0, PrintMode , PrintPath)
    Font = 'Courier New,8,L,0'
    convert ',' to @fm in Font
    HeadPos = '.5/.75/2/1/1/1/1/1/1/1'
    convert '/' to @fm in HeadPos
    TheHeader = " RDS by Customer by WO (Prod/Maint Hours ) from (":DateInFrom:") Thru (":DateInThru:')':" 'D' 'T' PAGE # 'P'":@fm
    COLHEADER = "RDS" : @vm : "Reactor":@vm: "Customer/City" : @vm : "Work Order" : @vm : "Wafers In" : @vm : "Wafers Out" : @vm : "Date In" : @vm : "Time In" : @vm : "Time Out" : @vm : "Total Hours":@fm
    COLHEADER:= str('_',5):@vm:str('_',7):@vm:str('_',20):@vm:str('_',10):@vm:str('_',10):@vm:str('_',10):@vm:str('_',10):@vm:str('_',10):@vm:str('_',10):@vm:str('_',10)
    Void = set_printer( 'FONTHEADFOOT', Font )
    Void = set_printer( 'HEADER', TheHeader, HeadPos, ColHeader )
    Void = set_printer( 'FONT', Font )
    Eof = false$
    loop 
        readnext @id else Eof = true$
      until Eof
          @record = xlate( 'RDS', @id, '', 'X' )
          PrintLine = @id:@vm
		  PrintLine:= @record<rds_reactor$>:@vm
		  PrintLine:= {CUST_CITY}:@vm
		  PrintLine:= @record<rds_wo$>:@vm
		  PrintLine:= @record<rds_wafers_in$>:@vm
		  PrintLine:= obj_RDS('WafersOut',@id:@RM:@record):@vm
		  PrintLine:= oconv( @record<rds_date_in$>, 'D2/' ):@vm
		  PrintLine:= oconv( @record<rds_time_in$>, 'MTH' ):@vm
		  PrintLine:= oconv( @record<rds_time_out$>, 'MTH' ):@vm
		  PrintLine:= {ELAPSED_HOURS}:@vm
          Void = set_printer( 'TEXTCOL', PrintLine )
    repeat
    Void = set_printer( 'TERM' )   
end else
   MsgInfo = ''
   MsgInfo<mtext$> = 'NO Records meeting your date criteria!!'
   MsgInfo<micon$> = '!'
   Void = MSG( '', MsgInfo )
end
return 0

