summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSebastian Wagner2011-10-06 18:43:29 +0200
committerSebastian Wagner2011-10-06 18:43:29 +0200
commit1710652ffe04ea217c13e6064fd5f234f796729f (patch)
tree15d400f73b55954f34d169ef44ece217ca13b849 /application
parentLayout korrigiert (diff)
downloadpoolctrl-1710652ffe04ea217c13e6064fd5f234f796729f.tar.gz
poolctrl-1710652ffe04ea217c13e6064fd5f234f796729f.tar.xz
poolctrl-1710652ffe04ea217c13e6064fd5f234f796729f.zip
runningPlot implemented
Diffstat (limited to 'application')
-rw-r--r--application/controllers/StatisticController.php21
-rwxr-xr-xapplication/models/EventMapper.php91
-rw-r--r--application/views/scripts/statistic/category.phtml11
-rw-r--r--application/views/scripts/statistic/running.phtml99
4 files changed, 156 insertions, 66 deletions
diff --git a/application/controllers/StatisticController.php b/application/controllers/StatisticController.php
index 7b15531..da1e56e 100644
--- a/application/controllers/StatisticController.php
+++ b/application/controllers/StatisticController.php
@@ -30,7 +30,6 @@ class StatisticController extends Zend_Controller_Action
public function indexAction()
{
-
}
public function checkrightAction() {
@@ -39,13 +38,6 @@ class StatisticController extends Zend_Controller_Action
$this->view->right = $this->acl->checkRight($rightShortcut);
}
- public function dumpAction() {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
- $data = $this->_request->getParam("data");
- var_dump($data);
- }
-
public function categorylistAction() {
$this->_helper->layout->disableLayout();
@@ -54,11 +46,11 @@ class StatisticController extends Zend_Controller_Action
$userIDsSession = new Zend_Session_Namespace('userIDs');
$userIDsSession->poolID = $poolID;
- /*if($this->acl->checkRight('eoo')) {
+ 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);
@@ -68,7 +60,7 @@ class StatisticController extends Zend_Controller_Action
}
- public function colorlistAction() {
+ public function runninglistAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
@@ -76,13 +68,14 @@ class StatisticController extends Zend_Controller_Action
$userIDsSession = new Zend_Session_Namespace('userIDs');
$userIDsSession->poolID = $poolID;
- /*if($this->acl->checkRight('eoo')) {
+ if($this->acl->checkRight('eoo')) {
$eventList = $this->eventMapper->fetchAll();
} else {
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
- }*/
+ }
- $ret = $this->eventcategoryMapper->getCategoryColor($poolID);
+ $ret['dataBar'] = $this->eventMapper->getRunningBarCount($poolID);
+ $ret['dataPie'] = $this->eventMapper->getRunningPieCount($poolID);
echo json_encode($ret);
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 8d05754..2fc4b71 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -190,7 +190,7 @@ class Application_Model_EventMapper
$select = $this->getDbTable()->select()
->setIntegrityCheck(false)
->from(array('pce' => 'poolctrl_event'),
- array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
+ array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
->join(array('pcec' => 'poolctrl_eventcategory'),
'pce.category = pcec.eventcategoryID',
array())
@@ -201,56 +201,87 @@ class Application_Model_EventMapper
$stmt = $db->query($select);
$result = $stmt->fetchAll(PDO::FETCH_NUM);
$ret = null;
-
+
foreach ($result as $r) {
$ret[] = array((int)$r[0], $r[1]);
}
return array($ret);
}
-
+
public function getCategoryPieCount($poolID) {
-
- $db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->setIntegrityCheck(false)
- ->from(array('pce' => 'poolctrl_event'),
- array('category' => 'pcec.title', 'count' => 'COUNT(*)'))
- ->join(array('pcec' => 'poolctrl_eventcategory'),
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pce' => 'poolctrl_event'),
+ array('category' => 'pcec.title', 'count' => 'COUNT(*)'))
+ ->join(array('pcec' => 'poolctrl_eventcategory'),
'pce.category = pcec.eventcategoryID',
- array())
- ->where('pce.pbs_poolID = ?', $poolID)
- ->group('pce.category')
- ->order('pce.category ASC');
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID)
+ ->group('pce.category')
+ ->order('pce.category ASC');
- $stmt = $db->query($select);
- $result = $stmt->fetchAll(PDO::FETCH_NUM);
- $ret = null;
-
- foreach ($result as $r) {
- $ret[] = array($r[0], (int)$r[1]);
- }
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+ $ret = null;
- return array($ret);
- }
+ foreach ($result as $r) {
+ $ret[] = array($r[0], (int)$r[1]);
+ }
- public function getRunningCount($poolID) {
+ return array($ret);
+ }
+
+ public function getRunningBarCount($poolID) {
$db = Zend_Db_Table::getDefaultAdapter();
$select = $this->getDbTable()->select()
->setIntegrityCheck(false)
->from(array('pce' => 'poolctrl_event'),
- array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
+ array('count1' => 'SUM(IF(pce.running=1,1,0))', 'count0' => 'SUM(IF(pce.running=0,1,0))')
+ )
->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID')
- ->where('pce.pbs_poolID = ?', $poolID)
- ->group('pce.category')
- ->order('pce.category ASC');
+ 'pce.category = pcec.eventcategoryID',
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID);
+
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+
+ foreach ($result as $r) {
+ $ret1 = array((int)$r[0],'Event over');
+ $ret2 = array((int)$r[1],'Event not over');
+ $return[] = array($ret1,$ret2);
+ }
+
+ return $return;
+ }
+
+ public function getRunningPieCount($poolID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pce' => 'poolctrl_event'),
+ array('count1' => 'SUM(IF(pce.running=1,1,0))', 'count0' => 'SUM(IF(pce.running=0,1,0))')
+ )
+ ->join(array('pcec' => 'poolctrl_eventcategory'),
+ 'pce.category = pcec.eventcategoryID',
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID);
$stmt = $db->query($select);
$result = $stmt->fetchAll(PDO::FETCH_NUM);
- return array($result);
+ foreach ($result as $r) {
+ $ret1 = array('running0', (int)$r[0]);
+ $ret2 = array('running1', (int)$r[1]);
+ $return[] = array($ret1,$ret2);
+ }
+
+ return $return;
}
} \ No newline at end of file
diff --git a/application/views/scripts/statistic/category.phtml b/application/views/scripts/statistic/category.phtml
index 563df7e..6b24f49 100644
--- a/application/views/scripts/statistic/category.phtml
+++ b/application/views/scripts/statistic/category.phtml
@@ -28,9 +28,13 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
$.get("/statistic/categorylist/poolID/" + poolID, function(data) {
- if(data.dataBar == '') {
+ if(data.dataBar == '' && poolID != 'default') {
$( "#noEventsDialog" ).dialog('open');
- $('#plot').empty();
+ $('#plotBar').empty();
+ $('#plotPie').empty();
+ } else if (poolID == 'default') {
+ $('#plotBar').empty();
+ $('#plotPie').empty();
} else refreshPlot(data.dataBar, data.dataPie, data.color);
}, "json");
}
@@ -60,7 +64,6 @@ function refreshPlot(dataBar, dataPie, color) {
highlighter: { show: false }
});
$('#plotPie').empty();
- //var data = [['Commuting', 7], ['Orientation', 9]];
$.jqplot('plotPie', dataPie,
{
seriesDefaults: {
@@ -118,5 +121,5 @@ $(function() {
<!-- no events -->
<div id="noEventsDialog" style="display: none">
-<p>There are no events in this pool to plot a statistic</p>
+<p>There are no events in this pool to plot a statistic.</p>
</div>
diff --git a/application/views/scripts/statistic/running.phtml b/application/views/scripts/statistic/running.phtml
index 019b7fc..927b18a 100644
--- a/application/views/scripts/statistic/running.phtml
+++ b/application/views/scripts/statistic/running.phtml
@@ -22,24 +22,60 @@ function setPoolIDtmp() {
}
function plot() {
- $('#plot').empty();
- var data = [['Commuting', 7], ['Orientation', 9]];
- $.jqplot('plot', [data],
- {
- seriesDefaults: {
- // Make this a pie chart.
- renderer: jQuery.jqplot.PieRenderer,
- rendererOptions: {
- // Put data labels on the pie slices.
- // By default, labels show the percentage of the slice.
- showDataLabels: true,
- lineLabels: true
- }
- }
- //legend: { show:true, location: 'e' }
- });
+ poolID = $("#poolselectbox option:selected").val();
+ $.get("/statistic/runninglist/poolID/" + poolID, function(data) {
+ if(data.dataBar == '0,running0,0,running1' && poolID != 'default') {
+ $( "#noEventsDialog" ).dialog('open');
+ $('#plotBar').empty();
+ $('#plotPie').empty();
+ } else if (poolID == 'default') {
+ $('#plotBar').empty();
+ $('#plotPie').empty();
+ } else refreshPlot(data.dataBar, data.dataPie, data.color);
+ }, "json");
}
+function refreshPlot(dataBar, dataPie, color) {
+ $('#plotBar').empty();
+ $.jqplot('plotBar', dataBar, {
+ seriesDefaults: {
+ //renderer: $.jqplot.PieRenderer,
+ renderer:$.jqplot.BarRenderer,
+ pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
+ shadowAngle: 135,
+ rendererOptions: {
+ //showDataLabels: true,
+ barDirection: 'horizontal',
+ varyBarColor : true
+ }
+ },
+ axes: {
+ yaxis: {
+ renderer: $.jqplot.CategoryAxisRenderer
+ }
+ },
+ seriesColors: color,
+ highlighter: { show: false }
+ });
+ $('#plotPie').empty();
+ $.jqplot('plotPie', dataPie,
+ {
+ seriesDefaults: {
+ // Make this a pie chart.
+ renderer: jQuery.jqplot.PieRenderer,
+ rendererOptions: {
+ // Put data labels on the pie slices.
+ // By default, labels show the percentage of the slice.
+ showDataLabels: true,
+ lineLabels: true,
+ varyBarColor : true
+ }
+ },
+ seriesColors: color
+ //legend: { show:true, location: 'e' }
+ });
+ }
+
$(document).ready(function(){
//fetch poollist from pbs database
@@ -50,7 +86,34 @@ $(document).ready(function(){
});
});
+$(function() {
+ $( "#noEventsDialog" ).dialog({
+ autoOpen: false,
+ width: 600,
+ modal: true,
+ title: "No Events",
+ buttons: {
+ "OK": function() {
+ $(this).dialog("close");
+ }
+ },
+ open: function () {
+ $(".ui-dialog-titlebar-close").hide();
+ //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
+ }
+ });
+ });
+
</script>
-<div id="plot"
- style="height: 300px; width: 300px;"></div>
+<div>
+<div id="plotBar" class="spalte"
+ style="height: 250px; width: 250px;"></div>
+<div id="plotPie" class="spalte"
+ style="height: 250px; width: 250px;"></div>
+</div>
+
+<!-- no events -->
+<div id="noEventsDialog" style="display: none">
+<p>There are no events in this pool to plot a statistic.</p>
+</div> \ No newline at end of file