function GetColumns()
 {
     global $conn;
     global $ReportLanguage;
     $this->LoadColumnValues($this->Filter);
     // 1st dimension = no of groups (level 0 used for grand total)
     // 2nd dimension = no of distinct values
     $nGrps = 1;
     $this->Val =& ewr_InitArray($this->ColCount + 1, NULL);
     $this->ValCnt =& ewr_InitArray($this->ColCount + 1, NULL);
     $this->Cnt =& ewr_Init2DArray($this->ColCount + 1, $nGrps + 1, NULL);
     $this->Smry =& ewr_Init2DArray($this->ColCount + 1, $nGrps + 1, NULL);
     $this->SmryCnt =& ewr_Init2DArray($this->ColCount + 1, $nGrps + 1, NULL);
     // Reset summary values
     $this->ResetLevelSummary(0);
     // Get active columns
     if (!is_array($this->dateCreated->SelectionList)) {
         $this->ColSpan = $this->ColCount;
     } else {
         $this->ColSpan = 0;
         for ($i = 1; $i <= $this->ColCount; $i++) {
             $bSelected = FALSE;
             $cntsel = count($this->dateCreated->SelectionList);
             for ($j = 0; $j < $cntsel; $j++) {
                 if (ewr_CompareValue($this->dateCreated->SelectionList[$j], $this->Col[$i]->Value, 3)) {
                     $this->ColSpan++;
                     $bSelected = TRUE;
                     break;
                 }
             }
             $this->Col[$i]->Visible = $bSelected;
         }
     }
     $this->ColSpan++;
     // Add summary column
 }
 function Page_Main()
 {
     global $rs;
     global $rsgrp;
     global $Security;
     global $gsFormError;
     global $gbDrillDownInPanel;
     global $ReportBreadcrumb;
     global $ReportLanguage;
     // Aggregate variables
     // 1st dimension = no of groups (level 0 used for grand total)
     // 2nd dimension = no of fields
     $nDtls = 3;
     $nGrps = 2;
     $this->Val =& ewr_InitArray($nDtls, 0);
     $this->Cnt =& ewr_Init2DArray($nGrps, $nDtls, 0);
     $this->Smry =& ewr_Init2DArray($nGrps, $nDtls, 0);
     $this->Mn =& ewr_Init2DArray($nGrps, $nDtls, NULL);
     $this->Mx =& ewr_Init2DArray($nGrps, $nDtls, NULL);
     $this->GrandCnt =& ewr_InitArray($nDtls, 0);
     $this->GrandSmry =& ewr_InitArray($nDtls, 0);
     $this->GrandMn =& ewr_InitArray($nDtls, NULL);
     $this->GrandMx =& ewr_InitArray($nDtls, NULL);
     // Set up array if accumulation required: array(Accum, SkipNullOrZero)
     $this->Col = array(array(FALSE, FALSE), array(TRUE, FALSE), array(FALSE, FALSE));
     // Set up groups per page dynamically
     $this->SetUpDisplayGrps();
     // Set up Breadcrumb
     if ($this->Export == "") {
         $this->SetupBreadcrumb();
     }
     // Check if search command
     $this->SearchCommand = @$_GET["cmd"] == "search";
     // Load default filter values
     $this->LoadDefaultFilters();
     // Load custom filters
     $this->Page_FilterLoad();
     // Set up popup filter
     $this->SetupPopup();
     // Load group db values if necessary
     $this->LoadGroupDbValues();
     // Handle Ajax popup
     $this->ProcessAjaxPopup();
     // Extended filter
     $sExtendedFilter = "";
     // Restore filter list
     $this->RestoreFilterList();
     // Build extended filter
     $sExtendedFilter = $this->GetExtendedFilter();
     ewr_AddFilter($this->Filter, $sExtendedFilter);
     // Build popup filter
     $sPopupFilter = $this->GetPopupFilter();
     //ewr_SetDebugMsg("popup filter: " . $sPopupFilter);
     ewr_AddFilter($this->Filter, $sPopupFilter);
     // Check if filter applied
     $this->FilterApplied = $this->CheckFilter();
     // Call Page Selecting event
     $this->Page_Selecting($this->Filter);
     $this->SearchOptions->GetItem("resetfilter")->Visible = $this->FilterApplied;
     // Get sort
     $this->Sort = $this->GetSort();
     // Get total group count
     $sGrpSort = ewr_UpdateSortFields($this->getSqlOrderByGroup(), $this->Sort, 2);
     // Get grouping field only
     $sSql = ewr_BuildReportSql($this->getSqlSelectGroup(), $this->getSqlWhere(), $this->getSqlGroupBy(), $this->getSqlHaving(), $this->getSqlOrderByGroup(), $this->Filter, $sGrpSort);
     $this->TotalGrps = $this->GetGrpCnt($sSql);
     if ($this->DisplayGrps <= 0 || $this->DrillDown) {
         // Display all groups
         $this->DisplayGrps = $this->TotalGrps;
     }
     $this->StartGrp = 1;
     // Show header
     $this->ShowHeader = $this->TotalGrps > 0;
     // Set up start position if not export all
     if ($this->ExportAll && $this->Export != "") {
         $this->DisplayGrps = $this->TotalGrps;
     } else {
         $this->SetUpStartGroup();
     }
     // Set no record found message
     if ($this->TotalGrps == 0) {
         if ($this->Filter == "0=101") {
             $this->setWarningMessage($ReportLanguage->Phrase("EnterSearchCriteria"));
         } else {
             $this->setWarningMessage($ReportLanguage->Phrase("NoRecord"));
         }
     }
     // Hide export options if export
     if ($this->Export != "") {
         $this->ExportOptions->HideAllOptions();
     }
     // Hide search/filter options if export/drilldown
     if ($this->Export != "" || $this->DrillDown) {
         $this->SearchOptions->HideAllOptions();
         $this->FilterOptions->HideAllOptions();
     }
     // Get current page groups
     $rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
     // Init detail recordset
     $rs = NULL;
     $this->SetupFieldCount();
 }
 function LoadColumnValues($filter = "")
 {
     global $conn;
     global $ReportLanguage;
     $arColumnCaptions = explode(",", $this->getColumnCaptions());
     $arColumnNames = explode(",", $this->getColumnNames());
     $arColumnValues = explode(",", $this->getColumnValues());
     // Get distinct column count
     $this->ColCount = count($arColumnNames);
     $this->Col =& ewr_Init2DArray($this->ColCount + 1, 2, NULL);
     for ($colcnt = 1; $colcnt <= $this->ColCount; $colcnt++) {
         $this->Col[$colcnt] = new crCrosstabColumn($arColumnValues[$colcnt - 1], $arColumnCaptions[$colcnt - 1], TRUE);
     }
     // Update crosstab sql
     $sSqlFlds = "";
     for ($i = 0; $i < $this->ColCount; $i++) {
         $sFld = ewr_CrossTabField($this->getSummaryType(), $this->getSummaryField(), $this->getColumnField(), $this->getColumnDateType(), $arColumnValues[$i], "", $arColumnNames[$i]);
         if ($sSqlFlds != "") {
             $sSqlFlds .= ", ";
         }
         $sSqlFlds .= $sFld;
     }
     $this->DistinctColumnFields = $sSqlFlds;
 }
