You are here

function uc_order_log in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_order/uc_order.admin.inc \uc_order_log()
  2. 7.3 uc_order/uc_order.admin.inc \uc_order_log()

Display a log of changes made to an order.

1 string reference to 'uc_order_log'
uc_order_menu in uc_order/uc_order.module
Implementation of hook_menu().

File

uc_order/uc_order.module, line 2106

Code

function uc_order_log($order_id) {
  $order = uc_order_load($order_id);
  if ($order === FALSE) {
    drupal_set_message(t('Order @order_id does not exist.', array(
      '@order_id' => $order_id,
    )));
    drupal_goto('admin/store/orders');
  }
  $result = db_query("SELECT * FROM {uc_order_log} WHERE order_id = %d", $order_id);
  if (db_num_rows($result) == 0) {
    $output = 'No changes have been logged for this order.';
  }
  else {
    $header = array(
      t('Time'),
      t('User'),
      t('Changes'),
    );
    while ($change = db_fetch_object($result)) {
      $user = uc_get_initials($change->uid);
      $rows[] = array(
        'data' => array(
          format_date($change->created, 'short'),
          $user == '-' ? $user : l($user, 'user/' . $change->uid),
          $change->changes,
        ),
        'valign' => 'top',
      );
    }
    $output = theme('table', $header, $rows);
  }
  return $output;
}