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