PageRenderTime 65ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/jf/web/reports/TKChucdanhsmry.php

http://tinkerportal.googlecode.com/
PHP | 1698 lines | 1229 code | 224 blank | 245 comment | 339 complexity | 4ab4def7e6154057b5b29f7abf2315af MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. if (session_id() == "") session_start(); // Initialize Session data
  3. ob_start();
  4. ?>
  5. <?php include_once "phprptinc/ewrcfg5.php"; ?>
  6. <?php include_once "phprptinc/ewmysql.php"; ?>
  7. <?php include_once "phprptinc/ewrfn5.php"; ?>
  8. <?php include_once "phprptinc/ewrusrfn.php"; ?>
  9. <?php
  10. // Global variable for table object
  11. $TKChucdanh = NULL;
  12. //
  13. // Table class for TKChucdanh
  14. //
  15. class crTKChucdanh {
  16. var $TableVar = 'TKChucdanh';
  17. var $TableName = 'TKChucdanh';
  18. var $TableType = 'REPORT';
  19. var $ShowCurrentFilter = EWRPT_SHOW_CURRENT_FILTER;
  20. var $FilterPanelOption = EWRPT_FILTER_PANEL_OPTION;
  21. var $CurrentOrder; // Current order
  22. var $CurrentOrderType; // Current order type
  23. // Table caption
  24. function TableCaption() {
  25. global $ReportLanguage;
  26. return $ReportLanguage->TablePhrase($this->TableVar, "TblCaption");
  27. }
  28. // Session Group Per Page
  29. function getGroupPerPage() {
  30. return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"];
  31. }
  32. function setGroupPerPage($v) {
  33. @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"] = $v;
  34. }
  35. // Session Start Group
  36. function getStartGroup() {
  37. return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"];
  38. }
  39. function setStartGroup($v) {
  40. @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"] = $v;
  41. }
  42. // Session Order By
  43. function getOrderBy() {
  44. return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"];
  45. }
  46. function setOrderBy($v) {
  47. @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"] = $v;
  48. }
  49. // var $SelectLimit = TRUE;
  50. var $name;
  51. var $Count28DISTINCT_tbl__employee2Eid29;
  52. var $Count28tbl__employee2Egender29;
  53. var $Count28tbl__profile2Ejoined_party_date29;
  54. var $fields = array();
  55. var $Export; // Export
  56. var $ExportAll = TRUE;
  57. var $UseTokenInUrl = EWRPT_USE_TOKEN_IN_URL;
  58. var $RowType; // Row type
  59. var $RowTotalType; // Row total type
  60. var $RowTotalSubType; // Row total subtype
  61. var $RowGroupLevel; // Row group level
  62. var $RowAttrs = array(); // Row attributes
  63. // Reset CSS styles for table object
  64. function ResetCSS() {
  65. $this->RowAttrs["style"] = "";
  66. $this->RowAttrs["class"] = "";
  67. foreach ($this->fields as $fld) {
  68. $fld->ResetCSS();
  69. }
  70. }
  71. //
  72. // Table class constructor
  73. //
  74. function crTKChucdanh() {
  75. global $ReportLanguage;
  76. // name
  77. $this->name = new crField('TKChucdanh', 'TKChucdanh', 'x_name', 'name', '`name`', 200, EWRPT_DATATYPE_STRING, -1);
  78. $this->name->GroupingFieldId = 1;
  79. $this->fields['name'] =& $this->name;
  80. $this->name->DateFilter = "";
  81. $this->name->SqlSelect = "SELECT DISTINCT `name` FROM " . $this->SqlFrom();
  82. $this->name->SqlOrderBy = "`name`";
  83. $this->name->FldGroupByType = "";
  84. $this->name->FldGroupInt = "0";
  85. $this->name->FldGroupSql = "";
  86. // Count(DISTINCT tbl__employee.id)
  87. $this->Count28DISTINCT_tbl__employee2Eid29 = new crField('TKChucdanh', 'TKChucdanh', 'x_Count28DISTINCT_tbl__employee2Eid29', 'Count(DISTINCT tbl__employee.id)', '`Count(DISTINCT tbl__employee.id)`', 20, EWRPT_DATATYPE_NUMBER, -1);
  88. $this->Count28DISTINCT_tbl__employee2Eid29->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  89. $this->fields['Count28DISTINCT_tbl__employee2Eid29'] =& $this->Count28DISTINCT_tbl__employee2Eid29;
  90. $this->Count28DISTINCT_tbl__employee2Eid29->DateFilter = "";
  91. $this->Count28DISTINCT_tbl__employee2Eid29->SqlSelect = "";
  92. $this->Count28DISTINCT_tbl__employee2Eid29->SqlOrderBy = "";
  93. // Count(tbl__employee.gender)
  94. $this->Count28tbl__employee2Egender29 = new crField('TKChucdanh', 'TKChucdanh', 'x_Count28tbl__employee2Egender29', 'Count(tbl__employee.gender)', '`Count(tbl__employee.gender)`', 20, EWRPT_DATATYPE_NUMBER, -1);
  95. $this->Count28tbl__employee2Egender29->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  96. $this->fields['Count28tbl__employee2Egender29'] =& $this->Count28tbl__employee2Egender29;
  97. $this->Count28tbl__employee2Egender29->DateFilter = "";
  98. $this->Count28tbl__employee2Egender29->SqlSelect = "";
  99. $this->Count28tbl__employee2Egender29->SqlOrderBy = "";
  100. // Count(tbl__profile.joined_party_date)
  101. $this->Count28tbl__profile2Ejoined_party_date29 = new crField('TKChucdanh', 'TKChucdanh', 'x_Count28tbl__profile2Ejoined_party_date29', 'Count(tbl__profile.joined_party_date)', '`Count(tbl__profile.joined_party_date)`', 20, EWRPT_DATATYPE_NUMBER, -1);
  102. $this->Count28tbl__profile2Ejoined_party_date29->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  103. $this->fields['Count28tbl__profile2Ejoined_party_date29'] =& $this->Count28tbl__profile2Ejoined_party_date29;
  104. $this->Count28tbl__profile2Ejoined_party_date29->DateFilter = "";
  105. $this->Count28tbl__profile2Ejoined_party_date29->SqlSelect = "";
  106. $this->Count28tbl__profile2Ejoined_party_date29->SqlOrderBy = "";
  107. }
  108. // Multiple column sort
  109. function UpdateSort(&$ofld, $ctrl) {
  110. if ($this->CurrentOrder == $ofld->FldName) {
  111. $sLastSort = $ofld->getSort();
  112. if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
  113. $sThisSort = $this->CurrentOrderType;
  114. } else {
  115. $sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
  116. }
  117. $ofld->setSort($sThisSort);
  118. } else {
  119. if ($ofld->GroupingFieldId == 0 && !$ctrl) $ofld->setSort("");
  120. }
  121. }
  122. // Get Sort SQL
  123. function SortSql() {
  124. $sDtlSortSql = "";
  125. $argrps = array();
  126. foreach ($this->fields as $fld) {
  127. if ($fld->getSort() <> "") {
  128. if ($fld->GroupingFieldId > 0) {
  129. if ($fld->FldGroupSql <> "")
  130. $argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
  131. else
  132. $argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
  133. } else {
  134. if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
  135. $sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
  136. }
  137. }
  138. }
  139. $sSortSql = "";
  140. foreach ($argrps as $grp) {
  141. if ($sSortSql <> "") $sSortSql .= ", ";
  142. $sSortSql .= $grp;
  143. }
  144. if ($sDtlSortSql <> "") {
  145. if ($sSortSql <> "") $sSortSql .= ",";
  146. $sSortSql .= $sDtlSortSql;
  147. }
  148. return $sSortSql;
  149. }
  150. // Table level SQL
  151. function SqlFrom() { // From
  152. return "`vw__official_reports`";
  153. }
  154. function SqlSelect() { // Select
  155. return "SELECT * FROM " . $this->SqlFrom();
  156. }
  157. function SqlWhere() { // Where
  158. return "";
  159. }
  160. function SqlGroupBy() { // Group By
  161. return "";
  162. }
  163. function SqlHaving() { // Having
  164. return "";
  165. }
  166. function SqlOrderBy() { // Order By
  167. return "`name` ASC";
  168. }
  169. // Table Level Group SQL
  170. function SqlFirstGroupField() {
  171. return "`name`";
  172. }
  173. function SqlSelectGroup() {
  174. return "SELECT DISTINCT " . $this->SqlFirstGroupField() . " FROM " . $this->SqlFrom();
  175. }
  176. function SqlOrderByGroup() {
  177. return "`name` ASC";
  178. }
  179. function SqlSelectAgg() {
  180. return "SELECT SUM(`Count(DISTINCT tbl__employee.id)`) AS `sum_count28distinct_tbl__employee2eid29`, SUM(`Count(tbl__employee.gender)`) AS `sum_count28tbl__employee2egender29`, SUM(`Count(tbl__profile.joined_party_date)`) AS `sum_count28tbl__profile2ejoined_party_date29` FROM " . $this->SqlFrom();
  181. }
  182. function SqlAggPfx() {
  183. return "";
  184. }
  185. function SqlAggSfx() {
  186. return "";
  187. }
  188. function SqlSelectCount() {
  189. return "SELECT COUNT(*) FROM " . $this->SqlFrom();
  190. }
  191. // Sort URL
  192. function SortUrl(&$fld) {
  193. if ($this->Export <> "" ||
  194. in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
  195. return "";
  196. } elseif ($fld->Sortable) {
  197. $sUrlParm = "order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort();
  198. return ewrpt_CurrentPage() . "?" . $sUrlParm;
  199. } else {
  200. return "";
  201. }
  202. }
  203. // Row attributes
  204. function RowAttributes() {
  205. $sAtt = "";
  206. foreach ($this->RowAttrs as $k => $v) {
  207. if (trim($v) <> "")
  208. $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
  209. }
  210. return $sAtt;
  211. }
  212. // Field object by fldvar
  213. function &fields($fldvar) {
  214. return $this->fields[$fldvar];
  215. }
  216. // Table level events
  217. // Row Rendering event
  218. function Row_Rendering() {
  219. // Enter your code here
  220. }
  221. // Cell Rendered event
  222. function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue) {
  223. //$ViewValue = "xxx";
  224. //$ViewAttrs["style"] = "xxx";
  225. }
  226. // Row Rendered event
  227. function Row_Rendered() {
  228. // To view properties of field class, use:
  229. //var_dump($this-><FieldName>);
  230. }
  231. // Load Filters event
  232. function Filters_Load() {
  233. // Enter your code here
  234. // Example: Register/Unregister Custom Extended Filter
  235. //ewrpt_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter');
  236. //ewrpt_UnregisterFilter($this-><Field>, 'StartsWithA');
  237. }
  238. // Page Filter Validated event
  239. function Page_FilterValidated() {
  240. // Example:
  241. //global $MyTable;
  242. //$MyTable->MyField1->SearchValue = "your search criteria"; // Search value
  243. }
  244. // Chart Rendering event
  245. function Chart_Rendering(&$chart) {
  246. // var_dump($chart);
  247. }
  248. // Chart Rendered event
  249. function Chart_Rendered($chart, &$chartxml) {
  250. // Example:
  251. //$doc = $chart->XmlDoc; // Get the DOMDocument object
  252. // Enter your code to manipulate the DOMDocument object here
  253. //$chartxml = $doc->saveXML(); // Output the XML
  254. }
  255. // Email Sending event
  256. function Email_Sending(&$Email, &$Args) {
  257. //var_dump($Email); var_dump($Args); exit();
  258. return TRUE;
  259. }
  260. }
  261. ?>
  262. <?php ewrpt_Header(FALSE) ?>
  263. <?php
  264. // Create page object
  265. $TKChucdanh_summary = new crTKChucdanh_summary();
  266. $Page =& $TKChucdanh_summary;
  267. // Page init
  268. $TKChucdanh_summary->Page_Init();
  269. // Page main
  270. $TKChucdanh_summary->Page_Main();
  271. ?>
  272. <?php include_once "phprptinc/header.php"; ?>
  273. <?php if ($TKChucdanh->Export == "" || $TKChucdanh->Export == "print" || $TKChucdanh->Export == "email") { ?>
  274. <script type="text/javascript">
  275. // Create page object
  276. var TKChucdanh_summary = new ewrpt_Page("TKChucdanh_summary");
  277. // page properties
  278. TKChucdanh_summary.PageID = "summary"; // page ID
  279. TKChucdanh_summary.FormID = "fTKChucdanhsummaryfilter"; // form ID
  280. var EWRPT_PAGE_ID = TKChucdanh_summary.PageID;
  281. // extend page with Chart_Rendering function
  282. TKChucdanh_summary.Chart_Rendering =
  283. function(chart, chartid) { // DO NOT CHANGE THIS LINE!
  284. //alert(chartid);
  285. }
  286. // extend page with Chart_Rendered function
  287. TKChucdanh_summary.Chart_Rendered =
  288. function(chart, chartid) { // DO NOT CHANGE THIS LINE!
  289. //alert(chartid);
  290. }
  291. </script>
  292. <?php } ?>
  293. <?php if ($TKChucdanh->Export == "") { ?>
  294. <script language="JavaScript" type="text/javascript">
  295. <!--
  296. // Write your client script here, no need to add script tags.
  297. //-->
  298. </script>
  299. <?php } ?>
  300. <?php if ($TKChucdanh->Export == "" || $TKChucdanh->Export == "print" || $TKChucdanh->Export == "email") { ?>
  301. <script src="<?php echo EWRPT_FUSIONCHARTS_FREE_JSCLASS_FILE; ?>" type="text/javascript"></script>
  302. <?php } ?>
  303. <?php if ($TKChucdanh->Export == "") { ?>
  304. <div id="ewrpt_PopupFilter"><div class="bd"></div></div>
  305. <script src="phprptjs/ewrptpop.js" type="text/javascript"></script>
  306. <script type="text/javascript">
  307. // popup fields
  308. <?php $jsdata = ewrpt_GetJsData($TKChucdanh->name, $TKChucdanh->name->FldType); ?>
  309. ewrpt_CreatePopup("TKChucdanh_name", [<?php echo $jsdata ?>]);
  310. </script>
  311. <?php } ?>
  312. <?php if ($TKChucdanh->Export == "" || $TKChucdanh->Export == "print" || $TKChucdanh->Export == "email") { ?>
  313. <!-- Table Container (Begin) -->
  314. <table id="ewContainer" cellspacing="0" cellpadding="0" border="0">
  315. <!-- Top Container (Begin) -->
  316. <tr><td colspan="3"><div id="ewTop" class="phpreportmaker">
  317. <!-- top slot -->
  318. <a name="top"></a>
  319. <?php } ?>
  320. <p class="phpreportmaker ewTitle"><?php echo $TKChucdanh->TableCaption() ?>
  321. &nbsp;&nbsp;<?php $TKChucdanh_summary->ExportOptions->Render("body"); ?></p>
  322. <?php $TKChucdanh_summary->ShowPageHeader(); ?>
  323. <?php $TKChucdanh_summary->ShowMessage(); ?>
  324. <br><br>
  325. <?php if ($TKChucdanh->Export == "" || $TKChucdanh->Export == "print" || $TKChucdanh->Export == "email") { ?>
  326. </div></td></tr>
  327. <!-- Top Container (End) -->
  328. <tr>
  329. <!-- Left Container (Begin) -->
  330. <td style="vertical-align: top;"><div id="ewLeft" class="phpreportmaker">
  331. <!-- Left slot -->
  332. </div></td>
  333. <!-- Left Container (End) -->
  334. <!-- Center Container - Report (Begin) -->
  335. <td style="vertical-align: top;" class="ewPadding"><div id="ewCenter" class="phpreportmaker">
  336. <!-- center slot -->
  337. <?php } ?>
  338. <!-- summary report starts -->
  339. <div id="report_summary">
  340. <?php if ($TKChucdanh->ShowCurrentFilter) { ?>
  341. <div id="ewrptFilterList">
  342. <?php $TKChucdanh_summary->ShowFilterList() ?>
  343. </div>
  344. <br>
  345. <?php } ?>
  346. <table class="ewGrid" cellspacing="0"><tr>
  347. <td class="ewGridContent">
  348. <?php if ($TKChucdanh->Export == "") { ?>
  349. <div class="ewGridUpperPanel">
  350. <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
  351. <table border="0" cellspacing="0" cellpadding="0">
  352. <tr>
  353. <td style="white-space: nowrap;">
  354. <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKChucdanh_summary->StartGrp, $TKChucdanh_summary->DisplayGrps, $TKChucdanh_summary->TotalGrps) ?>
  355. <?php if ($Pager->RecordCount > 0) { ?>
  356. <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
  357. <!--first page button-->
  358. <?php if ($Pager->FirstButton->Enabled) { ?>
  359. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="phprptimages/first.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
  360. <?php } else { ?>
  361. <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
  362. <?php } ?>
  363. <!--previous page button-->
  364. <?php if ($Pager->PrevButton->Enabled) { ?>
  365. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="phprptimages/prev.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
  366. <?php } else { ?>
  367. <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
  368. <?php } ?>
  369. <!--current page number-->
  370. <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
  371. <!--next page button-->
  372. <?php if ($Pager->NextButton->Enabled) { ?>
  373. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="phprptimages/next.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
  374. <?php } else { ?>
  375. <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
  376. <?php } ?>
  377. <!--last page button-->
  378. <?php if ($Pager->LastButton->Enabled) { ?>
  379. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="phprptimages/last.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
  380. <?php } else { ?>
  381. <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
  382. <?php } ?>
  383. <td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
  384. </tr></table>
  385. </td>
  386. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  387. <td>
  388. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Record") ?> <?php echo $Pager->FromIndex ?> <?php echo $ReportLanguage->Phrase("To") ?> <?php echo $Pager->ToIndex ?> <?php echo $ReportLanguage->Phrase("Of") ?> <?php echo $Pager->RecordCount ?></span>
  389. <?php } else { ?>
  390. <?php if ($TKChucdanh_summary->Filter == "0=101") { ?>
  391. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
  392. <?php } else { ?>
  393. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
  394. <?php } ?>
  395. <?php } ?>
  396. </td>
  397. <?php if ($TKChucdanh_summary->TotalGrps > 0) { ?>
  398. <td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  399. <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
  400. <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
  401. <option value="1"<?php if ($TKChucdanh_summary->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
  402. <option value="2"<?php if ($TKChucdanh_summary->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
  403. <option value="3"<?php if ($TKChucdanh_summary->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
  404. <option value="4"<?php if ($TKChucdanh_summary->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
  405. <option value="5"<?php if ($TKChucdanh_summary->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
  406. <option value="10"<?php if ($TKChucdanh_summary->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
  407. <option value="20"<?php if ($TKChucdanh_summary->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
  408. <option value="50"<?php if ($TKChucdanh_summary->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
  409. <option value="ALL"<?php if ($TKChucdanh->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
  410. </select>
  411. </span></td>
  412. <?php } ?>
  413. </tr>
  414. </table>
  415. </form>
  416. </div>
  417. <?php } ?>
  418. <!-- Report Grid (Begin) -->
  419. <div class="ewGridMiddlePanel">
  420. <table class="<?php echo $TKChucdanh_summary->ReportTableClass ?>" cellspacing="0">
  421. <?php
  422. // Set the last group to display if not export all
  423. if ($TKChucdanh->ExportAll && $TKChucdanh->Export <> "") {
  424. $TKChucdanh_summary->StopGrp = $TKChucdanh_summary->TotalGrps;
  425. } else {
  426. $TKChucdanh_summary->StopGrp = $TKChucdanh_summary->StartGrp + $TKChucdanh_summary->DisplayGrps - 1;
  427. }
  428. // Stop group <= total number of groups
  429. if (intval($TKChucdanh_summary->StopGrp) > intval($TKChucdanh_summary->TotalGrps))
  430. $TKChucdanh_summary->StopGrp = $TKChucdanh_summary->TotalGrps;
  431. $TKChucdanh_summary->RecCount = 0;
  432. // Get first row
  433. if ($TKChucdanh_summary->TotalGrps > 0) {
  434. $TKChucdanh_summary->GetGrpRow(1);
  435. $TKChucdanh_summary->GrpCount = 1;
  436. }
  437. while (($rsgrp && !$rsgrp->EOF && $TKChucdanh_summary->GrpCount <= $TKChucdanh_summary->DisplayGrps) || $TKChucdanh_summary->ShowFirstHeader) {
  438. // Show header
  439. if ($TKChucdanh_summary->ShowFirstHeader) {
  440. ?>
  441. <thead>
  442. <tr>
  443. <td class="ewTableHeader">
  444. <?php if ($TKChucdanh->Export <> "") { ?>
  445. <?php echo $TKChucdanh->name->FldCaption() ?>
  446. <?php } else { ?>
  447. <table cellspacing="0" class="ewTableHeaderBtn"><tr>
  448. <?php if ($TKChucdanh->SortUrl($TKChucdanh->name) == "") { ?>
  449. <td style="vertical-align: bottom;"><?php echo $TKChucdanh->name->FldCaption() ?></td>
  450. <?php } else { ?>
  451. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKChucdanh->SortUrl($TKChucdanh->name) ?>',2);"><?php echo $TKChucdanh->name->FldCaption() ?></td><td style="width: 10px;">
  452. <?php if ($TKChucdanh->name->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKChucdanh->name->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  453. <?php } ?>
  454. <td style="width: 20px;" align="right"><a href="#" onclick="ewrpt_ShowPopup(this.name, 'TKChucdanh_name', false, '<?php echo $TKChucdanh->name->RangeFrom; ?>', '<?php echo $TKChucdanh->name->RangeTo; ?>');return false;" name="x_name<?php echo $TKChucdanh_summary->Cnt[0][0]; ?>" id="x_name<?php echo $TKChucdanh_summary->Cnt[0][0]; ?>"><img src="phprptimages/popup.gif" width="15" height="14" border="0" alt="<?php echo $ReportLanguage->Phrase("Filter") ?>"></a></td>
  455. </tr></table>
  456. <?php } ?>
  457. </td>
  458. <td class="ewTableHeader">
  459. <?php if ($TKChucdanh->Export <> "") { ?>
  460. <?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->FldCaption() ?>
  461. <?php } else { ?>
  462. <table cellspacing="0" class="ewTableHeaderBtn"><tr>
  463. <?php if ($TKChucdanh->SortUrl($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29) == "") { ?>
  464. <td style="vertical-align: bottom;"><?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->FldCaption() ?></td>
  465. <?php } else { ?>
  466. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKChucdanh->SortUrl($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29) ?>',2);"><?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->FldCaption() ?></td><td style="width: 10px;">
  467. <?php if ($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  468. <?php } ?>
  469. </tr></table>
  470. <?php } ?>
  471. </td>
  472. <td class="ewTableHeader">
  473. <?php if ($TKChucdanh->Export <> "") { ?>
  474. <?php echo $TKChucdanh->Count28tbl__employee2Egender29->FldCaption() ?>
  475. <?php } else { ?>
  476. <table cellspacing="0" class="ewTableHeaderBtn"><tr>
  477. <?php if ($TKChucdanh->SortUrl($TKChucdanh->Count28tbl__employee2Egender29) == "") { ?>
  478. <td style="vertical-align: bottom;"><?php echo $TKChucdanh->Count28tbl__employee2Egender29->FldCaption() ?></td>
  479. <?php } else { ?>
  480. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKChucdanh->SortUrl($TKChucdanh->Count28tbl__employee2Egender29) ?>',2);"><?php echo $TKChucdanh->Count28tbl__employee2Egender29->FldCaption() ?></td><td style="width: 10px;">
  481. <?php if ($TKChucdanh->Count28tbl__employee2Egender29->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKChucdanh->Count28tbl__employee2Egender29->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  482. <?php } ?>
  483. </tr></table>
  484. <?php } ?>
  485. </td>
  486. <td class="ewTableHeader">
  487. <?php if ($TKChucdanh->Export <> "") { ?>
  488. <?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->FldCaption() ?>
  489. <?php } else { ?>
  490. <table cellspacing="0" class="ewTableHeaderBtn"><tr>
  491. <?php if ($TKChucdanh->SortUrl($TKChucdanh->Count28tbl__profile2Ejoined_party_date29) == "") { ?>
  492. <td style="vertical-align: bottom;"><?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->FldCaption() ?></td>
  493. <?php } else { ?>
  494. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKChucdanh->SortUrl($TKChucdanh->Count28tbl__profile2Ejoined_party_date29) ?>',2);"><?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->FldCaption() ?></td><td style="width: 10px;">
  495. <?php if ($TKChucdanh->Count28tbl__profile2Ejoined_party_date29->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKChucdanh->Count28tbl__profile2Ejoined_party_date29->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  496. <?php } ?>
  497. </tr></table>
  498. <?php } ?>
  499. </td>
  500. </tr>
  501. </thead>
  502. <tbody>
  503. <?php
  504. $TKChucdanh_summary->ShowFirstHeader = FALSE;
  505. }
  506. // Build detail SQL
  507. $sWhere = ewrpt_DetailFilterSQL($TKChucdanh->name, $TKChucdanh->SqlFirstGroupField(), $TKChucdanh->name->GroupValue());
  508. if ($TKChucdanh_summary->Filter != "")
  509. $sWhere = "($TKChucdanh_summary->Filter) AND ($sWhere)";
  510. $sSql = ewrpt_BuildReportSql($TKChucdanh->SqlSelect(), $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), $TKChucdanh->SqlOrderBy(), $sWhere, $TKChucdanh_summary->Sort);
  511. $rs = $conn->Execute($sSql);
  512. $rsdtlcnt = ($rs) ? $rs->RecordCount() : 0;
  513. if ($rsdtlcnt > 0)
  514. $TKChucdanh_summary->GetRow(1);
  515. while ($rs && !$rs->EOF) { // Loop detail records
  516. $TKChucdanh_summary->RecCount++;
  517. // Render detail row
  518. $TKChucdanh->ResetCSS();
  519. $TKChucdanh->RowType = EWRPT_ROWTYPE_DETAIL;
  520. $TKChucdanh_summary->RenderRow();
  521. ?>
  522. <tr<?php echo $TKChucdanh->RowAttributes(); ?>>
  523. <td<?php echo $TKChucdanh->name->CellAttributes(); ?>>
  524. <span<?php echo $TKChucdanh->name->ViewAttributes(); ?>><?php echo $TKChucdanh->name->GroupViewValue; ?></span></td>
  525. <td<?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CellAttributes() ?>>
  526. <span<?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ViewAttributes(); ?>><?php echo $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ListViewValue(); ?></span></td>
  527. <td<?php echo $TKChucdanh->Count28tbl__employee2Egender29->CellAttributes() ?>>
  528. <span<?php echo $TKChucdanh->Count28tbl__employee2Egender29->ViewAttributes(); ?>><?php echo $TKChucdanh->Count28tbl__employee2Egender29->ListViewValue(); ?></span></td>
  529. <td<?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CellAttributes() ?>>
  530. <span<?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ViewAttributes(); ?>><?php echo $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ListViewValue(); ?></span></td>
  531. </tr>
  532. <?php
  533. // Accumulate page summary
  534. $TKChucdanh_summary->AccumulateSummary();
  535. // Get next record
  536. $TKChucdanh_summary->GetRow(2);
  537. // Show Footers
  538. ?>
  539. <?php
  540. } // End detail records loop
  541. ?>
  542. <?php
  543. // Next group
  544. $TKChucdanh_summary->GetGrpRow(2);
  545. $TKChucdanh_summary->GrpCount++;
  546. } // End while
  547. ?>
  548. </tbody>
  549. <tfoot>
  550. </tfoot>
  551. </table>
  552. </div>
  553. <?php if ($TKChucdanh_summary->TotalGrps > 0) { ?>
  554. <?php if ($TKChucdanh->Export == "") { ?>
  555. <div class="ewGridLowerPanel">
  556. <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
  557. <table border="0" cellspacing="0" cellpadding="0">
  558. <tr>
  559. <td style="white-space: nowrap;">
  560. <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKChucdanh_summary->StartGrp, $TKChucdanh_summary->DisplayGrps, $TKChucdanh_summary->TotalGrps) ?>
  561. <?php if ($Pager->RecordCount > 0) { ?>
  562. <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
  563. <!--first page button-->
  564. <?php if ($Pager->FirstButton->Enabled) { ?>
  565. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->FirstButton->Start ?>"><img src="phprptimages/first.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
  566. <?php } else { ?>
  567. <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
  568. <?php } ?>
  569. <!--previous page button-->
  570. <?php if ($Pager->PrevButton->Enabled) { ?>
  571. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->PrevButton->Start ?>"><img src="phprptimages/prev.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
  572. <?php } else { ?>
  573. <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
  574. <?php } ?>
  575. <!--current page number-->
  576. <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
  577. <!--next page button-->
  578. <?php if ($Pager->NextButton->Enabled) { ?>
  579. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->NextButton->Start ?>"><img src="phprptimages/next.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
  580. <?php } else { ?>
  581. <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
  582. <?php } ?>
  583. <!--last page button-->
  584. <?php if ($Pager->LastButton->Enabled) { ?>
  585. <td><a href="<?php echo ewrpt_CurrentPage() ?>?start=<?php echo $Pager->LastButton->Start ?>"><img src="phprptimages/last.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
  586. <?php } else { ?>
  587. <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
  588. <?php } ?>
  589. <td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
  590. </tr></table>
  591. </td>
  592. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  593. <td>
  594. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Record") ?> <?php echo $Pager->FromIndex ?> <?php echo $ReportLanguage->Phrase("To") ?> <?php echo $Pager->ToIndex ?> <?php echo $ReportLanguage->Phrase("Of") ?> <?php echo $Pager->RecordCount ?></span>
  595. <?php } else { ?>
  596. <?php if ($TKChucdanh_summary->Filter == "0=101") { ?>
  597. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
  598. <?php } else { ?>
  599. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
  600. <?php } ?>
  601. <?php } ?>
  602. </td>
  603. <?php if ($TKChucdanh_summary->TotalGrps > 0) { ?>
  604. <td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  605. <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
  606. <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
  607. <option value="1"<?php if ($TKChucdanh_summary->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
  608. <option value="2"<?php if ($TKChucdanh_summary->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
  609. <option value="3"<?php if ($TKChucdanh_summary->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
  610. <option value="4"<?php if ($TKChucdanh_summary->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
  611. <option value="5"<?php if ($TKChucdanh_summary->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
  612. <option value="10"<?php if ($TKChucdanh_summary->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
  613. <option value="20"<?php if ($TKChucdanh_summary->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
  614. <option value="50"<?php if ($TKChucdanh_summary->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
  615. <option value="ALL"<?php if ($TKChucdanh->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
  616. </select>
  617. </span></td>
  618. <?php } ?>
  619. </tr>
  620. </table>
  621. </form>
  622. </div>
  623. <?php } ?>
  624. <?php } ?>
  625. </td></tr></table>
  626. </div>
  627. <!-- Summary Report Ends -->
  628. <?php if ($TKChucdanh->Export == "" || $TKChucdanh->Export == "print" || $TKChucdanh->Export == "email") { ?>
  629. </div><br></td>
  630. <!-- Center Container - Report (End) -->
  631. <!-- Right Container (Begin) -->
  632. <td style="vertical-align: top;"><div id="ewRight" class="phpreportmaker">
  633. <!-- Right slot -->
  634. </div></td>
  635. <!-- Right Container (End) -->
  636. </tr>
  637. <!-- Bottom Container (Begin) -->
  638. <tr><td colspan="3"><div id="ewBottom" class="phpreportmaker">
  639. <!-- Bottom slot -->
  640. </div><br></td></tr>
  641. <!-- Bottom Container (End) -->
  642. </table>
  643. <!-- Table Container (End) -->
  644. <?php } ?>
  645. <?php $TKChucdanh_summary->ShowPageFooter(); ?>
  646. <?php if (EWRPT_DEBUG_ENABLED) echo ewrpt_DebugMsg(); ?>
  647. <?php
  648. // Close recordsets
  649. if ($rsgrp) $rsgrp->Close();
  650. if ($rs) $rs->Close();
  651. ?>
  652. <?php if ($TKChucdanh->Export == "") { ?>
  653. <script language="JavaScript" type="text/javascript">
  654. <!--
  655. // Write your table-specific startup script here
  656. // document.write("page loaded");
  657. //-->
  658. </script>
  659. <?php } ?>
  660. <?php include_once "phprptinc/footer.php"; ?>
  661. <?php
  662. $TKChucdanh_summary->Page_Terminate();
  663. ?>
  664. <?php
  665. //
  666. // Page class
  667. //
  668. class crTKChucdanh_summary {
  669. // Page ID
  670. var $PageID = 'summary';
  671. // Table name
  672. var $TableName = 'TKChucdanh';
  673. // Page object name
  674. var $PageObjName = 'TKChucdanh_summary';
  675. // Page name
  676. function PageName() {
  677. return ewrpt_CurrentPage();
  678. }
  679. // Page URL
  680. function PageUrl() {
  681. $PageUrl = ewrpt_CurrentPage() . "?";
  682. global $TKChucdanh;
  683. if ($TKChucdanh->UseTokenInUrl) $PageUrl .= "t=" . $TKChucdanh->TableVar . "&"; // Add page token
  684. return $PageUrl;
  685. }
  686. // Export URLs
  687. var $ExportPrintUrl;
  688. var $ExportExcelUrl;
  689. var $ExportWordUrl;
  690. var $ExportPdfUrl;
  691. var $ReportTableClass;
  692. // Message
  693. function getMessage() {
  694. return @$_SESSION[EWRPT_SESSION_MESSAGE];
  695. }
  696. function setMessage($v) {
  697. if (@$_SESSION[EWRPT_SESSION_MESSAGE] <> "") { // Append
  698. $_SESSION[EWRPT_SESSION_MESSAGE] .= "<br>" . $v;
  699. } else {
  700. $_SESSION[EWRPT_SESSION_MESSAGE] = $v;
  701. }
  702. }
  703. // Show message
  704. function ShowMessage() {
  705. $sMessage = $this->getMessage();
  706. $this->Message_Showing($sMessage);
  707. if ($sMessage <> "") { // Message in Session, display
  708. echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
  709. $_SESSION[EWRPT_SESSION_MESSAGE] = ""; // Clear message in Session
  710. }
  711. }
  712. var $PageHeader;
  713. var $PageFooter;
  714. // Show Page Header
  715. function ShowPageHeader() {
  716. $sHeader = $this->PageHeader;
  717. $this->Page_DataRendering($sHeader);
  718. if ($sHeader <> "") { // Header exists, display
  719. echo "<p><span class=\"phpreportmaker\">" . $sHeader . "</span></p>";
  720. }
  721. }
  722. // Show Page Footer
  723. function ShowPageFooter() {
  724. $sFooter = $this->PageFooter;
  725. $this->Page_DataRendered($sFooter);
  726. if ($sFooter <> "") { // Fotoer exists, display
  727. echo "<p><span class=\"phpreportmaker\">" . $sFooter . "</span></p>";
  728. }
  729. }
  730. // Validate page request
  731. function IsPageRequest() {
  732. global $TKChucdanh;
  733. if ($TKChucdanh->UseTokenInUrl) {
  734. if (ewrpt_IsHttpPost())
  735. return ($TKChucdanh->TableVar == @$_POST("t"));
  736. if (@$_GET["t"] <> "")
  737. return ($TKChucdanh->TableVar == @$_GET["t"]);
  738. } else {
  739. return TRUE;
  740. }
  741. }
  742. //
  743. // Page class constructor
  744. //
  745. function crTKChucdanh_summary() {
  746. global $conn, $ReportLanguage;
  747. // Language object
  748. $ReportLanguage = new crLanguage();
  749. // Table object (TKChucdanh)
  750. $GLOBALS["TKChucdanh"] = new crTKChucdanh();
  751. $GLOBALS["Table"] =& $GLOBALS["TKChucdanh"];
  752. // Initialize URLs
  753. $this->ExportPrintUrl = $this->PageUrl() . "export=print";
  754. $this->ExportExcelUrl = $this->PageUrl() . "export=excel";
  755. $this->ExportWordUrl = $this->PageUrl() . "export=word";
  756. $this->ExportPdfUrl = $this->PageUrl() . "export=pdf";
  757. // Page ID
  758. if (!defined("EWRPT_PAGE_ID"))
  759. define("EWRPT_PAGE_ID", 'summary', TRUE);
  760. // Table name (for backward compatibility)
  761. if (!defined("EWRPT_TABLE_NAME"))
  762. define("EWRPT_TABLE_NAME", 'TKChucdanh', TRUE);
  763. // Start timer
  764. $GLOBALS["gsTimer"] = new crTimer();
  765. // Open connection
  766. $conn = ewrpt_Connect();
  767. // Export options
  768. $this->ExportOptions = new crListOptions();
  769. $this->ExportOptions->Tag = "span";
  770. $this->ExportOptions->Separator = "&nbsp;&nbsp;";
  771. }
  772. //
  773. // Page_Init
  774. //
  775. function Page_Init() {
  776. global $gsExport, $gsExportFile, $ReportLanguage, $Security;
  777. global $TKChucdanh;
  778. // Get export parameters
  779. if (@$_GET["export"] <> "") {
  780. $TKChucdanh->Export = $_GET["export"];
  781. }
  782. $gsExport = $TKChucdanh->Export; // Get export parameter, used in header
  783. $gsExportFile = $TKChucdanh->TableVar; // Get export file, used in header
  784. if ($TKChucdanh->Export == "excel") {
  785. header('Content-Type: application/vnd.ms-excel;charset=utf-8');
  786. header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
  787. }
  788. if ($TKChucdanh->Export == "word") {
  789. header('Content-Type: application/vnd.ms-word;charset=utf-8');
  790. header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
  791. }
  792. // Setup export options
  793. $this->SetupExportOptions();
  794. // Global Page Loading event (in userfn*.php)
  795. Page_Loading();
  796. // Page Load event
  797. $this->Page_Load();
  798. }
  799. // Set up export options
  800. function SetupExportOptions() {
  801. global $ReportLanguage, $TKChucdanh;
  802. // Printer friendly
  803. $item =& $this->ExportOptions->Add("print");
  804. $item->Body = "<a href=\"" . $this->ExportPrintUrl . "\">" . $ReportLanguage->Phrase("PrinterFriendly") . "</a>";
  805. $item->Visible = TRUE;
  806. // Export to Excel
  807. $item =& $this->ExportOptions->Add("excel");
  808. $item->Body = "<a href=\"" . $this->ExportExcelUrl . "\">" . $ReportLanguage->Phrase("ExportToExcel") . "</a>";
  809. $item->Visible = TRUE;
  810. // Export to Word
  811. $item =& $this->ExportOptions->Add("word");
  812. $item->Body = "<a href=\"" . $this->ExportWordUrl . "\">" . $ReportLanguage->Phrase("ExportToWord") . "</a>";
  813. $item->Visible = TRUE;
  814. // Export to Pdf
  815. $item =& $this->ExportOptions->Add("pdf");
  816. $item->Body = "<a href=\"" . $this->ExportPdfUrl . "\">" . $ReportLanguage->Phrase("ExportToPDF") . "</a>";
  817. $item->Visible = FALSE;
  818. // Uncomment codes below to show export to Pdf link
  819. // $item->Visible = FALSE;
  820. // Export to Email
  821. $item =& $this->ExportOptions->Add("email");
  822. $item->Body = "<a name=\"emf_TKChucdanh\" id=\"emf_TKChucdanh\" href=\"javascript:void(0);\" onclick=\"ewrpt_EmailDialogShow({lnk:'emf_TKChucdanh',hdr:ewLanguage.Phrase('ExportToEmail')});\">" . $ReportLanguage->Phrase("ExportToEmail") . "</a>";
  823. $item->Visible = FALSE;
  824. // Reset filter
  825. $item =& $this->ExportOptions->Add("resetfilter");
  826. $item->Body = "<a href=\"" . ewrpt_CurrentPage() . "?cmd=reset\">" . $ReportLanguage->Phrase("ResetAllFilter") . "</a>";
  827. $item->Visible = TRUE;
  828. $this->SetupExportOptionsExt();
  829. // Hide options for export
  830. if ($TKChucdanh->Export <> "")
  831. $this->ExportOptions->HideAllOptions();
  832. // Set up table class
  833. if ($TKChucdanh->Export == "word" || $TKChucdanh->Export == "excel" || $TKChucdanh->Export == "pdf")
  834. $this->ReportTableClass = "ewTable";
  835. else
  836. $this->ReportTableClass = "ewTable ewTableSeparate";
  837. }
  838. //
  839. // Page_Terminate
  840. //
  841. function Page_Terminate($url = "") {
  842. global $conn;
  843. global $ReportLanguage;
  844. global $TKChucdanh;
  845. // Page Unload event
  846. $this->Page_Unload();
  847. // Global Page Unloaded event (in userfn*.php)
  848. Page_Unloaded();
  849. // Export to Email (use ob_file_contents for PHP)
  850. if ($TKChucdanh->Export == "email") {
  851. $sContent = ob_get_contents();
  852. $this->ExportEmail($sContent);
  853. ob_end_clean();
  854. // Close connection
  855. $conn->Close();
  856. header("Location: " . ewrpt_CurrentPage());
  857. exit();
  858. }
  859. // Export to PDF (use ob_file_contents for PHP)
  860. if ($TKChucdanh->Export == "pdf") {
  861. $sContent = ob_get_contents();
  862. $this->ExportPDF($sContent);
  863. ob_end_clean();
  864. // Close connection
  865. $conn->Close();
  866. }
  867. // Close connection
  868. $conn->Close();
  869. // Go to URL if specified
  870. if ($url <> "") {
  871. if (!EWRPT_DEBUG_ENABLED && ob_get_length())
  872. ob_end_clean();
  873. header("Location: " . $url);
  874. }
  875. exit();
  876. }
  877. // Initialize common variables
  878. var $ExportOptions; // Export options
  879. // Paging variables
  880. var $RecCount = 0; // Record count
  881. var $StartGrp = 0; // Start group
  882. var $StopGrp = 0; // Stop group
  883. var $TotalGrps = 0; // Total groups
  884. var $GrpCount = 0; // Group count
  885. var $DisplayGrps = 20; // Groups per page
  886. var $GrpRange = 10;
  887. var $Sort = "";
  888. var $Filter = "";
  889. var $UserIDFilter = "";
  890. // Clear field for ext filter
  891. var $ClearExtFilter = "";
  892. var $FilterApplied;
  893. var $ShowFirstHeader;
  894. var $Cnt, $Col, $Val, $Smry, $Mn, $Mx, $GrandSmry, $GrandMn, $GrandMx;
  895. var $TotCount;
  896. //
  897. // Page main
  898. //
  899. function Page_Main() {
  900. global $TKChucdanh;
  901. global $rs;
  902. global $rsgrp;
  903. global $gsFormError;
  904. // Aggregate variables
  905. // 1st dimension = no of groups (level 0 used for grand total)
  906. // 2nd dimension = no of fields
  907. $nDtls = 4;
  908. $nGrps = 2;
  909. $this->Val =& ewrpt_InitArray($nDtls, 0);
  910. $this->Cnt =& ewrpt_Init2DArray($nGrps, $nDtls, 0);
  911. $this->Smry =& ewrpt_Init2DArray($nGrps, $nDtls, 0);
  912. $this->Mn =& ewrpt_Init2DArray($nGrps, $nDtls, NULL);
  913. $this->Mx =& ewrpt_Init2DArray($nGrps, $nDtls, NULL);
  914. $this->GrandSmry =& ewrpt_InitArray($nDtls, 0);
  915. $this->GrandMn =& ewrpt_InitArray($nDtls, NULL);
  916. $this->GrandMx =& ewrpt_InitArray($nDtls, NULL);
  917. // Set up if accumulation required
  918. $this->Col = array(FALSE, TRUE, TRUE, TRUE);
  919. // Set up groups per page dynamically
  920. $this->SetUpDisplayGrps();
  921. $TKChucdanh->name->SelectionList = "";
  922. $TKChucdanh->name->DefaultSelectionList = "";
  923. $TKChucdanh->name->ValueList = "";
  924. // Load default filter values
  925. $this->LoadDefaultFilters();
  926. // Load custom filters
  927. $TKChucdanh->Filters_Load();
  928. // Set up popup filter
  929. $this->SetupPopup();
  930. // Extended filter
  931. $sExtendedFilter = "";
  932. // Build popup filter
  933. $sPopupFilter = $this->GetPopupFilter();
  934. //ewrpt_SetDebugMsg("popup filter: " . $sPopupFilter);
  935. if ($sPopupFilter <> "") {
  936. if ($this->Filter <> "")
  937. $this->Filter = "($this->Filter) AND ($sPopupFilter)";
  938. else
  939. $this->Filter = $sPopupFilter;
  940. }
  941. // Check if filter applied
  942. $this->FilterApplied = $this->CheckFilter();
  943. $this->ExportOptions->GetItem("resetfilter")->Visible = $this->FilterApplied;
  944. // Get sort
  945. $this->Sort = $this->GetSort();
  946. // Get total group count
  947. $sGrpSort = ewrpt_UpdateSortFields($TKChucdanh->SqlOrderByGroup(), $this->Sort, 2); // Get grouping field only
  948. $sSql = ewrpt_BuildReportSql($TKChucdanh->SqlSelectGroup(), $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), $TKChucdanh->SqlOrderByGroup(), $this->Filter, $sGrpSort);
  949. $this->TotalGrps = $this->GetGrpCnt($sSql);
  950. if ($this->DisplayGrps <= 0) // Display all groups
  951. $this->DisplayGrps = $this->TotalGrps;
  952. $this->StartGrp = 1;
  953. // Show header
  954. $this->ShowFirstHeader = ($this->TotalGrps > 0);
  955. //$this->ShowFirstHeader = TRUE; // Uncomment to always show header
  956. // Set up start position if not export all
  957. if ($TKChucdanh->ExportAll && $TKChucdanh->Export <> "")
  958. $this->DisplayGrps = $this->TotalGrps;
  959. else
  960. $this->SetUpStartGroup();
  961. // Hide all options if export
  962. if ($TKChucdanh->Export <> "") {
  963. $this->ExportOptions->HideAllOptions();
  964. }
  965. // Get current page groups
  966. $rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
  967. // Init detail recordset
  968. $rs = NULL;
  969. }
  970. // Check level break
  971. function ChkLvlBreak($lvl) {
  972. global $TKChucdanh;
  973. switch ($lvl) {
  974. case 1:
  975. return (is_null($TKChucdanh->name->CurrentValue) && !is_null($TKChucdanh->name->OldValue)) ||
  976. (!is_null($TKChucdanh->name->CurrentValue) && is_null($TKChucdanh->name->OldValue)) ||
  977. ($TKChucdanh->name->GroupValue() <> $TKChucdanh->name->GroupOldValue());
  978. }
  979. }
  980. // Accummulate summary
  981. function AccumulateSummary() {
  982. $cntx = count($this->Smry);
  983. for ($ix = 0; $ix < $cntx; $ix++) {
  984. $cnty = count($this->Smry[$ix]);
  985. for ($iy = 1; $iy < $cnty; $iy++) {
  986. $this->Cnt[$ix][$iy]++;
  987. if ($this->Col[$iy]) {
  988. $valwrk = $this->Val[$iy];
  989. if (is_null($valwrk) || !is_numeric($valwrk)) {
  990. // skip
  991. } else {
  992. $this->Smry[$ix][$iy] += $valwrk;
  993. if (is_null($this->Mn[$ix][$iy])) {
  994. $this->Mn[$ix][$iy] = $valwrk;
  995. $this->Mx[$ix][$iy] = $valwrk;
  996. } else {
  997. if ($this->Mn[$ix][$iy] > $valwrk) $this->Mn[$ix][$iy] = $valwrk;
  998. if ($this->Mx[$ix][$iy] < $valwrk) $this->Mx[$ix][$iy] = $valwrk;
  999. }
  1000. }
  1001. }
  1002. }
  1003. }
  1004. $cntx = count($this->Smry);
  1005. for ($ix = 1; $ix < $cntx; $ix++) {
  1006. $this->Cnt[$ix][0]++;
  1007. }
  1008. }
  1009. // Reset level summary
  1010. function ResetLevelSummary($lvl) {
  1011. // Clear summary values
  1012. $cntx = count($this->Smry);
  1013. for ($ix = $lvl; $ix < $cntx; $ix++) {
  1014. $cnty = count($this->Smry[$ix]);
  1015. for ($iy = 1; $iy < $cnty; $iy++) {
  1016. $this->Cnt[$ix][$iy] = 0;
  1017. if ($this->Col[$iy]) {
  1018. $this->Smry[$ix][$iy] = 0;
  1019. $this->Mn[$ix][$iy] = NULL;
  1020. $this->Mx[$ix][$iy] = NULL;
  1021. }
  1022. }
  1023. }
  1024. $cntx = count($this->Smry);
  1025. for ($ix = $lvl; $ix < $cntx; $ix++) {
  1026. $this->Cnt[$ix][0] = 0;
  1027. }
  1028. // Reset record count
  1029. $this->RecCount = 0;
  1030. }
  1031. // Accummulate grand summary
  1032. function AccumulateGrandSummary() {
  1033. $this->Cnt[0][0]++;
  1034. $cntgs = count($this->GrandSmry);
  1035. for ($iy = 1; $iy < $cntgs; $iy++) {
  1036. if ($this->Col[$iy]) {
  1037. $valwrk = $this->Val[$iy];
  1038. if (is_null($valwrk) || !is_numeric($valwrk)) {
  1039. // skip
  1040. } else {
  1041. $this->GrandSmry[$iy] += $valwrk;
  1042. if (is_null($this->GrandMn[$iy])) {
  1043. $this->GrandMn[$iy] = $valwrk;
  1044. $this->GrandMx[$iy] = $valwrk;
  1045. } else {
  1046. if ($this->GrandMn[$iy] > $valwrk) $this->GrandMn[$iy] = $valwrk;
  1047. if ($this->GrandMx[$iy] < $valwrk) $this->GrandMx[$iy] = $valwrk;
  1048. }
  1049. }
  1050. }
  1051. }
  1052. }
  1053. // Get group count
  1054. function GetGrpCnt($sql) {
  1055. global $conn;
  1056. global $TKChucdanh;
  1057. $rsgrpcnt = $conn->Execute($sql);
  1058. $grpcnt = ($rsgrpcnt) ? $rsgrpcnt->RecordCount() : 0;
  1059. if ($rsgrpcnt) $rsgrpcnt->Close();
  1060. return $grpcnt;
  1061. }
  1062. // Get group rs
  1063. function GetGrpRs($sql, $start, $grps) {
  1064. global $conn;
  1065. global $TKChucdanh;
  1066. $wrksql = $sql;
  1067. if ($start > 0 && $grps > -1)
  1068. $wrksql .= " LIMIT " . ($start-1) . ", " . ($grps);
  1069. $rswrk = $conn->Execute($wrksql);
  1070. return $rswrk;
  1071. }
  1072. // Get group row values
  1073. function GetGrpRow($opt) {
  1074. global $rsgrp;
  1075. global $TKChucdanh;
  1076. if (!$rsgrp)
  1077. return;
  1078. if ($opt == 1) { // Get first group
  1079. //$rsgrp->MoveFirst(); // NOTE: no need to move position
  1080. $TKChucdanh->name->setDbValue(""); // Init first value
  1081. } else { // Get next group
  1082. $rsgrp->MoveNext();
  1083. }
  1084. if (!$rsgrp->EOF)
  1085. $TKChucdanh->name->setDbValue($rsgrp->fields[0]);
  1086. if ($rsgrp->EOF) {
  1087. $TKChucdanh->name->setDbValue("");
  1088. }
  1089. }
  1090. // Get row values
  1091. function GetRow($opt) {
  1092. global $rs;
  1093. global $TKChucdanh;
  1094. if (!$rs)
  1095. return;
  1096. if ($opt == 1) { // Get first row
  1097. // $rs->MoveFirst(); // NOTE: no need to move position
  1098. } else { // Get next row
  1099. $rs->MoveNext();
  1100. }
  1101. if (!$rs->EOF) {
  1102. if ($opt <> 1) {
  1103. if (is_array($TKChucdanh->name->GroupDbValues))
  1104. $TKChucdanh->name->setDbValue(@$TKChucdanh->name->GroupDbValues[$rs->fields('name')]);
  1105. else
  1106. $TKChucdanh->name->setDbValue(ewrpt_GroupValue($TKChucdanh->name, $rs->fields('name')));
  1107. }
  1108. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->setDbValue($rs->fields('Count(DISTINCT tbl__employee.id)'));
  1109. $TKChucdanh->Count28tbl__employee2Egender29->setDbValue($rs->fields('Count(tbl__employee.gender)'));
  1110. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->setDbValue($rs->fields('Count(tbl__profile.joined_party_date)'));
  1111. $this->Val[1] = $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CurrentValue;
  1112. $this->Val[2] = $TKChucdanh->Count28tbl__employee2Egender29->CurrentValue;
  1113. $this->Val[3] = $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CurrentValue;
  1114. } else {
  1115. $TKChucdanh->name->setDbValue("");
  1116. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->setDbValue("");
  1117. $TKChucdanh->Count28tbl__employee2Egender29->setDbValue("");
  1118. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->setDbValue("");
  1119. }
  1120. }
  1121. // Set up starting group
  1122. function SetUpStartGroup() {
  1123. global $TKChucdanh;
  1124. // Exit if no groups
  1125. if ($this->DisplayGrps == 0)
  1126. return;
  1127. // Check for a 'start' parameter
  1128. if (@$_GET[EWRPT_TABLE_START_GROUP] != "") {
  1129. $this->StartGrp = $_GET[EWRPT_TABLE_START_GROUP];
  1130. $TKChucdanh->setStartGroup($this->StartGrp);
  1131. } elseif (@$_GET["pageno"] != "") {
  1132. $nPageNo = $_GET["pageno"];
  1133. if (is_numeric($nPageNo)) {
  1134. $this->StartGrp = ($nPageNo-1)*$this->DisplayGrps+1;
  1135. if ($this->StartGrp <= 0) {
  1136. $this->StartGrp = 1;
  1137. } elseif ($this->StartGrp >= intval(($this->TotalGrps-1)/$this->DisplayGrps)*$this->DisplayGrps+1) {
  1138. $this->StartGrp = intval(($this->TotalGrps-1)/$this->DisplayGrps)*$this->DisplayGrps+1;
  1139. }
  1140. $TKChucdanh->setStartGroup($this->StartGrp);
  1141. } else {
  1142. $this->StartGrp = $TKChucdanh->getStartGroup();
  1143. }
  1144. } else {
  1145. $this->StartGrp = $TKChucdanh->getStartGroup();
  1146. }
  1147. // Check if correct start group counter
  1148. if (!is_numeric($this->StartGrp) || $this->StartGrp == "") { // Avoid invalid start group counter
  1149. $this->StartGrp = 1; // Reset start group counter
  1150. $TKChucdanh->setStartGroup($this->StartGrp);
  1151. } elseif (intval($this->StartGrp) > intval($this->TotalGrps)) { // Avoid starting group > total groups
  1152. $this->StartGrp = intval(($this->TotalGrps-1)/$this->DisplayGrps) * $this->DisplayGrps + 1; // Point to last page first group
  1153. $TKChucdanh->setStartGroup($this->StartGrp);
  1154. } elseif (($this->StartGrp-1) % $this->DisplayGrps <> 0) {
  1155. $this->StartGrp = intval(($this->StartGrp-1)/$this->DisplayGrps) * $this->DisplayGrps + 1; // Point to page boundary
  1156. $TKChucdanh->setStartGroup($this->StartGrp);
  1157. }
  1158. }
  1159. // Set up popup
  1160. function SetupPopup() {
  1161. global $conn, $ReportLanguage;
  1162. global $TKChucdanh;
  1163. // Initialize popup
  1164. // Build distinct values for name
  1165. $bNullValue = FALSE;
  1166. $bEmptyValue = FALSE;
  1167. $sSql = ewrpt_BuildReportSql($TKChucdanh->name->SqlSelect, $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), $TKChucdanh->name->SqlOrderBy, $this->Filter, "");
  1168. $rswrk = $conn->Execute($sSql);
  1169. while ($rswrk && !$rswrk->EOF) {
  1170. $TKChucdanh->name->setDbValue($rswrk->fields[0]);
  1171. if (is_null($TKChucdanh->name->CurrentValue)) {
  1172. $bNullValue = TRUE;
  1173. } elseif ($TKChucdanh->name->CurrentValue == "") {
  1174. $bEmptyValue = TRUE;
  1175. } else {
  1176. $TKChucdanh->name->GroupViewValue = ewrpt_DisplayGroupValue($TKChucdanh->name,$TKChucdanh->name->GroupValue());
  1177. ewrpt_SetupDistinctValues($TKChucdanh->name->ValueList, $TKChucdanh->name->GroupValue(), $TKChucdanh->name->GroupViewValue, FALSE);
  1178. }
  1179. $rswrk->MoveNext();
  1180. }
  1181. if ($rswrk)
  1182. $rswrk->Close();
  1183. if ($bEmptyValue)
  1184. ewrpt_SetupDistinctValues($TKChucdanh->name->ValueList, EWRPT_EMPTY_VALUE, $ReportLanguage->Phrase("EmptyLabel"), FALSE);
  1185. if ($bNullValue)
  1186. ewrpt_SetupDistinctValues($TKChucdanh->name->ValueList, EWRPT_NULL_VALUE, $ReportLanguage->Phrase("NullLabel"), FALSE);
  1187. // Process post back form
  1188. if (ewrpt_IsHttpPost()) {
  1189. $sName = @$_POST["popup"]; // Get popup form name
  1190. if ($sName <> "") {
  1191. $cntValues = (is_array(@$_POST["sel_$sName"])) ? count($_POST["sel_$sName"]) : 0;
  1192. if ($cntValues > 0) {
  1193. $arValues = ewrpt_StripSlashes($_POST["sel_$sName"]);
  1194. if (trim($arValues[0]) == "") // Select all
  1195. $arValues = EWRPT_INIT_VALUE;
  1196. $_SESSION["sel_$sName"] = $arValues;
  1197. $_SESSION["rf_$sName"] = ewrpt_StripSlashes(@$_POST["rf_$sName"]);
  1198. $_SESSION["rt_$sName"] = ewrpt_StripSlashes(@$_POST["rt_$sName"]);
  1199. $this->ResetPager();
  1200. }
  1201. }
  1202. // Get 'reset' command
  1203. } elseif (@$_GET["cmd"] <> "") {
  1204. $sCmd = $_GET["cmd"];
  1205. if (strtolower($sCmd) == "reset") {
  1206. $this->ClearSessionSelection('name');
  1207. $this->ResetPager();
  1208. }
  1209. }
  1210. // Load selection criteria to array
  1211. // Get Chá?Šc danh selected values
  1212. if (is_array(@$_SESSION["sel_TKChucdanh_name"])) {
  1213. $this->LoadSelectionFromSession('name');
  1214. } elseif (@$_SESSION["sel_TKChucdanh_name"] == EWRPT_INIT_VALUE) { // Select all
  1215. $TKChucdanh->name->SelectionList = "";
  1216. }
  1217. }
  1218. // Reset pager
  1219. function ResetPager() {
  1220. // Reset start position (reset command)
  1221. global $TKChucdanh;
  1222. $this->StartGrp = 1;
  1223. $TKChucdanh->setStartGroup($this->StartGrp);
  1224. }
  1225. // Set up number of groups displayed per page
  1226. function SetUpDisplayGrps() {
  1227. global $TKChucdanh;
  1228. $sWrk = @$_GET[EWRPT_TABLE_GROUP_PER_PAGE];
  1229. if ($sWrk <> "") {
  1230. if (is_numeric($sWrk)) {
  1231. $this->DisplayGrps = intval($sWrk);
  1232. } else {
  1233. if (strtoupper($sWrk) == "ALL") { // display all groups
  1234. $this->DisplayGrps = -1;
  1235. } else {
  1236. $this->DisplayGrps = 20; // Non-numeric, load default
  1237. }
  1238. }
  1239. $TKChucdanh->setGroupPerPage($this->DisplayGrps); // Save to session
  1240. // Reset start position (reset command)
  1241. $this->StartGrp = 1;
  1242. $TKChucdanh->setStartGroup($this->StartGrp);
  1243. } else {
  1244. if ($TKChucdanh->getGroupPerPage() <> "") {
  1245. $this->DisplayGrps = $TKChucdanh->getGroupPerPage(); // Restore from session
  1246. } else {
  1247. $this->DisplayGrps = 20; // Load default
  1248. }
  1249. }
  1250. }
  1251. function RenderRow() {
  1252. global $conn, $rs, $Security;
  1253. global $TKChucdanh;
  1254. if ($TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_GRAND) { // Grand total
  1255. // Get total count from sql directly
  1256. $sSql = ewrpt_BuildReportSql($TKChucdanh->SqlSelectCount(), $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), "", $this->Filter, "");
  1257. $rstot = $conn->Execute($sSql);
  1258. if ($rstot) {
  1259. $this->TotCount = ($rstot->RecordCount()>1) ? $rstot->RecordCount() : $rstot->fields[0];
  1260. $rstot->Close();
  1261. } else {
  1262. $this->TotCount = 0;
  1263. }
  1264. // Get total from sql directly
  1265. $sSql = ewrpt_BuildReportSql($TKChucdanh->SqlSelectAgg(), $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), "", $this->Filter, "");
  1266. $sSql = $TKChucdanh->SqlAggPfx() . $sSql . $TKChucdanh->SqlAggSfx();
  1267. $rsagg = $conn->Execute($sSql);
  1268. if ($rsagg) {
  1269. $this->GrandSmry[1] = $rsagg->fields("sum_count28distinct_tbl__employee2eid29");
  1270. $this->GrandSmry[2] = $rsagg->fields("sum_count28tbl__employee2egender29");
  1271. $this->GrandSmry[3] = $rsagg->fields("sum_count28tbl__profile2ejoined_party_date29");
  1272. $rsagg->Close();
  1273. } else {
  1274. // Accumulate grand summary from detail records
  1275. $sSql = ewrpt_BuildReportSql($TKChucdanh->SqlSelect(), $TKChucdanh->SqlWhere(), $TKChucdanh->SqlGroupBy(), $TKChucdanh->SqlHaving(), "", $this->Filter, "");
  1276. $rs = $conn->Execute($sSql);
  1277. if ($rs) {
  1278. $this->GetRow(1);
  1279. while (!$rs->EOF) {
  1280. $this->AccumulateGrandSummary();
  1281. $this->GetRow(2);
  1282. }
  1283. $rs->Close();
  1284. }
  1285. }
  1286. }
  1287. // Call Row_Rendering event
  1288. $TKChucdanh->Row_Rendering();
  1289. //
  1290. // Render view codes
  1291. //
  1292. if ($TKChucdanh->RowType == EWRPT_ROWTYPE_TOTAL) { // Summary row
  1293. // name
  1294. $TKChucdanh->name->GroupViewValue = $TKChucdanh->name->GroupOldValue();
  1295. $TKChucdanh->name->CellAttrs["class"] = ($TKChucdanh->RowGroupLevel == 1) ? "ewRptGrpSummary1" : "ewRptGrpField1";
  1296. $TKChucdanh->name->GroupViewValue = ewrpt_DisplayGroupValue($TKChucdanh->name, $TKChucdanh->name->GroupViewValue);
  1297. $TKChucdanh->name->GroupSummaryOldValue = $TKChucdanh->name->GroupSummaryValue;
  1298. $TKChucdanh->name->GroupSummaryValue = $TKChucdanh->name->GroupViewValue;
  1299. $TKChucdanh->name->GroupSummaryViewValue = ($TKChucdanh->name->GroupSummaryOldValue <> $TKChucdanh->name->GroupSummaryValue) ? $TKChucdanh->name->GroupSummaryValue : "&nbsp;";
  1300. // Count(DISTINCT tbl__employee.id)
  1301. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->SumViewValue = $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->SumValue;
  1302. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CellAttrs["class"] = ($TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_PAGE || $TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_GRAND) ? "ewRptGrpAggregate" : "ewRptGrpSummary" . $TKChucdanh->RowGroupLevel;
  1303. // Count(tbl__employee.gender)
  1304. $TKChucdanh->Count28tbl__employee2Egender29->SumViewValue = $TKChucdanh->Count28tbl__employee2Egender29->SumValue;
  1305. $TKChucdanh->Count28tbl__employee2Egender29->CellAttrs["class"] = ($TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_PAGE || $TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_GRAND) ? "ewRptGrpAggregate" : "ewRptGrpSummary" . $TKChucdanh->RowGroupLevel;
  1306. // Count(tbl__profile.joined_party_date)
  1307. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->SumViewValue = $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->SumValue;
  1308. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CellAttrs["class"] = ($TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_PAGE || $TKChucdanh->RowTotalType == EWRPT_ROWTOTAL_GRAND) ? "ewRptGrpAggregate" : "ewRptGrpSummary" . $TKChucdanh->RowGroupLevel;
  1309. // name
  1310. $TKChucdanh->name->HrefValue = "";
  1311. } else {
  1312. // name
  1313. $TKChucdanh->name->GroupViewValue = $TKChucdanh->name->GroupValue();
  1314. $TKChucdanh->name->CellAttrs["class"] = "ewRptGrpField1";
  1315. $TKChucdanh->name->GroupViewValue = ewrpt_DisplayGroupValue($TKChucdanh->name, $TKChucdanh->name->GroupViewValue);
  1316. if ($TKChucdanh->name->GroupValue() == $TKChucdanh->name->GroupOldValue() && !$this->ChkLvlBreak(1))
  1317. $TKChucdanh->name->GroupViewValue = "&nbsp;";
  1318. // Count(DISTINCT tbl__employee.id)
  1319. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ViewValue = $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CurrentValue;
  1320. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CellAttrs["class"] = ($this->RecCount % 2 <> 1) ? "ewTableAltRow" : "ewTableRow";
  1321. // Count(tbl__employee.gender)
  1322. $TKChucdanh->Count28tbl__employee2Egender29->ViewValue = $TKChucdanh->Count28tbl__employee2Egender29->CurrentValue;
  1323. $TKChucdanh->Count28tbl__employee2Egender29->CellAttrs["class"] = ($this->RecCount % 2 <> 1) ? "ewTableAltRow" : "ewTableRow";
  1324. // Count(tbl__profile.joined_party_date)
  1325. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ViewValue = $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CurrentValue;
  1326. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CellAttrs["class"] = ($this->RecCount % 2 <> 1) ? "ewTableAltRow" : "ewTableRow";
  1327. // name
  1328. $TKChucdanh->name->HrefValue = "";
  1329. // Count(DISTINCT tbl__employee.id)
  1330. $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->HrefValue = "";
  1331. // Count(tbl__employee.gender)
  1332. $TKChucdanh->Count28tbl__employee2Egender29->HrefValue = "";
  1333. // Count(tbl__profile.joined_party_date)
  1334. $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->HrefValue = "";
  1335. }
  1336. // Call Cell_Rendered event
  1337. if ($TKChucdanh->RowType == EWRPT_ROWTYPE_TOTAL) { // Summary row
  1338. // name
  1339. $CurrentValue = $TKChucdanh->name->GroupViewValue;
  1340. $ViewValue =& $TKChucdanh->name->GroupViewValue;
  1341. $ViewAttrs =& $TKChucdanh->name->ViewAttrs;
  1342. $CellAttrs =& $TKChucdanh->name->CellAttrs;
  1343. $HrefValue =& $TKChucdanh->name->HrefValue;
  1344. $TKChucdanh->Cell_Rendered($TKChucdanh->name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1345. // Count(DISTINCT tbl__employee.id)
  1346. $CurrentValue = $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->SumValue;
  1347. $ViewValue =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->SumViewValue;
  1348. $ViewAttrs =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ViewAttrs;
  1349. $CellAttrs =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CellAttrs;
  1350. $HrefValue =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->HrefValue;
  1351. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1352. // Count(tbl__employee.gender)
  1353. $CurrentValue = $TKChucdanh->Count28tbl__employee2Egender29->SumValue;
  1354. $ViewValue =& $TKChucdanh->Count28tbl__employee2Egender29->SumViewValue;
  1355. $ViewAttrs =& $TKChucdanh->Count28tbl__employee2Egender29->ViewAttrs;
  1356. $CellAttrs =& $TKChucdanh->Count28tbl__employee2Egender29->CellAttrs;
  1357. $HrefValue =& $TKChucdanh->Count28tbl__employee2Egender29->HrefValue;
  1358. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28tbl__employee2Egender29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1359. // Count(tbl__profile.joined_party_date)
  1360. $CurrentValue = $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->SumValue;
  1361. $ViewValue =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->SumViewValue;
  1362. $ViewAttrs =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ViewAttrs;
  1363. $CellAttrs =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CellAttrs;
  1364. $HrefValue =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->HrefValue;
  1365. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28tbl__profile2Ejoined_party_date29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1366. } else {
  1367. // name
  1368. $CurrentValue = $TKChucdanh->name->GroupValue();
  1369. $ViewValue =& $TKChucdanh->name->GroupViewValue;
  1370. $ViewAttrs =& $TKChucdanh->name->ViewAttrs;
  1371. $CellAttrs =& $TKChucdanh->name->CellAttrs;
  1372. $HrefValue =& $TKChucdanh->name->HrefValue;
  1373. $TKChucdanh->Cell_Rendered($TKChucdanh->name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1374. // Count(DISTINCT tbl__employee.id)
  1375. $CurrentValue = $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CurrentValue;
  1376. $ViewValue =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ViewValue;
  1377. $ViewAttrs =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->ViewAttrs;
  1378. $CellAttrs =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->CellAttrs;
  1379. $HrefValue =& $TKChucdanh->Count28DISTINCT_tbl__employee2Eid29->HrefValue;
  1380. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28DISTINCT_tbl__employee2Eid29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1381. // Count(tbl__employee.gender)
  1382. $CurrentValue = $TKChucdanh->Count28tbl__employee2Egender29->CurrentValue;
  1383. $ViewValue =& $TKChucdanh->Count28tbl__employee2Egender29->ViewValue;
  1384. $ViewAttrs =& $TKChucdanh->Count28tbl__employee2Egender29->ViewAttrs;
  1385. $CellAttrs =& $TKChucdanh->Count28tbl__employee2Egender29->CellAttrs;
  1386. $HrefValue =& $TKChucdanh->Count28tbl__employee2Egender29->HrefValue;
  1387. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28tbl__employee2Egender29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1388. // Count(tbl__profile.joined_party_date)
  1389. $CurrentValue = $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CurrentValue;
  1390. $ViewValue =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ViewValue;
  1391. $ViewAttrs =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->ViewAttrs;
  1392. $CellAttrs =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->CellAttrs;
  1393. $HrefValue =& $TKChucdanh->Count28tbl__profile2Ejoined_party_date29->HrefValue;
  1394. $TKChucdanh->Cell_Rendered($TKChucdanh->Count28tbl__profile2Ejoined_party_date29, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
  1395. }
  1396. // Call Row_Rendered event
  1397. $TKChucdanh->Row_Rendered();
  1398. }
  1399. function SetupExportOptionsExt() {
  1400. global $ReportLanguage, $TKChucdanh;
  1401. }
  1402. // Clear selection stored in session
  1403. function ClearSessionSelection($parm) {
  1404. $_SESSION["sel_TKChucdanh_$parm"] = "";
  1405. $_SESSION["rf_TKChucdanh_$parm"] = "";
  1406. $_SESSION["rt_TKChucdanh_$parm"] = "";
  1407. }
  1408. // Load selection from session
  1409. function LoadSelectionFromSession($parm) {
  1410. global $TKChucdanh;
  1411. $fld =& $TKChucdanh->fields($parm);
  1412. $fld->SelectionList = @$_SESSION["sel_TKChucdanh_$parm"];
  1413. $fld->RangeFrom = @$_SESSION["rf_TKChucdanh_$parm"];
  1414. $fld->RangeTo = @$_SESSION["rt_TKChucdanh_$parm"];
  1415. }
  1416. // Load default value for filters
  1417. function LoadDefaultFilters() {
  1418. global $TKChucdanh;
  1419. /**
  1420. * Set up default values for non Text filters
  1421. */
  1422. /**
  1423. * Set up default values for extended filters
  1424. * function SetDefaultExtFilter(&$fld, $so1, $sv1, $sc, $so2, $sv2)
  1425. * Parameters:
  1426. * $fld - Field object
  1427. * $so1 - Default search operator 1
  1428. * $sv1 - Default ext filter value 1
  1429. * $sc - Default search condition (if operator 2 is enabled)
  1430. * $so2 - Default search operator 2 (if operator 2 is enabled)
  1431. * $sv2 - Default ext filter value 2 (if operator 2 is enabled)
  1432. */
  1433. /**
  1434. * Set up default values for popup filters
  1435. */
  1436. // Field name
  1437. // $TKChucdanh->name->DefaultSelectionList = array("val1", "val2");
  1438. $TKChucdanh->name->DefaultSelectionList = "";
  1439. $TKChucdanh->name->SelectionList = $TKChucdanh->name->DefaultSelectionList;
  1440. }
  1441. // Check if filter applied
  1442. function CheckFilter() {
  1443. global $TKChucdanh;
  1444. // Check name popup filter
  1445. if (!ewrpt_MatchedArray($TKChucdanh->name->DefaultSelectionList, $TKChucdanh->name->SelectionList))
  1446. return TRUE;
  1447. return FALSE;
  1448. }
  1449. // Show list of filters
  1450. function ShowFilterList() {
  1451. global $TKChucdanh;
  1452. global $ReportLanguage;
  1453. // Initialize
  1454. $sFilterList = "";
  1455. // Field name
  1456. $sExtWrk = "";
  1457. $sWrk = "";
  1458. if (is_array($TKChucdanh->name->SelectionList))
  1459. $sWrk = ewrpt_JoinArray($TKChucdanh->name->SelectionList, ", ", EWRPT_DATATYPE_STRING);
  1460. if ($sExtWrk <> "" || $sWrk <> "")
  1461. $sFilterList .= $TKChucdanh->name->FldCaption() . "<br>";
  1462. if ($sExtWrk <> "")
  1463. $sFilterList .= "&nbsp;&nbsp;$sExtWrk<br>";
  1464. if ($sWrk <> "")
  1465. $sFilterList .= "&nbsp;&nbsp;$sWrk<br>";
  1466. // Show Filters
  1467. if ($sFilterList <> "")
  1468. echo $ReportLanguage->Phrase("CurrentFilters") . "<br>$sFilterList";
  1469. }
  1470. // Return poup filter
  1471. function GetPopupFilter() {
  1472. global $TKChucdanh;
  1473. $sWrk = "";
  1474. if (is_ar