You are here

function forena_format_form_submit in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 forena.admin.inc \forena_format_form_submit()
  2. 7.2 forena.admin.inc \forena_format_form_submit()

File

./forena.admin.inc, line 317

Code

function forena_format_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $name = $values['report_name'];
  $r = forena_get_report_editor($name);
  $options = array(
    'form' => $values['form'],
  );
  $r
    ->setOptions($options);

  // Doc gen settings.
  if (isset($form['docgen'])) {
    $docgen = array();
    if ($selected = array_filter(@$values['docgen']['docs'])) {
      if ($selected) {
        foreach ($selected as $key => $value) {
          if ($value) {
            $docgen[] = array(
              'type' => $key,
            );
          }
        }
      }
    }
    $r
      ->setDocgen($docgen);
  }
  if (forena_save_report($name, $r
    ->asXML(), TRUE) == 1) {
    drupal_set_message(t('Your report, %s has been saved.', array(
      '%s' => $name,
    )));
  }
  else {
    drupal_set_message(t('There was an error saving your report, %s to the database.', array(
      '%s' => $name,
    )));
  }
}