You are here

function commerce_reports_customer_map in Commerce Reporting 7.3

Implementation of billing information block.

1 call to commerce_reports_customer_map()
commerce_reports_block_view in ./commerce_reports.module
Implements hook_block_view().
2 string references to 'commerce_reports_customer_map'
commerce_reports_block_view in ./commerce_reports.module
Implements hook_block_view().
commerce_reports_commerce_reports_dashboard in ./commerce_reports.module
Implements hook_commerce_reports_dashboard().

File

./commerce_reports.blocks.inc, line 110
Provides all statistics and other features that are not powered by Views.

Code

function commerce_reports_customer_map() {
  $data = array();
  $result = db_query("SELECT ca.commerce_customer_address_country AS country, COUNT(*) AS count FROM {field_data_commerce_customer_address} ca WHERE ca.bundle = 'billing' GROUP BY ca.commerce_customer_address_country");
  $result
    ->setFetchMode(PDO::FETCH_ASSOC);
  foreach ($result as $record) {
    $data[] = $record;
  }
  $options = array(
    'title' => 'Customer map',
    'fields' => array(
      'country' => array(
        'label' => t('Country'),
      ),
      'count' => array(
        'enabled' => TRUE,
        'label' => t('Amount'),
      ),
    ),
    'xAxis' => array(
      'labelField' => 'country',
    ),
    'data' => $data,
    'type' => 'map',
    'height' => '400px',
  );
  return array(
    '#theme' => 'visualization',
    '#options' => $options,
  );
}