You are here

function forena_admin_reports in Forena Reports 7.3

Same name and namespace in other branches
  1. 8 forena_ui/forena.admin.inc \forena_admin_reports()
  2. 6.2 forena.admin.inc \forena_admin_reports()
  3. 7.5 forena.admin.inc \forena_admin_reports()
  4. 7.2 forena.admin.inc \forena_admin_reports()
  5. 7.4 forena.admin.inc \forena_admin_reports()

Display reports to edit for admins in the structure menu Enter description here ...

1 string reference to 'forena_admin_reports'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.admin.inc, line 13

Code

function forena_admin_reports() {
  global $language;
  $data = array();
  $links[] = array(
    'href' => 'reports/add',
    'title' => 'Create New Report',
  );
  $content = drupal_get_form('forena_sync_form');
  $output = drupal_render($content);
  $output .= theme('links', array(
    'links' => $links,
    'attributes' => array(
      'class' => 'action-links',
    ),
  ));

  // Add Data tables if it exists.
  drupal_add_css(drupal_get_path('module', 'forena') . '/forena.css');
  if (file_exists('sites/all/libraries/dataTables/media/js/jquery.dataTables.min.js')) {
    drupal_add_js(drupal_get_path('module', 'forena') . '/forena.admin.js');
    drupal_add_js('sites/all/libraries/dataTables/media/js/jquery.dataTables.min.js');
  }
  $headers = array(
    t('title'),
    t('name'),
    t('category'),
    t('operation'),
  );
  $result = db_query('SELECT * FROM {forena_reports} where language=:language ORDER BY category,title', array(
    ':language' => $language->language,
  ));
  foreach ($result as $row) {
    $rpt = str_replace('/', '.', $row->report_name);
    $edit = l(t('Edit'), 'reports/' . $rpt . '/edit');
    $clone = l(t('Clone'), 'reports/add/' . $rpt);
    $delete = l(t('Delete'), 'reports/' . $rpt . '/delete', array(
      'query' => array(
        'destination' => 'admin/structure/reports',
      ),
    ));
    $title = l(t($row->title), 'reports/' . $rpt);
    $data[] = array(
      $title,
      $row->report_name,
      $row->category,
      $edit . ' ' . $clone . ' ' . $delete,
    );
  }
  $output .= '<div id="forena-reports-list">';
  $output .= theme_table(array(
    'header' => $headers,
    'rows' => $data,
    'attributes' => array(
      'class' => array(
        'dataTable-paged',
      ),
    ),
    'caption' => '',
    'sticky' => TRUE,
    'colgroups' => array(),
    'empty' => '',
  ));
  $output .= '</div>';
  return $output;
}