aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2007-05-09 19:26:09 +0000
committermatthew <matthew>2007-05-09 19:26:09 +0000
commitd6a5aa4a41496006d2ec8f7adf250e57a9374e9e (patch)
treeba25bd481885123a2b7e18ee12e775d01e71f43b
parent62c001d16bb86d3e9ff055042a7cf9845ea79d9b (diff)
Summary table for main report page.
-rwxr-xr-xweb/report.cgi40
1 files changed, 27 insertions, 13 deletions
diff --git a/web/report.cgi b/web/report.cgi
index 6eefb258c..76b371cc6 100755
--- a/web/report.cgi
+++ b/web/report.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: report.cgi,v 1.17 2007-05-09 19:15:35 matthew Exp $
+# $Id: report.cgi,v 1.18 2007-05-09 19:26:09 matthew Exp $
use strict;
require 5.8.0;
@@ -39,7 +39,7 @@ sub main {
my $one_council = $q->param('council');
$all = 0 unless $one_council;
my @params;
- my $where_extra;
+ my $where_extra = '';
if ($one_council) {
push @params, $one_council;
$where_extra = "and council like '%'||?||'%'";
@@ -74,30 +74,44 @@ sub main {
print Page::header($q, 'Summary reports');
if (!$one_council) {
print $q->p('This is a summary of all reports on this site that have been sent to a council; select \'show only\' to see the reports for just one council.');
+ print '<table>';
+ print '<tr><th>Name</th><th>New problems</th><th>Old problems, still present</th>
+<th>Old problems, state unknown</th><th>Recently fixed</th><th>Old fixed</th></tr>';
+ foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) {
+ print '<tr><td><a href="report?council=' . $_ . '">' . $areas_info->{$_}->{name} . '</a></td>';
+ summary_cell(\@{$open{$_}{new}{new}});
+ summary_cell(\@{$open{$_}{old}{new}});
+ summary_cell(\@{$open{$_}{old}{old}});
+ summary_cell(\@{$fixed{$_}{new}});
+ summary_cell(\@{$fixed{$_}{old}});
+ print "</tr>\n";
+ }
+ print '</table>';
} else {
print $q->p('This is a summary of all reports for one council. You can ' .
$q->a({href => NewURL($q, all=>1) }, 'see more details') .
' or go back and ' .
$q->a({href => NewURL($q, all=>undef, council=>undef) }, 'show all councils') .
'.');
- }
- foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) {
- print '<h2>' . $areas_info->{$_}->{name};
- if (!$one_council) {
- print ' ' . $q->small('('.$q->a({href => NewURL($q, 'council'=>$_) }, 'show only').')');
+ foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) {
+ print '<h2>' . $areas_info->{$_}->{name} . "</h2>\n";
+ list_problems('New problems', $open{$_}{new}{new}, $all) if $open{$_}{new}{new};
+ list_problems('Old problems, still present', $open{$_}{old}{new}, $all) if $open{$_}{old}{new};
+ list_problems('Old problems, state unknown', $open{$_}{old}{old}, $all) if $open{$_}{old}{old};
+ list_problems('Recently fixed', $fixed{$_}{new}, $all) if $fixed{$_}{new};
+ list_problems('Old fixed', $fixed{$_}{old}, $all) if $fixed{$_}{old};
}
- print "</h2>\n";
- list_problems('New problems', $open{$_}{new}{new}, $all) if $open{$_}{new}{new};
- list_problems('Old problems, still present', $open{$_}{old}{new}, $all) if $open{$_}{old}{new};
- list_problems('Old problems, state unknown', $open{$_}{old}{old}, $all) if $open{$_}{old}{old};
- list_problems('Recently fixed', $fixed{$_}{new}, $all) if $fixed{$_}{new};
- list_problems('Old fixed', $fixed{$_}{old}, $all) if $fixed{$_}{old};
}
print Page::footer();
dbh()->rollback();
}
Page::do_fastcgi(\&main);
+sub summary_cell {
+ my $c = shift;
+ print $c ? '<td>' . scalar @$c . '</td>' : '<td>0</td>';
+}
+
sub list_problems {
my ($title, $problems, $all) = @_;
print "<h3>$title</h3>\n<ul>";