function GetLookupValues($sql, $ds, $df, $dlm) { global $ReportLanguage; $rsarr = array(); $rowcnt = 0; $conn = ewr_Connect(); if ($rs = $conn->Execute($sql)) { $rowcnt = $rs->RecordCount(); $fldcnt = $rs->FieldCount(); $rsarr = $rs->GetRows(); $rs->Close(); } $conn->Close(); // Clean output buffer if (!EWR_DEBUG_ENABLED && ob_get_length()) { ob_end_clean(); } // Output $key = array(); $arr = array(); if (is_array($rsarr) && $rowcnt > 0) { for ($i = 0; $i < $rowcnt; $i++) { $row = $rsarr[$i]; if ($dlm != "") { $cnt = 0; for ($j = 0; $j < $fldcnt; $j++) { if (strpos(strval($row[$j]), $dlm) !== FALSE) { $row[$j] = explode($dlm, $row[$j]); if (count($row[$j]) > $cnt) { $cnt = count($row[$j]); } } else { if ($cnt < 1) { $cnt = 1; } } } } else { $cnt = 1; } for ($k = 0; $k < $cnt; $k++) { $val0 = ""; $str0 = ""; $rec = array(); for ($j = 0; $j < $fldcnt; $j++) { if ($dlm != "" && is_array($row[$j])) { if (count($row[$j]) > $k) { $val = $row[$j][$k]; } else { $val = $row[$j][0]; } } else { $val = $row[$j]; } if ($j == 0) { $str = ewr_ConvertValue($ds, $val); $val0 = $val; $str0 = $str; } elseif ($j == 1 && is_null($val0)) { $str = $ReportLanguage->Phrase("NullLabel"); } elseif ($j == 1 && strval($val0) == "") { $str = $ReportLanguage->Phrase("EmptyLabel"); } elseif ($j == 1) { $str = ewr_DropDownDisplayValue(ewr_ConvertValue($ds, $val), $ds, $df); } else { $str = strval($val); } $str = ewr_ConvertToUtf8($str); $rec[$j] = $str; } if (!in_array($str0, $key)) { $arr[] = $rec; $key[] = $str0; } } } } echo ewr_ArrayToJson($arr); }
function SetAttribute(&$element, $name, $value) { if (!$element) { return; } $element->setAttribute($name, ewr_ConvertToUtf8($value)); }
function WriteAtt(&$node, $name, $val) { $val = $this->CheckColorCode(strval($val)); $val = $this->ChartEncode($val); if ($node->hasAttribute($name)) { $node->getAttributeNode($name)->value = ewr_XmlEncode(ewr_ConvertToUtf8($val)); } else { $att = $this->XmlDoc->createAttribute($name); $att->value = ewr_XmlEncode(ewr_ConvertToUtf8($val)); $node->appendChild($att); } }