SELECT Lftdetail2003100.icid AS Cid, Lftdetail2003100.cani AS A_Line, ;
Lftdetail2003100.DATE AS D_Date,Lftdetail2003100.ctime AS M_Time, ;
Lftdetail2003100.cterm_ph AS Number_Dialed, Lftdetail2003100.cterm_pl AS Term_Place,;
Lftdetail2003100.cterm_pr AS Term_Prov, Lftdetail2003100.Ndur AS Duration,;
Lftdetail2003100.ncharge AS Charge, Projcode.ncode AS Acct_Code, Projcode.cname AS Employee;
FROM Lftdetail2003100 LEFT OUTER JOIN suntel!Projcode ;
ON Lftdetail2003100.cacc_t1 = Projcode.ncode;
WHERE Lftdetail2003100.icid = 38340;
AND Lftdetail2003100.codebill = "1";
AND SUBSTR(Projcode.wtnno,1,3) <> "403";
GROUP BY Lftdetail2003100.cacc_t1, Lftdetail2003100.cani,;
Lftdetail2003100.DATE, Lftdetail2003100.ctime,;
Lftdetail2003100.corg_pr, Lftdetail2003100.cterm_ph,;
Lftdetail2003100.cterm_pl, Lftdetail2003100.cterm_pr,;
Lftdetail2003100.cdest, Lftdetail2003100.Ndur,;
Lftdetail2003100.ncharge, Projcode.ncode;
ORDER BY Projcode.cname, Lftdetail2003100.DATE, Lftdetail2003100.ctime ;
INTO CURSOR OBUSSMR3RAW READWRITE
SELECT SPACE(10) AS SPACE,Acct_Code,Employee, SUM(Duration) AS minutes, SUM(Charge) AS Charge FROM OBUSSMR3RAW GROUP BY Employee ORDER BY 2 INTO CURSOR cursor1
SELECT SPACE(10) AS SPACE,"Acct. code" AS field1,"Employee" AS field2,"Minutes" AS field3,;
"Charge" AS field3 FROM cursor1 INTO CURSOR cursor4
LOCAL oExcel AS excel.APPLICATION
LOCAL owb AS excel.Workbook
oExcel = CREATEOBJECT("excel.application")
owb = oExcel.Workbooks.ADD()
oExcel.VISIBLE =.T.
WITH owb
.Sheets.ADD
.Sheets(1).SELECT
WITH .activesheet
.NAME = "obus october 2003 smr3 report"
SELECT cursor4
nrow=9
nfieldno=AFIELDS(arrfielda,'cursor4')
SCAN
FOR N=1 TO nfieldno
cfield='cursor4.'+arrfielda(N,1)
.Cells(nrow,N).VALUE=(&cfield)
ENDFOR
.Cells(nrow,1).SELECT
nrow=nrow+1
ENDSCAN
nfieldno=AFIELDS(arrfielda,'cursor1')
nrow=10
SELECT cursor1
SCAN
FOR N=1 TO nfieldno
cfield='cursor1.'+arrfielda(N,1)
.Cells(nrow,N).VALUE=(&cfield)
ENDFOR
.Cells(nrow,1).SELECT
nrow=nrow+1
ENDSCAN
ENDWITH
LOCAL cRange
cRange = "B10:"+"E"+TRANSFORM(nrow-1)
osheet = owb.activesheet
osheet.RANGE(cRange).SELECT
oRn = osheet.RANGE(cRange)
WITH oRn
.BORDERS(xlEdgeLeft)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeTop)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeBottom)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeRight)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlInsideVertical)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlInsideHorizontal)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
cRange = "B"+TRANSFORM(nrow)+":"+"E"+TRANSFORM(nrow)
osheet.RANGE(cRange).SELECT
oRn = osheet.RANGE(cRange)
WITH oRn
.BORDERS(xlEdgeLeft)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeTop)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeBottom)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeRight)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlInsideVertical)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlInsideHorizontal)
.Interior.PATTERN = xlSolid
.Interior.ColorIndex = 15
.Interior.PatternColorIndex = xlAutomatic
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
SELECT SPACE(10) AS SPACER,"Total" AS TOTAL,"Grand Total" AS GR,SUM(cursor1.minutes),SUM(cursor1.Charge) FROM cursor1 INTO CURSOR cursor2
SELECT cursor2
nfieldno=AFIELDS(arrfielda,'cursor2')
WITH .activesheet
SCAN
FOR N=1 TO nfieldno
cfield='cursor2.'+arrfielda(N,1)
.Cells(nrow,N).VALUE=(&cfield)
ENDFOR
.Cells(nrow,1).SELECT
nrow=nrow+1
ENDSCAN
cRange = "B10:"+"C"+TRANSFORM(nrow-1)
osheet = owb.activesheet
osheet.RANGE(cRange).SELECT
oRn = osheet.RANGE(cRange)
WITH oRn.FONT
.NAME = "Arial"
.FontStyle = "Bold"
.SIZE = 10
.Strikethrough = .F.
.Superscript = .F.
.Subscript = .F.
.OutlineFont = .F.
.SHADOW = .F.
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
ENDWITH
cRange = "B9:E9"
osheet = owb.activesheet
osheet.RANGE(cRange).SELECT
oRn = osheet.RANGE(cRange)
WITH oRn.FONT
.NAME = "Arial"
.FontStyle = "Bold"
.SIZE = 10
.Strikethrough = .F.
.Superscript = .F.
.Subscript = .F.
.OutlineFont = .F.
.SHADOW = .F.
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
ENDWITH
WITH oRn
.BORDERS(xlEdgeLeft)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeTop)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeBottom)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlEdgeRight)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
WITH oRn
.BORDERS(xlInsideVertical)
WITH .BORDERS
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
ENDWITH
ENDWITH
.COLUMNS("D:D").AUTOFIT
.COLUMNS("B:B").AUTOFIT
.COLUMNS("C:C").AUTOFIT
.COLUMNS("E:E").AUTOFIT
.COLUMNS("E:E").NumberFormat = "$#,##0.00"
.COLUMNS("B:B").HorizontalAlignment = xlCenter
.COLUMNS("C:C").HorizontalAlignment = xlCenter
.COLUMNS("D:D").HorizontalAlignment = xlCenter
.COLUMNS("E:E").HorizontalAlignment = xlCenter
ENDWITH
ENDWITH