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