PageRenderTime 59ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/jf/web/reports/TKTrinhdoctb.php

http://tinkerportal.googlecode.com/
PHP | 1865 lines | 1366 code | 239 blank | 260 comment | 349 complexity | 25ff3ef192b56f5fab7fbe429b60ebbc MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  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. $TKTrinhdo = NULL;
  12. //
  13. // Table class for TKTrinhdo
  14. //
  15. class crTKTrinhdo {
  16. var $TableVar = 'TKTrinhdo';
  17. var $TableName = 'TKTrinhdo';
  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 $id;
  51. var $name;
  52. var $qlf_name;
  53. var $count;
  54. var $pqlf_name;
  55. var $fields = array();
  56. var $Export; // Export
  57. var $ExportAll = TRUE;
  58. var $UseTokenInUrl = EWRPT_USE_TOKEN_IN_URL;
  59. var $RowType; // Row type
  60. var $RowTotalType; // Row total type
  61. var $RowTotalSubType; // Row total subtype
  62. var $RowGroupLevel; // Row group level
  63. var $RowAttrs = array(); // Row attributes
  64. // Reset CSS styles for table object
  65. function ResetCSS() {
  66. $this->RowAttrs["style"] = "";
  67. $this->RowAttrs["class"] = "";
  68. foreach ($this->fields as $fld) {
  69. $fld->ResetCSS();
  70. }
  71. }
  72. // Summary cells
  73. var $SummaryCellAttrs;
  74. var $SummaryViewAttrs;
  75. var $SummaryCurrentValue;
  76. var $SummaryViewValue;
  77. // Summary cell attributes
  78. function SummaryCellAttributes($i) {
  79. $sAtt = "";
  80. if (is_array($this->SummaryCellAttrs)) {
  81. if ($i >= 0 && $i < count($this->SummaryCellAttrs)) {
  82. $Attrs = $this->SummaryCellAttrs[$i];
  83. if (is_array($Attrs)) {
  84. foreach ($Attrs as $k => $v) {
  85. if (trim($v) <> "")
  86. $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
  87. }
  88. }
  89. }
  90. }
  91. return $sAtt;
  92. }
  93. // Summary view attributes
  94. function SummaryViewAttributes($i) {
  95. $sAtt = "";
  96. if (is_array($this->SummaryViewAttrs)) {
  97. if ($i >= 0 && $i < count($this->SummaryViewAttrs)) {
  98. $Attrs = $this->SummaryViewAttrs[$i];
  99. if (is_array($Attrs)) {
  100. foreach ($Attrs as $k => $v) {
  101. if (trim($v) <> "")
  102. $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
  103. }
  104. }
  105. }
  106. }
  107. return $sAtt;
  108. }
  109. //
  110. // Table class constructor
  111. //
  112. function crTKTrinhdo() {
  113. global $ReportLanguage;
  114. // id
  115. $this->id = new crField('TKTrinhdo', 'TKTrinhdo', 'x_id', 'id', '`id`', 19, EWRPT_DATATYPE_NUMBER, -1);
  116. $this->id->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  117. $this->fields['id'] =& $this->id;
  118. $this->id->DateFilter = "";
  119. $this->id->SqlSelect = "";
  120. $this->id->SqlOrderBy = "";
  121. // name
  122. $this->name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_name', 'name', '`name`', 200, EWRPT_DATATYPE_STRING, -1);
  123. $this->fields['name'] =& $this->name;
  124. $this->name->DateFilter = "";
  125. $this->name->SqlSelect = "";
  126. $this->name->SqlOrderBy = "";
  127. // qlf_name
  128. $this->qlf_name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_qlf_name', 'qlf_name', '`qlf_name`', 200, EWRPT_DATATYPE_STRING, -1);
  129. $this->qlf_name->GroupingFieldId = 2;
  130. $this->fields['qlf_name'] =& $this->qlf_name;
  131. $this->qlf_name->DateFilter = "";
  132. $this->qlf_name->SqlSelect = "";
  133. $this->qlf_name->SqlOrderBy = "";
  134. // count
  135. $this->count = new crField('TKTrinhdo', 'TKTrinhdo', 'x_count', 'count', '`count`', 20, EWRPT_DATATYPE_NUMBER, -1);
  136. $this->count->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
  137. $this->fields['count'] =& $this->count;
  138. $this->count->DateFilter = "";
  139. $this->count->SqlSelect = "";
  140. $this->count->SqlOrderBy = "";
  141. // pqlf_name
  142. $this->pqlf_name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_pqlf_name', 'pqlf_name', '`pqlf_name`', 200, EWRPT_DATATYPE_STRING, -1);
  143. $this->pqlf_name->GroupingFieldId = 1;
  144. $this->fields['pqlf_name'] =& $this->pqlf_name;
  145. $this->pqlf_name->DateFilter = "";
  146. $this->pqlf_name->SqlSelect = "SELECT DISTINCT `pqlf_name` FROM " . $this->SqlFrom();
  147. $this->pqlf_name->SqlOrderBy = "`pqlf_name`";
  148. }
  149. // Multiple column sort
  150. function UpdateSort(&$ofld, $ctrl) {
  151. if ($this->CurrentOrder == $ofld->FldName) {
  152. $sLastSort = $ofld->getSort();
  153. if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
  154. $sThisSort = $this->CurrentOrderType;
  155. } else {
  156. $sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
  157. }
  158. $ofld->setSort($sThisSort);
  159. } else {
  160. if ($ofld->GroupingFieldId == 0 && !$ctrl) $ofld->setSort("");
  161. }
  162. }
  163. // Get Sort SQL
  164. function SortSql() {
  165. $sDtlSortSql = "";
  166. $argrps = array();
  167. foreach ($this->fields as $fld) {
  168. if ($fld->getSort() <> "") {
  169. if ($fld->GroupingFieldId > 0) {
  170. if ($fld->FldGroupSql <> "")
  171. $argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
  172. else
  173. $argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
  174. } else {
  175. if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
  176. $sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
  177. }
  178. }
  179. }
  180. $sSortSql = "";
  181. foreach ($argrps as $grp) {
  182. if ($sSortSql <> "") $sSortSql .= ", ";
  183. $sSortSql .= $grp;
  184. }
  185. if ($sDtlSortSql <> "") {
  186. if ($sSortSql <> "") $sSortSql .= ",";
  187. $sSortSql .= $sDtlSortSql;
  188. }
  189. return $sSortSql;
  190. }
  191. // Table level SQL
  192. function ColumnField() { // Column field
  193. return "`name`";
  194. }
  195. function ColumnDateType() { // Column date type
  196. return "";
  197. }
  198. function SummaryField() { // Summary field
  199. return "`count`";
  200. }
  201. function SummaryType() { // Summary type
  202. return "SUM";
  203. }
  204. function ColumnCaptions() { // Column captions
  205. global $ReportLanguage;
  206. return "";
  207. }
  208. function ColumnNames() { // Column names
  209. return "";
  210. }
  211. function ColumnValues() { // Column values
  212. return "";
  213. }
  214. function SqlFrom() { // From
  215. return "`vw__official_reports_by_qlf`";
  216. }
  217. function SqlSelect() { // Select
  218. return "SELECT `pqlf_name`, `qlf_name`, <DistinctColumnFields> FROM " . $this->SqlFrom();
  219. }
  220. function SqlWhere() { // Where
  221. return "";
  222. }
  223. function SqlGroupBy() { // Group By
  224. return "`pqlf_name`, `qlf_name`";
  225. }
  226. function SqlHaving() { // Having
  227. return "";
  228. }
  229. function SqlOrderBy() { // Order By
  230. return "`pqlf_name` ASC, `qlf_name` ASC";
  231. }
  232. function SqlDistinctSelect() {
  233. return "SELECT DISTINCT `name` FROM `vw__official_reports_by_qlf`";
  234. }
  235. function SqlDistinctWhere() {
  236. return "";
  237. }
  238. function SqlDistinctOrderBy() {
  239. return "`name` ASC";
  240. }
  241. // Table Level Group SQL
  242. function SqlFirstGroupField() {
  243. return "`pqlf_name`";
  244. }
  245. function SqlSelectGroup() {
  246. return "SELECT DISTINCT " . $this->SqlFirstGroupField() . " FROM " . $this->SqlFrom();
  247. }
  248. function SqlOrderByGroup() {
  249. return "`pqlf_name` ASC";
  250. }
  251. function SqlSelectAgg() {
  252. return "SELECT <DistinctColumnFields> FROM " . $this->SqlFrom();
  253. }
  254. function SqlGroupByAgg() {
  255. return "";
  256. }
  257. // Sort URL
  258. function SortUrl(&$fld) {
  259. if ($this->Export <> "" ||
  260. in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
  261. return "";
  262. } elseif ($fld->Sortable) {
  263. $sUrlParm = "order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort();
  264. return ewrpt_CurrentPage() . "?" . $sUrlParm;
  265. } else {
  266. return "";
  267. }
  268. }
  269. // Row attributes
  270. function RowAttributes() {
  271. $sAtt = "";
  272. foreach ($this->RowAttrs as $k => $v) {
  273. if (trim($v) <> "")
  274. $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
  275. }
  276. return $sAtt;
  277. }
  278. // Field object by fldvar
  279. function &fields($fldvar) {
  280. return $this->fields[$fldvar];
  281. }
  282. // Table level events
  283. // Row Rendering event
  284. function Row_Rendering() {
  285. // Enter your code here
  286. }
  287. // Cell Rendered event
  288. function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue) {
  289. //$ViewValue = "xxx";
  290. //$ViewAttrs["style"] = "xxx";
  291. }
  292. // Row Rendered event
  293. function Row_Rendered() {
  294. // To view properties of field class, use:
  295. //var_dump($this-><FieldName>);
  296. }
  297. // Load Filters event
  298. function Filters_Load() {
  299. // Enter your code here
  300. // Example: Register/Unregister Custom Extended Filter
  301. //ewrpt_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter');
  302. //ewrpt_UnregisterFilter($this-><Field>, 'StartsWithA');
  303. }
  304. // Page Filter Validated event
  305. function Page_FilterValidated() {
  306. // Example:
  307. //global $MyTable;
  308. //$MyTable->MyField1->SearchValue = "your search criteria"; // Search value
  309. }
  310. // Chart Rendering event
  311. function Chart_Rendering(&$chart) {
  312. // var_dump($chart);
  313. }
  314. // Chart Rendered event
  315. function Chart_Rendered($chart, &$chartxml) {
  316. // Example:
  317. //$doc = $chart->XmlDoc; // Get the DOMDocument object
  318. // Enter your code to manipulate the DOMDocument object here
  319. //$chartxml = $doc->saveXML(); // Output the XML
  320. }
  321. // Email Sending event
  322. function Email_Sending(&$Email, &$Args) {
  323. //var_dump($Email); var_dump($Args); exit();
  324. return TRUE;
  325. }
  326. }
  327. ?>
  328. <?php ewrpt_Header(FALSE) ?>
  329. <?php
  330. // Create page object
  331. $TKTrinhdo_crosstab = new crTKTrinhdo_crosstab();
  332. $Page =& $TKTrinhdo_crosstab;
  333. // Page init
  334. $TKTrinhdo_crosstab->Page_Init();
  335. // Page main
  336. $TKTrinhdo_crosstab->Page_Main();
  337. ?>
  338. <?php include_once "phprptinc/header.php"; ?>
  339. <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
  340. <script type="text/javascript">
  341. // Create page object
  342. var TKTrinhdo_crosstab = new ewrpt_Page("TKTrinhdo_crosstab");
  343. // page properties
  344. TKTrinhdo_crosstab.PageID = "crosstab"; // page ID
  345. TKTrinhdo_crosstab.FormID = "fTKTrinhdocrosstabfilter"; // form ID
  346. var EWRPT_PAGE_ID = TKTrinhdo_crosstab.PageID;
  347. // extend page with Chart_Rendering function
  348. TKTrinhdo_crosstab.Chart_Rendering =
  349. function(chart, chartid) { // DO NOT CHANGE THIS LINE!
  350. //alert(chartid);
  351. }
  352. // extend page with Chart_Rendered function
  353. TKTrinhdo_crosstab.Chart_Rendered =
  354. function(chart, chartid) { // DO NOT CHANGE THIS LINE!
  355. //alert(chartid);
  356. }
  357. </script>
  358. <?php } ?>
  359. <?php if ($TKTrinhdo->Export == "") { ?>
  360. <script language="JavaScript" type="text/javascript">
  361. <!--
  362. // Write your client script here, no need to add script tags.
  363. //-->
  364. </script>
  365. <?php } ?>
  366. <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
  367. <script src="<?php echo EWRPT_FUSIONCHARTS_FREE_JSCLASS_FILE; ?>" type="text/javascript"></script>
  368. <?php } ?>
  369. <?php if ($TKTrinhdo->Export == "") { ?>
  370. <div id="ewrpt_PopupFilter"><div class="bd"></div></div>
  371. <script src="phprptjs/ewrptpop.js" type="text/javascript"></script>
  372. <script type="text/javascript">
  373. // popup fields
  374. <?php $jsdata = ewrpt_GetJsData($TKTrinhdo->pqlf_name, $TKTrinhdo->pqlf_name->FldType); ?>
  375. ewrpt_CreatePopup("TKTrinhdo_pqlf_name", [<?php echo $jsdata ?>]);
  376. </script>
  377. <?php } ?>
  378. <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
  379. <!-- Table container (begin) -->
  380. <table id="ewContainer" cellspacing="0" cellpadding="0" border="0">
  381. <!-- Top container (begin) -->
  382. <tr><td colspan="3"><div id="ewTop" class="phpreportmaker">
  383. <!-- top slot -->
  384. <a name="top"></a>
  385. <?php } ?>
  386. <p class="phpreportmaker ewTitle"><?php echo $TKTrinhdo->TableCaption() ?>
  387. &nbsp;&nbsp;<?php $TKTrinhdo_crosstab->ExportOptions->Render("body"); ?></p>
  388. <?php $TKTrinhdo_crosstab->ShowPageHeader(); ?>
  389. <?php $TKTrinhdo_crosstab->ShowMessage(); ?>
  390. <br><br>
  391. <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
  392. </div></td></tr>
  393. <!-- Top container (end) -->
  394. <tr>
  395. <!-- Left container (begin) -->
  396. <td style="vertical-align: top;"><div id="ewLeft" class="phpreportmaker">
  397. <!-- left slot -->
  398. </div></td>
  399. <!-- Left container (end) -->
  400. <!-- Center container (report) (begin) -->
  401. <td style="vertical-align: top;" class="ewPadding"><div id="ewCenter" class="phpreportmaker">
  402. <!-- center slot -->
  403. <?php } ?>
  404. <!-- crosstab report starts -->
  405. <div id="report_crosstab">
  406. <?php if ($TKTrinhdo->ShowCurrentFilter) { ?>
  407. <div id="ewrptFilterList">
  408. <?php $TKTrinhdo_crosstab->ShowFilterList() ?>
  409. </div>
  410. <br>
  411. <?php } ?>
  412. <table class="ewGrid" cellspacing="0"><tr>
  413. <td class="ewGridContent">
  414. <?php if ($TKTrinhdo->Export == "") { ?>
  415. <div class="ewGridUpperPanel">
  416. <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
  417. <table border="0" cellspacing="0" cellpadding="0">
  418. <tr>
  419. <td style="white-space: nowrap;">
  420. <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKTrinhdo_crosstab->StartGrp, $TKTrinhdo_crosstab->DisplayGrps, $TKTrinhdo_crosstab->TotalGrps) ?>
  421. <?php if ($Pager->RecordCount > 0) { ?>
  422. <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
  423. <!--first page button-->
  424. <?php if ($Pager->FirstButton->Enabled) { ?>
  425. <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>
  426. <?php } else { ?>
  427. <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
  428. <?php } ?>
  429. <!--previous page button-->
  430. <?php if ($Pager->PrevButton->Enabled) { ?>
  431. <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>
  432. <?php } else { ?>
  433. <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
  434. <?php } ?>
  435. <!--current page number-->
  436. <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
  437. <!--next page button-->
  438. <?php if ($Pager->NextButton->Enabled) { ?>
  439. <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>
  440. <?php } else { ?>
  441. <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
  442. <?php } ?>
  443. <!--last page button-->
  444. <?php if ($Pager->LastButton->Enabled) { ?>
  445. <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>
  446. <?php } else { ?>
  447. <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
  448. <?php } ?>
  449. <td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
  450. </tr></table>
  451. </td>
  452. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  453. <td>
  454. <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>
  455. <?php } else { ?>
  456. <?php if ($TKTrinhdo_crosstab->Filter == "0=101") { ?>
  457. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
  458. <?php } else { ?>
  459. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
  460. <?php } ?>
  461. <?php } ?>
  462. </td>
  463. <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
  464. <td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  465. <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
  466. <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
  467. <option value="1"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
  468. <option value="2"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
  469. <option value="3"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
  470. <option value="4"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
  471. <option value="5"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
  472. <option value="10"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
  473. <option value="20"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
  474. <option value="50"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
  475. <option value="ALL"<?php if ($TKTrinhdo->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
  476. </select>
  477. </span></td>
  478. <?php } ?>
  479. </tr>
  480. </table>
  481. </form>
  482. </div>
  483. <?php } ?>
  484. <!-- Report grid (begin) -->
  485. <div class="ewGridMiddlePanel">
  486. <table class="<?php echo $TKTrinhdo_crosstab->ReportTableClass ?>" cellspacing="0">
  487. <?php if ($TKTrinhdo_crosstab->ShowFirstHeader) { // Show header ?>
  488. <thead>
  489. <!-- Table header -->
  490. <tr>
  491. <td class="ewRptColSummary" colspan="2" style="white-space: nowrap;"><div class="phpreportmaker"><?php echo $TKTrinhdo->count->FldCaption() ?>&nbsp;(<?php echo $ReportLanguage->Phrase("RptSum") ?>)&nbsp;</div></td>
  492. <td class="ewRptColHeader" colspan="<?php echo @$TKTrinhdo_crosstab->ColSpan; ?>" style="white-space: nowrap;">
  493. <?php echo $TKTrinhdo->name->FldCaption() ?>
  494. </td>
  495. </tr>
  496. <tr>
  497. <td class="ewTableHeader">
  498. <?php if ($TKTrinhdo->Export <> "") { ?>
  499. <?php echo $TKTrinhdo->pqlf_name->FldCaption() ?>
  500. <?php } else { ?>
  501. <table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><tr>
  502. <?php if ($TKTrinhdo->SortUrl($TKTrinhdo->pqlf_name) == "") { ?>
  503. <td style="vertical-align: bottom;"><?php echo $TKTrinhdo->pqlf_name->FldCaption() ?></td>
  504. <?php } else { ?>
  505. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKTrinhdo->SortUrl($TKTrinhdo->pqlf_name) ?>',2);"><?php echo $TKTrinhdo->pqlf_name->FldCaption() ?></td><td style="width: 10px;">
  506. <?php if ($TKTrinhdo->pqlf_name->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKTrinhdo->pqlf_name->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  507. <?php } ?>
  508. <td style="width: 20px;" align="right"><a href="#" onclick="ewrpt_ShowPopup(this.name, 'TKTrinhdo_pqlf_name', false, '<?php echo $TKTrinhdo->pqlf_name->RangeFrom; ?>', '<?php echo $TKTrinhdo->pqlf_name->RangeTo; ?>');return false;" name="x_pqlf_name" id="x_pqlf_name"><img src="phprptimages/popup.gif" width="15" height="14" border="0" alt="<?php echo $ReportLanguage->Phrase("Filter") ?>"></a></td>
  509. </tr></table>
  510. <?php } ?>
  511. </td>
  512. <td class="ewTableHeader">
  513. <?php if ($TKTrinhdo->Export <> "") { ?>
  514. <?php echo $TKTrinhdo->qlf_name->FldCaption() ?>
  515. <?php } else { ?>
  516. <table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><tr>
  517. <?php if ($TKTrinhdo->SortUrl($TKTrinhdo->qlf_name) == "") { ?>
  518. <td style="vertical-align: bottom;"><?php echo $TKTrinhdo->qlf_name->FldCaption() ?></td>
  519. <?php } else { ?>
  520. <td class="ewPointer" onmousedown="ewrpt_Sort(event,'<?php echo $TKTrinhdo->SortUrl($TKTrinhdo->qlf_name) ?>',2);"><?php echo $TKTrinhdo->qlf_name->FldCaption() ?></td><td style="width: 10px;">
  521. <?php if ($TKTrinhdo->qlf_name->getSort() == "ASC") { ?><img src="phprptimages/sortup.gif" width="10" height="9" border="0"><?php } elseif ($TKTrinhdo->qlf_name->getSort() == "DESC") { ?><img src="phprptimages/sortdown.gif" width="10" height="9" border="0"><?php } ?></td>
  522. <?php } ?>
  523. </tr></table>
  524. <?php } ?>
  525. </td>
  526. <!-- Dynamic columns begin -->
  527. <?php
  528. $cntval = count($TKTrinhdo_crosstab->Val);
  529. for ($iy = 1; $iy < $cntval; $iy++) {
  530. if ($TKTrinhdo_crosstab->Col[$iy]->Visible) {
  531. $TKTrinhdo->SummaryCurrentValue[$iy-1] = $TKTrinhdo_crosstab->Col[$iy]->Caption;
  532. $TKTrinhdo->SummaryViewValue[$iy-1] = $TKTrinhdo->SummaryCurrentValue[$iy-1];
  533. ?>
  534. <td class="ewTableHeader"<?php echo $TKTrinhdo->name->CellAttributes() ?>><span<?php echo $TKTrinhdo->name->ViewAttributes() ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
  535. <?php
  536. }
  537. }
  538. ?>
  539. <!-- Dynamic columns end -->
  540. </tr>
  541. </thead>
  542. <?php } // End show header ?>
  543. <tbody>
  544. <?php
  545. if ($TKTrinhdo_crosstab->TotalGrps > 0) {
  546. // Set the last group to display if not export all
  547. if ($TKTrinhdo->ExportAll && $TKTrinhdo->Export <> "") {
  548. $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->TotalGrps;
  549. } else {
  550. $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->StartGrp + $TKTrinhdo_crosstab->DisplayGrps - 1;
  551. }
  552. // Stop group <= total number of groups
  553. if (intval($TKTrinhdo_crosstab->StopGrp) > intval($TKTrinhdo_crosstab->TotalGrps)) {
  554. $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->TotalGrps;
  555. }
  556. // Navigate
  557. $TKTrinhdo_crosstab->RecCount = 0;
  558. // Get first row
  559. if ($TKTrinhdo_crosstab->TotalGrps > 0) {
  560. $TKTrinhdo_crosstab->GetGrpRow(1);
  561. $TKTrinhdo_crosstab->GrpCount = 1;
  562. }
  563. while ($rsgrp && !$rsgrp->EOF && $TKTrinhdo_crosstab->GrpCount <= $TKTrinhdo_crosstab->DisplayGrps) {
  564. // Build detail SQL
  565. $sWhere = ewrpt_DetailFilterSQL($TKTrinhdo->pqlf_name, $TKTrinhdo->SqlFirstGroupField(), $TKTrinhdo->pqlf_name->GroupValue());
  566. if ($TKTrinhdo_crosstab->Filter != "")
  567. $sWhere = "($TKTrinhdo_crosstab->Filter) AND ($sWhere)";
  568. $sSql = ewrpt_BuildReportSql($TKTrinhdo_crosstab->SqlSelectWork, $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupBy(), "", $TKTrinhdo->SqlOrderBy(), $sWhere, $TKTrinhdo_crosstab->Sort);
  569. $rs = $conn->Execute($sSql);
  570. $rsdtlcnt = ($rs) ? $rs->RecordCount() : 0;
  571. if ($rsdtlcnt > 0)
  572. $TKTrinhdo_crosstab->GetRow(1);
  573. while ($rs && !$rs->EOF) {
  574. $TKTrinhdo_crosstab->RecCount++;
  575. // Render row
  576. $TKTrinhdo->ResetCSS();
  577. $TKTrinhdo->RowType = EWRPT_ROWTYPE_DETAIL;
  578. $TKTrinhdo_crosstab->RenderRow();
  579. ?>
  580. <!-- Data -->
  581. <tr<?php echo $TKTrinhdo->RowAttributes(); ?>>
  582. <!-- Trinh do -->
  583. <td<?php echo $TKTrinhdo->pqlf_name->CellAttributes(); ?>>
  584. <span<?php echo $TKTrinhdo->pqlf_name->ViewAttributes(); ?>><?php echo $TKTrinhdo->pqlf_name->GroupViewValue; ?></span></td>
  585. <!-- Chi tiet -->
  586. <td<?php echo $TKTrinhdo->qlf_name->CellAttributes(); ?>>
  587. <span<?php echo $TKTrinhdo->qlf_name->ViewAttributes(); ?>><?php echo $TKTrinhdo->qlf_name->GroupViewValue; ?></span></td>
  588. <!-- Dynamic columns begin -->
  589. <?php
  590. $cntcol = count($TKTrinhdo->SummaryViewValue);
  591. for ($iy = 1; $iy <= $cntcol; $iy++) {
  592. $bColShow = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Visible : TRUE;
  593. $sColDesc = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Caption : $ReportLanguage->Phrase("Summary");
  594. if ($bColShow) {
  595. ?>
  596. <!-- <?php //echo $TKTrinhdo_crosstab->Col[$iy]->Caption; ?> -->
  597. <!-- <?php echo $sColDesc; ?> -->
  598. <td<?php echo $TKTrinhdo->SummaryCellAttributes($iy-1) ?>><span<?php echo $TKTrinhdo->SummaryViewAttributes($iy-1); ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
  599. <?php
  600. }
  601. }
  602. ?>
  603. <!-- Dynamic columns end -->
  604. </tr>
  605. <?php
  606. // Accumulate page summary
  607. $TKTrinhdo_crosstab->AccumulateSummary();
  608. // Get next record
  609. $TKTrinhdo_crosstab->GetRow(2);
  610. ?>
  611. <?php
  612. } // End detail records loop
  613. ?>
  614. <?php
  615. // Process summary level 1
  616. if ($TKTrinhdo_crosstab->ChkLvlBreak(1)) {
  617. $TKTrinhdo->ResetCSS();
  618. $TKTrinhdo->RowType = EWRPT_ROWTYPE_TOTAL;
  619. $TKTrinhdo->RowTotalType = EWRPT_ROWTOTAL_GROUP;
  620. $TKTrinhdo->RowTotalSubType = EWRPT_ROWTOTAL_FOOTER;
  621. $TKTrinhdo->RowGroupLevel = 1;
  622. $TKTrinhdo_crosstab->RenderRow();
  623. ?>
  624. <!-- Summary Trinh do (level 1) -->
  625. <tr<?php echo $TKTrinhdo->RowAttributes(); ?>>
  626. <td colspan="2"<?php echo $TKTrinhdo->pqlf_name->CellAttributes() ?>><?php echo $ReportLanguage->Phrase("RptSumHead") ?> <?php echo $TKTrinhdo->pqlf_name->FldCaption() ?>: <?php echo $TKTrinhdo->pqlf_name->GroupViewValue; ?></td>
  627. <!-- Dynamic columns begin -->
  628. <?php
  629. $cntcol = count($TKTrinhdo->SummaryViewValue);
  630. for ($iy = 1; $iy <= $cntcol; $iy++) {
  631. $bColShow = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Visible : TRUE;
  632. $sColDesc = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Caption : $ReportLanguage->Phrase("Summary");
  633. if ($bColShow) {
  634. ?>
  635. <!-- <?php //echo $TKTrinhdo_crosstab->Col[$iy]->Caption; ?> -->
  636. <!-- <?php echo $sColDesc; ?> -->
  637. <td<?php echo $TKTrinhdo->SummaryCellAttributes($iy-1) ?>><span<?php echo $TKTrinhdo->SummaryViewAttributes($iy-1); ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
  638. <?php
  639. }
  640. }
  641. ?>
  642. <!-- Dynamic columns end -->
  643. </tr>
  644. <?php
  645. // Reset level 1 summary
  646. $TKTrinhdo_crosstab->ResetLevelSummary(1);
  647. }
  648. ?>
  649. <?php
  650. $TKTrinhdo_crosstab->GetGrpRow(2);
  651. $TKTrinhdo_crosstab->GrpCount++;
  652. }
  653. ?>
  654. </tbody>
  655. <tfoot>
  656. <?php } ?>
  657. </tfoot>
  658. </table>
  659. </div>
  660. <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
  661. <?php if ($TKTrinhdo->Export == "") { ?>
  662. <div class="ewGridLowerPanel">
  663. <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
  664. <table border="0" cellspacing="0" cellpadding="0">
  665. <tr>
  666. <td style="white-space: nowrap;">
  667. <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKTrinhdo_crosstab->StartGrp, $TKTrinhdo_crosstab->DisplayGrps, $TKTrinhdo_crosstab->TotalGrps) ?>
  668. <?php if ($Pager->RecordCount > 0) { ?>
  669. <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?>&nbsp;</span></td>
  670. <!--first page button-->
  671. <?php if ($Pager->FirstButton->Enabled) { ?>
  672. <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>
  673. <?php } else { ?>
  674. <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
  675. <?php } ?>
  676. <!--previous page button-->
  677. <?php if ($Pager->PrevButton->Enabled) { ?>
  678. <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>
  679. <?php } else { ?>
  680. <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
  681. <?php } ?>
  682. <!--current page number-->
  683. <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
  684. <!--next page button-->
  685. <?php if ($Pager->NextButton->Enabled) { ?>
  686. <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>
  687. <?php } else { ?>
  688. <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
  689. <?php } ?>
  690. <!--last page button-->
  691. <?php if ($Pager->LastButton->Enabled) { ?>
  692. <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>
  693. <?php } else { ?>
  694. <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
  695. <?php } ?>
  696. <td><span class="phpreportmaker">&nbsp;<?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
  697. </tr></table>
  698. </td>
  699. <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  700. <td>
  701. <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>
  702. <?php } else { ?>
  703. <?php if ($TKTrinhdo_crosstab->Filter == "0=101") { ?>
  704. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
  705. <?php } else { ?>
  706. <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
  707. <?php } ?>
  708. <?php } ?>
  709. </td>
  710. <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
  711. <td style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  712. <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>&nbsp;
  713. <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
  714. <option value="1"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
  715. <option value="2"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
  716. <option value="3"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
  717. <option value="4"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
  718. <option value="5"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
  719. <option value="10"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
  720. <option value="20"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
  721. <option value="50"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
  722. <option value="ALL"<?php if ($TKTrinhdo->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
  723. </select>
  724. </span></td>
  725. <?php } ?>
  726. </tr>
  727. </table>
  728. </form>
  729. </div>
  730. <?php } ?>
  731. <?php } ?>
  732. </td></tr></table>
  733. </div>
  734. <!-- Crosstab report ends -->
  735. <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
  736. </div><br></td>
  737. <!-- Center container (report) (end) -->
  738. <!-- Right container (begin) -->
  739. <td style="vertical-align: top;"><div id="ewRight" class="phpreportmaker">
  740. <!-- Right slot -->
  741. </div></td>
  742. <!-- Right container (end) -->
  743. </tr>
  744. <!-- Bottom container (begin) -->
  745. <tr><td colspan="3"><div id="ewBottom" class="phpreportmaker">
  746. <!-- Bottom slot -->
  747. </div><br></td></tr>
  748. <!-- Bottom container (end) -->
  749. </table>
  750. <!-- Table container (end) -->
  751. <?php } ?>
  752. <?php $TKTrinhdo_crosstab->ShowPageFooter(); ?>
  753. <?php if (EWRPT_DEBUG_ENABLED) echo ewrpt_DebugMsg(); ?>
  754. <?php
  755. // Close recordsets
  756. if ($rsgrp) $rsgrp->Close();
  757. if ($rs) $rs->Close();
  758. ?>
  759. <?php if ($TKTrinhdo->Export == "") { ?>
  760. <script language="JavaScript" type="text/javascript">
  761. <!--
  762. // Write your table-specific startup script here
  763. // document.write("page loaded");
  764. //-->
  765. </script>
  766. <?php } ?>
  767. <?php include_once "phprptinc/footer.php"; ?>
  768. <?php
  769. $TKTrinhdo_crosstab->Page_Terminate();
  770. ?>
  771. <?php
  772. //
  773. // Page class
  774. //
  775. class crTKTrinhdo_crosstab {
  776. // Page ID
  777. var $PageID = 'crosstab';
  778. // Table name
  779. var $TableName = 'TKTrinhdo';
  780. // Page object name
  781. var $PageObjName = 'TKTrinhdo_crosstab';
  782. // Page name
  783. function PageName() {
  784. return ewrpt_CurrentPage();
  785. }
  786. // Page URL
  787. function PageUrl() {
  788. $PageUrl = ewrpt_CurrentPage() . "?";
  789. global $TKTrinhdo;
  790. if ($TKTrinhdo->UseTokenInUrl) $PageUrl .= "t=" . $TKTrinhdo->TableVar . "&"; // Add page token
  791. return $PageUrl;
  792. }
  793. // Export URLs
  794. var $ExportPrintUrl;
  795. var $ExportExcelUrl;
  796. var $ExportWordUrl;
  797. var $ExportPdfUrl;
  798. var $ReportTableClass;
  799. // Message
  800. function getMessage() {
  801. return @$_SESSION[EWRPT_SESSION_MESSAGE];
  802. }
  803. function setMessage($v) {
  804. if (@$_SESSION[EWRPT_SESSION_MESSAGE] <> "") { // Append
  805. $_SESSION[EWRPT_SESSION_MESSAGE] .= "<br>" . $v;
  806. } else {
  807. $_SESSION[EWRPT_SESSION_MESSAGE] = $v;
  808. }
  809. }
  810. // Show message
  811. function ShowMessage() {
  812. $sMessage = $this->getMessage();
  813. $this->Message_Showing($sMessage);
  814. if ($sMessage <> "") { // Message in Session, display
  815. echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
  816. $_SESSION[EWRPT_SESSION_MESSAGE] = ""; // Clear message in Session
  817. }
  818. }
  819. var $PageHeader;
  820. var $PageFooter;
  821. // Show Page Header
  822. function ShowPageHeader() {
  823. $sHeader = $this->PageHeader;
  824. $this->Page_DataRendering($sHeader);
  825. if ($sHeader <> "") { // Header exists, display
  826. echo "<p><span class=\"phpreportmaker\">" . $sHeader . "</span></p>";
  827. }
  828. }
  829. // Show Page Footer
  830. function ShowPageFooter() {
  831. $sFooter = $this->PageFooter;
  832. $this->Page_DataRendered($sFooter);
  833. if ($sFooter <> "") { // Fotoer exists, display
  834. echo "<p><span class=\"phpreportmaker\">" . $sFooter . "</span></p>";
  835. }
  836. }
  837. // Validate page request
  838. function IsPageRequest() {
  839. global $TKTrinhdo;
  840. if ($TKTrinhdo->UseTokenInUrl) {
  841. if (ewrpt_IsHttpPost())
  842. return ($TKTrinhdo->TableVar == @$_POST("t"));
  843. if (@$_GET["t"] <> "")
  844. return ($TKTrinhdo->TableVar == @$_GET["t"]);
  845. } else {
  846. return TRUE;
  847. }
  848. }
  849. //
  850. // Page class constructor
  851. //
  852. function crTKTrinhdo_crosstab() {
  853. global $conn, $ReportLanguage;
  854. // Language object
  855. $ReportLanguage = new crLanguage();
  856. // Table object (TKTrinhdo)
  857. $GLOBALS["TKTrinhdo"] = new crTKTrinhdo();
  858. $GLOBALS["Table"] =& $GLOBALS["TKTrinhdo"];
  859. // Initialize URLs
  860. $this->ExportPrintUrl = $this->PageUrl() . "export=print";
  861. $this->ExportExcelUrl = $this->PageUrl() . "export=excel";
  862. $this->ExportWordUrl = $this->PageUrl() . "export=word";
  863. $this->ExportPdfUrl = $this->PageUrl() . "export=pdf";
  864. // Page ID
  865. if (!defined("EWRPT_PAGE_ID"))
  866. define("EWRPT_PAGE_ID", 'crosstab', TRUE);
  867. // Table name (for backward compatibility)
  868. if (!defined("EWRPT_TABLE_NAME"))
  869. define("EWRPT_TABLE_NAME", 'TKTrinhdo', TRUE);
  870. // Start timer
  871. $GLOBALS["gsTimer"] = new crTimer();
  872. // Open connection
  873. $conn = ewrpt_Connect();
  874. // Export options
  875. $this->ExportOptions = new crListOptions();
  876. $this->ExportOptions->Tag = "span";
  877. $this->ExportOptions->Separator = "&nbsp;&nbsp;";
  878. }
  879. //
  880. // Page_Init
  881. //
  882. function Page_Init() {
  883. global $gsExport, $gsExportFile, $ReportLanguage, $Security;
  884. global $TKTrinhdo;
  885. // Get export parameters
  886. if (@$_GET["export"] <> "") {
  887. $TKTrinhdo->Export = $_GET["export"];
  888. }
  889. $gsExport = $TKTrinhdo->Export; // Get export parameter, used in header
  890. $gsExportFile = $TKTrinhdo->TableVar; // Get export file, used in header
  891. if ($TKTrinhdo->Export == "excel") {
  892. header('Content-Type: application/vnd.ms-excel;charset=utf-8');
  893. header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
  894. }
  895. if ($TKTrinhdo->Export == "word") {
  896. header('Content-Type: application/vnd.ms-word;charset=utf-8');
  897. header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
  898. }
  899. // Setup export options
  900. $this->SetupExportOptions();
  901. // Global Page Loading event (in userfn*.php)
  902. Page_Loading();
  903. // Page Load event
  904. $this->Page_Load();
  905. }
  906. // Set up export options
  907. function SetupExportOptions() {
  908. global $ReportLanguage, $TKTrinhdo;
  909. // Printer friendly
  910. $item =& $this->ExportOptions->Add("print");
  911. $item->Body = "<a href=\"" . $this->ExportPrintUrl . "\">" . $ReportLanguage->Phrase("PrinterFriendly") . "</a>";
  912. $item->Visible = TRUE;
  913. // Export to Excel
  914. $item =& $this->ExportOptions->Add("excel");
  915. $item->Body = "<a href=\"" . $this->ExportExcelUrl . "\">" . $ReportLanguage->Phrase("ExportToExcel") . "</a>";
  916. $item->Visible = TRUE;
  917. // Export to Word
  918. $item =& $this->ExportOptions->Add("word");
  919. $item->Body = "<a href=\"" . $this->ExportWordUrl . "\">" . $ReportLanguage->Phrase("ExportToWord") . "</a>";
  920. $item->Visible = TRUE;
  921. // Export to Pdf
  922. $item =& $this->ExportOptions->Add("pdf");
  923. $item->Body = "<a href=\"" . $this->ExportPdfUrl . "\">" . $ReportLanguage->Phrase("ExportToPDF") . "</a>";
  924. $item->Visible = FALSE;
  925. // Uncomment codes below to show export to Pdf link
  926. // $item->Visible = FALSE;
  927. // Export to Email
  928. $item =& $this->ExportOptions->Add("email");
  929. $item->Body = "<a name=\"emf_TKTrinhdo\" id=\"emf_TKTrinhdo\" href=\"javascript:void(0);\" onclick=\"ewrpt_EmailDialogShow({lnk:'emf_TKTrinhdo',hdr:ewLanguage.Phrase('ExportToEmail')});\">" . $ReportLanguage->Phrase("ExportToEmail") . "</a>";
  930. $item->Visible = FALSE;
  931. // Reset filter
  932. $item =& $this->ExportOptions->Add("resetfilter");
  933. $item->Body = "<a href=\"" . ewrpt_CurrentPage() . "?cmd=reset\">" . $ReportLanguage->Phrase("ResetAllFilter") . "</a>";
  934. $item->Visible = TRUE;
  935. $this->SetupExportOptionsExt();
  936. // Hide options for export
  937. if ($TKTrinhdo->Export <> "")
  938. $this->ExportOptions->HideAllOptions();
  939. // Set up table class
  940. if ($TKTrinhdo->Export == "word" || $TKTrinhdo->Export == "excel" || $TKTrinhdo->Export == "pdf")
  941. $this->ReportTableClass = "ewTable";
  942. else
  943. $this->ReportTableClass = "ewTable ewTableSeparate";
  944. }
  945. //
  946. // Page_Terminate
  947. //
  948. function Page_Terminate($url = "") {
  949. global $conn;
  950. global $ReportLanguage;
  951. global $TKTrinhdo;
  952. // Page Unload event
  953. $this->Page_Unload();
  954. // Global Page Unloaded event (in userfn*.php)
  955. Page_Unloaded();
  956. // Export to Email (use ob_file_contents for PHP)
  957. if ($TKTrinhdo->Export == "email") {
  958. $sContent = ob_get_contents();
  959. $this->ExportEmail($sContent);
  960. ob_end_clean();
  961. // Close connection
  962. $conn->Close();
  963. header("Location: " . ewrpt_CurrentPage());
  964. exit();
  965. }
  966. // Export to PDF (use ob_file_contents for PHP)
  967. if ($TKTrinhdo->Export == "pdf") {
  968. $sContent = ob_get_contents();
  969. $this->ExportPDF($sContent);
  970. ob_end_clean();
  971. // Close connection
  972. $conn->Close();
  973. }
  974. // Close connection
  975. $conn->Close();
  976. // Go to URL if specified
  977. if ($url <> "") {
  978. if (!EWRPT_DEBUG_ENABLED && ob_get_length())
  979. ob_end_clean();
  980. header("Location: " . $url);
  981. }
  982. exit();
  983. }
  984. // Initialize common variables
  985. var $ExportOptions; // Export options
  986. // Paging variables
  987. var $RecCount = 0; // Record count
  988. var $StartGrp = 0; // Start group
  989. var $StopGrp = 0; // Stop group
  990. var $TotalGrps = 0; // Total groups
  991. var $GrpCount = 0; // Group count
  992. var $DisplayGrps = 20; // Groups per page
  993. var $GrpRange = 10;
  994. var $Sort = "";
  995. var $Filter = "";
  996. var $UserIDFilter = "";
  997. // Clear field for ext filter
  998. var $ClearExtFilter = "";
  999. var $FilterApplied;
  1000. var $ShowFirstHeader;
  1001. var $Cnt, $Col, $Val, $Smry;
  1002. var $ColCount, $ColSpan;
  1003. var $SqlSelectWork, $SqlSelectAggWork;
  1004. var $SqlChartWork;
  1005. //
  1006. // Page main
  1007. //
  1008. function Page_Main() {
  1009. global $TKTrinhdo;
  1010. global $rs;
  1011. global $rsgrp;
  1012. global $gsFormError;
  1013. // Get sort
  1014. $this->Sort = $this->GetSort();
  1015. // Set up groups per page dynamically
  1016. $this->SetUpDisplayGrps();
  1017. // Popup values and selections
  1018. $TKTrinhdo->pqlf_name->SelectionList = "";
  1019. $TKTrinhdo->pqlf_name->DefaultSelectionList = "";
  1020. $TKTrinhdo->pqlf_name->ValueList = "";
  1021. // Load default filter values
  1022. $this->LoadDefaultFilters();
  1023. // Load custom filters
  1024. $TKTrinhdo->Filters_Load();
  1025. // Set up popup filter
  1026. $this->SetupPopup();
  1027. // Extended filter
  1028. $sExtendedFilter = "";
  1029. // Load columns to array
  1030. $this->GetColumns();
  1031. // Build popup filter
  1032. $sPopupFilter = $this->GetPopupFilter();
  1033. //ewrpt_SetDebugMsg("popup filter: " . $sPopupFilter);
  1034. if ($sPopupFilter <> "") {
  1035. if ($this->Filter <> "")
  1036. $this->Filter = "($this->Filter) AND ($sPopupFilter)";
  1037. else
  1038. $this->Filter = $sPopupFilter;
  1039. }
  1040. // Check if filter applied
  1041. $this->FilterApplied = $this->CheckFilter();
  1042. $this->ExportOptions->GetItem("resetfilter")->Visible = $this->FilterApplied;
  1043. // Get total group count
  1044. $sGrpSort = ewrpt_UpdateSortFields($TKTrinhdo->SqlOrderByGroup(), $this->Sort, 2); // Get grouping field only
  1045. $sSql = ewrpt_BuildReportSql($TKTrinhdo->SqlSelectGroup(), $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupBy(), "", $TKTrinhdo->SqlOrderByGroup(), $this->Filter, $sGrpSort);
  1046. $this->TotalGrps = $this->GetGrpCnt($sSql);
  1047. if ($this->DisplayGrps <= 0) // Display all groups
  1048. $this->DisplayGrps = $this->TotalGrps;
  1049. $this->StartGrp = 1;
  1050. // Show header
  1051. $this->ShowFirstHeader = ($this->TotalGrps > 0);
  1052. //$this->ShowFirstHeader = TRUE; // Uncomment to always show header
  1053. // Set up start position if not export all
  1054. if ($TKTrinhdo->ExportAll && $TKTrinhdo->Export <> "")
  1055. $this->DisplayGrps = $this->TotalGrps;
  1056. else
  1057. $this->SetUpStartGroup();
  1058. // Hide all options if export
  1059. if ($TKTrinhdo->Export <> "") {
  1060. $this->ExportOptions->HideAllOptions();
  1061. }
  1062. // Get total groups
  1063. $rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
  1064. // Init detail recordset
  1065. $rs = NULL;
  1066. // Set up column attributes
  1067. $TKTrinhdo->name->ViewAttrs["style"] = "";
  1068. $TKTrinhdo->name->CellAttrs["style"] = "white-space: nowrap; vertical-align: top;";
  1069. }
  1070. // Get column values
  1071. function GetColumns() {
  1072. global $conn;
  1073. global $TKTrinhdo;
  1074. global $ReportLanguage;
  1075. // Build SQL
  1076. $sSql = ewrpt_BuildReportSql($TKTrinhdo->SqlDistinctSelect(), $TKTrinhdo->SqlDistinctWhere(), "", "", $TKTrinhdo->SqlDistinctOrderBy(), $this->Filter, "");
  1077. // Load recordset
  1078. $rscol = $conn->Execute($sSql);
  1079. // Get distinct column count
  1080. $this->ColCount = ($rscol) ? $rscol->RecordCount() : 0;
  1081. /* Uncomment to show phrase
  1082. if ($this->ColCount == 0) {
  1083. if ($rscol) $rscol->Close();
  1084. echo $ReportLanguage->Phrase("NoDistinctColVals") . $sSql . "<br>";
  1085. exit();
  1086. }
  1087. */
  1088. // 1st dimension = no of groups (level 0 used for grand total)
  1089. // 2nd dimension = no of distinct values
  1090. $nGrps = 2;
  1091. $this->Col =& ewrpt_InitArray($this->ColCount+1, NULL);
  1092. $this->Val =& ewrpt_InitArray($this->ColCount+1, NULL);
  1093. $this->ValCnt =& ewrpt_InitArray($this->ColCount+1, NULL);
  1094. $this->Cnt =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
  1095. $this->Smry =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
  1096. $this->SmryCnt =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
  1097. // Reset summary values
  1098. $this->ResetLevelSummary(0);
  1099. $colcnt = 0;
  1100. while (!$rscol->EOF) {
  1101. if (is_null($rscol->fields[0])) {
  1102. $wrkValue = EWRPT_NULL_VALUE;
  1103. $wrkCaption = $ReportLanguage->Phrase("NullLabel");
  1104. } elseif ($rscol->fields[0] == "") {
  1105. $wrkValue = EWRPT_EMPTY_VALUE;
  1106. $wrkCaption = $ReportLanguage->Phrase("EmptyLabel");
  1107. } else {
  1108. $wrkValue = $rscol->fields[0];
  1109. $wrkCaption = $rscol->fields[0];
  1110. }
  1111. $colcnt++;
  1112. $this->Col[$colcnt] = new crCrosstabColumn($wrkValue, $wrkCaption, TRUE);
  1113. $rscol->MoveNext();
  1114. }
  1115. $rscol->Close();
  1116. // Get active columns
  1117. if (!is_array($TKTrinhdo->name->SelectionList)) {
  1118. $this->ColSpan = $this->ColCount;
  1119. } else {
  1120. $this->ColSpan = 0;
  1121. for ($i = 1; $i <= $this->ColCount; $i++) {
  1122. $bSelected = FALSE;
  1123. $cntsel = count($TKTrinhdo->name->SelectionList);
  1124. for ($j = 0; $j < $cntsel; $j++) {
  1125. if (ewrpt_CompareValue($TKTrinhdo->name->SelectionList[$j], $this->Col[$i]->Value, $TKTrinhdo->name->FldType)) {
  1126. $this->ColSpan++;
  1127. $bSelected = TRUE;
  1128. break;
  1129. }
  1130. }
  1131. $this->Col[$i]->Visible = $bSelected;
  1132. }
  1133. }
  1134. // Update crosstab sql
  1135. $sSqlFlds = "";
  1136. for ($colcnt = 1; $colcnt <= $this->ColCount; $colcnt++) {
  1137. $sFld = ewrpt_CrossTabField($TKTrinhdo->SummaryType(), $TKTrinhdo->SummaryField(), $TKTrinhdo->ColumnField(), $TKTrinhdo->ColumnDateType(), $this->Col[$colcnt]->Value, "'", "C" . $colcnt);
  1138. if ($sSqlFlds <> "")
  1139. $sSqlFlds .= ", ";
  1140. $sSqlFlds .= $sFld;
  1141. }
  1142. $this->SqlSelectWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $TKTrinhdo->SqlSelect());
  1143. $this->SqlSelectAggWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $TKTrinhdo->SqlSelectAgg());
  1144. // Update chart sql if Y Axis = Column Field
  1145. $this->SqlChartWork = "";
  1146. for ($i = 0; $i < $this->ColCount; $i++) {
  1147. if ($this->Col[$i+1]->Visible) {
  1148. $sChtFld = ewrpt_CrossTabField("SUM", $TKTrinhdo->SummaryField(), $TKTrinhdo->ColumnField(), $TKTrinhdo->ColumnDateType(), $this->Col[$i+1]->Value, "'");
  1149. if ($this->SqlChartWork != "") $this->SqlChartWork .= "+";
  1150. $this->SqlChartWork .= $sChtFld;
  1151. }
  1152. }
  1153. }
  1154. // Get group count
  1155. function GetGrpCnt($sql) {
  1156. global $conn;
  1157. $rsgrpcnt = $conn->Execute($sql);
  1158. $grpcnt = ($rsgrpcnt) ? $rsgrpcnt->RecordCount() : 0;
  1159. if ($rsgrpcnt) $rsgrpcnt->Close();
  1160. return $grpcnt;
  1161. }
  1162. // Get group rs
  1163. function GetGrpRs($sql, $start, $grps) {
  1164. global $conn;
  1165. $wrksql = $sql;
  1166. if ($start > 0 && $grps > -1)
  1167. $wrksql .= " LIMIT " . ($start-1) . ", " . ($grps);
  1168. $rswrk = $conn->Execute($wrksql);
  1169. return $rswrk;
  1170. }
  1171. // Get group row values
  1172. function GetGrpRow($opt) {
  1173. global $rsgrp;
  1174. global $TKTrinhdo;
  1175. if (!$rsgrp)
  1176. return;
  1177. if ($opt == 1) { // Get first group
  1178. // $rsgrp->MoveFirst(); // NOTE: no need to move position
  1179. $TKTrinhdo->pqlf_name->setDbValue(""); // Init first value
  1180. } else { // Get next group
  1181. $rsgrp->MoveNext();
  1182. }
  1183. if (!$rsgrp->EOF) {
  1184. $TKTrinhdo->pqlf_name->setDbValue($rsgrp->fields[0]);
  1185. } else {
  1186. $TKTrinhdo->pqlf_name->setDbValue("");
  1187. }
  1188. }
  1189. // Get row values
  1190. function GetRow($opt) {
  1191. global $rs;
  1192. global $TKTrinhdo;
  1193. if (!$rs)
  1194. return;
  1195. if ($opt == 1) { // Get first row
  1196. // $rs->MoveFirst(); // NOTE: no need to move position
  1197. } else { // Get next row
  1198. $rs->MoveNext();
  1199. }
  1200. if (!$rs->EOF) {
  1201. if ($opt <> 1)
  1202. $TKTrinhdo->pqlf_name->setDbValue($rs->fields('pqlf_name'));
  1203. $TKTrinhdo->qlf_name->setDbValue($rs->fields('qlf_name'));
  1204. $cntval = count($this->Val);
  1205. for ($ix = 1; $ix < $cntval; $ix++)
  1206. $this->Val[$ix] = $rs->fields[$ix+2-1];
  1207. } else {
  1208. $TKTrinhdo->pqlf_name->setDbValue("");
  1209. $TKTrinhdo->qlf_name->setDbValue("");
  1210. }
  1211. }
  1212. // Check level break
  1213. function ChkLvlBreak($lvl) {
  1214. global $TKTrinhdo;
  1215. switch ($lvl) {
  1216. case 1:
  1217. return (is_null($TKTrinhdo->pqlf_name->CurrentValue) && !is_null($TKTrinhdo->pqlf_name->OldValue)) ||
  1218. (!is_null($TKTrinhdo->pqlf_name->CurrentValue) && is_null($TKTrinhdo->pqlf_name->OldValue)) ||
  1219. ($TKTrinhdo->pqlf_name->GroupValue() <> $TKTrinhdo->pqlf_name->GroupOldValue());
  1220. case 2:
  1221. return (is_null($TKTrinhdo->qlf_name->CurrentValue) && !is_null($TKTrinhdo->qlf_name->OldValue)) ||
  1222. (!is_null($TKTrinhdo->qlf_name->CurrentValue) && is_null($TKTrinhdo->qlf_name->OldValue)) ||
  1223. ($TKTrinhdo->qlf_name->GroupValue() <> $TKTrinhdo->qlf_name->GroupOldValue()) || $this->ChkLvlBreak(1); // Recurse upper level
  1224. }
  1225. }
  1226. // Accummulate summary
  1227. function AccumulateSummary() {
  1228. global $TKTrinhdo;
  1229. $cntx = count($this->Smry);
  1230. for ($ix = 1; $ix < $cntx; $ix++) {
  1231. $cnty = count($this->Smry[$ix]);
  1232. for ($iy = 0; $iy < $cnty; $iy++) {
  1233. $valwrk = $this->Val[$ix];
  1234. $this->Cnt[$ix][$iy]++;
  1235. $this->Smry[$ix][$iy] = ewrpt_SummaryValue($this->Smry[$ix][$iy], $valwrk, $TKTrinhdo->SummaryType());
  1236. }
  1237. }
  1238. }
  1239. // Reset level summary
  1240. function ResetLevelSummary($lvl) {
  1241. // Clear summary values
  1242. $cntx = count($this->Smry);
  1243. for ($ix = 1; $ix < $cntx; $ix++) {
  1244. $cnty = count($this->Smry[$ix]);
  1245. for ($iy = $lvl; $iy < $cnty; $iy++) {
  1246. $this->Cnt[$ix][$iy] = 0;
  1247. $this->Smry[$ix][$iy] = 0;
  1248. }
  1249. }
  1250. // Reset record count
  1251. $this->RecCount = 0;
  1252. }
  1253. // Set up starting group
  1254. function SetUpStartGroup() {
  1255. global $TKTrinhdo;
  1256. // Exit if no groups
  1257. if ($this->DisplayGrps == 0)
  1258. return;
  1259. // Check for a 'start' parameter
  1260. if (@$_GET[EWRPT_TABLE_START_GROUP] != "") {
  1261. $this->StartGrp = $_GET[EWRPT_TABLE_START_GROUP];
  1262. $TKT

Large files files are truncated, but you can click here to view the full file