File: statistics.tpl.php

package info (click to toggle)
simplesamlphp 1.16.3-1%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,036 kB
  • sloc: php: 73,175; ansic: 875; sh: 83; perl: 82; xml: 52; makefile: 46
file content (205 lines) | stat: -rw-r--r-- 7,657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
$this->data['header'] = 'SimpleSAMLphp Statistics';

$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);

$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/style.css") . '" />' . "\n";
$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/javascript.js") . '"></script>' . "\n";

$this->includeAtTemplateBase('includes/header.php');

echo '<h1>'. $this->data['available.rules'][$this->data['selected.rule']]['name'] . '</h1>';
echo '<p>' . $this->data['available.rules'][$this->data['selected.rule']]['descr'] . '</p>';

// Report settings
echo '<table class="selecttime">';
echo '<tr><td class="selecttime_icon"><img src="' . SimpleSAML\Utils\HTTP::getBaseUrl() . 'resources/icons/crystal_project/kchart.32x32.png" alt="Report settings" /></td>';

// Select report
echo '<td>';
echo '<form action="#">';
echo $this->data['post_rule'];
if (!empty($this->data['available.rules'])) {
    echo '<select onchange="submit();" name="rule">';
    foreach ($this->data['available.rules'] as $key => $rule) {
        if ($key === $this->data['selected.rule']) {
            echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>';
        } else {
            echo '<option value="' . $key . '">' . $rule['name'] . '</option>';
        }
    }
    echo '</select>';
}
echo '</form></td>';

// Select delimiter
echo '<td class="td_right">';
echo '<form action="#">';
echo $this->data['post_d'];
if(!empty($this->data['availdelimiters'])) {
    echo '<select onchange="submit();" name="d">';
    foreach ($this->data['availdelimiters'] as $key => $delim) {
        $delimName = $delim;
        if (array_key_exists($delim, $this->data['delimiterPresentation'])) {
            $delimName = $this->data['delimiterPresentation'][$delim];
        }

        if ($key == '_') {
            echo '<option value="_">Total</option>';
        } elseif (isset($_REQUEST['d']) && $delim == $_REQUEST['d']) {
            echo '<option selected="selected" value="' . htmlspecialchars($delim) . '">' . htmlspecialchars($delimName) . '</option>';
        } else {
            echo '<option  value="' . htmlspecialchars($delim) . '">' . htmlspecialchars($delimName) . '</option>';
        }
    }
    echo '</select>';
}
echo '</form></td></tr>';

echo '</table>';

// End report settings


// Select time and date
echo '<table class="selecttime">';
echo '<tr><td class="selecttime_icon"><img src="' . SimpleSAML\Utils\HTTP::getBaseUrl() . 'resources/icons/crystal_project/date.32x32.png" alt="Select date and time" /></td>';

if (isset($this->data['available.times.prev'])) {
    echo '<td><a href="' . $this->data['get_times_prev'] . '">« Previous</a></td>';
} else {
    echo '<td class="selecttime_link_grey">« Previous</td>';
}

echo '<td class="td_right">';
echo '<form action="#">';
echo $this->data['post_res'];
if (!empty($this->data['available.timeres'])) {
    echo '<select onchange="submit();" name="res">';
    foreach ($this->data['available.timeres'] as $key => $timeresname) {
        if ($key == $this->data['selected.timeres']) {
            echo '<option selected="selected" value="' . $key . '">' . $timeresname . '</option>';
        } else {
            echo '<option  value="' . $key . '">' . $timeresname . '</option>';
        }
    }
    echo '</select>';
}
echo '</form></td>';

echo '<td class="td_left">';
echo '<form action="#">';
echo $this->data['post_time'];
if (!empty($this->data['available.times'])) {
    echo '<select onchange="submit();" name="time">';
    foreach ($this->data['available.times'] as $key => $timedescr) {
        if ($key == $this->data['selected.time']) {
            echo '<option selected="selected" value="' . $key . '">' . $timedescr . '</option>';
        } else {
            echo '<option  value="' . $key . '">' . $timedescr . '</option>';
        }
    }
    echo '</select>';
}
echo '</form></td>';

