function uc_payment_by_order_form in Ubercart 6.2
Same name and namespace in other branches
- 5 payment/uc_payment/uc_payment.module \uc_payment_by_order_form()
- 7.3 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()
theme_uc_payment_by_order_form()
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 347 - Payment administration menu items.
Code
function uc_payment_by_order_form($form_state, $order) {
$total = $order->order_total;
$payments = uc_payment_load_payments($order->order_id);
$context = array(
'revision' => 'themed-original',
'type' => 'order_total',
'subject' => array(
'order' => $order,
),
);
$form['order_total'] = array(
'#value' => uc_price($total, $context),
);
$form['payments'] = tapir_get_table('uc_payments_table');
if ($payments !== FALSE) {
foreach ($payments as $payment) {
$context['type'] = 'payment';
$context['subject']['payment'] = $payment;
$form['payments'][$payment->receipt_id]['#attributes'] = array(
'valign' => 'top',
);
$form['payments'][$payment->receipt_id]['received'] = array(
'#value' => format_date($payment->received, 'custom', variable_get('uc_date_format_default', 'm/d/Y') . '<b\\r>H:i:s'),
);
$form['payments'][$payment->receipt_id]['user'] = array(
'#value' => uc_get_initials($payment->uid),
);
$form['payments'][$payment->receipt_id]['method'] = array(
'#value' => $payment->method == '' ? t('Unknown') : $payment->method,
);
$form['payments'][$payment->receipt_id]['amount'] = array(
'#value' => uc_price($payment->amount, $context),
);
$total -= $payment->amount;
unset($context['subject']['payment']);
$context['type'] = 'amount';
$context['subject']['total'] = $total;
$form['payments'][$payment->receipt_id]['balance'] = array(
'#value' => uc_price($total, $context, array(
'cache' => FALSE,
)),
);
$form['payments'][$payment->receipt_id]['comment'] = array(
'#value' => $payment->comment == '' ? '-' : filter_xss_admin($payment->comment),
);
if (variable_get('uc_payment_deleting', TRUE) && 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(
'#value' => $action_value,
);
}
}
$form['balance'] = array(
'#value' => uc_price($total, $context),
);
$form['order_id'] = array(
'#type' => 'hidden',
'#value' => $order->order_id,
);
$now = time();
if (user_access('manual payments')) {
$form['payments']['new']['#attributes'] = array(
'valign' => 'top',
);
$form['payments']['new']['received'] = array(
'#type' => 'date',
'#default_value' => array(
'month' => format_date($now, 'custom', 'n'),
'day' => format_date($now, 'custom', 'j'),
'year' => format_date($now, 'custom', 'Y'),
),
);
$form['payments']['new']['user'] = array(
'#value' => '-',
);
$methods = _payment_method_list();
foreach ($methods as $method) {
$options[$method['id']] = $method['name'];
}
$form['payments']['new']['method'] = array(
'#type' => 'select',
'#options' => $options,
);
$form['payments']['new']['amount'] = array(
'#type' => 'textfield',
'#size' => 6,
);
$form['payments']['new']['balance'] = array(
'#value' => '-',
);
$form['payments']['new']['comment'] = array(
'#type' => 'textfield',
'#size' => 32,
'#maxlength' => 256,
);
$form['payments']['new']['action'] = array(
'#type' => 'submit',
'#value' => t('Enter'),
);
}
return $form;
}