3
class COUNTView extends VIEW {
4
var $title = "Count Records";
6
function __construct(REQUEST $req = NULL, $options) {
7
parent::__construct($req, $options);
10
function GetOptions() {
11
$req = $this->req->CreateGroupRequest();
12
$x = $req->GetProp("view_x", false);
13
if ($x) list($x_gid, $x_id) = explode(":", $x);
14
else list($x_gid, $x_id) = array(0, 0);
16
$rdr = $req->CreateReader();
17
$group = $rdr->CreateGroup();
18
$caches = $rdr->CreateCacheSet($group, $mask);
23
foreach ($caches as $key => $cachewrap) {
24
array_push($result, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
25
array_push($result2, array("label" => $cachewrap->GetGroupTitle(), "disabled" => 1));
28
$list = $cachewrap->GetItemList();
29
foreach ($list as $id => $info) {
30
$title = $info['name'];
31
array_push($result, array("value" => "$gid:$id", "label" => " $title"));
32
if (($x_gid == $gid)&&($x_id != $id))
33
array_push($result2, array("value" => "$gid:$id", "label" => " $title"));
41
// array("input" => array("label" => _("Channel Combination (i.e. v1 - 2 * v2)"), "id" => "count_formula", "type" => "text", "value" => "v1")),
42
// array("xml"=>"<br/>"),
44
array("input" => array("label" => _("x"), "id" => "x_mult", "type" => "text", "size" => "3", "value" => "1")),
45
array("select" => array("label" => _("*"), "id" => "x", "options" => $result)),
46
array("xml"=>"<br/>"),
47
array("input" => array("label" => _("y"), "id" => "y_mult", "type" => "text", "size" => "3", "value" => "1")),
48
array("select" => array("label" => _("*"), "id" => "y", "options" => $result2)),
49
array("xml"=>"<br/>"),
50
array("input" => array("label" => _("From"), "id" => "count_min", "type" => "text", size => "8", "value" => "0")),
51
array("input" => array("label" => _("To"), "id" => "count_max", "type" => "text", size => "8", "value" => "0"))
58
$req = $this->req->CreateDataRequest();
59
$x = $req->GetProp("view_x", false);
60
$y = $req->GetProp("view_y", false);
61
$x_mult = $req->GetProp("view_x_mult", 1);
62
$y_mult = $req->GetProp("view_y_mult", 1);
63
$min = $req->GetProp("view_count_min", false);
64
$max = $req->GetProp("view_count_max", false);
67
throw new ADEIException(translate("Parameter view_x should be set"));
69
list($x_gid, $x_id) = explode(":", $x);
70
list($y_gid, $y_id) = explode(":", $y);
72
if ((!$y)&&($x_gid != $y_gid))
73
throw new ADEIException(translate("Both x and y should belong to the same group"));
75
$rdr = $req->CreateReader();
76
$group = $rdr->CreateGroup();
77
$caches = $rdr->CreateCacheSet($group);
78
$iv = $caches->CreateInterval($req, true);
83
foreach ($caches as $key => $cachewrap) {
92
$points = $cachewrap->GetAllPoints($iv);
93
foreach($points as $t => $v) {
96
$vx = $v['mean'.$x_id];
97
if ($y) $vy = $v['mean'.$y_id];
100
$sum = $x_mult * $vx + $y_mult * $vy;
102
if ($min !== false) {
103
if ($sum < $min) continue;
106
if ($max !== false) {
107
if ($sum > $max) continue;
115
array("title"=>_("Total"), "value" => $total),
116
array("title"=>_("In Range"), "value" => $inrange),
121
return array("div" => array("xml" => "not found"));
b'\\ No newline at end of file'