From 128b6853f4799addddeb30fd93dc3b0112ce92aa Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Tue, 7 Jul 2015 15:57:31 +0800 Subject: [PATCH] Styling tweaks to the admin account page --- app/assets/stylesheets/admin/account.css.scss | 12 ++++- app/controllers/admin/account_controller.rb | 3 +- app/views/admin/account/show.html.haml | 48 +++++++++---------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/assets/stylesheets/admin/account.css.scss b/app/assets/stylesheets/admin/account.css.scss index 5f0289ef91..7d58147d91 100644 --- a/app/assets/stylesheets/admin/account.css.scss +++ b/app/assets/stylesheets/admin/account.css.scss @@ -2,6 +2,16 @@ margin-bottom: 0px; } -.invoice_summary { +table.invoice_summary { margin-bottom: 70px; + + tr.total { + font-weight: bold; + } +} + +.invoice_title { + .balance { + color: #9fc820; + } } diff --git a/app/controllers/admin/account_controller.rb b/app/controllers/admin/account_controller.rb index fd33857e05..63114b05f8 100644 --- a/app/controllers/admin/account_controller.rb +++ b/app/controllers/admin/account_controller.rb @@ -1,7 +1,8 @@ class Admin::AccountController < Spree::Admin::BaseController def show - @enterprises = spree_current_user.owned_enterprises + @invoices = spree_current_user.orders.where(distributor_id: Spree::Config[:accounts_distributor_id]) + @enterprises = Enterprise.where(id: BillablePeriod.where(owner_id: spree_current_user).map(&:enterprise_id)) # .group_by('enterprise.id').joins(:billable_periods) # .select('SUM(billable_periods.turnover) AS turnover').order('turnover DESC') end diff --git a/app/views/admin/account/show.html.haml b/app/views/admin/account/show.html.haml index c185ccb0b0..30d9eab0b3 100644 --- a/app/views/admin/account/show.html.haml +++ b/app/views/admin/account/show.html.haml @@ -2,12 +2,11 @@ - content_for :page_title do = t(:account) -- invoices = spree_current_user.orders.where(distributor_id: Spree::Config[:accounts_distributor_id]) -- if invoices.empty? +- if @invoices.empty? %h4 No invoices to display -- invoices.order('created_at DESC').each do |invoice| +- @invoices.order('created_at DESC').each do |invoice| - month = (invoice.created_at.localtime - 1.day) - range = "#{month.beginning_of_month.strftime("%d/%m/%y")}" - range += " - #{[month.end_of_month, Time.now].min.strftime("%d/%m/%y")}" @@ -15,7 +14,7 @@ .eight.columns.alpha %h4= "#{month.strftime("%b %Y")}#{( invoice.completed_at ? '' : '*' )}" .eight.columns.omega.text-right - %h4= invoice.display_total + %h4.balance= invoice.display_total %table.invoice_summary %col{ width: '20%' } %col{ width: '60%' } @@ -41,23 +40,24 @@ %td TOTAL %td= invoice.display_total - - --# - @enterprises.each do |enterprise| --# %h2= enterprise.name --# %table --# %thead --# %th Begins --# %th Ends --# %th Sells --# %th Trial? --# %th Turnover --# %th Bill --# - enterprise.billable_periods.each do |billable_period| --# %tr --# %td= billable_period.begins_at.strftime("%F %T") --# %td= billable_period.ends_at.strftime("%F %T") --# %td= billable_period.sells --# %td= billable_period.trial? --# %td= billable_period.display_turnover --# %td= billable_period.display_bill +-# - if @enterprises.empty? +-# %h4 No enterprises to display +-# +-# - @enterprises.each do |enterprise| +-# %h2= enterprise.name +-# %table +-# %thead +-# %th Begins +-# %th Ends +-# %th Sells +-# %th Trial? +-# %th Turnover +-# %th Bill +-# - enterprise.billable_periods.each do |billable_period| +-# %tr +-# %td= billable_period.begins_at.localtime.strftime("%F %T") +-# %td= billable_period.ends_at.localtime.strftime("%F %T") +-# %td= billable_period.sells +-# %td= billable_period.trial? +-# %td= billable_period.display_turnover +-# %td= billable_period.display_bill