You are here

function uc_order_workflow_form in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_order/uc_order.module \uc_order_workflow_form()
  2. 7.3 uc_order/uc_order.admin.inc \uc_order_workflow_form()

Displays the order workflow form for order state and status customization.

See also

uc_order_workflow_form_submit()

theme_uc_order_state_table()

theme_uc_order_status_table()

1 string reference to 'uc_order_workflow_form'
uc_order_menu in uc_order/uc_order.module
Implements hook_menu().

File

uc_order/uc_order.admin.inc, line 134
Order administration menu items.

Code

function uc_order_workflow_form() {
  $states = uc_order_state_list();
  $statuses = uc_order_status_list();
  $form['order_states'] = array(
    '#type' => 'fieldset',
    '#title' => t('Order states'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#summary callback' => 'summarize_null',
    '#theme' => 'uc_order_state_table',
    '#tree' => TRUE,
  );
  foreach ($states as $state) {
    $form['order_states'][$state['id']]['#summary callback'] = 'summarize_form';
    $form['order_states'][$state['id']]['title'] = array(
      '#value' => $state['title'],
    );

    // Create the select box for specifying a default status per order state.
    $options = array();
    foreach ($statuses as $status) {
      if ($status['state'] == $state['id']) {
        $options[$status['id']] = $status['title'];
      }
    }
    if (empty($options)) {
      $form['order_states'][$state['id']]['default'] = array(
        '#value' => t('- N/A -'),
      );
    }
    else {
      $form['order_states'][$state['id']]['default'] = array(
        '#type' => 'select',
        '#options' => $options,
        '#default_value' => uc_order_state_default($state['id']),
      );
    }
  }
  $form['order_statuses'] = array(
    '#type' => 'fieldset',
    '#title' => t('Order statuses'),
    '#collapsible' => FALSE,
    '#summary callback' => '_uc_order_states_summarize',
    '#summary arguments' => array(
      $states,
    ),
    '#theme' => 'uc_order_status_table',
    '#tree' => TRUE,
  );

  // Build the state option array for the order status table.
  $options = array();
  foreach ($states as $state) {
    $options[$state['id']] = $state['title'];
  }
  foreach ($statuses as $status) {
    $form['order_statuses'][$status['id']]['id'] = array(
      '#value' => $status['id'],
    );
    $form['order_statuses'][$status['id']]['title'] = array(
      '#type' => 'textfield',
      '#default_value' => $status['title'],
      '#size' => 32,
      '#required' => TRUE,
    );
    $form['order_statuses'][$status['id']]['weight'] = array(
      '#type' => 'weight',
      '#delta' => 20,
      '#default_value' => $status['weight'],
    );
    if ($status['locked']) {
      $form['order_statuses'][$status['id']]['state'] = array(
        '#value' => uc_order_state_data($status['state'], 'title'),
      );
      $form['order_statuses'][$status['id']]['locked'] = array(
        '#type' => 'hidden',
        '#value' => TRUE,
      );
    }
    else {
      $form['order_statuses'][$status['id']]['state'] = array(
        '#type' => 'select',
        '#options' => $options,
        '#default_value' => $status['state'],
      );
      $form['order_statuses'][$status['id']]['remove'] = array(
        '#type' => 'checkbox',
      );
    }
  }
  $form['order_statuses']['create'] = array(
    '#type' => 'submit',
    '#value' => t('Create new status'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit changes'),
  );
  return $form;
}