Exemple #4
0
 function LoadColumnValues($filter = "")
 {
     global $conn;
     global $ReportLanguage;
     // Build SQL
     $sSql = ewr_BuildReportSql($this->getSqlDistinctSelect(), $this->getSqlDistinctWhere(), "", "", $this->getSqlDistinctOrderBy(), $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 "<p>" . $ReportLanguage->Phrase("NoDistinctColVals") . $sSql . "</p>";
     			exit();
     		}
     */
     $this->Col =& ewr_Init2DArray($this->ColCount + 1, 2, NULL);
     $colcnt = 0;
     while (!$rscol->EOF) {
         if (is_null($rscol->fields[0])) {
             $wrkValue = EWR_NULL_VALUE;
             $wrkCaption = $ReportLanguage->Phrase("NullLabel");
         } elseif ($rscol->fields[0] == "") {
             $wrkValue = EWR_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();
     // Update crosstab sql
     $sSqlFlds = "";
     for ($colcnt = 1; $colcnt <= $this->ColCount; $colcnt++) {
         $sFld = ewr_CrossTabField($this->getSummaryType(), $this->getSummaryField(), $this->getColumnField(), $this->getColumnDateType(), $this->Col[$colcnt]->Value, "", "C" . $colcnt);
         if ($sSqlFlds != "") {
             $sSqlFlds .= ", ";
         }
         $sSqlFlds .= $sFld;
     }
     $this->DistinctColumnFields = $sSqlFlds;
 }