You are here

function uc_op_order_comments_view_table in Ubercart 7.3

Builds the order comments table.

1 string reference to 'uc_op_order_comments_view_table'
uc_order_pane_order_comments in uc_order/uc_order.order_pane.inc
Handles the "Order Comments" order pane.

File

uc_order/uc_order.order_pane.inc, line 1234
This file contains the callbacks for the default order panes supplied with Ubercart and their corresponding helper functions.

Code

function uc_op_order_comments_view_table($comments) {
  $table = array(
    '#type' => 'tapir_table',
    '#attributes' => array(
      'class' => array(
        'order-pane-table uc-order-comments',
      ),
    ),
  );
  $table['#columns']['date'] = array(
    'cell' => array(
      'data' => t('Date'),
      'class' => array(
        'date',
      ),
    ),
    'weight' => 0,
  );
  $table['#columns']['user'] = array(
    'cell' => array(
      'data' => t('User'),
      'class' => array(
        'user',
      ),
    ),
    'weight' => 1,
  );
  $table['#columns']['notified'] = array(
    'cell' => array(
      'data' => t('Notified'),
      'class' => array(
        'notified',
      ),
    ),
    'weight' => 2,
  );
  $table['#columns']['status'] = array(
    'cell' => array(
      'data' => t('Status'),
      'class' => array(
        'status',
      ),
    ),
    'weight' => 3,
  );
  $table['#columns']['comment'] = array(
    'cell' => array(
      'data' => t('Comment'),
      'class' => array(
        'message',
      ),
    ),
    'weight' => 4,
  );
  if (is_array($comments) && !empty($comments)) {
    foreach ($comments as $comment) {
      $data = array();
      $data['date'] = array(
        '#markup' => format_date($comment->created, 'short'),
        '#cell_attributes' => array(
          'class' => 'date',
        ),
      );
      $data['user'] = array(
        '#markup' => theme('uc_uid', array(
          'uid' => $comment->uid,
        )),
        '#cell_attributes' => array(
          'class' => 'user',
        ),
      );
      $icon = $comment->notified ? 'true-icon.gif' : 'false-icon.gif';
      $data['notified'] = array(
        '#markup' => theme('image', array(
          'path' => drupal_get_path('module', 'uc_order') . '/images/' . $icon,
        )),
        '#cell_attributes' => array(
          'class' => 'notified',
        ),
      );
      $data['status'] = array(
        '#markup' => $comment->title,
        '#cell_attributes' => array(
          'class' => 'status',
        ),
      );
      $data['comment'] = array(
        '#markup' => check_plain($comment->message),
        '#cell_attributes' => array(
          'class' => 'message',
        ),
      );
      $table['#rows'][] = $data;
    }
  }
  else {
    $data['comment'] = array(
      '#markup' => t('This order has no comments associated with it.'),
      '#cell_attributes' => array(
        'colspan' => 'full',
      ),
    );
    $table['#rows'][] = $data;
  }
  return $table;
}