You are here

function forena_create_report_submit in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena.report.inc \forena_create_report_submit()
  2. 7.4 forena.report.inc \forena_create_report_submit()
1 string reference to 'forena_create_report_submit'
forena_add_report_form in ./forena.report.inc

File

./forena.report.inc, line 114

Code

function forena_create_report_submit($form, &$form_state) {
  $values = $form_state['values'];
  $report_name = $values['report_name'];
  $desc = Frx::Menu()
    ->parseURL($report_name);
  $report_name = $desc['name'];
  if ($values['report_name']) {
    $r = Frx::Editor($values['clone_report_name']);
    $r->report_name = $values['report_name'];
  }
  else {
    $r = Frx::Editor($values['report_name']);
  }

  // Title and category
  $r
    ->setTitle($values['title']);
  $r
    ->setCategory($values['category']);

  // Form options
  $options = array(
    'hidden' => $values['hidden'],
  );
  $r
    ->setOptions($options);

  //determine redirection.
  $filename = $desc['filename'];
  $r
    ->update();

  //if this is a new report then redirect to data blocks
  if ($values['report_name']) {
    $edit = '/edit';
  }
  else {
    $edit = '/edit/select-data/add-data';
  }
  $form_state['redirect'] = $desc['i_link'] . $edit;
}