Esempio n. 1
0
function ewrpt_SelectedValue(&$ar, $val, $ft, $af)
{
    if (!is_array($ar)) {
        return TRUE;
    } else {
        $isaf = substr($val, 0, 2) == "@@";
        foreach ($ar as $value) {
            if ($val == "" && $value == EWRPT_EMPTY_VALUE) {
                // Empty string
                return TRUE;
            } elseif (is_null($val) && $value == EWRPT_NULL_VALUE) {
                // Null value
                return TRUE;
            } elseif ($isaf || substr($value, 0, 2) == "@@") {
                // Advanced filter
                if (is_array($af) && !is_null($val)) {
                    $result = ewrpt_SelectedFilter($af, $value, $val);
                    // Process popup filter
                    if ($result) {
                        return TRUE;
                    }
                }
            } elseif (ewrpt_CompareValue($value, $val, $ft)) {
                return TRUE;
            }
        }
    }
    return FALSE;
}
 function GetColumns()
 {
     global $conn;
     global $Crosstab1;
     global $ReportLanguage;
     // Build SQL
     $sSql = ewrpt_BuildReportSql($Crosstab1->SqlDistinctSelect(), $Crosstab1->SqlDistinctWhere(), "", "", $Crosstab1->SqlDistinctOrderBy(), $this->Filter, "");
     // Load recordset
     $rscol = $conn->Execute($sSql);
     // Get distinct column count
     $this->ColCount = $rscol ? $rscol->RecordCount() : 0;
     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($Crosstab1->Total_Marks->SelectionList)) {
         $this->ColSpan = $this->ColCount;
     } else {
         $this->ColSpan = 0;
         for ($i = 1; $i <= $this->ColCount; $i++) {
             $bSelected = FALSE;
             $cntsel = count($Crosstab1->Total_Marks->SelectionList);
             for ($j = 0; $j < $cntsel; $j++) {
                 if (ewrpt_CompareValue($Crosstab1->Total_Marks->SelectionList[$j], $this->Col[$i]->Value, $Crosstab1->Total_Marks->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($Crosstab1->SummaryType(), $Crosstab1->SummaryField(), $Crosstab1->ColumnField(), $Crosstab1->ColumnDateType(), $this->Col[$colcnt]->Value, "", "C" . $colcnt);
         if ($sSqlFlds != "") {
             $sSqlFlds .= ", ";
         }
         $sSqlFlds .= $sFld;
     }
     $this->SqlSelectWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $Crosstab1->SqlSelect());
     $this->SqlSelectAggWork = str_replace("<DistinctColumnFields>", $sSqlFlds, $Crosstab1->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", $Crosstab1->SummaryField(), $Crosstab1->ColumnField(), $Crosstab1->ColumnDateType(), $this->Col[$i + 1]->Value, "");
             if ($this->SqlChartWork != "") {
                 $this->SqlChartWork .= "+";
             }
             $this->SqlChartWork .= $sChtFld;
         }
     }
 }