From abd3a30d827d26713e03471b95271d1bca33567e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 5 Oct 2011 15:27:41 +0200 Subject: category statistic implemented --- application/controllers/EventController.php | 1 - application/controllers/StatisticController.php | 13 +----- application/models/EventMapper.php | 40 +++++++++---------- application/views/scripts/statistic/index.phtml | 53 ++++++++++++++----------- 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php index c063f2e..0a07247 100755 --- a/application/controllers/EventController.php +++ b/application/controllers/EventController.php @@ -844,7 +844,6 @@ class EventController extends Zend_Controller_Action } else { $eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID'])); } - foreach ($eventList as $event){ if($event->getPbs_poolID() == $poolID) { diff --git a/application/controllers/StatisticController.php b/application/controllers/StatisticController.php index 32503e5..1610f4c 100644 --- a/application/controllers/StatisticController.php +++ b/application/controllers/StatisticController.php @@ -59,19 +59,10 @@ class StatisticController extends Zend_Controller_Action } else { $eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID'])); }*/ - - //echo $count; - $ret2 = $this->eventMapper->getCategoryCount($poolID); - - $ret = array(); - - $ret[] = array(3,'Lecture'); - $ret[] = array(2,'Boot'); - $ret[] = array(65,'Shutdown'); - $ret[] = array(20,'Maintenance'); + $ret = $this->eventMapper->getCategoryCount($poolID); - echo json_encode($ret2); + echo json_encode($ret); } } \ No newline at end of file diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php index 144fb64..7ebb18f 100755 --- a/application/models/EventMapper.php +++ b/application/models/EventMapper.php @@ -185,33 +185,29 @@ class Application_Model_EventMapper } public function getCategoryCount($poolID) { - + $db = Zend_Db_Table::getDefaultAdapter(); $select = $this->getDbTable()->select() - ->from($this->_dbTable, - array('count' => 'COUNT(*)', 'category')) - ->where('poolctrl_event.pbs_poolID = ?', $poolID) - ->group('category'); - - $stmt = $db->query($select); - $result = $stmt->fetchAll(); - - return array($result); + ->setIntegrityCheck(false) + ->from(array('pce' => 'poolctrl_event'), + array('count' => 'COUNT(*)', 'category' => 'pcec.title')) + ->join(array('pcec' => 'poolctrl_eventcategory'), + 'pce.category = pcec.eventcategoryID') + ->where('pce.pbs_poolID = ?', $poolID) + ->group('pce.category'); + + $stmt = $db->query($select); + $result = $stmt->fetchAll(PDO::FETCH_NUM); + + return array($result); } - /* Erzeugt diese Anfrage: - // SELECT p."product_id", COUNT(*) AS line_items_per_product - // FROM "products" AS p JOIN "line_items" AS l - // ON p.product_id = l.product_id - // GROUP BY p.product_id + /* FROM "products" AS p JOIN "line_items" AS l + * ON p.product_id = l.product_id * - * - * - * - * SELECT category, COUNT( * ) AS count - * FROM `poolctrl_event` - * GROUP BY category - * LIMIT 0 , 30 + * ->join(array('l' => 'line_items'), + * 'p.product_id = l.product_id'); */ + } \ No newline at end of file diff --git a/application/views/scripts/statistic/index.phtml b/application/views/scripts/statistic/index.phtml index 8f63416..17bcc15 100644 --- a/application/views/scripts/statistic/index.phtml +++ b/application/views/scripts/statistic/index.phtml @@ -29,39 +29,21 @@ function setPoolIDtmp() { function plot() { poolID = $("#poolselectbox option:selected").val(); - $.get("/statistic/categorylist/poolID/" + poolID, function(data) { -// lecture = data.lecture; -// boot = data.boot; -// shutdown = data.shutdown; -// maintenance = data.maintenance; - refreshPlot(data); -// $.ajax({ -// type: 'POST', -// url: "/statistic/dump", -// data: {data: [[[boot,'Boot'], [shutdown,'Shutdwon'], [maintenance,'Maintenance'], [lecture,'Lecture']]]}, -// success: function(){alert("done");}, -// dataType: "json" -// }); - + if(data == '') { + $( "#noEventsDialog" ).dialog('open'); + $('#plot').empty(); + } else refreshPlot(data); }, "json"); } function refreshPlot(data) { $('#plot').empty(); -// $.jqplot('plot', [ -// [[boot,'Boot'], [shutdown,'Shutdwon'], [maintenance,'Maintenance'], [lecture,'Lecture']]], { $.jqplot('plot', data, { seriesDefaults: { renderer:$.jqplot.BarRenderer, - // Show point labels to the right ('e'ast) of each bar. - // edgeTolerance of -15 allows labels flow outside the grid - // up to 15 pixels. If they flow out more than that, they - // will be hidden. pointLabels: { show: true, location: 'e', edgeTolerance: -15 }, - // Rotate the bar shadow as if bar is lit from top right. shadowAngle: 135, - // Here's where we tell the chart it is oriented horizontally. rendererOptions: { barDirection: 'horizontal' } @@ -83,6 +65,31 @@ $(document).ready(function(){ fetchPoolEvents(); }); }); + +$(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"); + } + }); + }); + -
+
+ + + -- cgit v1.2.3-55-g7522