xref: /plugin/bez/ctl/report.php (revision d00bbb0cd3d53bb4b45776b5bcc676c7616019a9)
1<?php
2include_once DOKU_PLUGIN."bez/models/report.php";
3include_once DOKU_PLUGIN."bez/models/entities.php";
4
5/*jeżeli nie mamy tokenu generujemy nowy i przekierowujemy*/
6$toko = new Tokens();
7if (!isset($_GET['t']) || ! $toko->check(trim($_GET['t']), $ID))
8	header('Location: '.$uri.'?'.$_SERVER['QUERY_STRING'].'&t='.$toko->get($ID));
9
10$repo = new Report();
11$ento = new Entities();
12
13$value = array('entity' => '-all', 'year' => '-all', 'month' => '-all');
14if (count($_POST) > 0) {
15	$filters = $repo->validate_filters($_POST);
16
17	$query_uri = '';
18	foreach ($filters as $k => $v)
19		if ($v != '-all')
20			$query_uri .= ':'.urlencode($k).':'.urlencode($v);
21
22	header('Location: ?id=bez:report'.$query_uri);
23}
24
25/*rekordy parzyste to nagłówki, nieparzyste to ich wartości.*/
26/*np. status:1:type:2:podmiot:PCA*/
27for ($i = 0; $i < count($params); $i += 2)
28	$value[urldecode($params[$i])] = urldecode($params[$i+1]);
29
30$template['entities'] = $ento->get_list();
31
32$template['uri'] = $uri;
33$template['hidden'] = array();
34if (isset($value['year']))
35	$template['hidden']['year'] = $value['year'];
36if (isset($value['month']))
37	$template['hidden']['month'] = $value['month'];
38
39$template['report'] = $repo->report($value);
40
41$template['title'] = $bezlang['report'].($value['year'] != '-all' ? ' '.$value['year'] : '').
42					($value['month'] != '-all' ? '/'.($value['month'] > 10 ? $value['month'] : '0'.$value['month']) : '');
43
44$template['uri'] = $uri.'?'.$_SERVER['QUERY_STRING'];
45