@@ -6,6 +6,14 @@ require 'lib/models' | |||||
get '/' do | get '/' do | ||||
@directorates = Directorate.all( :order => ['name'] ) | @directorates = Directorate.all( :order => ['name'] ) | ||||
# @payments_count = Payment.all.size | |||||
# @suppliers_count = Supplier.all.size | |||||
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM payments") | |||||
@payments_count = @results[0] | |||||
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM suppliers") | |||||
@suppliers_count = @results[0] | |||||
@results = repository(:default).adapter.query("SELECT COUNT(*) FROM services") | |||||
@services_count = @results[0] | |||||
haml :home | haml :home | ||||
end | end | ||||
@@ -61,6 +69,11 @@ end | |||||
get '/services/:slug' do | get '/services/:slug' do | ||||
@service = Service.first(:slug => params[:slug]) | @service = Service.first(:slug => params[:slug]) | ||||
@total = @service.payments.sum(:amount) | @total = @service.payments.sum(:amount) | ||||
@count = @service.payments.size | |||||
@avg = @service.payments.avg(:amount) | |||||
@max = @service.payments.max(:amount) | |||||
@min = @service.payments.min(:amount) | |||||
haml :service | haml :service | ||||
end | end | ||||
@@ -134,3 +134,12 @@ tr | |||||
background-color: #eee; | background-color: #eee; | ||||
color: red; | color: red; | ||||
} | } | ||||
.callout | |||||
{ | |||||
background-color: beige; | |||||
padding: 0px; | |||||
font-size: 150%; | |||||
line-height: 1.5em; | |||||
} |
@@ -1,11 +1,32 @@ | |||||
.grid_12 | .grid_12 | ||||
-# | |||||
%ul#breadcrumb | %ul#breadcrumb | ||||
%li.home | %li.home | ||||
.clear | |||||
.grid_6 | |||||
%h2 Directorates | %h2 Directorates | ||||
- for directorate in @directorates | - for directorate in @directorates | ||||
%p | %p | ||||
%a{ :href=> "/directorates/#{directorate.slug}" } | %a{ :href=> "/directorates/#{directorate.slug}" } | ||||
= directorate.name | = directorate.name | ||||
.grid_6 | |||||
.callout | |||||
%p | |||||
Armchair Auditor lets you see how your council spends your money. | |||||
%p | |||||
We've got | |||||
= @payments_count | |||||
payments from | |||||
%a{ :href => "/services" } | |||||
= @services_count | |||||
services | |||||
at the Royal Borough of Windsor and Maidenhead to | |||||
%a{ :href => "/suppliers" } | |||||
= @suppliers_count | |||||
suppliers. |
@@ -24,7 +24,7 @@ | |||||
- for payment in @service.payments | - for payment in @service.payments | ||||
%tr | %tr | ||||
%td= payment.d.strftime("%d %b %Y") | %td= payment.d.strftime("%d %b %Y") | ||||
%td | |||||
%td.right | |||||
%a{ :href => "/payments/#{payment.id}" } | %a{ :href => "/payments/#{payment.id}" } | ||||
= payment.id | = payment.id | ||||
%td | %td | ||||
@@ -42,5 +42,17 @@ | |||||
%td | %td | ||||
%strong TOTAL | %strong TOTAL | ||||
%td.right= sprintf("%0d", @total) | %td.right= sprintf("%0d", @total) | ||||
%table | |||||
%tr | |||||
%th.right Count | |||||
%th.right Max | |||||
%th.right Min | |||||
%th.right Average | |||||
%tr | |||||
%td.right= @count | |||||
%td.right= sprintf("%0d", @max) | |||||
%td.right= sprintf("%0d", @min) | |||||
%td.right= sprintf("%0d", @avg) | |||||