You are here

function forena_data_select_block_submit in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 forena.admin.inc \forena_data_select_block_submit()
  2. 7.2 forena.admin.inc \forena_data_select_block_submit()
1 string reference to 'forena_data_select_block_submit'
forena_add_data_block_form in ./forena.admin.inc

File

./forena.admin.inc, line 1712

Code

function forena_data_select_block_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $values = $form_state['values'];
  $name = $values['report_name'];
  $data_block = $form_state['storage']['data_block'] = $values['data_block'];
  $params = $form_state['storage']['params'] = isset($values['params']) ? $values['params'] : array();
  $parameters = $form_state['storage']['parm_data'] = $values['parameters'];
  $parms = isset($values['parms']) ? $values['parms'] : array();
  $xml = '';
  $block_info = '';
  if ($data_block) {

    //get xml from data block

    //check for and store parameters
    $block_info = Frx::RepoMan()
      ->loadBlock($data_block);
    if ($block_info) {

      //if there were not any parameters passed. Use the report parameters
      if (!$parms) {
        $r = FrxReportGenerator::instance()
          ->get_report($values['report_name']);
        $rpt_params = $r->parameters;
        if ($rpt_params) {
          foreach ($block_info['tokens'] as $index => $id) {
            $parms[$id] = @$rpt_params[$id]['value'];
          }
        }
      }
      drupal_alter('forena_parameters', $name, $parms);

      //now invoke the data provider with the correct params
      Frx::Data()
        ->push($parms, 'parm');
      $form_state['storage']['parms'] = $params;
      $xml = Frx::RepoMan()
        ->data($data_block, $parms);
      if ($xml) {
        $form_state['storage']['step'] = 'select_template';
        $form_state['storage']['xml'] = $xml
          ->asXML();
        $form_state['storage']['parms'] = $parms;
      }
      else {
        $form_state['storage']['parameters'] = @$block_info['tokens'];
      }

      //create xml from template object
    }
  }
}