You are here

function commerce_reports_dashboard in Commerce Reporting 7.3

Same name and namespace in other branches
  1. 7.4 commerce_reports.dashboard.inc \commerce_reports_dashboard()

Renders the dashboard.

1 string reference to 'commerce_reports_dashboard'
commerce_reports_menu in ./commerce_reports.module
Implements hook_menu().

File

./commerce_reports.dashboard.inc, line 24
Dashboard for reporting module.

Code

function commerce_reports_dashboard() {
  drupal_add_js(drupal_get_path('module', 'commerce_reports') . '/js/dashboard.js', 'file');
  drupal_add_css(drupal_get_path('module', 'commerce_reports') . '/commerce_reports_dashboard.css');
  $info = module_invoke_all('commerce_reports_dashboard');
  drupal_alter('commerce_reports_dashboard', $info);
  $weights = array();
  foreach ($info as $block) {
    $weights[] = isset($block['weight']) ? $block['weight'] : 1000;
  }
  array_multisort($weights, $info);
  $render = array();
  $items = array();
  foreach ($info as $name => $block) {
    $type = isset($block['type']) ? $block['type'] : COMMERCE_REPORTS_DASHBOARD_BLOCK;
    if (commerce_reports_dashboard_block_width($items) + $type > 3) {
      $render[] = commerce_reports_dashboard_row($items);
      $items = array();
    }
    $items[] = commerce_reports_dashboard_block($name, $block);
  }
  if (!empty($items)) {
    $render[] = commerce_reports_dashboard_row($items);
    $items = array();
  }
  return $render;
}