xref: /plugin/bez/ctl/tasks.php (revision bb6152976ef5a966a55ac4e8f31e012471ce33ba)
1<?php
2include_once DOKU_PLUGIN."bez/models/tasks.php";
3include_once DOKU_PLUGIN."bez/models/taskactions.php";
4include_once DOKU_PLUGIN."bez/models/taskstates.php";
5
6if	(!$helper->user_viewer()) {
7	$errors[] = $bezlang['error_issues'];
8	$controller->preventDefault();
9}
10
11$tasko = new Tasks();
12$taskao = new Taskactions();
13$taskso = new Taskstates();
14
15if (count($_POST) > 0) {
16	$filters = $tasko->validate_filters($_POST);
17
18	$query_uri = '';
19	foreach ($filters as $k => $v)
20		if ($v != '-all')
21			$query_uri .= ':'.urlencode($k).':'.urlencode($v);
22
23	header('Location: ?id=bez:tasks'.$query_uri);
24}
25
26/*rekordy parzyste to nagłówki, nieparzyste to ich wartości.*/
27/*np. status:1:type:2:podmiot:PCA*/
28$value = array('action' => '-all', 'state' => '-all', 'executor' => '-all', 'year' => '-all');
29for ($i = 0; $i < count($params); $i += 2)
30	$value[urldecode($params[$i])] = urldecode($params[$i+1]);
31
32
33$template['uri'] = $uri;
34
35$template['actions'] = $taskao->get();
36$template['states'] = $taskso->get();
37$template['executors'] = $tasko->get_executors();
38$template['years'] = $tasko->get_years();
39
40$template['tasks'] = $tasko->get_filtered($value);
41