| 20 |
rodolico |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
function remove_newlines ( $string ) {
|
|
|
4 |
$string = str_replace("\n", "", $string);
|
|
|
5 |
$string = str_replace("\r", "", $string);
|
|
|
6 |
return $string;
|
|
|
7 |
}
|
|
|
8 |
|
|
|
9 |
$numParameters = 5;
|
|
|
10 |
if ( $_POST['name'] ) { // we assume we have a report definition
|
|
|
11 |
$newReport = 'insert into report ( name, query, parameters ) values (';
|
|
|
12 |
$newReport .= "'" . $_POST['name'] . "'";
|
|
|
13 |
$newReport .= ",";
|
|
|
14 |
$newReport .= "'" . $_POST['query'] . "'";
|
|
|
15 |
$newReport .= ",";
|
|
|
16 |
$lines = array();
|
|
|
17 |
for ( $i = 0; $i < $numParameters; $i++ ) {
|
|
|
18 |
if ( $_POST["parameter_name_$i"] ) {
|
|
|
19 |
$name = $_POST["parameter_name_$i"];
|
|
|
20 |
$prompt = $_POST["parameter_prompt_$i"];
|
|
|
21 |
$query = $_POST["parameter_query_$i"];
|
|
|
22 |
$displayQuery = $_POST["parameter_displayquery_$i"];
|
|
|
23 |
$lines[] = remove_newlines(implode('++',array($name,$prompt,$query,$displayQuery)));
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
$newReport .= "'" . implode("\n", $lines ) . "'";
|
|
|
27 |
$newReport .= ")";
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
// include_once('reports.php');
|
|
|
31 |
?>
|
|
|
32 |
<?xml version="1.0" encoding="utf-8"?>
|
|
|
33 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
|
|
34 |
>
|
|
|
35 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
36 |
<head>
|
|
|
37 |
<title>Create a Report</title>
|
|
|
38 |
</head>
|
|
|
39 |
<body>
|
|
|
40 |
<?php
|
|
|
41 |
if ($newReport) {
|
|
|
42 |
print "<textarea rows='10' cols='80'>$newReport</textarea>";
|
|
|
43 |
} else {
|
|
|
44 |
?>
|
|
|
45 |
<p>
|
|
|
46 |
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.
|
|
|
47 |
</p>
|
|
|
48 |
<?php
|
|
|
49 |
}
|
|
|
50 |
?>
|
|
|
51 |
<h1>
|
|
|
52 |
Define a Report
|
|
|
53 |
</h1>
|
|
|
54 |
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
|
|
|
55 |
<table border='1'>
|
|
|
56 |
<tr>
|
|
|
57 |
<td title='The name for this report as displayed to the user'>
|
|
|
58 |
Report Name
|
|
|
59 |
</td>
|
|
|
60 |
<td title='The name for this report as displayed to the user'>
|
|
|
61 |
<input type='text' name='name' value='New Report' />
|
|
|
62 |
</tr>
|
|
|
63 |
<tr>
|
|
|
64 |
<td title='A valid SQL query, with optional parameters, that will be run to create the report'>
|
|
|
65 |
Query
|
|
|
66 |
</td>
|
|
|
67 |
<td title='A valid SQL query, with optional parameters, that will be run to create the report'>
|
|
|
68 |
<textarea width="40" name="query" rows="10" cols="40">select columnnames from tablename</textarea>
|
|
|
69 |
</td>
|
|
|
70 |
</tr>
|
|
|
71 |
<tr>
|
|
|
72 |
<td colspan="2">
|
|
|
73 |
<table width="100%" border="1">
|
|
|
74 |
<caption>
|
|
|
75 |
Parameters
|
|
|
76 |
</caption>
|
|
|
77 |
<thead>
|
|
|
78 |
<tr>
|
|
|
79 |
<th>
|
|
|
80 |
Parameter
|
|
|
81 |
</th>
|
|
|
82 |
<th title="The name of the parameter AS IT APPEARS in the query above">
|
|
|
83 |
Name
|
|
|
84 |
</th>
|
|
|
85 |
<th title="What the user will see">
|
|
|
86 |
User Prompt
|
|
|
87 |
</th>
|
|
|
88 |
<th title="An optional query to create a dropdown. First parameter is the value used, second parameter is shown to the user">
|
|
|
89 |
Query
|
|
|
90 |
</th>
|
|
|
91 |
<th title="A query that will show the user friendly result of Query for this row">
|
|
|
92 |
Display Query
|
|
|
93 |
</th>
|
|
|
94 |
</tr>
|
|
|
95 |
</thead>
|
|
|
96 |
<tbody valign="top">
|
|
|
97 |
<?php
|
|
|
98 |
for ( $i = 0; $i < $numParameters; $i++ ) {
|
|
|
99 |
?>
|
|
|
100 |
<tr>
|
|
|
101 |
<td align="center">
|
|
|
102 |
<?php print $i;
|
|
|
103 |
?>
|
|
|
104 |
</td>
|
|
|
105 |
<td>
|
|
|
106 |
<input type="text" name="parameter_name_<?php print $i; ?>" />
|
|
|
107 |
</td>
|
|
|
108 |
<td>
|
|
|
109 |
<input type="text" name="parameter_prompt_<?php print $i; ?>" />
|
|
|
110 |
</td>
|
|
|
111 |
<td>
|
|
|
112 |
<textarea name="parameter_query_<?php print $i; ?>" rows="5" cols="40"></textarea>
|
|
|
113 |
</td>
|
|
|
114 |
<td>
|
|
|
115 |
<textarea name="parameter_displayquery_<?php print $i; ?>" rows="5" cols="40"></textarea>
|
|
|
116 |
</td>
|
|
|
117 |
</tr>
|
|
|
118 |
<?php
|
|
|
119 |
} // end of for loop
|
|
|
120 |
?>
|
|
|
121 |
</tbody>
|
|
|
122 |
</table>
|
|
|
123 |
</td>
|
|
|
124 |
</tr>
|
|
|
125 |
<tr>
|
|
|
126 |
<td colspan="2" align="center">
|
|
|
127 |
<input type="submit" name="CreateDefinition" value="Create Definition" />
|
|
|
128 |
</td>
|
|
|
129 |
</tr>
|
|
|
130 |
</table>
|
|
|
131 |
</form>
|
|
|
132 |
</body>
|
|
|
133 |
</html>
|