You are here

public function SupportClientUIController::overviewTable in Support Ticketing System 7

Generates the render array for a overview table for arbitrary entities matching the given conditions.

Parameters

$conditions: An array of conditions as needed by entity_load().

Return value

Array A renderable array.

Overrides EntityDefaultUIController::overviewTable

File

includes/support.ui.inc, line 19
UI controllers for support entities.

Class

SupportClientUIController
@file UI controllers for support entities.

Code

public function overviewTable($conditions = array()) {

  // Used for _support_admin_default_mail().
  module_load_include('inc', 'support', 'support.admin');
  $rows = array();
  $header = array(
    array(
      'data' => t('Client name'),
      'field' => 'name',
      'type' => 'property',
      'specifier' => 'name',
    ),
    array(
      'data' => t('Status'),
      'field' => 'status',
      'type' => 'property',
      'specifier' => 'status',
    ),
    array(
      'data' => t('Inbound email'),
      'field' => 'integrate_email',
      'type' => 'property',
      'specifier' => 'integrate_email',
    ),
    array(
      'data' => t('From address'),
      'field' => 'mailfrom',
      'type' => 'property',
      'specifier' => 'mailfrom',
    ),
  );
  if (!empty($this->entityInfo['exportable'])) {
    $header[] = t('Status');
  }

  // Add operations with the right colspan.
  $field_ui = !empty($this->entityInfo['bundle of']) && module_exists('field_ui');
  $exportable = !empty($this->entityInfo['exportable']);
  $colspan = 4;
  $colspan = $field_ui ? $colspan + 2 : $colspan;
  $colspan = $exportable ? $colspan + 1 : $colspan;
  $header[] = array(
    'data' => t('Operations'),
    'colspan' => $colspan,
  );
  $query = new EntityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'support_client')
    ->tableSort($header)
    ->pager(50)
    ->execute();
  if (!empty($result['support_client'])) {
    $clients = entity_load('support_client', array_keys($result['support_client']), $conditions);
    foreach ($clients as $entity) {
      $rows[] = $this
        ->overviewTableRow($conditions, entity_id($this->entityType, $entity), $entity);
    }
  }
  $render = array();
  $render[] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('None.'),
  );
  return $render;
}