:ruby currency = current_currency.code.upcase total_for_today = Forgeos::Commerce::Statistics.total_of_sales(Date.current).to_f total_for_yesterday = Forgeos::Commerce::Statistics.total_of_sales(Date.current.yesterday).to_f total_for_week = Forgeos::Commerce::Statistics.total_of_sales(Date.current.ago(1.week)..Date.current).to_f total_for_last_week = Forgeos::Commerce::Statistics.total_of_sales(Date.current.ago(2.week)..Date.current.ago(1.week)).to_f week_diff = total_for_week.diff(total_for_last_week) total_for_month = Forgeos::Commerce::Statistics.total_of_sales(Date.current.ago(1.month)..Date.current).to_f total_for_last_month = Forgeos::Commerce::Statistics.total_of_sales(Date.current.ago(2.month)..Date.current.ago(1.month)).to_f month_diff = total_for_month.diff(total_for_last_month) lifetime_sales = Forgeos::Commerce::Statistics.total_of_sales.to_f online_users = User.where{{ :updated_at.gt => (Time.now - 10.minutes) }}.count today_users = User.count(:conditions => { :updated_at => Date.current.beginning_of_day..Date.current.end_of_day }) online_visitors = Forgeos::Statistics.total_of_visitors(Date.current) out_of_stock_products = Product.where{{ :deleted => false, :active => true, :stock.lt => 5 }}.count pages_viewed_today = Forgeos::Cms::Statistics.total_of_pages(Date.current) products_sales_today = Forgeos::Commerce::Statistics.total_of_sold_products(Date.current) #dashboard.grid_16.alpha.omega .left-dashboard.grid_12.alpha.omega .padding-wrap %p.summary = raw t('dashboard.intro', :visitors => online_visitors, :customers => today_users, :pages => pages_viewed_today, :products => products_sales_today, :total => price_with_currency(total_for_today.to_i)) - if out_of_stock_products > 0 = raw t('dashboard.out_of_stock', :products => out_of_stock_products) .quick-actions = link_to [forgeos_cms, :new, :admin, :page], :class => 'quick-action-button' do %span.big-icons.create-page = t('page.create.action').capitalize = link_to [forgeos_commerce, :new, :admin, :product], :class => 'quick-action-button' do %span.big-icons.create-product = t('product.create.action').capitalize = link_to [forgeos_commerce, :new, :admin, :special_offer], :class => 'quick-action-button' do %span.big-icons.create-offer = t('special_offer.create.action').capitalize = link_to [forgeos_core, :admin, :statistics], :class => 'quick-action-button' do %span.small-icons.see-stats = t('statistic.show.all').capitalize .clear - pending_orders = Order.all(:order => 'created_at DESC', :conditions => { :status => %w(unpaid accepted)}) - lastest_orders_count = 5 - lastest_orders = Order.all(:order => 'created_at DESC', :limit => lastest_orders_count) %h2.small-icons.orders = t('order', :count => 2).capitalize #to-tab.ui-tabs.ui-widget.ui-widget-content.ui-corner-all %ul.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all %li.ui-state-default.ui-corner-top.ui-tabs-selected.ui-state-active %a{ :href => "#last-orders" } = t('order.lastest', :count => lastest_orders_count).capitalize %li.ui-state-default.ui-corner-top %a{ :href => "#pending-orders" } = pending_orders.size = t('order.pendings', :count => pending_orders.size).capitalize #last-orders.ui-tabs-panel.ui-widget-content.ui-corner-bottom %table %tbody - lastest_orders.each do |order| %tr{ :class => cycle('','even')} %td.table-price= price_with_currency order.total %td.table-product = order.order_details.count = t(:product, :count => order.order_details.count).capitalize %td{ :class => "table-state #{order.status}"} = t(order.status, :scope => [:order,:status]).capitalize %td.table-customer =h order.user.fullname if order.user %td.table-time = t(:ago, :time => time_ago_in_words(order.created_at)) = link_to t('order.show.all').capitalize, [forgeos_commerce, :admin, :orders], :class => 'see-all-orders' #pending-orders.ui-tabs-panel.ui-widget-content.ui-corner-bottom.ui-tabs-hide %table %tbody - pending_orders.each do |order| %tr{ :class => cycle('','even')} %td.table-price= price_with_currency order.total %td.table-product = order.order_details.count = t(:product, :count => order.order_details.count).capitalize %td{ :class => "table-state #{order.status}"} = t(order.status, :scope => [:order,:status]).capitalize %td.table-customer =h order.user.fullname if order.user %td.table-time = t(:ago, :time => time_ago_in_words(order.created_at)) = link_to t('order.show.all').capitalize, [forgeos_commerce, :admin, :orders], :class => 'see-all-orders' / %h2.small-icons.activity Latest activity .latest-activity %table %tbody %tr %td.table-product %span.big-icons.create-page Page "About us" created %td by Quentin Tousart %td 2 hours before %tr.even %td %span.big-icons.create-page Page "About us" created %td by Quentin Tousart %td 2 hours before %tr %td %span.big-icons.create-page Page "About us" created %td by Quentin Tousart %td 2 hours before %tr.even %td %span.big-icons.create-product Page "About us" created %td by Quentin Tousart %td 2 hours before %tr %td %span.big-icons.create-page Page "About us" created %td by Quentin Tousart %td 2 hours before .right-dahsboard.grid_4 %h2.small-icons.sales = t(:sale, :count => 2).capitalize .sales-info-block .today-sales.first-block %span.left = t('sale.day.current').capitalize %span.right = total_for_today.floor %sup - decimal = total_for_today.decimal = "#{t(:separator, :scope => :number)}#{decimal}" if decimal > 0 = currency .clear .yesterday-sales.second-block %span.left = t('sale.day.previous').capitalize %span.right = total_for_yesterday.floor %sup - decimal = total_for_yesterday.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency .clear .sales-info-block .week-sales.first-block %span.left = t('sale.week.current').capitalize %span.right = total_for_week.floor %sup - decimal = total_for_week.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency .clear .last-week-sales.second-block %span.left = t('sale.week.previous').capitalize %span.right = total_for_last_week.floor %sup - decimal = total_for_last_week.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency - if week_diff >= 0 %div{ :class => 'diff-positive' } = "+#{week_diff}%" - else %div{ :class => 'diff-negative' } = "#{week_diff}%" .clear .sales-info-block .month-sales.first-block %span.left = t('sale.month.current').capitalize %span.right = total_for_month.floor %sup - decimal = total_for_month.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency .clear .last-month-sales.second-block %span.left = t('sale.month.previous').capitalize %span.right = total_for_last_month.floor %sup - decimal = total_for_last_month.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency - if month_diff >= 0 %div{ :class => 'diff-positive' } = "+#{month_diff}%" - else %div{ :class => 'diff-negative' } = "#{month_diff}%" .clear .sales-info-block .life-time-sales %span.left = t('sale.lifetime').capitalize %span.right = lifetime_sales.floor %sup - decimal = lifetime_sales.decimal = "#{t(:separator, :scope => [:number, :format])}#{decimal}" if decimal > 0 = currency .clear %h2.small-icons.live-stats = t('statistic.live', :count => 2).capitalize .live-stats-content %span= t('visitor.online', :count => online_visitors) %span= t('user.online', :count => online_users) %span= t('cart.created', :count => Cart.count(:conditions => '`products`.`id` IS NOT NULL', :include => :products)) .clear