X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Flib%2FMAPSWeb.pm;h=3389c6a7bde03b285108d22201fae8f033a879ee;hb=8d6e59ba7728e19d42da1533b9f24d0216867899;hp=50105f888457615afa5ae84e3bd7725df77f5d27;hpb=c48641da34d8e980a682818c1f627fd174bb9f07;p=clearscm.git diff --git a/maps/lib/MAPSWeb.pm b/maps/lib/MAPSWeb.pm index 50105f8..3389c6a 100644 --- a/maps/lib/MAPSWeb.pm +++ b/maps/lib/MAPSWeb.pm @@ -14,31 +14,35 @@ package MAPSWeb; use strict; -#use warnings; +use warnings; -use MAPS; -use MAPSLog; -use MAPSUtil; +use base qw(Exporter); -use CGI qw (:standard *table start_Tr end_Tr start_div end_div); -use vars qw (@ISA @EXPORT); +use DateUtils; -use Exporter; +use MAPS; +use MAPSLog; -@ISA = qw (Exporter); +use CGI qw(:standard *table start_Tr end_Tr start_div end_div); -@EXPORT = qw ( - Debug +our @EXPORT = qw( + DebugWeb DisplayError Footing Heading NavigationBar ); -sub getquickstats($) { - my ($date) = @_; +sub getquickstats(%) { + my (%params) = @_; + + my %dates = GetStats( + userid => $params{userid}, + days => 1, + date => $params{date}, + ); - my %dates = GetStats (1, $date); + my $date = $params{date}; for (@MAPSLog::Types) { $dates{$date}{processed} += $dates{$date}{$_}; @@ -47,19 +51,24 @@ sub getquickstats($) { return %dates; } # getquickstats -sub displayquickstats() { - # Quick stats are today only. +sub displayquickstats($) { + my ($userid) = @_; + + # Quick stats are today only my $today = Today2SQLDatetime; my $time = substr $today, 11; my $date = substr $today, 0, 10; - my %dates = getquickstats $date; + my %dates = getquickstats( + userid => $userid, + date => $date + ); print start_div {-class => 'quickstats'}; - print h4 {-class => 'header', + print h4 {-class => 'todaysactivity', -align => 'center'}, 'Today\'s Activity'; print p {-align => 'center'}, - b ('as of ' . FormatTime ($time)); + b ('as of ' . FormatTime($time)); print start_table { -align => 'center', -border => 0, @@ -85,6 +94,7 @@ sub displayquickstats() { my $value = $dates{$date}{$_}; my $percent; + if ($_ eq 'mailloop' || $_ eq 'registered') { $percent = 'n/a'; } else { @@ -92,16 +102,22 @@ sub displayquickstats() { 0 : $dates{$date}{$_} / $dates{$date}{processed} * 100; $percent = sprintf '%5.1f%s', $percent, '%'; } # if - my $stat = $value == 0 ? - 0 : a {-href => "detail.cgi?type=$_;date=$date"}, $value; - print - td {-class => 'smalllabel'}, ucfirst ($_); - print - td {-class => 'smallnumber'}, $stat; - print - td {-class => 'smallnumber'}, $percent; + + 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 + + print td {-class => 'smalllabel'}, $report, + td {-class => 'smallnumber'}, $value, + td {-class => 'smallnumber'}, $percent; + print end_Tr; - } # foreach + } # for + print end_table; print end_div; @@ -132,10 +148,10 @@ sub Footing(;$) { return; } # Footing -sub Debug($) { +sub DebugWeb($) { my ($msg) = @_; - print br, font ({ -class => 'error' }, 'DEBUG: '), $msg; + print br, font({ -class => 'error' }, 'DEBUG: '), $msg; return; } # Debug @@ -143,8 +159,11 @@ sub Debug($) { sub DisplayError($) { my ($errmsg) = @_; - print h3 ({-class => 'error', - -align => 'center'}, 'ERROR: ' . $errmsg); + print h3({ + -class => 'error', + -align => 'center'}, + 'ERROR: ' . $errmsg + ); Footing; @@ -154,13 +173,13 @@ sub DisplayError($) { # This subroutine puts out the header for web pages. It is called by # various cgi scripts thus has a few parameters. sub Heading($$$$;$$@) { - my ($action, # One of getcookie, setcookie, unsetcookie - $userid, # User id (if setting a cookie) - $title, # Title string - $h1, # H1 header - $h2, # H2 header (optional) - $table_name, # Name of table in page, if any - @scripts) = @_; # Array of JavaScript scripts to include + my ($action, # One of getcookie, setcookie, unsetcookie + $userid, # User id (if setting a cookie) + $title, # Title string + $h1, # H1 header + $h2, # H2 header (optional) + $table_name, # Name of table in page, if any + @scripts) = @_; # Array of JavaScript scripts to include my @java_scripts; my $cookie; @@ -205,48 +224,48 @@ sub Heading($$$$;$$@) { ); } # if - print - header (-title => "MAPS: $title", - -cookie => $cookie); - - if (defined $table_name) { - print - start_html (-title => "MAPS: $title", - -author => 'Andrew\@DeFaria.com', - -style => {-src => '/maps/css/MAPSStyle.css'}, - -onResize => "AdjustTableWidth (\"$table_name\");", - -head => [ - Link ({-rel => 'icon', - -href => '/maps/MAPS.png', - -type => 'image/png'}), - Link ({-rel => 'shortcut icon', - -href => '/maps/favicon.ico'}) - ], - -script => @java_scripts); + print header( + -title => $title, + -cookie => $cookie + ); + + if ($table_name) { + print start_html( + -title => $title, + -author => 'Andrew\@DeFaria.com', + -style => {-src => '/maps/css/MAPSStyle.css'}, + -onResize => "AdjustTableWidth (\"$table_name\");", + -head => [ + Link({-rel => 'icon', + -href => '/maps/MAPS.png', + -type => 'image/png'}), + Link({-rel => 'shortcut icon', + -href => '/maps/favicon.ico'}) + ], + -script => @java_scripts); } else { - print - start_html (-title => "MAPS: $title", - -author => 'Andrew\@DeFaria.com', - -style => {-src => '/maps/css/MAPSStyle.css'}, - -head => [ - Link ({-rel => 'icon', - -href => '/maps/MAPS.png', - -type => 'image/png'}), - Link ({-rel => 'shortcut icon', - -href => '/maps/favicon.ico'})], - -script => @java_scripts); + print start_html( + -title => $title, + -author => 'Andrew\@DeFaria.com', + -style => {-src => '/maps/css/MAPSStyle.css'}, + -head => [ + Link({-rel => 'icon', + -href => '/maps/MAPS.png', + -type => 'image/png'}), + Link({-rel => 'shortcut icon', + -href => '/maps/favicon.ico'})], + -script => @java_scripts); } # if print start_div {class => 'heading'}; - print h2 {-align => 'center', - -class => 'header'}, - font ({-class => 'standout'}, 'MAPS'), - $h1; + print h2 { + -align => 'center', + -class => 'header'}, $h1; if (defined $h2 && $h2 ne '') { - print h3 {-align => 'center', - -class => 'header'}, - $h2; + print h3 { + -align => 'center', + -class => 'header'}, $h2; } # if print end_div; @@ -261,7 +280,8 @@ sub NavigationBar($) { print start_div {-id => 'leftbar'}; - if (!defined $userid) { + unless ($userid) { + print h2({-align => 'center'}, font({-color => 'white'}, "MAPS $MAPS::Version")); print div ({-class => 'username'}, 'Welcome to MAPS'); print div ({-class => 'menu'}, (a {-href => '/maps/doc/'}, @@ -278,7 +298,9 @@ sub NavigationBar($) { 'Help
'), ); } else { + print h2({-align => 'center'}, font({-color => 'white'}, "MAPS $MAPS::Version")); print div ({-class => 'username'}, 'Welcome '. ucfirst $userid); + print div ({-class => 'menu'}, (a {-href => '/maps/'}, 'Home
'), @@ -301,6 +323,9 @@ sub NavigationBar($) { (a {-href => '/maps/?logout=yes'}, 'Logout'), ); + + displayquickstats($userid); + print start_div {-class => 'search'}; print start_form {-method => 'get', -action => '/maps/bin/search.cgi', @@ -316,8 +341,6 @@ sub NavigationBar($) { print end_form; print end_div; - displayquickstats; - print start_div {-class => 'search'}; print start_form {-method => 'post', -action => 'javascript://', @@ -331,11 +354,14 @@ sub NavigationBar($) { -maxlength => 255, -value => '', -onclick => "document.address.email.value = '';"}; + print p ""; print end_form; print end_div; } # if print end_div; + + return; } # NavigationBar 1;