1c9044e56Sghi<?php 2c9044e56Sghiinclude_once DOKU_PLUGIN."bez/models/tasks.php"; 3c9044e56Sghiinclude_once DOKU_PLUGIN."bez/models/taskactions.php"; 4c9044e56Sghiinclude_once DOKU_PLUGIN."bez/models/taskstates.php"; 57f853d3aSghiinclude_once DOKU_PLUGIN."bez/models/users.php"; 6c9044e56Sghi 7c9044e56Sghiif (!$helper->user_viewer()) { 8c9044e56Sghi $errors[] = $bezlang['error_issues']; 9c9044e56Sghi $controller->preventDefault(); 10c9044e56Sghi} 11c9044e56Sghi 12c9044e56Sghi$tasko = new Tasks(); 13c9044e56Sghi$taskao = new Taskactions(); 14c9044e56Sghi$taskso = new Taskstates(); 157f853d3aSghi$usro = new Users(); 16c9044e56Sghi 17c9044e56Sghiif (count($_POST) > 0) { 18c9044e56Sghi $filters = $tasko->validate_filters($_POST); 19c9044e56Sghi 20c9044e56Sghi $query_uri = ''; 21c9044e56Sghi foreach ($filters as $k => $v) 22c9044e56Sghi if ($v != '-all') 23c9044e56Sghi $query_uri .= ':'.urlencode($k).':'.urlencode($v); 24c9044e56Sghi 25*05c9d3bcSghi header('Location: ?id='.$this->id('tasks').$query_uri); 26c9044e56Sghi} 27c9044e56Sghi 28c9044e56Sghi/*rekordy parzyste to nagłówki, nieparzyste to ich wartości.*/ 29c9044e56Sghi/*np. status:1:type:2:podmiot:PCA*/ 30c9044e56Sghi$value = array('action' => '-all', 'state' => '-all', 'executor' => '-all', 'year' => '-all'); 31c9044e56Sghifor ($i = 0; $i < count($params); $i += 2) 32c9044e56Sghi $value[urldecode($params[$i])] = urldecode($params[$i+1]); 33c9044e56Sghi 34c9044e56Sghi 35c9044e56Sghi$template['uri'] = $uri; 36c9044e56Sghi 37c9044e56Sghi$template['actions'] = $taskao->get(); 38c9044e56Sghi$template['states'] = $taskso->get(); 397f853d3aSghi$template['executors'] = $usro->get(); 40c9044e56Sghi$template['years'] = $tasko->get_years(); 41c9044e56Sghi 42d00bbb0cSghi$tasks = $tasko->get_filtered($value); 43d00bbb0cSghi$template['tasks'] = $tasks; 44d00bbb0cSghi 45d00bbb0cSghi$template['tasks_stats']['total'] = count($tasks); 46d00bbb0cSghi 47d00bbb0cSghi$tcost = 0; 48d00bbb0cSghiforeach ($tasks as $task) { 49d00bbb0cSghi $tcost += (int)$task['cost']; 50d00bbb0cSghi} 51d00bbb0cSghi$template['tasks_stats']['totalcost'] = $tcost; 52d00bbb0cSghi 53d00bbb0cSghi 54