You are here

function support_substatus_admin_form in Support Ticketing System 6

1 string reference to 'support_substatus_admin_form'
support_substatus_menu in support_substatus/support_substatus.module
Implementation of hook_menu().

File

support_substatus/support_substatus.admin.inc, line 57

Code

function support_substatus_admin_form(&$form_state, $substatus = array()) {
  $form = array();
  $form['substatus'] = array(
    '#title' => t('Substatus'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#maxlength' => 255,
    '#default_value' => isset($substatus->substatus) ? $substatus->substatus : '',
    '#description' => t('The Substatus field name. This name is visible to clients.'),
  );
  $options = _support_states();
  $form['state'] = array(
    '#title' => t('State'),
    '#type' => 'select',
    '#options' => $options,
    '#required' => TRUE,
    '#multiple' => TRUE,
    '#maxlength' => 255,
    '#size' => count($options),
    '#default_value' => isset($substatus->state) ? $substatus->state : '',
    '#description' => t('Specify which state(s) this substatus field applies to.'),
  );
  $form['disabled'] = array(
    '#title' => t('Disabled'),
    '#type' => 'checkbox',
    '#default_value' => isset($substatus->disabled) ? $substatus->disabled : 0,
    '#description' => t('Disabled substatus fields won\'t show up as an option when creating new tickets.'),
  );
  $form['weight'] = array(
    '#title' => t('Weight'),
    '#type' => 'weight',
    '#default_value' => isset($substatus->weight) ? $substatus->weight : 0,
    '#description' => t('When multiple substatus fields are available, the substatus field with the smallest (negative) weight will be selected as the default.'),
  );
  $clients = _support_clients_load();
  if (!isset($clients)) {
    drupal_set_message(t('You must !create a client before you can add substatus fields.', array(
      '!create' => l(t('create and enable'), 'admin/support/clients/add'),
    )), 'error');
    drupal_goto('admin/support/clients');
  }
  $form['clids'] = array(
    '#title' => t('Clients'),
    '#type' => 'select',
    '#options' => $clients,
    '#multiple' => TRUE,
    '#size' => count($clients) > 5 ? count($clients) : 5,
    '#default_value' => isset($substatus->clids) ? $substatus->clids : array(),
    '#description' => t('Select the client(s) this substatus field applies to.  Select no clients to have this substatus field apply to all clients.'),
  );
  $form['ssid'] = array(
    '#value' => $substatus->ssid,
    '#type' => 'hidden',
  );
  $form['submit'] = array(
    '#value' => isset($substatus->ssid) ? t('Update substatus field') : t('Add substatus field'),
    '#type' => 'submit',
  );
  if (isset($substatus->ssid)) {
    $form['delete'] = array(
      '#value' => t('Delete substatus field'),
      '#type' => 'submit',
    );
    $form['cancel'] = array(
      '#value' => l(t('Cancel'), 'admin/support/substatus'),
    );
  }
  return $form;
}