You are here

function uc_order_pane_admin_comments in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_order/uc_order_order_pane.inc \uc_order_pane_admin_comments()
  2. 7.3 uc_order/uc_order.order_pane.inc \uc_order_pane_admin_comments()

Handles the "Admin Comments" order pane.

1 string reference to 'uc_order_pane_admin_comments'
uc_order_order_pane in uc_order/uc_order.module
Implements hook_order_pane().

File

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

Code

function uc_order_pane_admin_comments($op, $arg1) {
  switch ($op) {
    case 'view':
      $comments = uc_order_comments_load($arg1->order_id, TRUE);
      return tapir_get_table('op_admin_comments_view_table', $comments);
    case 'edit-form':
      $form['admin_comment_field'] = array(
        '#type' => 'fieldset',
        '#title' => t('Add an admin comment'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['admin_comment_field']['admin_comment'] = array(
        '#type' => 'textarea',
        '#description' => t('Admin comments are only seen by store administrators.'),
        '#wysiwyg' => FALSE,
      );
      return $form;
    case 'edit-theme':
      $comments = uc_order_comments_load($arg1['order_id']['#value'], TRUE);
      if (is_array($comments) && count($comments) > 0) {
        foreach ($comments as $comment) {
          $items[] = '[' . uc_get_initials($comment->uid) . '] ' . filter_xss_admin($comment->message);
        }
      }
      else {
        $items = array(
          t('No admin comments have been entered for this order.'),
        );
      }
      $output = theme('item_list', $items) . drupal_render($arg1['admin_comment_field']);
      return $output;
    case 'edit-process':
      if (!is_null($arg1['admin_comment']) && strlen(trim($arg1['admin_comment'])) > 0) {
        global $user;
        uc_order_comment_save($arg1['order_id'], $user->uid, $arg1['admin_comment']);
      }
      return;
  }
}