You are here

function uc_payment_pack_receive_check_form in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_payment_pack/uc_payment_pack.admin.inc \uc_payment_pack_receive_check_form()
  2. 7.3 payment/uc_payment_pack/uc_payment_pack.admin.inc \uc_payment_pack_receive_check_form()

Receive a check for an order and put in a clear date.

1 string reference to 'uc_payment_pack_receive_check_form'
uc_payment_pack_menu in payment/uc_payment_pack/uc_payment_pack.module

File

payment/uc_payment_pack/uc_payment_pack.module, line 370
Provides the check/money order, COD, and "other" payment methods.

Code

function uc_payment_pack_receive_check_form($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');
  }
  $balance = uc_payment_balance($order);
  $form['balance'] = array(
    '#value' => uc_currency_format($balance),
  );
  $form['order_id'] = array(
    '#type' => 'hidden',
    '#value' => $order_id,
  );
  $form['check_exists'] = array(
    '#type' => 'checkbox',
    '#title' => t('Check has already been received.'),
    '#attributes' => array(
      'onclick' => 'receive_check_toggle(this.checked);',
    ),
  );
  $form['amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Amount'),
    '#default_value' => uc_currency_format($balance, FALSE, FALSE),
    '#size' => 10,
    '#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'),
    '#field_suffix' => variable_get('uc_sign_after_amount', FALSE) ? variable_get('uc_currency_sign', '$') : '',
  );
  $form['comment'] = array(
    '#type' => 'textfield',
    '#title' => t('Comment'),
    '#description' => t('Any notes about the check, like type or check number.'),
    '#size' => 64,
    '#maxlength' => 256,
  );
  $form['clear'] = array(
    '#type' => 'fieldset',
    '#title' => t('Expected clear date'),
    '#collapsible' => FALSE,
  );
  $form['clear']['clear_month'] = uc_select_month(NULL, format_date(time(), 'custom', 'n'));
  $form['clear']['clear_day'] = uc_select_day(NULL, format_date(time(), 'custom', 'j'));
  $form['clear']['clear_year'] = uc_select_year(NULL, format_date(time(), 'custom', 'Y'), format_date(time(), 'custom', 'Y'), format_date(time(), 'custom', 'Y') + 1);
  foreach (array(
    'clear_month',
    'clear_day',
    'clear_year',
  ) as $key) {
    $form['clear'][$key]['#prefix'] = '<div style="float: left; margin-right: 1em;">';
    $form['clear'][$key]['#suffix'] = '</div>';
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Receive check'),
  );
  return $form;
}