You are here

function uc_order_workflow_form_submit in Ubercart 6.2

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

Form submission handler for uc_order_workflow_form().

See also

uc_order_workflow_form()

File

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

Code

function uc_order_workflow_form_submit($form, &$form_state) {
  foreach ($form_state['values']['order_states'] as $key => $value) {
    variable_set('uc_state_' . $key . '_default', $value['default']);
  }
  foreach ($form_state['values']['order_statuses'] as $key => $value) {
    if ($value['locked'] != TRUE && $value['remove'] == TRUE) {
      db_query("DELETE FROM {uc_order_statuses} WHERE order_status_id = '%s'", $key);
      drupal_set_message(t('Order status %status removed.', array(
        '%status' => $key,
      )));
    }
    else {
      if ($value['locked'] == TRUE) {
        db_query("UPDATE {uc_order_statuses} SET title = '%s', weight = %d " . "WHERE order_status_id = '%s'", $value['title'], $value['weight'], $key);
      }
      else {
        db_query("UPDATE {uc_order_statuses} SET title = '%s', state = '%s', " . "weight = %d WHERE order_status_id = '%s'", $value['title'], $value['state'], $value['weight'], $key);
      }
    }
  }
  switch ($form_state['values']['op']) {
    case t('Submit changes'):
      drupal_set_message(t('Order workflow information saved.'));
      break;
    case t('Create new status'):
      $form_state['redirect'] = 'admin/store/settings/orders/edit/workflow/create';
  }
}