You are here

function uc_payment_by_order_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 payment/uc_payment/uc_payment.module \uc_payment_by_order_form()
  2. 6.2 payment/uc_payment/uc_payment.admin.inc \uc_payment_by_order_form()

Displays a list of payments attached to an order.

See also

uc_payment_by_order_form_validate()

uc_payment_by_order_form_submit()

1 string reference to 'uc_payment_by_order_form'
uc_payment_menu in payment/uc_payment/uc_payment.module
Implements hook_menu().

File

payment/uc_payment/uc_payment.admin.inc, line 126
Payment administration menu items.

Code

function uc_payment_by_order_form($form, &$form_state, $order) {
  $form['#attached']['css'][] = drupal_get_path('module', 'uc_payment') . '/uc_payment.css';
  $total = $order->order_total;
  $payments = uc_payment_load_payments($order->order_id);
  $form['order_total'] = array(
    '#type' => 'item',
    '#title' => t('Order total'),
    '#theme' => 'uc_price',
    '#price' => $total,
  );
  $form['payments'] = tapir_get_table('uc_payments_table');
  $form['payments']['#weight'] = 10;
  if ($payments !== FALSE) {
    foreach ($payments as $payment) {
      $form['payments'][$payment->receipt_id]['received'] = array(
        '#markup' => format_date($payment->received, 'custom', variable_get('date_format_uc_store', 'm/d/Y') . '<b\\r />H:i:s'),
      );
      $form['payments'][$payment->receipt_id]['user'] = array(
        '#markup' => theme('uc_uid', array(
          'uid' => $payment->uid,
        )),
      );
      $form['payments'][$payment->receipt_id]['method'] = array(
        '#markup' => $payment->method == '' ? t('Unknown') : $payment->method,
      );
      $form['payments'][$payment->receipt_id]['amount'] = array(
        '#theme' => 'uc_price',
        '#price' => $payment->amount,
      );
      $total -= $payment->amount;
      $form['payments'][$payment->receipt_id]['balance'] = array(
        '#theme' => 'uc_price',
        '#price' => $total,
      );
      $form['payments'][$payment->receipt_id]['comment'] = array(
        '#markup' => $payment->comment == '' ? '-' : filter_xss_admin($payment->comment),
      );
      if (user_access('delete payments')) {
        $action_value = l(t('Delete'), 'admin/store/orders/' . $order->order_id . '/payments/' . $payment->receipt_id . '/delete');
      }
      else {
        $action_value = '-';
      }
      $form['payments'][$payment->receipt_id]['action'] = array(
        '#markup' => $action_value,
      );
    }
  }
  $form['balance'] = array(
    '#type' => 'item',
    '#title' => t('Current balance'),
    '#theme' => 'uc_price',
    '#price' => $total,
  );
  $form['order_id'] = array(
    '#type' => 'hidden',
    '#value' => $order->order_id,
  );
  if (user_access('manual payments')) {
    $form['payments']['new']['received'] = array(
      '#type' => 'date',
      '#default_value' => array(
        'month' => format_date(REQUEST_TIME, 'custom', 'n'),
        'day' => format_date(REQUEST_TIME, 'custom', 'j'),
        'year' => format_date(REQUEST_TIME, 'custom', 'Y'),
      ),
    );
    $form['payments']['new']['user'] = array(
      '#markup' => '-',
    );
    $methods = _uc_payment_method_list();
    foreach ($methods as $id => $method) {
      $options[$id] = $method['name'];
    }
    $form['payments']['new']['method'] = array(
      '#type' => 'select',
      '#title' => t('Method'),
      '#title_display' => 'invisible',
      '#options' => $options,
    );
    $form['payments']['new']['amount'] = array(
      '#type' => 'textfield',
      '#title' => t('Amount'),
      '#title_display' => 'invisible',
      '#size' => 6,
    );
    $form['payments']['new']['balance'] = array(
      '#markup' => '-',
    );
    $form['payments']['new']['comment'] = array(
      '#type' => 'textfield',
      '#title' => t('Comment'),
      '#title_display' => 'invisible',
      '#size' => 32,
      '#maxlength' => 256,
    );
    $form['payments']['new']['action'] = array(
      '#type' => 'actions',
    );
    $form['payments']['new']['action']['action'] = array(
      '#type' => 'submit',
      '#value' => t('Enter'),
    );
  }
  return $form;
}