COMPILE SUBROUTINE Print_ReactModeLog( ReactNo ) /* Print Reactor Mode Log 04/28/2008 - John C. Henry, J.C. Henry, Inc. - Initial coding */ DECLARE SUBROUTINE Reduce,MSG,Utility,ErrMsg, Set_Status, Btree.Extract, RList, Make.List DECLARE FUNCTION Set_Printer,Get_Printer,Msg, Get_Status, Dialog_Box, obj_Install DECLARE FUNCTION FieldCount,Get_Status,Set_Status,Set_FSError,Printer_Select $INSERT OIPRINT_EQUATES $INSERT REACT_MODE_EQU $INSERT APPCOLORS $INSERT MSG_EQUATES $INSERT REACTOR_LOG_EQUATES ErrorTitle = 'Error in Store Procedure Print_ReactModeLog' IF ReactNo = '' THEN RETURN OPEN 'REACT_MODE' TO ReactModeTable ELSE ErrorMsg = 'Unable to Open "REACT_MODE" table!' Set_Status(1,ErrorTitle:@SVM:ErrorMsg) RETURN END OPEN 'DICT.REACT_MODE' TO @DICT ELSE ErrorMsg = 'Unable to Open "DICT.REACT_MODE" table!' Set_Status(1,ErrorTitle:@SVM:ErrorMsg) RETURN END TypeOver = '' TypeOver = 'Reactor Mode Log Report' DaysToReport = Msg(@WINDOW,TypeOver,'REPORT_DAYS') IF DaysToReport = '' OR DaysToReport = CHAR(27) THEN RETURN StartDt = Date() - DaysToReport StartDt = OCONV(StartDt,'D4/') SelectSent = 'SELECT REACT_MODE WITH REACT_NO = ':QUOTE(ReactNo):' AND WITH START_DT > ':QUOTE(StartDt):' BY-DSND START_DTM ' Set_Status(0) EQU TARGET_ACTIVELIST$ TO 5 errCode = '' RList(SelectSent, TARGET_ACTIVELIST$, "", "", "") IF Get_Status(errCode) THEN ErrMsg(errCode) RETURN END **START PRINTING PROCESS** FileName = 'Print Reactor Mode Log':@VM:'6' Title = 'Printing Reactor Mode Log':@VM:'Report' TopMargin = 0.5 BottomMargin = 0.5 LeftMargin = 0.25 RightMargin = 0.25 Margins = LeftMargin:@FM:TopMargin:@FM:RightMargin:@FM:BottomMargin PageSetup = '1' ;* LandScape PrintSetup = '2' ;* Preview Normal * PrintSetup<1,2> = '5' ;* Print & PDF buttons PrintSetup<1,2> = '0' ;* Show all buttons PrintSetup<1,5> = '1' ;* Page Range PrintSetup<1,6> = 7 ;* full mouse and keyboard support * PrintPath = Printer_Select('',1) ;* Get Default printer path PrintPath = '' stat = Set_Printer("INIT",FileName,Title,Margins,PageSetup,PrintSetup,PrintPath) IF stat < 0 THEN GOTO OIPrint_Err Header = @VM:obj_Install('Get_Prop','CompTitle'):' Reactor Mode Log - Reactor ':ReactNo:' - Last 60 days' Header<2> = @VM:'' font = 'Arial' font<2> = '10' font<4> = 1 ;* Bold stat = Set_Printer("FONTHEADFOOT", font) stat = Set_Printer("HEADER",Header) footer = " 'D' 'T'":@VM:@VM:" Page: 'P'" colfooter = " " stat = Set_Printer("FOOTER",footer,colfooter) @RECCOUNT = 0 FirstPass = 1 LastRecord = 0 ReadErr = 0 FirstLine = 1 * * * * * * * READRECORD: * * * * * * * READNEXT @ID ELSE LastRecord = 1 END IF FirstPass AND LastRecord THEN GOTO Bail END READO @RECORD FROM ReactModeTable,@ID ELSE stat = Set_Printer('TEXT', 'Unable to read record ':QUOTE(@ID):' from REACT_MODE table.') GOTO READRECORD END @RECCOUNT += 1 StartDTM = {START_DTM} ;*OCONV({START_DTM},'DT4/^S') StopDTM = OCONV({STOP_DTM},'DT4/^S') ElapsedHrs = OCONV({ELAP_HRS},'MD2,') Mode = OCONV({MODE},'[REACT_MODE_CONV]') StartRLID = {START_RL_ID} ProbCatIDs = {PROB_CAT_ID} ProbCatDescs = {PROB_CAT_DESC} ServIDs = {SERV_ID} ServDescs = {SERV_DESC} StartUser = {START_USER} StopUser = {STOP_USER} Notes = {START_NOTES} RLNotes = XLATE('REACTOR_LOG',StartRLID, REACTOR_LOG_NOTES$, 'X') SWAP ' ' WITH CRLF$ IN StartDTM SWAP ' ' WITH CRLF$ IN StopDTM FOR I = 1 TO COUNT(ProbCatIDs,@VM) + (ProbCatIDs NE '') ProbCatDescs<1,I> = ProbCatIDs<1,I>:' - ':ProbCatDescs<1,I> NEXT I FOR I = 1 TO COUNT(ServIDs,@VM) + (ServIDs NE '') ServDescs<1,I> = ServIDs<1,I>:' - ':ServDescs<1,I> NEXT I SWAP @VM WITH CRLF$ IN ProbCatDescs SWAP @VM WITH CRLF$ IN ServDescs colHeader = 'Start DTM' ; colFmt = '<1080' colHeader<1,2> = 'Elap Hrs' ; colFmt<1,2> = '>720' colHeader<1,3> = 'Mode' ; colFmt<1,3> = '<1440' colHeader<1,4> = 'Notes' ; colFmt<1,4> = '<2160' colHeader<1,5> = 'Category Description' ; colFmt<1,5> = '<2100' colHeader<1,6> = 'Start User' ; colFmt<1,6> = '<1260' colHeader<1,7> = 'RL ID' ; colFmt<1,7> = '^720' colHeader<1,8> = 'Service Description' ; colFmt<1,8> = '<2500' colHeader<1,9> = 'Service Notes' ; colFmt<1,9> = '<2500' colData = StartDTM colData<1,2> = ElapsedHrs colData<1,3> = Mode colData<1,4> = Notes colData<1,5> = ProbCatDescs colData<1,6> = StartUser colData<1,7> = StartRLID colData<1,8> = ServDescs colData<1,9> = RLNotes fontSpacing = 100 GOSUB PrintTable IF LastRecord THEN GOTO Bail END * * * * * * * DETAIL: * * * * * * * GOTO READRECORD * * * * * * Bail: * * * * * * stat = Set_Printer("TERM") ;* Terminiate this printing session IF stat < 0 THEN GOTO OIPrint_Err Utility('CURSOR','A') RETURN * * * * * * * OIPrint_Err: * * * * * * * *Set Error for OIPrint function and return to calling procedure Msg('',stat) Error_Msg = 'Set_Printer Returned Error Status: ':QUOTE(stat) IF Get_Status(errCode) THEN Stat = Set_Status(-1,'STPROC',ErrorTitle:@SVM:Error_Msg) END ELSE Stat = Set_Status(1,'STPROC',ErrorTitle:@SVM:Error_Msg) END stat = Set_Printer('TERM',1) RETURN * * * * * * PrintTable: * * * * * * stat = Set_Printer('CALCTABLE',colFmt:@FM:colData) TableSize = Get_Printer('CALCTABLE') TableHeight = TableSize<2> Test = Get_Printer('POS')<2> IF Get_Printer('POS')<2> + TableHeight > 7.00 OR FirstLine THEN IF NOT(FirstLine) THEN stat = Set_Printer('PAGEBREAK') END FirstLine = 0 font<2> = 8 font<4> = 1 ;* Bold stat = Set_Printer('FONT',font,'100') stat = Set_Printer('ADDTABLE',colFmt,colHeader,'',LTGREY$,'',0,TB_ALL) font<4> = 0 stat = Set_Printer('FONT',font,fontSpacing) stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',0,7) END ELSE font<2> = 8 font<4> = 0 stat = Set_Printer('FONT',font,fontSpacing) stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',1,TB_ALL) END RETURN