/jf/web/reports/TKTrinhdoctb.php
PHP | 1865 lines | 1366 code | 239 blank | 260 comment | 349 complexity | 25ff3ef192b56f5fab7fbe429b60ebbc MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- if (session_id() == "") session_start(); // Initialize Session data
- ob_start();
- ?>
- <?php include_once "phprptinc/ewrcfg5.php"; ?>
- <?php include_once "phprptinc/ewmysql.php"; ?>
- <?php include_once "phprptinc/ewrfn5.php"; ?>
- <?php include_once "phprptinc/ewrusrfn.php"; ?>
- <?php
-
- // Global variable for table object
- $TKTrinhdo = NULL;
-
- //
- // Table class for TKTrinhdo
- //
- class crTKTrinhdo {
- var $TableVar = 'TKTrinhdo';
- var $TableName = 'TKTrinhdo';
- var $TableType = 'REPORT';
- var $ShowCurrentFilter = EWRPT_SHOW_CURRENT_FILTER;
- var $FilterPanelOption = EWRPT_FILTER_PANEL_OPTION;
- var $CurrentOrder; // Current order
- var $CurrentOrderType; // Current order type
-
- // Table caption
- function TableCaption() {
- global $ReportLanguage;
- return $ReportLanguage->TablePhrase($this->TableVar, "TblCaption");
- }
-
- // Session Group Per Page
- function getGroupPerPage() {
- return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"];
- }
-
- function setGroupPerPage($v) {
- @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_grpperpage"] = $v;
- }
-
- // Session Start Group
- function getStartGroup() {
- return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"];
- }
-
- function setStartGroup($v) {
- @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_start"] = $v;
- }
-
- // Session Order By
- function getOrderBy() {
- return @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"];
- }
-
- function setOrderBy($v) {
- @$_SESSION[EWRPT_PROJECT_VAR . "_" . $this->TableVar . "_orderby"] = $v;
- }
-
- // var $SelectLimit = TRUE;
- var $id;
- var $name;
- var $qlf_name;
- var $count;
- var $pqlf_name;
- var $fields = array();
- var $Export; // Export
- var $ExportAll = TRUE;
- var $UseTokenInUrl = EWRPT_USE_TOKEN_IN_URL;
- var $RowType; // Row type
- var $RowTotalType; // Row total type
- var $RowTotalSubType; // Row total subtype
- var $RowGroupLevel; // Row group level
- var $RowAttrs = array(); // Row attributes
-
- // Reset CSS styles for table object
- function ResetCSS() {
- $this->RowAttrs["style"] = "";
- $this->RowAttrs["class"] = "";
- foreach ($this->fields as $fld) {
- $fld->ResetCSS();
- }
- }
-
- // Summary cells
- var $SummaryCellAttrs;
- var $SummaryViewAttrs;
- var $SummaryCurrentValue;
- var $SummaryViewValue;
-
- // Summary cell attributes
- function SummaryCellAttributes($i) {
- $sAtt = "";
- if (is_array($this->SummaryCellAttrs)) {
- if ($i >= 0 && $i < count($this->SummaryCellAttrs)) {
- $Attrs = $this->SummaryCellAttrs[$i];
- if (is_array($Attrs)) {
- foreach ($Attrs as $k => $v) {
- if (trim($v) <> "")
- $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
- }
- }
- }
- }
- return $sAtt;
- }
-
- // Summary view attributes
- function SummaryViewAttributes($i) {
- $sAtt = "";
- if (is_array($this->SummaryViewAttrs)) {
- if ($i >= 0 && $i < count($this->SummaryViewAttrs)) {
- $Attrs = $this->SummaryViewAttrs[$i];
- if (is_array($Attrs)) {
- foreach ($Attrs as $k => $v) {
- if (trim($v) <> "")
- $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
- }
- }
- }
- }
- return $sAtt;
- }
-
- //
- // Table class constructor
- //
- function crTKTrinhdo() {
- global $ReportLanguage;
-
- // id
- $this->id = new crField('TKTrinhdo', 'TKTrinhdo', 'x_id', 'id', '`id`', 19, EWRPT_DATATYPE_NUMBER, -1);
- $this->id->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
- $this->fields['id'] =& $this->id;
- $this->id->DateFilter = "";
- $this->id->SqlSelect = "";
- $this->id->SqlOrderBy = "";
-
- // name
- $this->name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_name', 'name', '`name`', 200, EWRPT_DATATYPE_STRING, -1);
- $this->fields['name'] =& $this->name;
- $this->name->DateFilter = "";
- $this->name->SqlSelect = "";
- $this->name->SqlOrderBy = "";
-
- // qlf_name
- $this->qlf_name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_qlf_name', 'qlf_name', '`qlf_name`', 200, EWRPT_DATATYPE_STRING, -1);
- $this->qlf_name->GroupingFieldId = 2;
- $this->fields['qlf_name'] =& $this->qlf_name;
- $this->qlf_name->DateFilter = "";
- $this->qlf_name->SqlSelect = "";
- $this->qlf_name->SqlOrderBy = "";
-
- // count
- $this->count = new crField('TKTrinhdo', 'TKTrinhdo', 'x_count', 'count', '`count`', 20, EWRPT_DATATYPE_NUMBER, -1);
- $this->count->FldDefaultErrMsg = $ReportLanguage->Phrase("IncorrectInteger");
- $this->fields['count'] =& $this->count;
- $this->count->DateFilter = "";
- $this->count->SqlSelect = "";
- $this->count->SqlOrderBy = "";
-
- // pqlf_name
- $this->pqlf_name = new crField('TKTrinhdo', 'TKTrinhdo', 'x_pqlf_name', 'pqlf_name', '`pqlf_name`', 200, EWRPT_DATATYPE_STRING, -1);
- $this->pqlf_name->GroupingFieldId = 1;
- $this->fields['pqlf_name'] =& $this->pqlf_name;
- $this->pqlf_name->DateFilter = "";
- $this->pqlf_name->SqlSelect = "SELECT DISTINCT `pqlf_name` FROM " . $this->SqlFrom();
- $this->pqlf_name->SqlOrderBy = "`pqlf_name`";
- }
-
- // Multiple column sort
- function UpdateSort(&$ofld, $ctrl) {
- if ($this->CurrentOrder == $ofld->FldName) {
- $sLastSort = $ofld->getSort();
- if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
- $sThisSort = $this->CurrentOrderType;
- } else {
- $sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
- }
- $ofld->setSort($sThisSort);
- } else {
- if ($ofld->GroupingFieldId == 0 && !$ctrl) $ofld->setSort("");
- }
- }
-
- // Get Sort SQL
- function SortSql() {
- $sDtlSortSql = "";
- $argrps = array();
- foreach ($this->fields as $fld) {
- if ($fld->getSort() <> "") {
- if ($fld->GroupingFieldId > 0) {
- if ($fld->FldGroupSql <> "")
- $argrps[$fld->GroupingFieldId] = str_replace("%s", $fld->FldExpression, $fld->FldGroupSql) . " " . $fld->getSort();
- else
- $argrps[$fld->GroupingFieldId] = $fld->FldExpression . " " . $fld->getSort();
- } else {
- if ($sDtlSortSql <> "") $sDtlSortSql .= ", ";
- $sDtlSortSql .= $fld->FldExpression . " " . $fld->getSort();
- }
- }
- }
- $sSortSql = "";
- foreach ($argrps as $grp) {
- if ($sSortSql <> "") $sSortSql .= ", ";
- $sSortSql .= $grp;
- }
- if ($sDtlSortSql <> "") {
- if ($sSortSql <> "") $sSortSql .= ",";
- $sSortSql .= $sDtlSortSql;
- }
- return $sSortSql;
- }
-
- // Table level SQL
- function ColumnField() { // Column field
- return "`name`";
- }
-
- function ColumnDateType() { // Column date type
- return "";
- }
-
- function SummaryField() { // Summary field
- return "`count`";
- }
-
- function SummaryType() { // Summary type
- return "SUM";
- }
-
- function ColumnCaptions() { // Column captions
- global $ReportLanguage;
- return "";
- }
-
- function ColumnNames() { // Column names
- return "";
- }
-
- function ColumnValues() { // Column values
- return "";
- }
-
- function SqlFrom() { // From
- return "`vw__official_reports_by_qlf`";
- }
-
- function SqlSelect() { // Select
- return "SELECT `pqlf_name`, `qlf_name`, <DistinctColumnFields> FROM " . $this->SqlFrom();
- }
-
- function SqlWhere() { // Where
- return "";
- }
-
- function SqlGroupBy() { // Group By
- return "`pqlf_name`, `qlf_name`";
- }
-
- function SqlHaving() { // Having
- return "";
- }
-
- function SqlOrderBy() { // Order By
- return "`pqlf_name` ASC, `qlf_name` ASC";
- }
-
- function SqlDistinctSelect() {
- return "SELECT DISTINCT `name` FROM `vw__official_reports_by_qlf`";
- }
-
- function SqlDistinctWhere() {
- return "";
- }
-
- function SqlDistinctOrderBy() {
- return "`name` ASC";
- }
-
- // Table Level Group SQL
- function SqlFirstGroupField() {
- return "`pqlf_name`";
- }
-
- function SqlSelectGroup() {
- return "SELECT DISTINCT " . $this->SqlFirstGroupField() . " FROM " . $this->SqlFrom();
- }
-
- function SqlOrderByGroup() {
- return "`pqlf_name` ASC";
- }
-
- function SqlSelectAgg() {
- return "SELECT <DistinctColumnFields> FROM " . $this->SqlFrom();
- }
-
- function SqlGroupByAgg() {
- return "";
- }
-
- // Sort URL
- function SortUrl(&$fld) {
- if ($this->Export <> "" ||
- in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
- return "";
- } elseif ($fld->Sortable) {
- $sUrlParm = "order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort();
- return ewrpt_CurrentPage() . "?" . $sUrlParm;
- } else {
- return "";
- }
- }
-
- // Row attributes
- function RowAttributes() {
- $sAtt = "";
- foreach ($this->RowAttrs as $k => $v) {
- if (trim($v) <> "")
- $sAtt .= " " . $k . "=\"" . trim($v) . "\"";
- }
- return $sAtt;
- }
-
- // Field object by fldvar
- function &fields($fldvar) {
- return $this->fields[$fldvar];
- }
-
- // Table level events
- // Row Rendering event
- function Row_Rendering() {
-
- // Enter your code here
- }
-
- // Cell Rendered event
- function Cell_Rendered(&$Field, $CurrentValue, &$ViewValue, &$ViewAttrs, &$CellAttrs, &$HrefValue) {
-
- //$ViewValue = "xxx";
- //$ViewAttrs["style"] = "xxx";
-
- }
-
- // Row Rendered event
- function Row_Rendered() {
-
- // To view properties of field class, use:
- //var_dump($this-><FieldName>);
-
- }
-
- // Load Filters event
- function Filters_Load() {
-
- // Enter your code here
- // Example: Register/Unregister Custom Extended Filter
- //ewrpt_RegisterFilter($this-><Field>, 'StartsWithA', 'Starts With A', 'GetStartsWithAFilter');
- //ewrpt_UnregisterFilter($this-><Field>, 'StartsWithA');
-
- }
-
- // Page Filter Validated event
- function Page_FilterValidated() {
-
- // Example:
- //global $MyTable;
- //$MyTable->MyField1->SearchValue = "your search criteria"; // Search value
-
- }
-
- // Chart Rendering event
- function Chart_Rendering(&$chart) {
-
- // var_dump($chart);
- }
-
- // Chart Rendered event
- function Chart_Rendered($chart, &$chartxml) {
-
- // Example:
- //$doc = $chart->XmlDoc; // Get the DOMDocument object
- // Enter your code to manipulate the DOMDocument object here
- //$chartxml = $doc->saveXML(); // Output the XML
-
- }
-
- // Email Sending event
- function Email_Sending(&$Email, &$Args) {
-
- //var_dump($Email); var_dump($Args); exit();
- return TRUE;
- }
- }
- ?>
- <?php ewrpt_Header(FALSE) ?>
- <?php
-
- // Create page object
- $TKTrinhdo_crosstab = new crTKTrinhdo_crosstab();
- $Page =& $TKTrinhdo_crosstab;
-
- // Page init
- $TKTrinhdo_crosstab->Page_Init();
-
- // Page main
- $TKTrinhdo_crosstab->Page_Main();
- ?>
- <?php include_once "phprptinc/header.php"; ?>
- <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
- <script type="text/javascript">
-
- // Create page object
- var TKTrinhdo_crosstab = new ewrpt_Page("TKTrinhdo_crosstab");
-
- // page properties
- TKTrinhdo_crosstab.PageID = "crosstab"; // page ID
- TKTrinhdo_crosstab.FormID = "fTKTrinhdocrosstabfilter"; // form ID
- var EWRPT_PAGE_ID = TKTrinhdo_crosstab.PageID;
-
- // extend page with Chart_Rendering function
- TKTrinhdo_crosstab.Chart_Rendering =
- function(chart, chartid) { // DO NOT CHANGE THIS LINE!
-
- //alert(chartid);
- }
-
- // extend page with Chart_Rendered function
- TKTrinhdo_crosstab.Chart_Rendered =
- function(chart, chartid) { // DO NOT CHANGE THIS LINE!
-
- //alert(chartid);
- }
- </script>
- <?php } ?>
- <?php if ($TKTrinhdo->Export == "") { ?>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your client script here, no need to add script tags.
- //-->
-
- </script>
- <?php } ?>
- <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
- <script src="<?php echo EWRPT_FUSIONCHARTS_FREE_JSCLASS_FILE; ?>" type="text/javascript"></script>
- <?php } ?>
- <?php if ($TKTrinhdo->Export == "") { ?>
- <div id="ewrpt_PopupFilter"><div class="bd"></div></div>
- <script src="phprptjs/ewrptpop.js" type="text/javascript"></script>
- <script type="text/javascript">
-
- // popup fields
- <?php $jsdata = ewrpt_GetJsData($TKTrinhdo->pqlf_name, $TKTrinhdo->pqlf_name->FldType); ?>
- ewrpt_CreatePopup("TKTrinhdo_pqlf_name", [<?php echo $jsdata ?>]);
- </script>
- <?php } ?>
- <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
- <!-- Table container (begin) -->
- <table id="ewContainer" cellspacing="0" cellpadding="0" border="0">
- <!-- Top container (begin) -->
- <tr><td colspan="3"><div id="ewTop" class="phpreportmaker">
- <!-- top slot -->
- <a name="top"></a>
- <?php } ?>
- <p class="phpreportmaker ewTitle"><?php echo $TKTrinhdo->TableCaption() ?>
- <?php $TKTrinhdo_crosstab->ExportOptions->Render("body"); ?></p>
- <?php $TKTrinhdo_crosstab->ShowPageHeader(); ?>
- <?php $TKTrinhdo_crosstab->ShowMessage(); ?>
- <br><br>
- <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
- </div></td></tr>
- <!-- Top container (end) -->
- <tr>
- <!-- Left container (begin) -->
- <td style="vertical-align: top;"><div id="ewLeft" class="phpreportmaker">
- <!-- left slot -->
- </div></td>
- <!-- Left container (end) -->
- <!-- Center container (report) (begin) -->
- <td style="vertical-align: top;" class="ewPadding"><div id="ewCenter" class="phpreportmaker">
- <!-- center slot -->
- <?php } ?>
- <!-- crosstab report starts -->
- <div id="report_crosstab">
- <?php if ($TKTrinhdo->ShowCurrentFilter) { ?>
- <div id="ewrptFilterList">
- <?php $TKTrinhdo_crosstab->ShowFilterList() ?>
- </div>
- <br>
- <?php } ?>
- <table class="ewGrid" cellspacing="0"><tr>
- <td class="ewGridContent">
- <?php if ($TKTrinhdo->Export == "") { ?>
- <div class="ewGridUpperPanel">
- <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td style="white-space: nowrap;">
- <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKTrinhdo_crosstab->StartGrp, $TKTrinhdo_crosstab->DisplayGrps, $TKTrinhdo_crosstab->TotalGrps) ?>
- <?php if ($Pager->RecordCount > 0) { ?>
- <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?> </span></td>
- <!--first page button-->
- <?php if ($Pager->FirstButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--previous page button-->
- <?php if ($Pager->PrevButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--current page number-->
- <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
- <!--next page button-->
- <?php if ($Pager->NextButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--last page button-->
- <?php if ($Pager->LastButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <td><span class="phpreportmaker"> <?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
- </tr></table>
- </td>
- <td> </td>
- <td>
- <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>
- <?php } else { ?>
- <?php if ($TKTrinhdo_crosstab->Filter == "0=101") { ?>
- <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
- <?php } else { ?>
- <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
- <?php } ?>
- <?php } ?>
- </td>
- <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
- <td style="white-space: nowrap;"> </td>
- <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>
- <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
- <option value="1"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
- <option value="2"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
- <option value="3"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
- <option value="4"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
- <option value="5"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
- <option value="10"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
- <option value="20"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
- <option value="50"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
- <option value="ALL"<?php if ($TKTrinhdo->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
- </select>
- </span></td>
- <?php } ?>
- </tr>
- </table>
- </form>
- </div>
- <?php } ?>
- <!-- Report grid (begin) -->
- <div class="ewGridMiddlePanel">
- <table class="<?php echo $TKTrinhdo_crosstab->ReportTableClass ?>" cellspacing="0">
- <?php if ($TKTrinhdo_crosstab->ShowFirstHeader) { // Show header ?>
- <thead>
- <!-- Table header -->
- <tr>
- <td class="ewRptColSummary" colspan="2" style="white-space: nowrap;"><div class="phpreportmaker"><?php echo $TKTrinhdo->count->FldCaption() ?> (<?php echo $ReportLanguage->Phrase("RptSum") ?>) </div></td>
- <td class="ewRptColHeader" colspan="<?php echo @$TKTrinhdo_crosstab->ColSpan; ?>" style="white-space: nowrap;">
- <?php echo $TKTrinhdo->name->FldCaption() ?>
- </td>
- </tr>
- <tr>
- <td class="ewTableHeader">
- <?php if ($TKTrinhdo->Export <> "") { ?>
- <?php echo $TKTrinhdo->pqlf_name->FldCaption() ?>
- <?php } else { ?>
- <table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><tr>
- <?php if ($TKTrinhdo->SortUrl($TKTrinhdo->pqlf_name) == "") { ?>
- <td style="vertical-align: bottom;"><?php echo $TKTrinhdo->pqlf_name->FldCaption() ?></td>
- <?php } else { ?>
- <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;">
- <?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>
- <?php } ?>
- <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>
- </tr></table>
- <?php } ?>
- </td>
- <td class="ewTableHeader">
- <?php if ($TKTrinhdo->Export <> "") { ?>
- <?php echo $TKTrinhdo->qlf_name->FldCaption() ?>
- <?php } else { ?>
- <table cellspacing="0" class="ewTableHeaderBtn" style="white-space: nowrap;"><tr>
- <?php if ($TKTrinhdo->SortUrl($TKTrinhdo->qlf_name) == "") { ?>
- <td style="vertical-align: bottom;"><?php echo $TKTrinhdo->qlf_name->FldCaption() ?></td>
- <?php } else { ?>
- <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;">
- <?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>
- <?php } ?>
- </tr></table>
- <?php } ?>
- </td>
- <!-- Dynamic columns begin -->
- <?php
- $cntval = count($TKTrinhdo_crosstab->Val);
- for ($iy = 1; $iy < $cntval; $iy++) {
- if ($TKTrinhdo_crosstab->Col[$iy]->Visible) {
- $TKTrinhdo->SummaryCurrentValue[$iy-1] = $TKTrinhdo_crosstab->Col[$iy]->Caption;
- $TKTrinhdo->SummaryViewValue[$iy-1] = $TKTrinhdo->SummaryCurrentValue[$iy-1];
- ?>
- <td class="ewTableHeader"<?php echo $TKTrinhdo->name->CellAttributes() ?>><span<?php echo $TKTrinhdo->name->ViewAttributes() ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
- <?php
- }
- }
- ?>
- <!-- Dynamic columns end -->
- </tr>
- </thead>
- <?php } // End show header ?>
- <tbody>
- <?php
- if ($TKTrinhdo_crosstab->TotalGrps > 0) {
-
- // Set the last group to display if not export all
- if ($TKTrinhdo->ExportAll && $TKTrinhdo->Export <> "") {
- $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->TotalGrps;
- } else {
- $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->StartGrp + $TKTrinhdo_crosstab->DisplayGrps - 1;
- }
-
- // Stop group <= total number of groups
- if (intval($TKTrinhdo_crosstab->StopGrp) > intval($TKTrinhdo_crosstab->TotalGrps)) {
- $TKTrinhdo_crosstab->StopGrp = $TKTrinhdo_crosstab->TotalGrps;
- }
-
- // Navigate
- $TKTrinhdo_crosstab->RecCount = 0;
-
- // Get first row
- if ($TKTrinhdo_crosstab->TotalGrps > 0) {
- $TKTrinhdo_crosstab->GetGrpRow(1);
- $TKTrinhdo_crosstab->GrpCount = 1;
- }
- while ($rsgrp && !$rsgrp->EOF && $TKTrinhdo_crosstab->GrpCount <= $TKTrinhdo_crosstab->DisplayGrps) {
-
- // Build detail SQL
- $sWhere = ewrpt_DetailFilterSQL($TKTrinhdo->pqlf_name, $TKTrinhdo->SqlFirstGroupField(), $TKTrinhdo->pqlf_name->GroupValue());
- if ($TKTrinhdo_crosstab->Filter != "")
- $sWhere = "($TKTrinhdo_crosstab->Filter) AND ($sWhere)";
- $sSql = ewrpt_BuildReportSql($TKTrinhdo_crosstab->SqlSelectWork, $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupBy(), "", $TKTrinhdo->SqlOrderBy(), $sWhere, $TKTrinhdo_crosstab->Sort);
- $rs = $conn->Execute($sSql);
- $rsdtlcnt = ($rs) ? $rs->RecordCount() : 0;
- if ($rsdtlcnt > 0)
- $TKTrinhdo_crosstab->GetRow(1);
- while ($rs && !$rs->EOF) {
- $TKTrinhdo_crosstab->RecCount++;
-
- // Render row
- $TKTrinhdo->ResetCSS();
- $TKTrinhdo->RowType = EWRPT_ROWTYPE_DETAIL;
- $TKTrinhdo_crosstab->RenderRow();
- ?>
- <!-- Data -->
- <tr<?php echo $TKTrinhdo->RowAttributes(); ?>>
- <!-- Trinh do -->
- <td<?php echo $TKTrinhdo->pqlf_name->CellAttributes(); ?>>
- <span<?php echo $TKTrinhdo->pqlf_name->ViewAttributes(); ?>><?php echo $TKTrinhdo->pqlf_name->GroupViewValue; ?></span></td>
- <!-- Chi tiet -->
- <td<?php echo $TKTrinhdo->qlf_name->CellAttributes(); ?>>
- <span<?php echo $TKTrinhdo->qlf_name->ViewAttributes(); ?>><?php echo $TKTrinhdo->qlf_name->GroupViewValue; ?></span></td>
- <!-- Dynamic columns begin -->
- <?php
- $cntcol = count($TKTrinhdo->SummaryViewValue);
- for ($iy = 1; $iy <= $cntcol; $iy++) {
- $bColShow = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Visible : TRUE;
- $sColDesc = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Caption : $ReportLanguage->Phrase("Summary");
- if ($bColShow) {
- ?>
- <!-- <?php //echo $TKTrinhdo_crosstab->Col[$iy]->Caption; ?> -->
- <!-- <?php echo $sColDesc; ?> -->
- <td<?php echo $TKTrinhdo->SummaryCellAttributes($iy-1) ?>><span<?php echo $TKTrinhdo->SummaryViewAttributes($iy-1); ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
- <?php
- }
- }
- ?>
- <!-- Dynamic columns end -->
- </tr>
- <?php
-
- // Accumulate page summary
- $TKTrinhdo_crosstab->AccumulateSummary();
-
- // Get next record
- $TKTrinhdo_crosstab->GetRow(2);
- ?>
- <?php
- } // End detail records loop
- ?>
- <?php
-
- // Process summary level 1
- if ($TKTrinhdo_crosstab->ChkLvlBreak(1)) {
- $TKTrinhdo->ResetCSS();
- $TKTrinhdo->RowType = EWRPT_ROWTYPE_TOTAL;
- $TKTrinhdo->RowTotalType = EWRPT_ROWTOTAL_GROUP;
- $TKTrinhdo->RowTotalSubType = EWRPT_ROWTOTAL_FOOTER;
- $TKTrinhdo->RowGroupLevel = 1;
- $TKTrinhdo_crosstab->RenderRow();
- ?>
- <!-- Summary Trinh do (level 1) -->
- <tr<?php echo $TKTrinhdo->RowAttributes(); ?>>
- <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>
- <!-- Dynamic columns begin -->
- <?php
- $cntcol = count($TKTrinhdo->SummaryViewValue);
- for ($iy = 1; $iy <= $cntcol; $iy++) {
- $bColShow = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Visible : TRUE;
- $sColDesc = ($iy <= $TKTrinhdo_crosstab->ColCount) ? $TKTrinhdo_crosstab->Col[$iy]->Caption : $ReportLanguage->Phrase("Summary");
- if ($bColShow) {
- ?>
- <!-- <?php //echo $TKTrinhdo_crosstab->Col[$iy]->Caption; ?> -->
- <!-- <?php echo $sColDesc; ?> -->
- <td<?php echo $TKTrinhdo->SummaryCellAttributes($iy-1) ?>><span<?php echo $TKTrinhdo->SummaryViewAttributes($iy-1); ?>><?php echo $TKTrinhdo->SummaryViewValue[$iy-1]; ?></span></td>
- <?php
- }
- }
- ?>
- <!-- Dynamic columns end -->
- </tr>
- <?php
-
- // Reset level 1 summary
- $TKTrinhdo_crosstab->ResetLevelSummary(1);
- }
- ?>
- <?php
- $TKTrinhdo_crosstab->GetGrpRow(2);
- $TKTrinhdo_crosstab->GrpCount++;
- }
- ?>
- </tbody>
- <tfoot>
- <?php } ?>
- </tfoot>
- </table>
- </div>
- <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
- <?php if ($TKTrinhdo->Export == "") { ?>
- <div class="ewGridLowerPanel">
- <form action="<?php echo ewrpt_CurrentPage() ?>" name="ewpagerform" id="ewpagerform" class="ewForm">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td style="white-space: nowrap;">
- <?php if (!isset($Pager)) $Pager = new crPrevNextPager($TKTrinhdo_crosstab->StartGrp, $TKTrinhdo_crosstab->DisplayGrps, $TKTrinhdo_crosstab->TotalGrps) ?>
- <?php if ($Pager->RecordCount > 0) { ?>
- <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("Page") ?> </span></td>
- <!--first page button-->
- <?php if ($Pager->FirstButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/firstdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--previous page button-->
- <?php if ($Pager->PrevButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/prevdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--current page number-->
- <td><input type="text" name="pageno" id="pageno" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
- <!--next page button-->
- <?php if ($Pager->NextButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/nextdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <!--last page button-->
- <?php if ($Pager->LastButton->Enabled) { ?>
- <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>
- <?php } else { ?>
- <td><img src="phprptimages/lastdisab.gif" alt="<?php echo $ReportLanguage->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
- <?php } ?>
- <td><span class="phpreportmaker"> <?php echo $ReportLanguage->Phrase("of") ?> <?php echo $Pager->PageCount ?></span></td>
- </tr></table>
- </td>
- <td> </td>
- <td>
- <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>
- <?php } else { ?>
- <?php if ($TKTrinhdo_crosstab->Filter == "0=101") { ?>
- <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("EnterSearchCriteria") ?></span>
- <?php } else { ?>
- <span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("NoRecord") ?></span>
- <?php } ?>
- <?php } ?>
- </td>
- <?php if ($TKTrinhdo_crosstab->TotalGrps > 0) { ?>
- <td style="white-space: nowrap;"> </td>
- <td align="right" style="vertical-align: top; white-space: nowrap;"><span class="phpreportmaker"><?php echo $ReportLanguage->Phrase("GroupsPerPage"); ?>
- <select name="<?php echo EWRPT_TABLE_GROUP_PER_PAGE; ?>" onchange="this.form.submit();">
- <option value="1"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 1) echo " selected=\"selected\"" ?>>1</option>
- <option value="2"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 2) echo " selected=\"selected\"" ?>>2</option>
- <option value="3"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 3) echo " selected=\"selected\"" ?>>3</option>
- <option value="4"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 4) echo " selected=\"selected\"" ?>>4</option>
- <option value="5"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 5) echo " selected=\"selected\"" ?>>5</option>
- <option value="10"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 10) echo " selected=\"selected\"" ?>>10</option>
- <option value="20"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 20) echo " selected=\"selected\"" ?>>20</option>
- <option value="50"<?php if ($TKTrinhdo_crosstab->DisplayGrps == 50) echo " selected=\"selected\"" ?>>50</option>
- <option value="ALL"<?php if ($TKTrinhdo->getGroupPerPage() == -1) echo " selected=\"selected\"" ?>><?php echo $ReportLanguage->Phrase("AllRecords") ?></option>
- </select>
- </span></td>
- <?php } ?>
- </tr>
- </table>
- </form>
- </div>
- <?php } ?>
- <?php } ?>
- </td></tr></table>
- </div>
- <!-- Crosstab report ends -->
- <?php if ($TKTrinhdo->Export == "" || $TKTrinhdo->Export == "print" || $TKTrinhdo->Export == "email") { ?>
- </div><br></td>
- <!-- Center container (report) (end) -->
- <!-- Right container (begin) -->
- <td style="vertical-align: top;"><div id="ewRight" class="phpreportmaker">
- <!-- Right slot -->
- </div></td>
- <!-- Right container (end) -->
- </tr>
- <!-- Bottom container (begin) -->
- <tr><td colspan="3"><div id="ewBottom" class="phpreportmaker">
- <!-- Bottom slot -->
- </div><br></td></tr>
- <!-- Bottom container (end) -->
- </table>
- <!-- Table container (end) -->
- <?php } ?>
- <?php $TKTrinhdo_crosstab->ShowPageFooter(); ?>
- <?php if (EWRPT_DEBUG_ENABLED) echo ewrpt_DebugMsg(); ?>
- <?php
-
- // Close recordsets
- if ($rsgrp) $rsgrp->Close();
- if ($rs) $rs->Close();
- ?>
- <?php if ($TKTrinhdo->Export == "") { ?>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php } ?>
- <?php include_once "phprptinc/footer.php"; ?>
- <?php
- $TKTrinhdo_crosstab->Page_Terminate();
- ?>
- <?php
-
- //
- // Page class
- //
- class crTKTrinhdo_crosstab {
-
- // Page ID
- var $PageID = 'crosstab';
-
- // Table name
- var $TableName = 'TKTrinhdo';
-
- // Page object name
- var $PageObjName = 'TKTrinhdo_crosstab';
-
- // Page name
- function PageName() {
- return ewrpt_CurrentPage();
- }
-
- // Page URL
- function PageUrl() {
- $PageUrl = ewrpt_CurrentPage() . "?";
- global $TKTrinhdo;
- if ($TKTrinhdo->UseTokenInUrl) $PageUrl .= "t=" . $TKTrinhdo->TableVar . "&"; // Add page token
- return $PageUrl;
- }
-
- // Export URLs
- var $ExportPrintUrl;
- var $ExportExcelUrl;
- var $ExportWordUrl;
- var $ExportPdfUrl;
- var $ReportTableClass;
-
- // Message
- function getMessage() {
- return @$_SESSION[EWRPT_SESSION_MESSAGE];
- }
-
- function setMessage($v) {
- if (@$_SESSION[EWRPT_SESSION_MESSAGE] <> "") { // Append
- $_SESSION[EWRPT_SESSION_MESSAGE] .= "<br>" . $v;
- } else {
- $_SESSION[EWRPT_SESSION_MESSAGE] = $v;
- }
- }
-
- // Show message
- function ShowMessage() {
- $sMessage = $this->getMessage();
- $this->Message_Showing($sMessage);
- if ($sMessage <> "") { // Message in Session, display
- echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
- $_SESSION[EWRPT_SESSION_MESSAGE] = ""; // Clear message in Session
- }
- }
- var $PageHeader;
- var $PageFooter;
-
- // Show Page Header
- function ShowPageHeader() {
- $sHeader = $this->PageHeader;
- $this->Page_DataRendering($sHeader);
- if ($sHeader <> "") { // Header exists, display
- echo "<p><span class=\"phpreportmaker\">" . $sHeader . "</span></p>";
- }
- }
-
- // Show Page Footer
- function ShowPageFooter() {
- $sFooter = $this->PageFooter;
- $this->Page_DataRendered($sFooter);
- if ($sFooter <> "") { // Fotoer exists, display
- echo "<p><span class=\"phpreportmaker\">" . $sFooter . "</span></p>";
- }
- }
-
- // Validate page request
- function IsPageRequest() {
- global $TKTrinhdo;
- if ($TKTrinhdo->UseTokenInUrl) {
- if (ewrpt_IsHttpPost())
- return ($TKTrinhdo->TableVar == @$_POST("t"));
- if (@$_GET["t"] <> "")
- return ($TKTrinhdo->TableVar == @$_GET["t"]);
- } else {
- return TRUE;
- }
- }
-
- //
- // Page class constructor
- //
- function crTKTrinhdo_crosstab() {
- global $conn, $ReportLanguage;
-
- // Language object
- $ReportLanguage = new crLanguage();
-
- // Table object (TKTrinhdo)
- $GLOBALS["TKTrinhdo"] = new crTKTrinhdo();
- $GLOBALS["Table"] =& $GLOBALS["TKTrinhdo"];
-
- // Initialize URLs
- $this->ExportPrintUrl = $this->PageUrl() . "export=print";
- $this->ExportExcelUrl = $this->PageUrl() . "export=excel";
- $this->ExportWordUrl = $this->PageUrl() . "export=word";
- $this->ExportPdfUrl = $this->PageUrl() . "export=pdf";
-
- // Page ID
- if (!defined("EWRPT_PAGE_ID"))
- define("EWRPT_PAGE_ID", 'crosstab', TRUE);
-
- // Table name (for backward compatibility)
- if (!defined("EWRPT_TABLE_NAME"))
- define("EWRPT_TABLE_NAME", 'TKTrinhdo', TRUE);
-
- // Start timer
- $GLOBALS["gsTimer"] = new crTimer();
-
- // Open connection
- $conn = ewrpt_Connect();
-
- // Export options
- $this->ExportOptions = new crListOptions();
- $this->ExportOptions->Tag = "span";
- $this->ExportOptions->Separator = " ";
- }
-
- //
- // Page_Init
- //
- function Page_Init() {
- global $gsExport, $gsExportFile, $ReportLanguage, $Security;
- global $TKTrinhdo;
-
- // Get export parameters
- if (@$_GET["export"] <> "") {
- $TKTrinhdo->Export = $_GET["export"];
- }
- $gsExport = $TKTrinhdo->Export; // Get export parameter, used in header
- $gsExportFile = $TKTrinhdo->TableVar; // Get export file, used in header
- if ($TKTrinhdo->Export == "excel") {
- header('Content-Type: application/vnd.ms-excel;charset=utf-8');
- header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
- }
- if ($TKTrinhdo->Export == "word") {
- header('Content-Type: application/vnd.ms-word;charset=utf-8');
- header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
- }
-
- // Setup export options
- $this->SetupExportOptions();
-
- // Global Page Loading event (in userfn*.php)
- Page_Loading();
-
- // Page Load event
- $this->Page_Load();
- }
-
- // Set up export options
- function SetupExportOptions() {
- global $ReportLanguage, $TKTrinhdo;
-
- // Printer friendly
- $item =& $this->ExportOptions->Add("print");
- $item->Body = "<a href=\"" . $this->ExportPrintUrl . "\">" . $ReportLanguage->Phrase("PrinterFriendly") . "</a>";
- $item->Visible = TRUE;
-
- // Export to Excel
- $item =& $this->ExportOptions->Add("excel");
- $item->Body = "<a href=\"" . $this->ExportExcelUrl . "\">" . $ReportLanguage->Phrase("ExportToExcel") . "</a>";
- $item->Visible = TRUE;
-
- // Export to Word
- $item =& $this->ExportOptions->Add("word");
- $item->Body = "<a href=\"" . $this->ExportWordUrl . "\">" . $ReportLanguage->Phrase("ExportToWord") . "</a>";
- $item->Visible = TRUE;
-
- // Export to Pdf
- $item =& $this->ExportOptions->Add("pdf");
- $item->Body = "<a href=\"" . $this->ExportPdfUrl . "\">" . $ReportLanguage->Phrase("ExportToPDF") . "</a>";
- $item->Visible = FALSE;
-
- // Uncomment codes below to show export to Pdf link
- // $item->Visible = FALSE;
- // Export to Email
-
- $item =& $this->ExportOptions->Add("email");
- $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>";
- $item->Visible = FALSE;
-
- // Reset filter
- $item =& $this->ExportOptions->Add("resetfilter");
- $item->Body = "<a href=\"" . ewrpt_CurrentPage() . "?cmd=reset\">" . $ReportLanguage->Phrase("ResetAllFilter") . "</a>";
- $item->Visible = TRUE;
- $this->SetupExportOptionsExt();
-
- // Hide options for export
- if ($TKTrinhdo->Export <> "")
- $this->ExportOptions->HideAllOptions();
-
- // Set up table class
- if ($TKTrinhdo->Export == "word" || $TKTrinhdo->Export == "excel" || $TKTrinhdo->Export == "pdf")
- $this->ReportTableClass = "ewTable";
- else
- $this->ReportTableClass = "ewTable ewTableSeparate";
- }
-
- //
- // Page_Terminate
- //
- function Page_Terminate($url = "") {
- global $conn;
- global $ReportLanguage;
- global $TKTrinhdo;
-
- // Page Unload event
- $this->Page_Unload();
-
- // Global Page Unloaded event (in userfn*.php)
- Page_Unloaded();
-
- // Export to Email (use ob_file_contents for PHP)
- if ($TKTrinhdo->Export == "email") {
- $sContent = ob_get_contents();
- $this->ExportEmail($sContent);
- ob_end_clean();
-
- // Close connection
- $conn->Close();
- header("Location: " . ewrpt_CurrentPage());
- exit();
- }
-
- // Export to PDF (use ob_file_contents for PHP)
- if ($TKTrinhdo->Export == "pdf") {
- $sContent = ob_get_contents();
- $this->ExportPDF($sContent);
- ob_end_clean();
-
- // Close connection
- $conn->Close();
- }
-
- // Close connection
- $conn->Close();
-
- // Go to URL if specified
- if ($url <> "") {
- if (!EWRPT_DEBUG_ENABLED && ob_get_length())
- ob_end_clean();
- header("Location: " . $url);
- }
- exit();
- }
-
- // Initialize common variables
- var $ExportOptions; // Export options
-
- // Paging variables
- var $RecCount = 0; // Record count
- var $StartGrp = 0; // Start group
- var $StopGrp = 0; // Stop group
- var $TotalGrps = 0; // Total groups
- var $GrpCount = 0; // Group count
- var $DisplayGrps = 20; // Groups per page
- var $GrpRange = 10;
- var $Sort = "";
- var $Filter = "";
- var $UserIDFilter = "";
-
- // Clear field for ext filter
- var $ClearExtFilter = "";
- var $FilterApplied;
- var $ShowFirstHeader;
- var $Cnt, $Col, $Val, $Smry;
- var $ColCount, $ColSpan;
- var $SqlSelectWork, $SqlSelectAggWork;
- var $SqlChartWork;
-
- //
- // Page main
- //
- function Page_Main() {
- global $TKTrinhdo;
- global $rs;
- global $rsgrp;
- global $gsFormError;
-
- // Get sort
- $this->Sort = $this->GetSort();
-
- // Set up groups per page dynamically
- $this->SetUpDisplayGrps();
-
- // Popup values and selections
- $TKTrinhdo->pqlf_name->SelectionList = "";
- $TKTrinhdo->pqlf_name->DefaultSelectionList = "";
- $TKTrinhdo->pqlf_name->ValueList = "";
-
- // Load default filter values
- $this->LoadDefaultFilters();
-
- // Load custom filters
- $TKTrinhdo->Filters_Load();
-
- // Set up popup filter
- $this->SetupPopup();
-
- // Extended filter
- $sExtendedFilter = "";
-
- // Load columns to array
- $this->GetColumns();
-
- // Build popup filter
- $sPopupFilter = $this->GetPopupFilter();
-
- //ewrpt_SetDebugMsg("popup filter: " . $sPopupFilter);
- if ($sPopupFilter <> "") {
- if ($this->Filter <> "")
- $this->Filter = "($this->Filter) AND ($sPopupFilter)";
- else
- $this->Filter = $sPopupFilter;
- }
-
- // Check if filter applied
- $this->FilterApplied = $this->CheckFilter();
- $this->ExportOptions->GetItem("resetfilter")->Visible = $this->FilterApplied;
-
- // Get total group count
- $sGrpSort = ewrpt_UpdateSortFields($TKTrinhdo->SqlOrderByGroup(), $this->Sort, 2); // Get grouping field only
- $sSql = ewrpt_BuildReportSql($TKTrinhdo->SqlSelectGroup(), $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupBy(), "", $TKTrinhdo->SqlOrderByGroup(), $this->Filter, $sGrpSort);
- $this->TotalGrps = $this->GetGrpCnt($sSql);
- if ($this->DisplayGrps <= 0) // Display all groups
- $this->DisplayGrps = $this->TotalGrps;
- $this->StartGrp = 1;
-
- // Show header
- $this->ShowFirstHeader = ($this->TotalGrps > 0);
-
- //$this->ShowFirstHeader = TRUE; // Uncomment to always show header
- // Set up start position if not export all
-
- if ($TKTrinhdo->ExportAll && $TKTrinhdo->Export <> "")
- $this->DisplayGrps = $this->TotalGrps;
- else
- $this->SetUpStartGroup();
-
- // Hide all options if export
- if ($TKTrinhdo->Export <> "") {
- $this->ExportOptions->HideAllOptions();
- }
-
- // Get total groups
- $rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
-
- // Init detail recordset
- $rs = NULL;
-
- // Set up column attributes
- $TKTrinhdo->name->ViewAttrs["style"] = "";
- $TKTrinhdo->name->CellAttrs["style"] = "white-space: nowrap; vertical-align: top;";
- }
-
- // Get column values
- function GetColumns() {
- global $conn;
- global $TKTrinhdo;
- global $ReportLanguage;
-
- // Build SQL
- $sSql = ewrpt_BuildReportSql($TKTrinhdo->SqlDistinctSelect(), $TKTrinhdo->SqlDistinctWhere(), "", "", $TKTrinhdo->SqlDistinctOrderBy(), $this->Filter, "");
-
- // Load recordset
- $rscol = $conn->Execute($sSql);
-
- // Get distinct column count
- $this->ColCount = ($rscol) ? $rscol->RecordCount() : 0;
-
- /* Uncomment to show phrase
- if ($this->ColCount == 0) {
- if ($rscol) $rscol->Close();
- echo $ReportLanguage->Phrase("NoDistinctColVals") . $sSql . "<br>";
- exit();
- }
- */
-
- // 1st dimension = no of groups (level 0 used for grand total)
- // 2nd dimension = no of distinct values
-
- $nGrps = 2;
- $this->Col =& ewrpt_InitArray($this->ColCount+1, NULL);
- $this->Val =& ewrpt_InitArray($this->ColCount+1, NULL);
- $this->ValCnt =& ewrpt_InitArray($this->ColCount+1, NULL);
- $this->Cnt =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
- $this->Smry =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
- $this->SmryCnt =& ewrpt_Init2DArray($this->ColCount+1, $nGrps+1, NULL);
-
- // Reset summary values
- $this->ResetLevelSummary(0);
- $colcnt = 0;
- while (!$rscol->EOF) {
- if (is_null($rscol->fields[0])) {
- $wrkValue = EWRPT_NULL_VALUE;
- $wrkCaption = $ReportLanguage->Phrase("NullLabel");
- } elseif ($rscol->fields[0] == "") {
- $wrkValue = EWRPT_EMPTY_VALUE;
- $wrkCaption = $ReportLanguage->Phrase("EmptyLabel");
- } else {
- $wrkValue = $rscol->fields[0];
- $wrkCaption = $rscol->fields[0];
- }
- $colcnt++;
- $this->Col[$colcnt] = new crCrosstabColumn($wrkValue, $wrkCaption, TRUE);
- $rscol->MoveNext();
- }
- $rscol->Close();
-
- // Get active columns
- if (!is_array($TKTrinhdo->name->SelectionList)) {
- $this->ColSpan = $this->ColCount;
- } else {
- $this->ColSpan = 0;
- for ($i = 1; $i <= $this->ColCount; $i++) {
- $bSelected = FALSE;
- $cntsel = count($TKTrinhdo->name->SelectionList);
- for ($j = 0; $j < $cntsel; $j++) {
- if (ewrpt_CompareValue($TKTrinhdo->name->SelectionList[$j], $this->Col[$i]->Value, $TKTrinhdo->name->FldType)) {
- $this->ColSpan++;
- $bSelected = TRUE;
- break;
- }
- }
- $this->Col[$i]->Visible = $bSelected;
- }
- }
-
- // Update crosstab sql
- $sSqlFlds = "";
- for ($colcnt = 1; $colcnt <= $this->ColCount; $colcnt++) {
- $sFld = ewrpt_CrossTabField($TKTrinhdo->SummaryType(), $TKTrinhdo->SummaryField(), $TKTrinhdo->ColumnField(), $TKTrinhdo->ColumnDateType(), $this->Col[$colcnt]->Value, "'", "C" . $colcnt);
- if ($sSqlFlds <> "")
- $sSqlFlds .= ", ";
- $sSqlFlds .= $sFld;
- }
- $this->SqlSelectWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $TKTrinhdo->SqlSelect());
- $this->SqlSelectAggWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $TKTrinhdo->SqlSelectAgg());
-
- // Update chart sql if Y Axis = Column Field
- $this->SqlChartWork = "";
- for ($i = 0; $i < $this->ColCount; $i++) {
- if ($this->Col[$i+1]->Visible) {
- $sChtFld = ewrpt_CrossTabField("SUM", $TKTrinhdo->SummaryField(), $TKTrinhdo->ColumnField(), $TKTrinhdo->ColumnDateType(), $this->Col[$i+1]->Value, "'");
- if ($this->SqlChartWork != "") $this->SqlChartWork .= "+";
- $this->SqlChartWork .= $sChtFld;
- }
- }
- }
-
- // Get group count
- function GetGrpCnt($sql) {
- global $conn;
- $rsgrpcnt = $conn->Execute($sql);
- $grpcnt = ($rsgrpcnt) ? $rsgrpcnt->RecordCount() : 0;
- if ($rsgrpcnt) $rsgrpcnt->Close();
- return $grpcnt;
- }
-
- // Get group rs
- function GetGrpRs($sql, $start, $grps) {
- global $conn;
- $wrksql = $sql;
- if ($start > 0 && $grps > -1)
- $wrksql .= " LIMIT " . ($start-1) . ", " . ($grps);
- $rswrk = $conn->Execute($wrksql);
- return $rswrk;
- }
-
- // Get group row values
- function GetGrpRow($opt) {
- global $rsgrp;
- global $TKTrinhdo;
- if (!$rsgrp)
- return;
- if ($opt == 1) { // Get first group
-
- // $rsgrp->MoveFirst(); // NOTE: no need to move position
- $TKTrinhdo->pqlf_name->setDbValue(""); // Init first value
- } else { // Get next group
- $rsgrp->MoveNext();
- }
- if (!$rsgrp->EOF) {
- $TKTrinhdo->pqlf_name->setDbValue($rsgrp->fields[0]);
- } else {
- $TKTrinhdo->pqlf_name->setDbValue("");
- }
- }
-
- // Get row values
- function GetRow($opt) {
- global $rs;
- global $TKTrinhdo;
- if (!$rs)
- return;
- if ($opt == 1) { // Get first row
-
- // $rs->MoveFirst(); // NOTE: no need to move position
- } else { // Get next row
- $rs->MoveNext();
- }
- if (!$rs->EOF) {
- if ($opt <> 1)
- $TKTrinhdo->pqlf_name->setDbValue($rs->fields('pqlf_name'));
- $TKTrinhdo->qlf_name->setDbValue($rs->fields('qlf_name'));
- $cntval = count($this->Val);
- for ($ix = 1; $ix < $cntval; $ix++)
- $this->Val[$ix] = $rs->fields[$ix+2-1];
- } else {
- $TKTrinhdo->pqlf_name->setDbValue("");
- $TKTrinhdo->qlf_name->setDbValue("");
- }
- }
-
- // Check level break
- function ChkLvlBreak($lvl) {
- global $TKTrinhdo;
- switch ($lvl) {
- case 1:
- return (is_null($TKTrinhdo->pqlf_name->CurrentValue) && !is_null($TKTrinhdo->pqlf_name->OldValue)) ||
- (!is_null($TKTrinhdo->pqlf_name->CurrentValue) && is_null($TKTrinhdo->pqlf_name->OldValue)) ||
- ($TKTrinhdo->pqlf_name->GroupValue() <> $TKTrinhdo->pqlf_name->GroupOldValue());
- case 2:
- return (is_null($TKTrinhdo->qlf_name->CurrentValue) && !is_null($TKTrinhdo->qlf_name->OldValue)) ||
- (!is_null($TKTrinhdo->qlf_name->CurrentValue) && is_null($TKTrinhdo->qlf_name->OldValue)) ||
- ($TKTrinhdo->qlf_name->GroupValue() <> $TKTrinhdo->qlf_name->GroupOldValue()) || $this->ChkLvlBreak(1); // Recurse upper level
- }
- }
-
- // Accummulate summary
- function AccumulateSummary() {
- global $TKTrinhdo;
- $cntx = count($this->Smry);
- for ($ix = 1; $ix < $cntx; $ix++) {
- $cnty = count($this->Smry[$ix]);
- for ($iy = 0; $iy < $cnty; $iy++) {
- $valwrk = $this->Val[$ix];
- $this->Cnt[$ix][$iy]++;
- $this->Smry[$ix][$iy] = ewrpt_SummaryValue($this->Smry[$ix][$iy], $valwrk, $TKTrinhdo->SummaryType());
- }
- }
- }
-
- // Reset level summary
- function ResetLevelSummary($lvl) {
-
- // Clear summary values
- $cntx = count($this->Smry);
- for ($ix = 1; $ix < $cntx; $ix++) {
- $cnty = count($this->Smry[$ix]);
- for ($iy = $lvl; $iy < $cnty; $iy++) {
- $this->Cnt[$ix][$iy] = 0;
- $this->Smry[$ix][$iy] = 0;
- }
- }
-
- // Reset record count
- $this->RecCount = 0;
- }
-
- // Set up starting group
- function SetUpStartGroup() {
- global $TKTrinhdo;
-
- // Exit if no groups
- if ($this->DisplayGrps == 0)
- return;
-
- // Check for a 'start' parameter
- if (@$_GET[EWRPT_TABLE_START_GROUP] != "") {
- $this->StartGrp = $_GET[EWRPT_TABLE_START_GROUP];
- $TKTrinhdo->setStartGroup($this->StartGrp);
- } elseif (@$_GET["pageno"] != "") {
- $nPageNo = $_GET["pageno"];
- if (is_numeric($nPageNo)) {
- $this->StartGrp = ($nPageNo-1)*$this->DisplayGrps+1;
- if ($this->StartGrp <= 0) {
- $this->StartGrp = 1;
- } elseif ($this->StartGrp >= intval(($this->TotalGrps-1)/$this->DisplayGrps)*$this->DisplayGrps+1) {
- $this->StartGrp = intval(($this->TotalGrps-1)/$this->DisplayGrps)*$this->DisplayGrps+1;
- }
- $TKTrinhdo->setStartGroup($this->StartGrp);
- } else {
- $this->StartGrp = $TKTrinhdo->getStartGroup();
- }
- } else {
- $this->StartGrp = $TKTrinhdo->getStartGroup();
- }
-
- // Check if correct start group counter
- if (!is_numeric($this->StartGrp) || $this->StartGrp == "") { // Avoid invalid start group counter
- $this->StartGrp = 1; // Reset start group counter
- $TKTrinhdo->setStartGroup($this->StartGrp);
- } elseif (intval($this->StartGrp) > intval($this->TotalGrps)) { // Avoid starting group > total groups
- $this->StartGrp = intval(($this->TotalGrps-1)/$this->DisplayGrps) * $this->DisplayGrps + 1; // Point to last page first group
- $TKTrinhdo->setStartGroup($this->StartGrp);
- } elseif (($this->StartGrp-1) % $this->DisplayGrps <> 0) {
- $this->StartGrp = intval(($this->StartGrp-1)/$this->DisplayGrps) * $this->DisplayGrps + 1; // Point to page boundary
- $TKTrinhdo->setStartGroup($this->StartGrp);
- }
- }
-
- // Set up popup
- function SetupPopup() {
- global $conn, $ReportLanguage;
- global $TKTrinhdo;
-
- // Build distinct values for Trinh do
- $bNullValue = FALSE;
- $bEmptyValue = FALSE;
- $sSql = ewrpt_BuildReportSql($TKTrinhdo->pqlf_name->SqlSelect, $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupBy(), $TKTrinhdo->SqlHaving(), $TKTrinhdo->pqlf_name->SqlOrderBy, $this->Filter, "");
- $rswrk = $conn->Execute($sSql);
- while ($rswrk && !$rswrk->EOF) {
- $TKTrinhdo->pqlf_name->setDbValue($rswrk->fields[0]);
- if (is_null($TKTrinhdo->pqlf_name->CurrentValue)) {
- $bNullValue = TRUE;
- } elseif ($TKTrinhdo->pqlf_name->CurrentValue == "") {
- $bEmptyValue = TRUE;
- } else {
- $TKTrinhdo->pqlf_name->GroupViewValue = $TKTrinhdo->pqlf_name->GroupValue();
- ewrpt_SetupDistinctValues($TKTrinhdo->pqlf_name->ValueList, $TKTrinhdo->pqlf_name->GroupValue(), $TKTrinhdo->pqlf_name->GroupViewValue, FALSE);
- }
- $rswrk->MoveNext();
- }
- if ($rswrk)
- $rswrk->Close();
- if ($bEmptyValue)
- ewrpt_SetupDistinctValues($TKTrinhdo->pqlf_name->ValueList, EWRPT_EMPTY_VALUE, $ReportLanguage->Phrase("EmptyLabel"), FALSE);
- if ($bNullValue)
- ewrpt_SetupDistinctValues($TKTrinhdo->pqlf_name->ValueList, EWRPT_NULL_VALUE, $ReportLanguage->Phrase("NullLabel"), FALSE);
-
- // Process post back form
- if (ewrpt_IsHttpPost()) {
- $sName = @$_POST["popup"]; // Get popup form name
- if ($sName <> "") {
- $cntValues = (is_array(@$_POST["sel_$sName"])) ? count($_POST["sel_$sName"]) : 0;
- if ($cntValues > 0) {
- $arValues = ewrpt_StripSlashes($_POST["sel_$sName"]);
- if (trim($arValues[0]) == "") // Select all
- $arValues = EWRPT_INIT_VALUE;
- $_SESSION["sel_$sName"] = $arValues;
- $_SESSION["rf_$sName"] = ewrpt_StripSlashes(@$_POST["rf_$sName"]);
- $_SESSION["rt_$sName"] = ewrpt_StripSlashes(@$_POST["rt_$sName"]);
- $this->ResetPager();
- }
- }
-
- // Get 'reset' command
- } elseif (@$_GET["cmd"] <> "") {
- $sCmd = $_GET["cmd"];
- if (strtolower($sCmd) == "reset") {
- $this->ClearSessionSelection('pqlf_name');
- $this->ResetPager();
- }
- }
-
- // Load selection criteria to array
- // Get Trinh do selected values
-
- if (is_array(@$_SESSION["sel_TKTrinhdo_pqlf_name"])) {
- $this->LoadSelectionFromSession('pqlf_name');
- } elseif (@$_SESSION["sel_TKTrinhdo_pqlf_name"] == EWRPT_INIT_VALUE) { // Select all
- $TKTrinhdo->pqlf_name->SelectionList = "";
- }
- }
-
- // Reset pager
- function ResetPager() {
- global $TKTrinhdo;
-
- // Reset start position (reset command)
- $this->StartGrp = 1;
- $TKTrinhdo->setStartGroup($this->StartGrp);
- }
-
- // Check if any column values is present
- function HasColumnValues(&$rs) {
- $cntcol = count($this->Col);
- for ($i = 1; $i < $cntcol; $i++) {
- if ($this->Col[$i]->Visible) {
- if ($rs->fields[2+$i-1] <> 0) return TRUE;
- }
- }
- return FALSE;
- }
-
- // Set up number of groups displayed per page
- function SetUpDisplayGrps() {
- global $TKTrinhdo;
- $sWrk = @$_GET[EWRPT_TABLE_GROUP_PER_PAGE];
- if ($sWrk <> "") {
- if (is_numeric($sWrk)) {
- $this->DisplayGrps = intval($sWrk);
- } else {
- if (strtoupper($sWrk) == "ALL") { // display all groups
- $this->DisplayGrps = -1;
- } else {
- $this->DisplayGrps = 20; // Non-numeric, load default
- }
- }
- $TKTrinhdo->setGroupPerPage($this->DisplayGrps); // Save to session
-
- // Reset start position (reset command)
- $this->StartGrp = 1;
- $TKTrinhdo->setStartGroup($this->StartGrp);
- } else {
- if ($TKTrinhdo->getGroupPerPage() <> "") {
- $this->DisplayGrps = $TKTrinhdo->getGroupPerPage(); // Restore from session
- } else {
- $this->DisplayGrps = 20; // Load default
- }
- }
- }
-
- function RenderRow() {
- global $conn, $Security;
- global $TKTrinhdo;
-
- // Set up summary values
- $colcnt = $this->ColCount;
- $TKTrinhdo->SummaryCellAttrs =& ewrpt_InitArray($colcnt, NULL);
- $TKTrinhdo->SummaryViewAttrs =& ewrpt_InitArray($colcnt, NULL);
- $TKTrinhdo->SummaryCurrentValue =& ewrpt_InitArray($colcnt, NULL);
- $TKTrinhdo->SummaryViewValue =& ewrpt_InitArray($colcnt, NULL);
- if ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_GRAND) { // Grand total
-
- // aggregate sql
- $sSql = ewrpt_BuildReportSql($this->SqlSelectAggWork, $TKTrinhdo->SqlWhere(), $TKTrinhdo->SqlGroupByAgg(), "", "", $this->Filter, "");
- $rsagg = $conn->Execute($sSql);
- if ($rsagg && !$rsagg->EOF) $rsagg->MoveFirst();
- }
- for ($i = 1; $i <= $this->ColCount; $i++) {
- if ($this->Col[$i]->Visible) {
- if ($TKTrinhdo->RowType == EWRPT_ROWTYPE_DETAIL) { // Detail row
- $thisval = $this->Val[$i];
- } elseif ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_GROUP) { // Group total
- $thisval = $this->Smry[$i][$TKTrinhdo->RowGroupLevel];
- } elseif ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_PAGE) { // Page total
- $thisval = $this->Smry[$i][0];
- } elseif ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_GRAND) { // Grand total
- $thisval = ($rsagg && !$rsagg->EOF) ? $rsagg->fields[$i+0-1] : 0;
- }
- $TKTrinhdo->SummaryCurrentValue[$i-1] = $thisval;
- }
- }
- if ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_GRAND) { // Grand total
- if ($rsagg) $rsagg->Close();
- }
-
- // Call Row_Rendering event
- $TKTrinhdo->Row_Rendering();
-
- //
- // Render view codes
- //
-
- if ($TKTrinhdo->RowType == EWRPT_ROWTYPE_TOTAL) { // Summary row
-
- // pqlf_name
- $TKTrinhdo->pqlf_name->GroupViewValue = $TKTrinhdo->pqlf_name->GroupOldValue();
- $TKTrinhdo->pqlf_name->CellAttrs["class"] = ($TKTrinhdo->RowGroupLevel == 1) ? "ewRptGrpSummary1" : "ewRptGrpField1";
- $TKTrinhdo->pqlf_name->CellAttrs["style"] = "white-space: nowrap;";
-
- // qlf_name
- $TKTrinhdo->qlf_name->GroupViewValue = $TKTrinhdo->qlf_name->GroupOldValue();
- $TKTrinhdo->qlf_name->CellAttrs["class"] = ($TKTrinhdo->RowGroupLevel == 2) ? "ewRptGrpSummary2" : "ewRptGrpField2";
- $TKTrinhdo->qlf_name->CellAttrs["style"] = "white-space: nowrap;";
-
- // Set up summary values
- $scvcnt = count($TKTrinhdo->SummaryCurrentValue);
- for ($i = 0; $i < $scvcnt; $i++) {
- $TKTrinhdo->SummaryViewValue[$i] = $TKTrinhdo->SummaryCurrentValue[$i];
- $TKTrinhdo->SummaryViewAttrs[$i]["style"] = "";
- $TKTrinhdo->SummaryCellAttrs[$i]["style"] = "";
- $TKTrinhdo->SummaryCellAttrs[$i]["class"] = ($TKTrinhdo->RowTotalType == EWRPT_ROWTOTAL_GROUP) ? "ewRptGrpSummary" . $TKTrinhdo->RowGroupLevel : "";
- }
-
- // pqlf_name
- $TKTrinhdo->pqlf_name->HrefValue = "";
-
- // qlf_name
- $TKTrinhdo->qlf_name->HrefValue = "";
- } else {
-
- // pqlf_name
- $TKTrinhdo->pqlf_name->GroupViewValue = $TKTrinhdo->pqlf_name->GroupValue();
- $TKTrinhdo->pqlf_name->CellAttrs["class"] = "ewRptGrpField1";
- $TKTrinhdo->pqlf_name->CellAttrs["style"] = "white-space: nowrap;";
- if ($TKTrinhdo->pqlf_name->GroupValue() == $TKTrinhdo->pqlf_name->GroupOldValue() && !$this->ChkLvlBreak(1))
- $TKTrinhdo->pqlf_name->GroupViewValue = " ";
-
- // qlf_name
- $TKTrinhdo->qlf_name->GroupViewValue = $TKTrinhdo->qlf_name->GroupValue();
- $TKTrinhdo->qlf_name->CellAttrs["class"] = "ewRptGrpField2";
- $TKTrinhdo->qlf_name->CellAttrs["style"] = "white-space: nowrap;";
- if ($TKTrinhdo->qlf_name->GroupValue() == $TKTrinhdo->qlf_name->GroupOldValue() && !$this->ChkLvlBreak(2))
- $TKTrinhdo->qlf_name->GroupViewValue = " ";
-
- // Set up summary values
- $scvcnt = count($TKTrinhdo->SummaryCurrentValue);
- for ($i = 0; $i < $scvcnt; $i++) {
- $TKTrinhdo->SummaryViewValue[$i] = $TKTrinhdo->SummaryCurrentValue[$i];
- $TKTrinhdo->SummaryViewAttrs[$i]["style"] = "";
- $TKTrinhdo->SummaryCellAttrs[$i]["style"] = "";
- $TKTrinhdo->SummaryCellAttrs[$i]["class"] = ($this->RecCount % 2 <> 1) ? "ewTableAltRow" : "ewTableRow";
- }
-
- // pqlf_name
- $TKTrinhdo->pqlf_name->HrefValue = "";
-
- // qlf_name
- $TKTrinhdo->qlf_name->HrefValue = "";
- }
-
- // Call Cell_Rendered event
- if ($TKTrinhdo->RowType == EWRPT_ROWTYPE_TOTAL) { // Summary row
-
- // pqlf_name
- $CurrentValue = $TKTrinhdo->pqlf_name->GroupOldValue();
- $ViewValue =& $TKTrinhdo->pqlf_name->GroupViewValue;
- $ViewAttrs =& $TKTrinhdo->pqlf_name->ViewAttrs;
- $CellAttrs =& $TKTrinhdo->pqlf_name->CellAttrs;
- $HrefValue =& $TKTrinhdo->pqlf_name->HrefValue;
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->pqlf_name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
-
- // qlf_name
- $CurrentValue = $TKTrinhdo->qlf_name->GroupOldValue();
- $ViewValue =& $TKTrinhdo->qlf_name->GroupViewValue;
- $ViewAttrs =& $TKTrinhdo->qlf_name->ViewAttrs;
- $CellAttrs =& $TKTrinhdo->qlf_name->CellAttrs;
- $HrefValue =& $TKTrinhdo->qlf_name->HrefValue;
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->qlf_name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
- for ($i = 0; $i < $scvcnt; $i++) {
- $CurrentValue = $TKTrinhdo->SummaryCurrentValue[$i];
- $ViewValue =& $TKTrinhdo->SummaryViewValue[$i];
- $ViewAttrs =& $TKTrinhdo->SummaryViewAttrs[$i];
- $CellAttrs =& $TKTrinhdo->SummaryCellAttrs[$i];
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->count, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
- }
- } else {
-
- // pqlf_name
- $CurrentValue = $TKTrinhdo->pqlf_name->GroupValue();
- $ViewValue =& $TKTrinhdo->pqlf_name->GroupViewValue;
- $ViewAttrs =& $TKTrinhdo->pqlf_name->ViewAttrs;
- $CellAttrs =& $TKTrinhdo->pqlf_name->CellAttrs;
- $HrefValue =& $TKTrinhdo->pqlf_name->HrefValue;
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->pqlf_name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
-
- // qlf_name
- $CurrentValue = $TKTrinhdo->qlf_name->GroupValue();
- $ViewValue =& $TKTrinhdo->qlf_name->GroupViewValue;
- $ViewAttrs =& $TKTrinhdo->qlf_name->ViewAttrs;
- $CellAttrs =& $TKTrinhdo->qlf_name->CellAttrs;
- $HrefValue =& $TKTrinhdo->qlf_name->HrefValue;
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->qlf_name, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
- for ($i = 0; $i < $scvcnt; $i++) {
- $CurrentValue = $TKTrinhdo->SummaryCurrentValue[$i];
- $ViewValue =& $TKTrinhdo->SummaryViewValue[$i];
- $ViewAttrs =& $TKTrinhdo->SummaryViewAttrs[$i];
- $CellAttrs =& $TKTrinhdo->SummaryCellAttrs[$i];
- $TKTrinhdo->Cell_Rendered($TKTrinhdo->count, $CurrentValue, $ViewValue, $ViewAttrs, $CellAttrs, $HrefValue);
- }
- }
-
- // Call Row_Rendered event
- $TKTrinhdo->Row_Rendered();
- }
-
- function SetupExportOptionsExt() {
- global $ReportLanguage, $TKTrinhdo;
- }
-
- // Clear selection stored in session
- function ClearSessionSelection($parm) {
- $_SESSION["sel_TKTrinhdo_$parm"] = "";
- $_SESSION["rf_TKTrinhdo_$parm"] = "";
- $_SESSION["rt_TKTrinhdo_$parm"] = "";
- }
-
- // Load selection from session
- function LoadSelectionFromSession($parm) {
- global $TKTrinhdo;
- $fld =& $TKTrinhdo->fields($parm);
- $fld->SelectionList = @$_SESSION["sel_TKTrinhdo_$parm"];
- $fld->RangeFrom = @$_SESSION["rf_TKTrinhdo_$parm"];
- $fld->RangeTo = @$_SESSION["rt_TKTrinhdo_$parm"];
- }
-
- // Load default value for filters
- function LoadDefaultFilters() {
- global $TKTrinhdo;
-
- /**
- * Set up default values for non Text filters
- */
-
- /**
- * Set up default values for extended filters
- * function SetDefaultExtFilter(&$fld, $so1, $sv1, $sc, $so2, $sv2)
- * Parameters:
- * $fld - Field object
- * $so1 - Default search operator 1
- * $sv1 - Default ext filter value 1
- * $sc - Default search condition (if operator 2 is enabled)
- * $so2 - Default search operator 2 (if operator 2 is enabled)
- * $sv2 - Default ext filter value 2 (if operator 2 is enabled)
- */
-
- /**
- * Set up default values for popup filters
- */
-
- // Field pqlf_name
- // $TKTrinhdo->pqlf_name->DefaultSelectionList = array("val1", "val2");
-
- $TKTrinhdo->pqlf_name->DefaultSelectionList = "";
- $TKTrinhdo->pqlf_name->SelectionList = $TKTrinhdo->pqlf_name->DefaultSelectionList;
- }
-
- // Check if filter applied
- function CheckFilter() {
- global $TKTrinhdo;
-
- // Check pqlf_name popup filter
- if (!ewrpt_MatchedArray($TKTrinhdo->pqlf_name->DefaultSelectionList, $TKTrinhdo->pqlf_name->SelectionList))
- return TRUE;
- return FALSE;
- }
-
- // Show list of filters
- function ShowFilterList() {
- global $TKTrinhdo;
- global $ReportLanguage;
-
- // Initialize
- $sFilterList = "";
-
- // Field pqlf_name
- $sExtWrk = "";
- $sWrk = "";
- if (is_array($TKTrinhdo->pqlf_name->SelectionList))
- $sWrk = ewrpt_JoinArray($TKTrinhdo->pqlf_name->SelectionList, ", ", EWRPT_DATATYPE_STRING);
- if ($sExtWrk <> "" || $sWrk <> "")
- $sFilterList .= $TKTrinhdo->pqlf_name->FldCaption() . "<br>";
- if ($sExtWrk <> "")
- $sFilterList .= " $sExtWrk<br>";
- if ($sWrk <> "")
- $sFilterList .= " $sWrk<br>";
-
- // Show Filters
- if ($sFilterList <> "")
- echo $ReportLanguage->Phrase("CurrentFilters") . "<br>$sFilterList";
- }
-
- // Return poup filter
- function GetPopupFilter() {
- global $TKTrinhdo;
- $sWrk = "";
- if (is_array($TKTrinhdo->pqlf_name->SelectionList)) {
- if ($sWrk <> "") $sWrk .= " AND ";
- $sWrk .= ewrpt_FilterSQL($TKTrinhdo->pqlf_name, "`pqlf_name`", EWRPT_DATATYPE_STRING);
- }
- return $sWrk;
- }
-
- //-------------------------------------------------------------------------------
- // Function GetSort
- // - Return Sort parameters based on Sort Links clicked
- // - Variables setup: Session[EWRPT_TABLE_SESSION_ORDER_BY], Session["sort_Table_Field"]
- function GetSort() {
- global $TKTrinhdo;
-
- // Check for Ctrl pressed
- $bCtrl = (@$_GET["ctrl"] <> "");
-
- // Check for a resetsort command
- if (strlen(@$_GET["cmd"]) > 0) {
- $sCmd = @$_GET["cmd"];
- if ($sCmd == "resetsort") {
- $TKTrinhdo->setOrderBy("");
- $TKTrinhdo->setStartGroup(1);
- $TKTrinhdo->pqlf_name->setSort("");
- $TKTrinhdo->qlf_name->setSort("");
- }
-
- // Check for an Order parameter
- } elseif (@$_GET["order"] <> "") {
- $TKT