if (isset($this->data['available.times.next'])) {
    echo '<td class="td_right td_next_right"><a href="' . $this->data['get_times_next'] . '">Next »</a></td>';
} else {
    echo '<td class="td_right selecttime_link_grey td_next_right">Next »</td>';
}

echo '</tr></table>';
echo '<div id="tabdiv">';
if (!empty($this->data['results'])){
    echo '<ul class="tabset_tabs">
       <li><a href="#graph">Graph</a></li>
       <li><a href="#table">Summary table</a></li>
       <li><a href="#debug">Time serie</a></li>
    </ul>';
    echo '

    <div id="graph" class="tabset_content">';

    echo '<img src="' . htmlspecialchars($this->data['imgurl']) . '" alt="Graph" />';

    echo '<form action="#">';
    echo '<p class="p_right">Compare with total from this dataset ';
    echo $this->data['post_rule2'];
    echo '<select onchange="submit();" name="rule2">';
    echo '	<option value="_">None</option>';
    foreach ($this->data['available.rules'] as $key => $rule) {
        if ($key === $this->data['selected.rule2']) {
            echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>';
        } else {
            echo '<option value="' . $key . '">' . $rule['name'] . '</option>';
        }
    }
    echo '</select></p></form>';

    echo '</div>'; // end graph content.

    /**
     * Handle table view - - - - - - 
     */
    $classint = array('odd', 'even'); $i = 0;
    echo '<div id="table" class="tabset_content">';

    if (isset($this->data['pieimgurl'])) {
        echo '<img src="' . $this->data['pieimgurl'] . '" alt="Pie chart" />';
    }
    echo '<table class="tableview"><tr><th class="value">Value</th><th class="category">Data range</th></tr>';

    foreach ($this->data['summaryDataset'] as $key => $value) {
        $clint = $classint[$i++ % 2];

        $keyName = $key;
        if (array_key_exists($key, $this->data['delimiterPresentation'])) {
            $keyName = $this->data['delimiterPresentation'][$key];
        }

        if ($key === '_') {
            echo '<tr class="total '  . $clint . '"><td  class="value">' . $value . '</td><td class="category">' . $keyName . '</td></tr>';
        } else {
            echo '<tr class="' . $clint . '"><td  class="value">' . $value . '</td><td class="category">' . $keyName . '</td></tr>';
        }
    }

    echo '</table></div>';
    //  - - - - - - - End table view - - - - - - - 

    echo '<div id="debug" >';
    echo '<table class="timeseries">';
    echo '<tr><th>Time</th><th>Total</th>';
    foreach ($this->data['topdelimiters'] as $key) {
        $keyName = $key;
        if (array_key_exists($key, $this->data['delimiterPresentation'])) {
            $keyName = $this->data['delimiterPresentation'][$key];
        }
        echo'<th>' . $keyName . '</th>';
    }
    echo '</tr>';

    $i = 0;
    foreach ($this->data['debugdata'] as $slot => $dd) {
        echo '<tr class="' . ((++$i % 2) == 0 ? 'odd' : 'even') . '">';
        echo '<td>' . $dd[0] . '</td>';
        echo '<td class="datacontent">' . $dd[1] . '</td>';

        foreach ($this->data['topdelimiters'] as $key) {
            echo '<td class="datacontent">' . (array_key_exists($key, $this->data['results'][$slot]) ?
                $this->data['results'][$slot][$key] : '&nbsp;') . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';


    echo '</div>'; // End debug tab content
} else {
    echo '<h4 align="center">'.$this->data['error'].'</h4>';
    echo '<p align="center"><a href="showstats.php">Clear selection</a></p>';
}
echo '</div>'; // End tab div

$this->includeAtTemplateBase('includes/footer.php');