3 require('../conf/config.php3');
4 require('../lib/functions.php3');
5 require('../lib/sql/functions.php3');
6 require('../lib/acctshow.php3');
8 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
9 include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
14 <title>Accounting Report Generator</title>
15 <meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
16 <link rel="stylesheet" href="style.css">
20 <b>Could not include SQL library functions. Aborting</b>
27 $operators=array( '=','<', '>', '<=', '>=', 'regexp', 'like' );
28 if ($config[sql_type] == 'pg'){
29 $operators=array( '=','<', '>', '<=', '>=', '~', 'like', '~*', '~~*', '<<=' );
32 $link = @da_sql_pconnect ($config) or die('cannot connect to sql databse');
33 $fields = @da_sql_list_fields($config[sql_accounting_table],$link,$config);
34 $no_fields = @da_sql_num_fields($fields,$config);
38 for($i=0;$i<$no_fields;$i++){
39 $key = strtolower(@da_sql_field_name($fields,$i,$config));
40 $val = $sql_attrs[$key][desc];
43 $show = $sql_attrs[$key][show];
44 $selected[$key] = ($show == 'yes') ? 'selected' : '';
45 $items[$key] = "$val";
57 function Qi($name,$item,$operator) {
60 $this->operator=$operator;
63 function show() { global $operators;
69 <input type=hidden name="item_of_$this->name" value="$this->item">
71 <select name=operator_of_$this->name>
73 foreach($operators as $operator){
74 if($this->operator == $operator)
75 $selected=" selected ";
78 print("<option value=\"$operator\" $selected>$operator</option>\n");
83 <input name="value_of_$this->name" type=text value="$this->value">
85 <input type=hidden name="delete_$this->name" value=0>
86 <input type=submit class=button size=5 value=del onclick="this.form.delete_$this->name.value=1">
91 function get($designator) { global ${"item_of_$designator"};
92 global ${"value_of_$designator"};
93 global ${"operator_of_$designator"};
94 if(${"item_of_$designator"}){
95 $this->value= ${"value_of_$designator"};
96 $this->operator=${"operator_of_$designator"};
97 $this->item=${"item_of_$designator"};
103 return $items[$this->item]." $this->operator '$this->value'";
110 <title>Accounting Report Generator</title>
111 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
112 <link rel="stylesheet" href="style.css">
120 <table border=0 width=740 cellpadding=1 cellspacing=1>
123 <b>Show the following attributes:</b><br>
124 <select name="accounting_show_attrs[]" size=5 multiple>
126 foreach($items as $key => $val)
128 <option $selected[$key] value="$key">$val</option>
135 <select name="order_by">
138 foreach($items as $key => $val)
139 if ($val == 'username')
141 <option selected value="$key">$val</option>
145 <option value="$key">$val</option>
151 <b>Max results returned:</b><br>
152 <input name=maxresults value=$config[sql_row_limit] size=5>
155 <input type=hidden name=add value=0>
156 <table border=0 width=340 cellpadding=1 cellspacing=1>
158 <b>Selection criteria:</b>
161 <select name=item_name onchange="this.form.add.value=1;this.form.submit()">
162 <option>--Attribute--</option>
165 foreach($items as $key => $val)
166 print("<option value=\"$key\">$val</option>");
175 while (${"item_of_w$number"}) {
176 if(${"delete_w$number"}==1) {$offset=1;$number++;}
178 $designator=$number-$offset;
179 ${"w$designator"} = new Qi("w$designator","","");
180 ${"w$designator"}->get("w$number");
181 ${"w$designator"}->show();
186 ${"w$number"} = new Qi("w$number","$item_name","$operators[0]");
187 ${"w$number"}->show();
194 <input type=hidden name=queryflag value=0>
195 <br><input type=submit class=button onclick="this.form.queryflag.value=1">
206 if ($queryflag == 1){
208 while (${"item_of_w$i"}){
210 foreach ($operators as $operator){
211 if (${"operator_of_w$i"} == $operator){
217 die("Operator passed is not valid. Exiting abnormaly.");
218 ${"item_of_w$i"} = preg_replace('/\s/','',${"item_of_w$i"});
219 ${"value_of_w$i"} = da_sql_escape_string(${"value_of_w$i"});
220 $where .= ($i == 1) ? ' WHERE ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" :
221 ' AND ' . ${"item_of_w$i"} . ' ' . ${"operator_of_w$i"} . " '" . ${"value_of_w$i"} . "'" ;
225 $order = ($order_by != '') ? "$order_by" : 'username';
227 if (preg_match("/[\s;]/",$order))
228 die("ORDER BY pattern is illegal. Exiting abnornally.");
230 if (!is_numeric($maxresults))
231 die("Max Results is not in numeric form. Exiting abnormally.");
234 foreach ($accounting_show_attrs as $val)
235 $query_view .= $val . ',';
236 $query_view = ereg_replace(',$','',$query_view);
237 unset($sql_extra_query);
238 if ($config[sql_accounting_extra_query] != '')
239 $sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
240 $sql_extra_query = da_sql_escape_string($sql_extra_query);
241 $query="SELECT da_sql_limit($maxresults,0,$config) $query_view FROM $config[sql_accounting_table]
242 $where $sql_extra_query da_sql_limit($maxresults,1,$config)
243 ORDER BY $order da_sql_limit($maxresults,2,$config);";
248 <link rel="stylesheet" href="style.css">
252 <table border=0 width=940 cellpadding=1 cellspacing=1>
255 <td bgcolor="black" width=200>
256 <table border=0 width=100% cellpadding=2 cellspacing=0>
257 <tr bgcolor="#907030" align=right valign=top><th>
258 <font color="white">Accounting Report Generator</font>
262 <tr bgcolor="black" valign=top><td colspan=2>
263 <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
266 <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
267 <tr bgcolor="#d0ddb0">
270 foreach($accounting_show_attrs as $val){
271 $desc = $sql_attrs[$val][desc];
272 echo "<th>$desc</th>\n";
276 $search = @da_sql_query($link,$config,$query);
278 while( $row = @da_sql_fetch_array($search,$config) ){
280 echo "<tr align=center>\n";
281 foreach($accounting_show_attrs as $val){
285 $info = $sql_attrs[$val][func]($info);
286 if ($val == 'username'){
287 $Info = urlencode($info);
288 $info = "<a href=\"user_admin.php3?login=$Info\" title=\"Edit user $info\">$info<a/>";
298 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";