function uc_order_workflow_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_order/uc_order.module \uc_order_workflow_form()
- 6.2 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()
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 51 - Order administration menu items.
Code
function uc_order_workflow_form($form, &$form_state) {
$states = uc_order_state_list();
$statuses = uc_order_status_list();
$form['order_states'] = array(
'#type' => 'fieldset',
'#title' => t('Order states'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#theme' => 'uc_order_state_table',
'#tree' => TRUE,
);
foreach ($states as $state_id => $state) {
$form['order_states'][$state_id]['title'] = array(
'#markup' => $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(
'#markup' => 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,
'#theme' => 'uc_order_status_table',
'#tree' => TRUE,
);
// Build the state option array for the order status table.
$options = array();
foreach ($states as $state_id => $state) {
$options[$state_id] = $state['title'];
}
foreach ($statuses as $status) {
$form['order_statuses'][$status['id']]['id'] = array(
'#markup' => $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'],
);
$form['order_statuses'][$status['id']]['locked'] = array(
'#type' => 'value',
'#value' => $status['locked'],
);
if ($status['locked']) {
$form['order_statuses'][$status['id']]['state'] = array(
'#markup' => uc_order_state_data($status['state'], 'title'),
);
}
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['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit changes'),
);
return $form;
}