PageRenderTime 30ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/jf/web/reports/TKChucdanhsmry.php

http://tinkerportal.googlecode.com/
PHP | 1698 lines | 1229 code | 224 blank | 245 comment | 339 complexity | 4ab4def7e6154057b5b29f7abf2315af MD5 | raw file

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

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

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