diff --git a/app.rb b/app.rb index 3853357..8e74bc8 100644 --- a/app.rb +++ b/app.rb @@ -6,6 +6,14 @@ require 'lib/models' get '/' do @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 end @@ -61,6 +69,11 @@ end get '/services/:slug' do @service = Service.first(:slug => params[:slug]) @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 end diff --git a/public/style.css b/public/style.css index 8bb3caa..6134c61 100644 --- a/public/style.css +++ b/public/style.css @@ -134,3 +134,12 @@ tr background-color: #eee; color: red; } + +.callout +{ + + background-color: beige; + padding: 0px; + font-size: 150%; + line-height: 1.5em; +} \ No newline at end of file diff --git a/views/home.haml b/views/home.haml index d2be2df..4a8e027 100644 --- a/views/home.haml +++ b/views/home.haml @@ -1,11 +1,32 @@ .grid_12 +-# %ul#breadcrumb %li.home - + +.clear + +.grid_6 %h2 Directorates - for directorate in @directorates %p %a{ :href=> "/directorates/#{directorate.slug}" } = 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. \ No newline at end of file diff --git a/views/service.haml b/views/service.haml index 6dec42c..26ce9b7 100644 --- a/views/service.haml +++ b/views/service.haml @@ -24,7 +24,7 @@ - for payment in @service.payments %tr %td= payment.d.strftime("%d %b %Y") - %td + %td.right %a{ :href => "/payments/#{payment.id}" } = payment.id %td @@ -42,5 +42,17 @@ %td %strong 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) \ No newline at end of file