Code

Updated stats plugin
[gosa.git] / gosa-core / plugins / generic / statistics / class_statistics.inc
index 8b5269da17e47b6b91ddda4dae2435d7be4f1791..c3fa0645b21fc0785f1e287c9f1ba7e38e4b87e2 100644 (file)
@@ -60,7 +60,14 @@ class statistics extends plugin
 
             // First try to retrieve values via RPC
             if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){
-                $res = $this->rpcHandle->getInstanceStats();
+
+
+                $days = 40;
+                $interval = 1;
+                $start = time() - ($days*86400);
+                $stop  = time();
+
+                $res = $this->rpcHandle->getInstanceStats($start,$stop,'day',$interval);
                 if(!$this->rpcHandle->success()){
                     msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcHandle->get_error()),ERROR_DIALOG);
                 }
@@ -75,8 +82,8 @@ class statistics extends plugin
                     // --------
 
                     // Get most used categories, but only eight at once.
-                    arsort($res['category_count']);
-                    $mostUsedCategories = array_slice($res['category_count'],0,8);
+                    arsort($res['actionsPerCategory']);
+                    $mostUsedCategories = array_slice($res['actionsPerCategory'],0,8);
 
                     // Dataset definition   
                     $DataSet = new pData;  
@@ -88,7 +95,7 @@ class statistics extends plugin
 
                     // Initialise the graph  
                     $Test = new pChart(400,200);  
-                    $Test->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",8);  
+                    $Test->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);  
                     $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),150,90,110,PIE_PERCENTAGE,TRUE,50,20,5);  
                     $Test->drawPieLegend(310,15,$DataSet->GetData(),$DataSet->GetDataDescription(),200,255,200);  
 
@@ -109,39 +116,38 @@ class statistics extends plugin
                     $DataSet2 = new pData;  
                     $dates = array();
                     $max = 0;
-                    foreach($res['action_per_date'] as $id => $data){
+
+                    foreach($res['actionsPerInterval'] as $id => $data){
 
                         $category = $data['category'];
-                        $date =  date('d .m', $data['date']);
+                        $date =  $data['date'];
 
                         if(!isset($mostUsedCategories[$category])) continue;
 
                         if($data['count'] > $max) $max = $data['count'];
                         $tmp[$category][$date] = $data['count'];
-                        $dates[] = $date;
+                        $dates[$date] = $date;
                     }
-                    $dates = array_unique($dates);
+                    $dates = array_values($dates);
+                    sort($dates);
 
                     foreach($tmp as $category => $data){
-                        
-                        foreach($dates as $date){
-                            if(!isset($tmp[$category][$date])){
-                                $tmp[$category][$date] =0;
-                            }
-                        }     
-
+                        ksort($tmp[$category]);
                         $DataSet2->AddPoint($tmp[$category], $category);
                         $DataSet2->SetSerieName(_($category), $category);
                     }
                     $DataSet2->AddAllSeries();  
 
-                    $DataSet2->AddPoint($dates, 'date');
+                    $tmp = array();
+                    foreach($dates as $date) $tmp[] = date('d.m', $date);
+
+                    $DataSet2->AddPoint($tmp, 'date');
                     $DataSet2->SetAbsciseLabelSerie('date');  
                     $DataSet2->RemoveSerie('date');  
 
                     $Test2 = new pChart(700,230);  
                     $Test2->setFixedScale(0,$max);  
-                    $Test2->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",8);  
+                    $Test2->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);  
                     $Test2->setGraphArea(50,30,585,200);  
                     $Test2->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);  
                     $Test2->drawRoundedRectangle(5,5,695,225,5,230,230,230);  
@@ -153,8 +159,9 @@ class statistics extends plugin
                     $Test2->drawTreshold(0,143,55,72,TRUE,TRUE);  
 
                     // Draw the cubic curve graph  
-#                    $Test2->drawBarGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE);  
-                    $Test2->drawLineGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE);  
+                    #$Test2->drawBarGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE);  
+                    #$Test2->drawLineGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE); 
+                    $Test2->drawFilledLineGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),50,TRUE);  
 
                     // Finish the graph  
                     $DataSet2->RemoveSerie('date');