<?php
include("common_db.php");
include("functions.php");
dbconnect($host, $username, $password); //from common_db.php
$strings = loadStrings($lang, 'VREPORT');
headers();
html();
head($strings['VR_TITLE']);
menu();
navpane();
?>
<div id="mainpane">
<?php
//TODO: join support
if(isset($_REQUEST['id'])) {
$report_id = intval($_REQUEST['id']);
} else {
//error!
echo("<p>$strings[VR_NOID]</p>");
}
mysql_select_db('HypatiaDB');
$query = "SELECT * FROM reports WHERE id = $report_id";
($report_details = mysql_fetch_array(mysql_query($query))) or die(mysql_error()); //TODO: L10N
$sql = buildReportSQL($report_id);
mysql_select_db($report_details['db']);
($results = mysql_query($sql)) or die(mysql_error());
//Print the heading
echo("<h2>$report_details[title]</h2>");
if($report_details['style'] == 'columnar') {
while($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
echo('<div class="report"><dl>');
foreach($row as $name => $value) {
echo('<dt>' . htmlspecialchars($name) . '</dt><dd>' . htmlspecialchars($value) . '</dd>');
}
echo('</dl></div>');
}
} else {
//tabular report
echo('<table class="browse"><thead><tr class="firstrow">');
for($i = 0; $i < mysql_num_fields($results); $i++) {
echo('<th>' . mysql_field_name($results, $i) . '</th>');
}
echo('</tr></thead><tbody>');
$i = 0;
while($row = mysql_fetch_array($results, MYSQL_NUM)) {
$i++;
echo('<tr>');
foreach($row as $v) {
echo('<td' . ($i % 2 == 0 ? ' class="banded"' : '') . '>' . htmlspecialchars($v) . '</td>');
}
echo('</tr>');
}
echo('</tbody></table>');
}
?>
<p><a href="view-report-pdf.php?report_id=<?php echo($report_id); ?>"><?php echo($strings['VR_PDF']); ?></a></p>
</div>
<?php
endhtml();
?>