1. **************************************************************************
  2. ** Method Name : main
  3. ** Author : Ramos, E. U.
  4. ** Creation Date: 08/27/2004
  5. **
  6. **
  7. ** Modification History:
  8. ** --------------------
  9. **04/21/2009 FDF included RANK on the payroll Report
  10. **************************************************************************
  11. local lcReccount
  12. private pcSection,pcJobtype,pnSheet1Ctr,pnSectSheetCtr,pnGroupRowStart
  13.  
  14. This.gather_data()
  15.  
  16. * Create Excel application
  17. if type('goXLApp')<>'O' and goXLApp = .f.
  18. wait window nowait noclear "Starting Excel ..."
  19. goXLApp=createobject("excel.application")
  20. else
  21. if type('goXLApp.Activewindow') = 'O' and goXLApp.Activewindow <> .null.
  22. goXLApp.Activewindow.close
  23. endif
  24. if !goXLApp.visible
  25. goXLApp.quit
  26. goXLApp=createobject("excel.application")
  27. else
  28. goXLApp=getobject(,"excel.application")
  29. endif
  30. endif
  31.  
  32.  
  33. with goXLApp
  34. if .caption <> This.caption
  35. .caption = This.caption+" "+.caption
  36. endif
  37. .workbooks.add
  38. .DisplayAlerts = .f.
  39. .sheets(1).name = "Employee Listing" &&alltrim(crDept.DEPT_CODE)
  40. if type('.worksheets("sheet2")') = 'O'
  41. .worksheets("sheet2").delete
  42. endif
  43. if type('.worksheets("sheet3")') = 'O'
  44. .worksheets("sheet3").delete
  45. endif
  46. endwith
  47.  
  48. * Report Header & Page setup
  49. with goXLApp.ActiveSheet.PageSetup
  50. .LeftMargin = goXLApp.InchesToPoints(0.75)
  51. .RightMargin = goXLApp.InchesToPoints(0.75)
  52. .TopMargin = goXLApp.InchesToPoints(1)
  53. .BottomMargin = goXLApp.InchesToPoints(1)
  54. .HeaderMargin = goXLApp.InchesToPoints(0.5)
  55. .FooterMargin = goXLApp.InchesToPoints(0.5)
  56. .LeftHeader ="Run date >> " +mdy(date())+chr(10)+"Page no.>> &P"
  57. .Orientation = 1 && Portrait
  58. .Papersize = 9 && xlPaperA4 1 = 8.5*11
  59. .CenterHorizontally = .t.
  60. .PrintTitleRows = "$1:$1"
  61. .zoom = .f.
  62. .FitToPagesWide = 1
  63. .FitToPagesTall = .f.
  64. endwith
  65.  
  66.  
  67. * 1st Sheet Columns
  68.  
  69. if thisform.check3.value = 1
  70. This.inc_rank(Thisform.check1.value)
  71. else
  72. This.set_columns(Thisform.check1.value)
  73. endif
  74.  
  75. store 2 to pnSheet1Ctr,pnSectSheetCtr
  76.  
  77.  
  78. select crPayslip
  79. lcReccount = alltrim(str(reccount()))
  80. go top
  81. *!* do while !eof('crPayslip')
  82. *!* set step on
  83. pnGrouprowstart=pnSheet1Ctr
  84. Scan
  85. wait window nowait "Transfering data ..."+crPayslip.E_EMPNO
  86.  
  87. select Jobtype
  88. locate for JOBTYPE = crPayslip.JOBTYPE
  89.  
  90. select crTimesht
  91. locate for E_EMPNO = crPayslip.E_EMPNO
  92.  
  93. select crOvertime
  94. locate for E_EMPNO = crPayslip.E_EMPNO
  95.  
  96. if thisform.check3.value = 1
  97. This.superRank(thisform.check1.value)
  98. else
  99. This.sheet1_details(Thisform.check1.value)
  100. endif
  101.  
  102. pnSheet1Ctr = pnSheet1Ctr + 1
  103. endscan
  104. *!* This.section_totals()
  105. ******************
  106. goXLApp.sheets(goXLApp.worksheets.count).select
  107.  
  108. * Headcount
  109. goXLApp.ActiveSheet.cells(pnSheet1Ctr,1).NumberFormat = "#,##0.00"
  110. goXLApp.ActiveSheet.cells(pnSheet1Ctr,1).formula = "=counta('Employee Listing'!"+goXLApp.ActiveSheet.cells(pnGroupRowStart,1).address(.f.,.f.)+":"+goXLApp.ActiveSheet.cells(pnSheet1Ctr-1,1).address(.f.,.f.)+")"
  111.  
  112. IF ThisForm.Check2.VALUE = 1
  113. lnCounter = 5
  114. ELSE
  115. lnCounter = 3
  116. ENDIF
  117. * Amounts
  118. lnCol_count = val(This.last_col)
  119. for lnCtr = lnCounter to lnCol_count
  120. goXLApp.ActiveSheet.cells(pnSheet1Ctr,lnCtr).formula = "=sum('Employee Listing'!"+goXLApp.ActiveSheet.cells(pnGroupRowStart,lnCtr).address(.f.,.f.)+":"+goXLApp.ActiveSheet.cells(pnSheet1Ctr-1,lnCtr).address(.f.,.f.)+")"
  121. endfor
  122.  
  123. goXLApp.ActiveSheet.cells.EntireColumn.AutoFit
  124. ******************
  125. pnSectSheetCtr = pnSectSheetCtr + 1
  126. *!* enddo
  127.  
  128. goXLApp.sheets(1).select
  129. goXLApp.ActiveSheet.cells.EntireColumn.AutoFit
  130. wait clear
  131. goXLApp.visible = .t.
  132.  
  133. * ito ung Gather_data()
  134. select Payslip
  135. locate for SPERIOD = ldSperiod
  136. if found()
  137. select a.*,JOBTYPE,NAME,TAX_UNIT,GL_ACCOUNT,RANK ;&&included RANK by FDF April 21, 2009
  138. from Payslip a ;
  139. inner join Empmas b on a.E_EMPNO = b.E_EMPNO ;
  140. order by NAME,a.SECTION_CO,JOBTYPE,a.E_EMPNO ;
  141. into cursor crPayslip
  142. sele crPayslip
  143. index on NAME to a
  144.  
  145. select distinct a.EARNCODE ;
  146. from Earndetl a;
  147. inner join Earncode b on a.EARNCODE = b.EARNCODE ;
  148. where a.E_EMPNO in (select E_EMPNO from crPayslip) and upper(POSTED) = 'Y' and upper(TAXABLE) <> 'Y';
  149. order by a.EARNCODE ;
  150. into cursor crNonTaxEarnlist
  151. Sele crNonTaxEarnlist
  152. index on EARNCODE to b
  153. scan
  154.  
  155. endscan
  156.  
  157. select distinct a.EARNCODE ;
  158. from Earndetl a;
  159. inner join Earncode b on a.EARNCODE = b.EARNCODE ;
  160. where a.E_EMPNO in (select E_EMPNO from crPayslip) and upper(POSTED) = 'Y' and upper(TAXABLE) = 'Y';
  161. order by a.EARNCODE ;
  162. into cursor crTaxEarnlist
  163. Sele crTaxEarnlist
  164. index on EARNCODE to c
  165.  
  166.  
  167. select distinct DEDCODE ;
  168. from Ded_detl a;
  169. inner join Empmas b on a.E_EMPNO = b.E_EMPNO ;
  170. where upper(POSTED) = 'Y' ;
  171. order by DEDCODE ;
  172. into cursor crDedlist
  173. Sele crDedlist
  174. index on DEDCODE to d
  175.  
  176. select a.E_EMPNO,EARNCODE,sum(AMOUNT) as AMOUNT ;
  177. from Earndetl a;
  178. inner join crPayslip b on a.E_EMPNO = b.E_EMPNO ;
  179. where upper(POSTED) = 'Y' ;
  180. order by a.E_EMPNO,EARNCODE ;
  181. group by a.E_EMPNO,EARNCODE ; && Jan 25, 2005 by RLA
  182. into cursor crEarndetl
  183. Sele crEarndetl
  184. index on E_EMPNO+EARNCODE to e
  185.  
  186. select a.E_EMPNO,DEDCODE,sum(AMOUNT) as AMOUNT ;
  187. from Ded_detl a;
  188. inner join crPayslip b on a.E_EMPNO = b.E_EMPNO ;
  189. where upper(POSTED) = 'Y' ;
  190. order by a.E_EMPNO,DEDCODE ;
  191. group by a.E_EMPNO,DEDCODE ; && Jan 25, 2005 by RLA
  192. into cursor crDed_detl
  193. sele crDed_detl
  194. index on E_EMPNO+DEDCODE to f
  195.  
  196. select a.* ;
  197. from Timesht a;
  198. inner join crPayslip b on a.E_EMPNO = b.E_EMPNO ;
  199. where DISREGARD <> 'Y' ;
  200. order by a.E_EMPNO ;
  201. into cursor crTimesht
  202. sele crTimesht
  203. index on E_EMPNO to g
  204.  
  205. select a.* ;
  206. from Overtime a;
  207. inner join crPayslip b on a.E_EMPNO = b.E_EMPNO ;
  208. where DISREGARD <> 'Y' ;
  209. order by a.E_EMPNO ;
  210. into cursor crOvertime
  211. Sele crOvertime
  212. index on E_EMPNO to h
  213. endif
  214.  
  215. * tpos papasok sya sa isang method ito naman gagawin
  216. * ito ung This.superrank()
  217. select crNonTaxEarnlist
  218. scan
  219. select crEarndetl
  220. locate for E_EMPNO+EARNCODE = crPayslip.E_EMPNO+crNonTaxEarnlist.EARNCODE
  221. This.is_uploaded(.f.,@lnCtr,crNonTaxEarnlist.EARNCODE)
  222. endscan
  223.  
  224. select crTaxEarnlist
  225. scan
  226. select crEarndetl
  227. locate for E_EMPNO+EARNCODE = crPayslip.E_EMPNO+crTaxEarnlist.EARNCODE
  228. This.is_uploaded(.f.,@lnCtr,crTaxEarnlist.EARNCODE)
  229. endscan
  230.  
  231. select crDedlist
  232. scan
  233. select crDed_detl
  234. locate for E_EMPNO+DEDCODE = crPayslip.E_EMPNO+crDedlist.DEDCODE
  235. goXLApp.ActiveSheet.cells(pnSheet1Ctr,lnCtr).value = iif(found(),AMOUNT,0)
  236. lnCtr = lnCtr + 1
  237. endscan