From b85e9746635fa63710dc791d013edc3f11091a60 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Mon, 7 Jun 2010 11:25:34 +0100 Subject: [PATCH] Added payment view --- app.rb | 5 +++++ public/style.css | 2 +- slugify.rb | 16 ++++++++++++++++ views/directorate.haml | 6 +++++- views/payment.haml | 33 +++++++++++++++++++++++++++++++++ views/service.haml | 4 ++++ views/supplier.haml | 4 ++++ 7 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 slugify.rb create mode 100644 views/payment.haml diff --git a/app.rb b/app.rb index 71e48f9..f341bb1 100644 --- a/app.rb +++ b/app.rb @@ -70,6 +70,11 @@ get '/services/?' do haml :services end +get '/payments/:id' do + @payment = Payment.get(params[:id]) + haml :payment +end + get '/error' do haml :error end diff --git a/public/style.css b/public/style.css index 770c436..8bb3caa 100644 --- a/public/style.css +++ b/public/style.css @@ -131,6 +131,6 @@ tr .download a:hover { - background-color: #ccc; + background-color: #eee; color: red; } diff --git a/slugify.rb b/slugify.rb new file mode 100644 index 0000000..b2072cd --- /dev/null +++ b/slugify.rb @@ -0,0 +1,16 @@ +require 'lib/models' + +for supplier in Supplier.all + supplier.slug = Supplier.slugify(supplier.name) + supplier.save! +end + +for service in Service.all + service.slug = Service.slugify(service.name) + service.save! +end + +for directorate in Directorate.all + directorate.slug = Directorate.slugify(directorate.name) + directorate.save! +end diff --git a/views/directorate.haml b/views/directorate.haml index 2e92230..1ac8ffb 100644 --- a/views/directorate.haml +++ b/views/directorate.haml @@ -12,6 +12,7 @@ %table %tr %th Date + %th Ref. %th Service %th Supplier %th.right £ @@ -19,6 +20,9 @@ - for payment in @directorate.payments %tr %td= payment.d.strftime("%d %b %Y") + %td + %a{ :href => "/payments/#{payment.id}" } + = payment.id %td %a{ :href => '/services/' + payment.service.slug } = payment.service.name @@ -33,5 +37,5 @@ %td %strong TOTAL %td.right= sprintf("%0d", @total) - + %td \ No newline at end of file diff --git a/views/payment.haml b/views/payment.haml new file mode 100644 index 0000000..f0380a3 --- /dev/null +++ b/views/payment.haml @@ -0,0 +1,33 @@ +.grid_12 + %h2= @page_title = "Payment " + @payment.id.to_s + + %table + %tr + %td Date + %td= @payment.d.strftime("%d %b %Y") + %tr + %td Directorate + %td + %a{ :href => "/directorates/#{@payment.directorate.slug}" } + = @payment.directorate.name + %tr + %td Service + %td + %a{ :href => "/services/#{@payment.service.slug}" } + = @payment.service.name + %tr + %td Supplier + %td + %a{ :href => "/suppliers/#{@payment.supplier.slug}" } + = @payment.supplier.name + %tr + %td Amount £ + %td= sprintf("%0.2f", @payment.amount) + %tr + %td Transaction Number + %td= @payment.trans_no > 0 ? @payment.trans_no : "unknown" + %tr + %td Type + %td= @payment.tyype + + \ No newline at end of file diff --git a/views/service.haml b/views/service.haml index 110efce..38a24d8 100644 --- a/views/service.haml +++ b/views/service.haml @@ -16,6 +16,7 @@ %table %tr %th Date + %th Ref. %th Directorate %th Supplier %th.right £ @@ -23,6 +24,9 @@ - for payment in @service.payments %tr %td= payment.d.strftime("%d %b %Y") + %td + %a{ :href => "/payments/#{payment.id}" } + = payment.id %td %a{ :href => '/directorates/' + payment.directorate.slug } = payment.directorate.name diff --git a/views/supplier.haml b/views/supplier.haml index f550ca8..9eed163 100644 --- a/views/supplier.haml +++ b/views/supplier.haml @@ -16,6 +16,7 @@ %table %tr %th Date + %th Ref. %th Directorate %th Service %th.right £ @@ -23,6 +24,9 @@ - for payment in @supplier.payments %tr %td= payment.d.strftime("%d %b %Y") + %td + %a{ :href => "/payments/#{payment.id}" } + = payment.id %td %a{ :href => '/directorates/' + payment.directorate.slug } = payment.directorate.name