r1325 + welcome the first report!
authorDenis Ovsienko <infrastation@yandex.ru>
Wed, 28 Nov 2007 19:43:29 +0000 (19:43 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Wed, 28 Nov 2007 19:43:29 +0000 (19:43 +0000)
ChangeLog
inc/database.php
inc/interface.php
inc/pagetitles.php

index c79d97c0dd9abd8f6212777f2b3acc4cff8a848f..6463912ecd00e956499661192f79796ad7959e99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
        new feature: more cisco models support in gateways/switchvlans
        new feature: initial implementation of SNMP port data importer
        new feature: reset UI configuration to defaults
+       new feature: initial reports code
 0.14.6 2007-10-15
        new feature: browser-side validation for a new IPv4 network
          (contributed by Aaron Dummer)
index dd9189c00ac2a64939029dd7e48761232c92f25d..c5478e7b2af2bcd0aa07ba6554fb65e00126d2c5 100644 (file)
@@ -1349,6 +1349,38 @@ function getDict ()
        return $dict;
 }
 
+function getDictStats ()
+{
+       $stock_chapters = array (1, 2, 3, 11, 12, 13, 14, 16, 17, 18, 19, 20);
+       global $dbxlink;
+       $query =
+               "select chapter_no, chapter_name, count(dict_key) as wc from " .
+               "Chapter natural left join Dictionary group by chapter_no";
+       $result = $dbxlink->query ($query);
+       if ($result == NULL)
+       {
+               showError ('SQL query failed in getDictStats()');
+               return NULL;
+       }
+       $tc = $tw = $uc = $uw = 0;
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+       {
+               $tc++;
+               $tw += $row['wc'];;
+               if (in_array ($row['chapter_no'], $stock_chapters))
+                       continue;
+               $uc++;
+               $uw += $row['wc'];;
+       }
+       $result->closeCursor();
+       $ret = array();
+       $ret['Total chapters in dictionary'] = $tc;
+       $ret['Total words in dictionary'] = $tw;
+       $ret['User chapters'] = $uc;
+       $ret['Words in user chapters'] = $uw;
+       return $ret;
+}
+
 function commitUpdateDictionary ($chapter_no = 0, $dict_key = 0, $dict_value = '')
 {
        if ($chapter_no <= 0 or $dict_key <= 0 or empty ($dict_value))
index ed8081ac7874ba77a43288ad4c89a088b5c72e9b..9995ce215a18f17e436c4d49d8d587cf29731308 100644 (file)
@@ -41,7 +41,7 @@ function renderIndex ()
                                                        <?php printImageHREF ('config'); ?></a></h1>
                                        </td>
                                        <td>
-                                               <h1><a href='<?php echo $root; ?>?page=reports'>[ Reports ]<br>
+                                               <h1><a href='<?php echo $root; ?>?page=reports'>Reports<br>
                                                <?php printImageHREF ('reports'); ?></a></h1>
                                        </td>
                                        <td>
@@ -2871,12 +2871,27 @@ function getFaviconURL ()
 
 function renderReportSummary ()
 {
+       echo "<table width='100%'>\n";
+       echo "<tr><td class=pcleft>\n";
+       startPortlet ("Dictionary stats");
+       echo "<table>\n";
+       foreach (getDictStats() as $header => $data)
+       {
+               echo "<tr><th>${header}:</th><td>${data}</td></tr>\n";
+       }
+       echo "</table>\n";
+       finishPortlet();
+
+       echo "</td><td class=pcright>\n";
+
        startPortlet ("Here be dragons");
        dragon();
        dragon();
        dragon();
        echo 'ASCII art &copy; Daniel C. Au';
        finishPortlet();
+       echo "</td></tr>\n";
+       echo "</table>\n";
 }
 
 function dragon ()
index 9d6c7cd1e42a4e0d84dad86194d351348d570182..f05ade7472461ee72e264db63be26f38910e76a9 100644 (file)
@@ -179,7 +179,7 @@ function static_title ($pageno)
                        $ret['name'] = 'User interface';
                        break;
                case 'reports':
-                       $ret['name'] = '[ Reports ]';
+                       $ret['name'] = 'Reports';
                        break;
                case 'help':
                        $ret['name'] = 'Help';