* @copyrights CBLUE SPRL 2011 * @package chamilo.reports */ exit; // name of the language file that needs to be included $language_file = array('reportlib'); $cidReset = true; // including files require_once '../inc/global.inc.php'; require_once 'reports.lib.php'; require_once 'multiquery.lib.php'; // protect script api_block_anonymous_users(); // defining constants // current section $this_section = SECTION_REPORTS; // setting the name of the tool $tool_name=get_lang('Reports'); // loading templates reports_loadTemplates(); // random suffix for div id (to enable multiple report per page) $idsuffix = rand(); // "Link" type if ($_REQUEST['format'] == 'link') { // converting post vars to get uri $params = ''; $kv = array(); foreach ($_POST as $key => $value) if ($key != 'format') $kv[] = $key.'='.urlencode($value); $query_string = join("&", $kv); die(''.get_lang('ReportTypeLink').''); } if ($_REQUEST['format'] == 'directlink') { foreach (array('jquery.dataTables.min.js') as $js) $htmlHeadXtra[] = ''."\n"; $htmlCSSXtra[] = 'dataTable.css'; ?> '; } // outputing a link to csv file instead of outputing csv data directly if ($_REQUEST['format'] == 'csv') { // converting post vars to get uri $params = ''; $kv = array(); foreach ($_POST as $key => $value) if ($key != 'format') $kv[] = $key.'='.urlencode($value); $query_string = join("&", $kv); die(''.get_lang('DownloadFile').''); } else if ($_REQUEST['format'] == 'downloadcsv') { if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) { header("Pragma: must-revalidate"); header("Cache-Control: must-revalidate"); header("Content-type: application/vnd.ms-excel"); } else { header("Content-type: text/csv"); } $date = date("Y-m-d"); $filename = "reporting-$date.csv"; header("Content-Disposition: attachment; filename=$filename"); $_REQUEST['format'] = 'csv'; } if (is_array($reports_template[$_REQUEST['type']])) { $query = $reports_template[$_REQUEST['type']]['getSQL'](); if (! is_array($query)) $query = array($query); if ($_REQUEST['format'] == 'sql') die(var_export($query, true)); $result = multiquery_query($query); // check number of result $numberOfResult = multiquery_num_rows($result); if ($numberOfResult == 0) { // This case should be taken care of by the display template itself, we should let the script run //die(get_lang('NoDataAvailable')); } } else { die(''.get_lang('ErrorWhileBuildingReport').''); } if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') { if (isset($reports_template[$_REQUEST['type']]['html_header'])) { echo $reports_template[$_REQUEST['type']]['html_header']; } echo ''; echo '
'.$columns[$i].' | '; } else $columns_islink[$i] = true; } // checking resolving link column id $columns_flip = array_flip($columns); $columns_link = array(); for ($i=0; $i < $nfields; $i++) if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) $columns_link[$i] = $columns_flip[$columns[$i].'_link']; else $columns_link[$i] = ''; echo '||
---|---|---|
'.$row[$i].' | '; } else { echo ''.$row[$i].' | '; } else echo ''.$row[$i].' | '; } echo "