summaryrefslogtreecommitdiffstats
path: root/application/controllers/StatisticController.php
blob: 3f42944673f4a74f9913de6a85c2f455e733178f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
class StatisticController extends Zend_Controller_Action
{
	protected $acl;
	protected $config;
	protected $pbs2host;
	protected $eventMapper;
	protected $eventcategoryMapper;
	protected $eventreportMapper;


	public function init()
	{
		$this->eventMapper = new Application_Model_EventMapper();
		$this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
		$this->eventreportMapper = new Application_Model_EventreportMapper();

	 if (Zend_Auth::getInstance()->hasIdentity()) {
	 	$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
	 	if(isset($this->userIDsNamespace['apikey'])) {
	 		$this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
	 	}
	 	if(!$this->userIDsNamespace['membershipID'] !='') {
	 		$this->_helper->redirector('selectmembership', 'person');
	 		return;
	 	}
	 } else {
	 	$this->_helper->redirector('login', 'auth');
	 	return;
	 }
	}

	public function indexAction()
	{
	}

	public function checkrightAction() {
		$this->_helper->layout->disableLayout();
		$rightShortcut = $this->_request->getParam("rightShortcut");
		$this->view->right = $this->acl->checkRight($rightShortcut);
	}

	public function categorylistAction() {

		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
		$poolID = $this->getRequest()->getParam('poolID');
		$userIDsSession = new Zend_Session_Namespace('userIDs');
		$userIDsSession->poolID = $poolID;

		if($this->acl->checkRight('eoo')) {
			$eventList = $this->eventMapper->fetchAll();
		} else {
			$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
		}

		$ret['dataBar'] = $this->eventMapper->getCategoryBarCount($poolID);
		$ret['dataPie'] = $this->eventMapper->getCategoryPieCount($poolID);
		$ret['color'] = $this->eventcategoryMapper->getCategoryColor($poolID);

		echo json_encode($ret);

	}

	public function runninglistAction() {

		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
		$poolID = $this->getRequest()->getParam('poolID');
		$userIDsSession = new Zend_Session_Namespace('userIDs');
		$userIDsSession->poolID = $poolID;

		if($this->acl->checkRight('eoo')) {
		 $eventList = $this->eventMapper->fetchAll();
		} else {
		 $eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
		}

		$ret['dataBar'] = $this->eventMapper->getRunningBarCount($poolID);
		$ret['dataPie'] = $this->eventMapper->getRunningPieCount($poolID);

		echo json_encode($ret);

	}

	public function successlistAction() {

		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
		$poolID = $this->getRequest()->getParam('poolID');
		$userIDsSession = new Zend_Session_Namespace('userIDs');
		$userIDsSession->poolID = $poolID;

		if($this->acl->checkRight('eoo')) {
			$eventList = $this->eventMapper->fetchAll();
		} else {
			$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
		}

		$ret['dataBar'] = $this->eventreportMapper->getSuccessBarCount($poolID);
		$ret['dataPie'] = $this->eventreportMapper->getSuccessPieCount($poolID);

		echo json_encode($ret);

	}

	public function categoryAction() {

	}

	public function runningAction() {

	}

	public function successAction() {

	}

}