You are here

function globallink_all_active_filter_form in GlobalLink Connect for Drupal 7.7

Same name in this branch
  1. 7.7 globallink_workbench_all_active_submissions.inc \globallink_all_active_filter_form()
  2. 7.7 globallink_workbench_all_submissions.inc \globallink_all_active_filter_form()

Builds form to filter GlobalLink submissions

3 string references to 'globallink_all_active_filter_form'
globallink_all_active_submissions in ./globallink_workbench_all_active_submissions.inc
Builds forms on entity active submissions dashboard.
globallink_dashboard_active_submissions_page in ./globallink_workbench_all_active_submissions.inc
globallink_dashboard_active_submissions_page in ./globallink_workbench_all_submissions.inc
Builds forms on GlobalLink active submissions dashboard.

File

./globallink_workbench_all_active_submissions.inc, line 107

Code

function globallink_all_active_filter_form() {
  $form = array();
  $filter = FALSE;
  $sub_rid = arg(4);
  $sub_sql = db_select('globallink_submission', 'gs');
  $sub_sql
    ->condition('rid', $sub_rid, '=');
  $sub_sql
    ->fields('gs');
  $sub_sql_result = $sub_sql
    ->execute()
    ->fetchAll();
  $submission_row = $sub_sql_result[0];
  if ($submission_row->status == 'Translation Imported') {
    $default_status = '[completed]';
    $status_arr = array(
      '[completed]' => t('All Completed'),
      GLOBALLINK_STATUS_TRANSLATION_IMPORTED => GLOBALLINK_STATUS_TRANSLATION_IMPORTED,
      GLOBALLINK_STATUS_TRANSLATION_SOURCE_CANCELLED => GLOBALLINK_STATUS_TRANSLATION_SOURCE_CANCELLED,
    );
  }
  else {
    $default_status = '[active]';
    $status_arr = array(
      '[active]' => t('Show Active Submissions Only'),
      GLOBALLINK_STATUS_TRANSLATION_SENT => GLOBALLINK_STATUS_TRANSLATION_SENT,
      GLOBALLINK_STATUS_TRANSLATION_COMPLETED => GLOBALLINK_STATUS_TRANSLATION_COMPLETED,
    );
  }
  if (!empty($_SESSION['globallink_all_receive_filter_status'])) {
    $default_status = $_SESSION['globallink_all_receive_filter_status'];
    $filter = TRUE;
  }
  $default_submission = '';
  if (!empty($_SESSION['globallink_all_receive_filter_submission'])) {
    $default_submission = $_SESSION['globallink_all_receive_filter_submission'];
    $filter = TRUE;
  }
  $form['node_receive_filter'] = array(
    '#type' => 'fieldset',
    '#title' => t('FILTER RECORDS'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['node_receive_filter']['filters'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
  );
  $form['node_receive_filter']['filters'][] = array(
    '#markup' => '<table>',
  );
  $form['node_receive_filter']['filters']['status'] = array(
    '#type' => 'select',
    '#title' => t('Status'),
    '#options' => $status_arr,
    '#default_value' => $default_status,
    '#field_suffix' => '&nbsp;&nbsp;&nbsp;&nbsp;',
    '#prefix' => '<tr><td style="text-align: left;width: 16%;vertical-align: middle;border: none;">',
    '#suffix' => '</tr>',
    '#field_suffix' => '</td>',
    '#field_prefix' => '</td><td>',
  );
  $form['node_receive_filter']['filters']['submission'] = array(
    '#type' => 'textfield',
    '#title' => t('Submission Name Contains'),
    '#size' => 40,
    '#field_suffix' => '&nbsp;&nbsp;&nbsp;&nbsp;',
    '#prefix' => '<tr><td style="text-align: left;width: 16%;vertical-align: middle;border: none;">',
    '#suffix' => '</tr>',
    '#field_suffix' => '</td>',
    '#field_prefix' => '<BR/><div class="description">' . t('The filter is case sensitive.') . '</div></td><td>',
  );
  $form['node_receive_filter']['filters'][] = array(
    '#markup' => '</table>',
  );
  $disable_submit = $filter ? TRUE : FALSE;
  $form['node_receive_filter']['filters']['filter'] = array(
    '#type' => 'submit',
    '#value' => t('Filter'),
    '#disabled' => $disable_submit,
  );
  if ($filter) {
    $form['filter-search'] = array(
      '#type' => 'fieldset',
      '#title' => t('FILTER CRITERIA'),
    );
    $form['filter-search']['filter-markup'] = array(
      '#type' => 'container',
    );
    $form['filter-search']['filter-markup'][] = array(
      '#markup' => '<table>',
    );
    $form['filter-search']['filter-markup'][] = array(
      '#prefix' => '<tr><td style="text-align: left;width: 16%;vertical-align: middle;border: none;"><b>',
      '#markup' => t('Status'),
      '#suffix' => '</b>:&nbsp;</td><td style="text-align: left;width: 84%;vertical-align: middle;border: none;">' . $status_arr[$default_status] . '</td></tr>',
    );
    $form['filter-search']['filter-markup'][] = array(
      '#prefix' => '<tr><td style="text-align: left;width: 16%;vertical-align: middle;border: none;"><b>',
      '#markup' => t('Submission Name Contains'),
      '#suffix' => '</b>:&nbsp;</td><td style="text-align: left;width: 84%;vertical-align: middle;border: none;">' . $default_submission . '</td></tr>',
    );
    $form['filter-search']['filter-markup'][] = array(
      '#markup' => '</table>',
    );
    $form['filter-search']['status']['actions'] = array(
      '#type' => 'actions',
      '#attributes' => array(
        'class' => array(
          'container-inline',
        ),
      ),
    );
    $form['filter-search']['status']['actions']['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset'),
    );
  }
  return $form;
}