You are here

function support_pm_admin_project_form in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support_pm/support_pm.admin.inc \support_pm_admin_project_form()
1 string reference to 'support_pm_admin_project_form'
support_pm_menu in support_pm/support_pm.module
Implementation of hook_menu(). TODO: Include date in 'view' and 'edit' tabs

File

support_pm/support_pm.admin.inc, line 505

Code

function support_pm_admin_project_form(&$form_state, $project = array()) {
  $form = array();
  $form['project'] = array(
    '#title' => t('Project'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#maxlength' => 255,
    '#default_value' => isset($project->project) ? $project->project : '',
    '#description' => t('The project name.  This name may appear on invoices.'),
  );
  $form['path'] = array(
    '#title' => t('Path'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#maxlength' => 255,
    '#default_value' => isset($project->path) ? $project->path : '',
    '#description' => t('A url friendly project path using alpha-numerics, "-", and "_".'),
  );
  $form['disabled'] = array(
    '#title' => t('Disabled'),
    '#type' => 'checkbox',
    '#default_value' => isset($project->disabled) ? $project->disabled : 0,
    '#description' => t('Disabled projects won\'t show up as an option when creating new tickets.'),
  );
  $form['weight'] = array(
    '#title' => t('Weight'),
    '#type' => 'weight',
    '#default_value' => isset($project->weight) ? $project->weight : 0,
    '#description' => t('When multiple projects are available, the project 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 projects.', array(
      '!create' => l(t('create and enable'), 'admin/support/clients/add'),
    )), 'error');
    drupal_goto('admin/support/project');
  }
  $form['clids'] = array(
    '#title' => t('Clients'),
    '#type' => 'select',
    '#options' => $clients,
    '#multiple' => TRUE,
    '#size' => count($clients) > 5 ? count($clients) : 5,
    '#default_value' => isset($project->clids) ? $project->clids : array(),
    '#description' => t('Select the client(s) this project applies to.  Select no clients to have this project apply to all clients.'),
  );
  $form['projid'] = array(
    '#value' => $project->projid,
    '#type' => 'hidden',
  );
  $form['submit'] = array(
    '#value' => isset($project->projid) ? t('Update project') : t('Add project'),
    '#type' => 'submit',
  );
  if (isset($project->projid)) {
    $form['delete'] = array(
      '#value' => t('Delete project'),
      '#type' => 'submit',
    );
    $form['cancel'] = array(
      '#value' => l(t('Cancel'), 'admin/support/project'),
    );
  }
  return $form;
}