You are here

function mandrill_reports_summary_page in Mandrill 7

Same name and namespace in other branches
  1. 7.2 modules/mandrill_reports/mandrill_reports.module \mandrill_reports_summary_page()

Displays summary information for the active API user.

1 string reference to 'mandrill_reports_summary_page'
mandrill_reports_menu in modules/mandrill_reports/mandrill_reports.module
Implements hook_menu().

File

modules/mandrill_reports/mandrill_reports.module, line 199
Main module functions for mandrill_reports.

Code

function mandrill_reports_summary_page() {
  $data = mandrill_reports_data();
  $info = $data['user'];
  $header = array(
    t('Range'),
    t('Sent'),
    t('hard_bounces'),
    t('soft_bounces'),
    t('Rejects'),
    t('Complaints'),
    t('Unsubs'),
    t('Opens'),
    t('unique_opens'),
    t('Clicks'),
    t('unique_clicks'),
  );
  $rows = array();
  foreach ($info['stats'] as $key => $stat) {
    $rows[] = array(
      str_replace('_', ' ', $key),
      $stat['sent'],
      $stat['hard_bounces'],
      $stat['soft_bounces'],
      $stat['rejects'],
      $stat['complaints'],
      $stat['unsubs'],
      $stat['opens'],
      $stat['unique_opens'],
      $stat['clicks'],
      $stat['unique_clicks'],
    );
  }
  $render = array(
    'info' => array(
      '#theme' => 'table',
      '#rows' => array(
        array(
          t('Username'),
          $info['username'],
        ),
        array(
          t('Reputation'),
          $info['reputation'],
        ),
        array(
          t('Hourly quota'),
          $info['hourly_quota'],
        ),
        array(
          t('Backlog'),
          $info['backlog'],
        ),
      ),
      '#header' => array(
        t('Attribute'),
        t('Value'),
      ),
      '#caption' => t('Active API user information.'),
    ),
    'stats' => array(
      '#theme' => 'table',
      '#rows' => $rows,
      '#header' => $header,
      '#caption' => t("This table contains an aggregate summary of the account's sending stats."),
    ),
  );
  return $render;
}