Code

Updated statistic generation
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Aug 2010 15:04:47 +0000 (15:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Aug 2010 15:04:47 +0000 (15:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19408 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/statistics/class_statistics.inc
gosa-core/plugins/generic/statistics/statistics.tpl

index 15db5bc1798e2838b4b08d4e8f43abcc7d543a0b..433e33833440fb7cfb4c2de8ab73a272294c605e 100644 (file)
@@ -70,6 +70,11 @@ class statistics extends plugin
         $available = $this->getLocalStatisticsFiles();
         $alreadyTransmitted = $this->getStatisticsDatesFromServer();
         $unsubmitted = array_intersect($available,$alreadyTransmitted);
+
+        // Exclude statistic collection from today, they are still active and cannot be submitted.
+        $curDate =  date('Y-m-d');
+        if(isset($unsubmitted)) unset($unsubmitted[$curDate]);
+
         return($unsubmitted);  
     }
 
@@ -202,6 +207,7 @@ class statistics extends plugin
                     $dates = array();
                     $DataSet2 = new pData;  
                     $max = 1;
+                    $seriesNumber = 0;
                     foreach($res['actionsPerInterval'] as $category => $entriesPerDate){
 
                         // Collect data per category and store used timestamps
@@ -227,6 +233,7 @@ class statistics extends plugin
                         $DataSet2->SetSerieName(_($category), $category);
                         $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1",0,"Daily incomes");  
                         $DataSet2->AddSerie($category);
+                        $seriesNumber++;
 
                         // Detect maximum value, to adjust the Y-Axis
                         $tmpMax = max($dataArray[$category]);
@@ -264,7 +271,6 @@ class statistics extends plugin
 
                     if(count($dates)){
                         $Test2->drawScale($DataSet2->GetData(),$DataSet2->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);     
-                        $DataSet2->RemoveSerie('date');
                     }
 
                     // Draw the cubic curve graph  
@@ -283,7 +289,9 @@ class statistics extends plugin
                     $DataSet2->AddPoint($errors, 'Errors');
                     $DataSet2->SetSerieName('Errors', 'Errors');
                     $DataSet2->AddSerie('Errors');
-                    
+                    $seriesNumber ++;
+                   
+                    $Test2->setColorPalette($seriesNumber-1,255,0,0);   
 
                     // Draw legend
                     $Test2->drawLegend(650,30,$DataSet2->GetDataDescription(),255,255,255);  
@@ -296,7 +304,7 @@ class statistics extends plugin
                     // Draw right scale (Errors per day)
                     $Test2->setFixedScale(0.0001,(max($errors) +1) *1.1);
                     $Test2->drawRightScale($DataSet2->GetData(),$DataSet2->GetDataDescription(),SCALE_NORMAL,120,150,150,TRUE,0,2);
-                    $Test2->drawBarGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE);
+                    $Test2->drawBarGraph($DataSet2->GetData(),$DataSet2->GetDataDescription());
 
                     $file = '/tmp/graph_'.$this->graphID_2;
                     $Test2->Render($file);
@@ -307,6 +315,11 @@ class statistics extends plugin
 
         $smarty->assign('graphID_1', $this->graphID_1);
         $smarty->assign('graphID_2', $this->graphID_2);
+        $smarty->assign('unsbmittedFiles', count($this->unsbmittedFiles));
+        $smarty->assign('unsbmittedFilesMsg', 
+                sprintf(
+                    _("You have currently %s unsubmitted statistic collection, do you want to transmit them now?"),
+                    count($this->unsbmittedFiles)));
         return($smarty->fetch(get_template_path('statistics.tpl', TRUE)));
     }
 
index 47fd7a832526a40d85d090484247e917707ef532..71572b76247ccbf5225f9ff88e24da6797d73a36 100644 (file)
 
 {else}
 
-    <button name='transmitStatistics'>{t}Send{/t}</button>
-    <button name='receiveStatistics'>{t}Receive{/t}</button>
+    {if $unsbmittedFiles != 0}
+        {$unsbmittedFilesMsg}
+        <button name='transmitStatistics'>{t}Send{/t}</button>
+        <hr>
+    {/if}
 
-    <hr>
-    <table width="100%">
+    <table>
         <tr>
-            <td>{t}Start{/t}</td>
-            <td>
+            <td>{t}Generate report for{/t}</td>
+            <td style='width:220px;'>
                  <input type="text" id="graph1DatePicker1" name="graph1DatePicker1" class="date" value="{$graph1DatePicker1}">
                  <script type="text/javascript">
                   {literal}
                   {/literal}
                  </script>
             </td>
-        </tr>
-        <tr>
-            <td>{t}Stop{/t}</td>
-            <td>
+            <td> - </td>
+            <td style='width:220px;'>
                 <input type="text" id="graph1DatePicker2" name="graph1DatePicker2" class="date" value="{$graph1DatePicker2}">
                 <script type="text/javascript">
                  {literal}
                  {/literal}
                 </script>
             </td>
+            <td>
+                <button name='receiveStatistics'>{t}Receive{/t}</button>
+            </td>
         </tr>
     </table>
+    <hr>
 
     <img src='plugins/statistics/getGraph.php?id={$graphID_1}'>
     <img src='plugins/statistics/getGraph.php?id={$graphID_2}'>