Fixed quickstats
authorAndrew DeFaria <Andrew@DeFaria.com>
Fri, 23 Jul 2021 21:56:48 +0000 (14:56 -0700)
committerAndrew DeFaria <Andrew@DeFaria.com>
Fri, 23 Jul 2021 21:56:48 +0000 (14:56 -0700)
Well not totally fixed. There are still some CSS issues.

maps/css/MAPSStyle.css
maps/lib/MAPS.pm
maps/lib/MAPSLog.pm
maps/lib/MAPSWeb.pm
maps/php/MAPS.php

index 3945309..cc790d5 100644 (file)
@@ -75,14 +75,44 @@ body {
   width:        125px;
 }
 
+#quickwrap {
+  width: 130px;
+}
+#quickwrap table {
+  width:           100%;
+  table-layout:    fixed;
+  border-collapse: collapse;
+  background:      #579;
+}
+#quickwrap td.link a {
+  float:           left;
+  width:           10px;
+  margin-left:     -60px;
+  padding:         0 60px;
+  position:        relative;
+  text-decoration: none;
+  color:           white;
+  font-size:       12px;
+  font-weight:     bold;
+}
+#quickwrap td.link a:hover {
+  background:      #c1dffc;
+  color:           steelblue;
+}
+table tr:hover td {
+  background:      #c1dffc;
+  color:           steelblue;
+}
+
 .quickstats {
-  font-size:        10px;
+  font-size:        12px;
+  font-weight:      bold;
   line-height:      10px;
   margin:           2px;
   width:            125px;
 }
 .quickstats a:link {
-  color:           white;
+  color:           #c1dffc;
   text-decoration: none;
 }
 .quickstats a:visited {
@@ -92,9 +122,6 @@ body {
   color:      steelblue;
   background: white;
 }
-.quickstats a:active {
-  color: Yellow;
-}
 
 .toolbar a:hover {
   background: transparent;
index 7bafc97..153c4bb 100644 (file)
@@ -34,7 +34,7 @@ use base qw(Exporter);
 
 our $db;
 
-our $Version = '2.0';
+our $VERSION = '2.0';
 
 # Globals
 my $userid = $ENV{MAPS_USERNAME} ? $ENV{MAPS_USERNAME} : $ENV{USER};
@@ -155,6 +155,8 @@ sub OpenDB($$) {
   $db = MyDB->new($username, $password, $dbname, $dbserver);
 
   croak "Unable to instantiate MyDB ($username\@$dbserver:$dbname)" unless $db;
+
+  return;
 } # OpenDB
 
 BEGIN {
@@ -346,6 +348,7 @@ sub AddUserOptions(%) {
   } # for
 
   return ($err, $msg) if $err;
+  return;
 } # AddUserOptions
 
 sub Blacklist(%) {
@@ -797,11 +800,7 @@ sub GetUser() {
 sub GetUserInfo($) {
   my ($userid) = @_;
 
-  my $userinfo = $db->getone('user', "userid='$userid'", ['name', 'email']);
-
   return %{$db->getone('user', "userid='$userid'", ['name', 'email'])};
-
-  return %$userinfo;
 } # GetUserInfo
 
 sub GetUserOptions($) {
@@ -1292,7 +1291,7 @@ sub SetContext($) {
   if (UserExists($to_user)) {
     $userid = $to_user;
 
-    return GetUserInfo $userid;
+    return GetUserOptions $userid;
   } else {
     return 0;
   } # if
@@ -1327,11 +1326,11 @@ sub UpdateList(%) {
   my $table     = 'list';
   my $condition = "userid = '$rec{userid}' and type = '$rec{type}' and sequence = $rec{sequence}";
 
-  if ($rec{pattern} =~ /\@/ and !$rec{domain}) {
+  if ($rec{pattern} =~ /\@/ && !$rec{domain}) {
     ($rec{pattern}, $rec{domain}) = split /\@/, $rec{pattern};
-  } elsif (!$rec{pattern} and $rec{domain} =~ /\@/) {
+  } elsif (!$rec{pattern} && $rec{domain} =~ /\@/) {
     ($rec{pattern}, $rec{domain}) = split /\@/, $rec{domain};
-  } elsif (!$rec{pattern} and !$rec{domain}) {
+  } elsif (!$rec{pattern} && !$rec{domain}) {
     return "Must specify either Username or Domain";
   } # if
 
index 433de2b..930dd17 100644 (file)
@@ -24,6 +24,7 @@ use MAPS;
 use DateUtils;
 use Utils;
 
+our @ISA = qw(Exporter);
 our @EXPORT = qw (
   Debug
   Error
@@ -34,12 +35,12 @@ our @EXPORT = qw (
 );
 
 our @Types = (
+  'nulllist',
   'returned',
   'whitelist',
   'blacklist',
   'registered',
   'mailloop',
-  'nulllist'
 );
 
 sub nbr_msgs($) {
index 3389c6a..5097b77 100644 (file)
@@ -44,7 +44,7 @@ sub getquickstats(%) {
 
   my $date = $params{date};
 
-  for (@MAPSLog::Types) {
+  for (@Types) {
     $dates{$date}{processed} += $dates{$date}{$_};
   } # for
 
@@ -69,11 +69,15 @@ sub displayquickstats($) {
     'Today\'s Activity';
   print p {-align     => 'center'},
     b ('as of ' . FormatTime($time));
+
+  print start_div {-id => 'quickwrap'};
+
   print start_table {
-    -align       => 'center',
-    -border      => 0,
     -cellspacing => 0,
-    -cellpadding => 2};
+    -border      => 0,
+    -align       => 'center',
+    -cellpadding => 2,
+  };
   print start_Tr {-align => 'right'};
   print
     td {-class => 'smalllabel',
@@ -89,9 +93,10 @@ sub displayquickstats($) {
       'n/a';
   print end_Tr;
 
-  for (@MAPSLog::Types) {
+  for (@Types) {
     print start_Tr {-align => 'right'};
 
+    my $foo = $_;
     my $value = $dates{$date}{$_};
     my $percent;
 
@@ -105,13 +110,9 @@ sub displayquickstats($) {
 
     my $report = ucfirst $_;
 
-    if ($value) {
-      $report  = a {-href => "detail.cgi?type=$_;date=$date"}, $report;
-      $value   = a {-href => "detail.cgi?type=$_;date=$date"}, $value;
-      $percent = a {-href => "detail.cgi?type=$_;date=$date"}, $percent;
-    } # if
+    $report  = a {-href => "detail.cgi?type=$_;date=$date"}, $report if $value;
 
-    print td {-class => 'smalllabel'},  $report,
+    print td {-class => 'link'},  $report,
           td {-class => 'smallnumber'}, $value,
           td {-class => 'smallnumber'}, $percent;
 
@@ -120,6 +121,7 @@ sub displayquickstats($) {
 
   print end_table;
   print end_div;
+  print end_div;
 
   return;
 } # displayquickstats
index 3816c00..6ccc76d 100755 (executable)
@@ -220,9 +220,9 @@ function displayquickstats() {
   $current_time = date("g:i:s a");
 
   // Start quickstats
-  print "<div class=quickstats>";
-  print "<h4 align=center class=todaysactivity>Today's Activity</h4>";
-  print "<p align=center><b>as of $current_time</b></p>";
+  print "<div class=\"quickstats\">";
+  print "<h4 align=\"center\" class=\"todaysactivity\">Today's Activity</h4>";
+  print "<p align=\"center\"><b>as of $current_time</b></p>";
 
   $processed     = $dates[$today]["processed"];
   $returned      = $dates[$today]["returned"];
@@ -240,20 +240,21 @@ function displayquickstats() {
   $nulllist_pct  = $processed == 0 ? 0 :
     number_format ($nulllist / $processed * 100, 1, ".", "");
 
-  $returned_link = $returned == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=returned;date=$today>$returned</a>";
-  $whitelist_link = $whitelist == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=whitelist;date=$today>$whitelist</a>";
-  $blacklist_link = $blacklist == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=blacklist;date=$today>$blacklist</a>";
-  $registered_link = $registered == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=registered;date=$today>$registered</a>";
-  $mailloop_link = $mailloop == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=mailloop;date=$today>$mailloop</a>";
-  $nulllist_link = $nulllist == 0 ? 0 :
-    "<a href=/maps/bin/detail.cgi?type=nulllist;date=$today>$nulllist</a>";
+  $returned_link = $returned == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=returned;date=$today\">";
+  $whitelist_link = $whitelist == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=whitelist;date=$today\">";
+  $blacklist_link = $blacklist == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=blacklist;date=$today\">";
+  $registered_link = $registered == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=registered;date=$today\">";
+  $mailloop_link = $mailloop == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=mailloop;date=$today>\"";
+  $nulllist_link = $nulllist == 0 ? '' :
+    "<a href=\"/maps/bin/detail.cgi?type=nulllist;date=$today\">";
 
 print <<<EOT
+<div id="quickwrap">
 <table cellpadding="2" border="0" align="center" cellspacing="0">
   <tr align="right">
     <td align="right" class="smalllabel">Processed</td>
@@ -261,37 +262,38 @@ print <<<EOT
     <td align="right" class="smallnumber">n/a</td>
   </tr>
   <tr align="right">
-    <td class="smalllabel">Returned</td>
-    <td class=smallnumber>$returned_link
+    <td class="link">${nulllist_link}Nulllist</a></td>
+    <td class="smallnumber">$nulllist</td>
+    <td class="smallnumber">$nulllist_pct%</td>
+  </tr>
+  <tr align="right">
+    <td class="link">${returned_link}Returned</a></td>
+    <td class=smallnumber>$returned</td>
     <td class="smallnumber">$returned_pct%</td>
   </tr>
   <tr align="right">
-    <td class="smalllabel">Whitelist</td>
-    <td class="smallnumber">$whitelist_link
+    <td class="link">${whitelist_link}Whitelist</a></td>
+    <td class="smallnumber">$whitelist</td>
     <td class="smallnumber">$whitelist_pct%</td>
   </tr>
   <tr align="right">
-    <td class="smalllabel">Blacklist</td>
-    <td class="smallnumber">$blacklist_link
+    <td class="link">${blacklist_link}Blacklist</a></td>
+    <td class="smallnumber">$blacklist</td>
     <td class="smallnumber">$blacklist_pct%</td>
   </tr>
   <tr align="right">
-    <td class="smalllabel">Registered</td>
-    <td class="smallnumber">$registered_link
+    <td class="link">${registered_link}Registered</a></td>
+    <td class="smallnumber">$registered</td>
     <td class="smallnumber">n/a</td>
   </tr>
   <tr align="right">
-    <td class="smalllabel">Mailloop</td>
-    <td class="smallnumber">$mailloop_link
+    <td class="link">${mailloop_link}Mailloop</a></td>
+    <td class="smallnumber">$mailloop</td>
     <td class="smallnumber">n/a</td>
   </tr>
-  <tr align="right">
-    <td class="smalllabel">Nulllist</td>
-    <td class="smallnumber">$nulllist_link
-    <td class="smallnumber">$nulllist_pct%</td>
-  </tr>
 </table>
 </div>
+</div>
 EOT;
 } // displayquickstats