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 Page_Main()
 {
     global $rs;
     global $rsgrp;
     global $Security;
     global $gsFormError;
     global $gbDrillDownInPanel;
     global $ReportBreadcrumb;
     global $ReportLanguage;
     // Set up groups per page dynamically
     $this->SetUpDisplayGrps();
     // Set up Breadcrumb
     if ($this->Export == "") {
         $this->SetupBreadcrumb();
     }
     // Get sort
     $this->Sort = $this->GetSort();
     // Popup values and selections
     $this->YEAR__dateCreated->SelectionList = "";
     $this->YEAR__dateCreated->DefaultSelectionList = "";
     $this->YEAR__dateCreated->ValueList = "";
     // Load custom filters
     $this->Page_FilterLoad();
     // Set up popup filter
     $this->SetupPopup();
     // Handle Ajax popup
     $this->ProcessAjaxPopup();
     // Restore filter list
     $this->RestoreFilterList();
     // Extended filter
     $sExtendedFilter = "";
     // Add year filter
     if ($this->YEAR__dateCreated->SelectionList != "") {
         if ($this->Filter != "") {
             $this->Filter .= " AND ";
         }
         $this->Filter .= "YEAR(`dateCreated`) = " . $this->YEAR__dateCreated->SelectionList;
     }
     // Load columns to array
     $this->GetColumns();
     // 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 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->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 total groups
     $rsgrp = $this->GetGrpRs($sSql, $this->StartGrp, $this->DisplayGrps);
     // Init detail recordset
     $rs = NULL;
     // Set up column attributes
     $this->dateCreated->ViewAttrs["style"] = "";
     $this->dateCreated->CellAttrs["style"] = "vertical-align: top;";
     $this->SetupFieldCount();
 }
Ejemplo n.º 3
0
function ewr_BuildReportSql($sSelect, $sWhere, $sGroupBy, $sHaving, $sOrderBy, $sFilter, $sSort)
{
    $sDbWhere = $sWhere;
    if ($sDbWhere != "") {
        $sDbWhere = "(" . $sDbWhere . ")";
    }
    if ($sFilter != "") {
        if ($sDbWhere != "") {
            $sDbWhere .= " AND ";
        }
        $sDbWhere .= "(" . $sFilter . ")";
    }
    $sDbOrderBy = ewr_UpdateSortFields($sOrderBy, $sSort, 1);
    $sSql = $sSelect;
    if ($sDbWhere != "") {
        $sSql .= " WHERE " . $sDbWhere;
    }
    if ($sGroupBy != "") {
        $sSql .= " GROUP BY " . $sGroupBy;
    }
    if ($sHaving != "") {
        $sSql .= " HAVING " . $sHaving;
    }
    if ($sDbOrderBy != "") {
        $sSql .= " ORDER BY " . $sDbOrderBy;
    }
    return $sSql;
}