Rev 20 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
function remove_newlines ( $string ) {
$string = str_replace("\n", "", $string);
$string = str_replace("\r", "", $string);
return $string;
}
$numParameters = 5;
if ( $_POST['name'] ) { // we assume we have a report definition
$newReport = 'insert into report ( name, query, parameters ) values (';
$newReport .= "'" . $_POST['name'] . "'";
$newReport .= ",";
$newReport .= "'" . $_POST['query'] . "'";
$newReport .= ",";
$lines = array();
for ( $i = 0; $i < $numParameters; $i++ ) {
if ( $_POST["parameter_name_$i"] ) {
$name = $_POST["parameter_name_$i"];
$prompt = $_POST["parameter_prompt_$i"];
$query = $_POST["parameter_query_$i"];
$displayQuery = $_POST["parameter_displayquery_$i"];
$lines[] = remove_newlines(implode('++',array($name,$prompt,$query,$displayQuery)));
}
}
$newReport .= "'" . implode("\n", $lines ) . "'";
$newReport .= ")";
}
// include_once('reports.php');
?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Create a Report</title>
</head>
<body>
<?php
if ($newReport) {
print "<textarea rows='10' cols='80'>$newReport</textarea>";
} else {
?>
<p>
Below, enter some information about a report to be run using the report class. There is a web page, <a href="reports.php.html">reports.php.html</a> that gives more detailed instructions on how the data is actually stored. This page is a supplement to that, and will make more sense if you read that documentation first.
</p>
<?php
}
?>
<h1>
Define a Report
</h1>
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<table border='1'>
<tr>
<td title='The name for this report as displayed to the user'>
Report Name
</td>
<td title='The name for this report as displayed to the user'>
<input type='text' name='name' value='New Report' />
</tr>
<tr>
<td title='A valid SQL query, with optional parameters, that will be run to create the report'>
Query
</td>
<td title='A valid SQL query, with optional parameters, that will be run to create the report'>
<textarea width="40" name="query" rows="10" cols="40">select columnnames from tablename</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="1">
<caption>
Parameters
</caption>
<thead>
<tr>
<th>
Parameter
</th>
<th title="The name of the parameter AS IT APPEARS in the query above">
Name
</th>
<th title="What the user will see">
User Prompt
</th>
<th title="An optional query to create a dropdown. First parameter is the value used, second parameter is shown to the user">
Query
</th>
<th title="A query that will show the user friendly result of Query for this row">
Display Query
</th>
</tr>
</thead>
<tbody valign="top">
<?php
for ( $i = 0; $i < $numParameters; $i++ ) {
?>
<tr>
<td align="center">
<?php print $i;
?>
</td>
<td>
<input type="text" name="parameter_name_<?php print $i; ?>" />
</td>
<td>
<input type="text" name="parameter_prompt_<?php print $i; ?>" />
</td>
<td>
<textarea name="parameter_query_<?php print $i; ?>" rows="5" cols="40"></textarea>
</td>
<td>
<textarea name="parameter_displayquery_<?php print $i; ?>" rows="5" cols="40"></textarea>
</td>
</tr>
<?php
} // end of for loop
?>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="CreateDefinition" value="Create Definition" />
</td>
</tr>
</table>
</form>
</body>
</html>