<?
	#---------------------------------------------------------------------#
	# This source code is (c)2000 White Pajamas, Inc                      #
	# see http://www.stonekeep.com/license.html for licensing information #
	#---------------------------------------------------------------------#

	#--------------------------------------------------------------------
	# $Id: filters.php3,v 1.9 2000/12/14 19:13:48 shevett Exp $
	#--------------------------------------------------------------------
	
	# filters

	echo "<tr><td bgcolor=#bbbbbb colspan=2 align=center><h3>Filters</td></tr>";
	echo "<form method=post action=\"nbrowse.php3\">";
	echo "<input type=hidden name=f_func value=\"addfilter\">";

	if (Empty($filtfunc)) {
		echo "<tr bgcolor=#202020><td align=center><table bgcolor=#808080 cellpadding=2 cellspacing=1 border=1>\n";
		$somefound=0;

		#
		# Show a list of all the filters on file for the user and current table.
		#
		$mylist = db_query("select * from filters where uid='$curruser' and fpublic=0 order by ftable,fdesc");
		if (db_numrows($mylist) > 0) {
			$somefound=1;
			echo "<tr valign=top>\n";
			echo "<td colspan=6><b>Filters owned by $curruser:</b></td></tr>";
			echo "<tr valign=bottom>\n";
			echo "<th>Func</th><th>Number</th><th>Table</th><th>Description</th><th>Expression</th><th>Public?</th>";
			echo "</tr>";
			while ($row = db_fetch_array($mylist)) {
				echo "<tr bgcolor=#c0c0c0>";
				echo "<td align=center><a href=\"nbrowse.php3?f_filtset=$row[ftable]:$row[_rowid]\">Select</a><br>";
				echo "<font size=2>";
				echo "<a href=\"nbrowse.php3?f_func=modfilter&f_filter=$row[_rowid]\">[Edit]</a>";
				echo "<a href=\"nbrowse.php3?f_func=delfilter&f_filter=$row[_rowid]\"> [Delt]</a>";
				echo "</font></td>";
				echo "<td># $row[_rowid]</td>";
				echo "<td>$row[ftable]</td>";
				echo "<td>$row[fdesc]</td>";
				echo "<td>$row[fselect]</td>";
				echo "<td>$row[fpublic]</td>";
				echo "</tr>";
			}
			echo "<tr valign=bottom>\n";
			echo "<td colspan=6><hr><b>Public filters:</b></td></tr>";
		}
		
		$publist = db_query("select * from filters where fpublic=1 order by uid,ftable");
		if (db_numrows($publist) > 0) {
			$somefound=1;
			echo "<tr valign=bottom>\n";
			echo "<th>Func</th><th>Number &<br>Owner</th><th>Table</th><th>Description</th><th>Expression</th><th>Public?</th>";
			while ($row = db_fetch_array($publist)) {
				echo "<tr bgcolor=#c0c0c0>";
				echo "<td align=center><a href=\"nbrowse.php3?f_filtset=$row[ftable]:$row[_rowid]\">Select</a><br>";
				echo "<font size=2>";
				echo "<a href=\"nbrowse.php3?f_func=modfilter&f_filter=$row[_rowid]\">[Edit]</a>";
				echo "<a href=\"nbrowse.php3?f_func=delfilter&f_filter=$row[_rowid]\"> [Delt]</a>";
				echo "</font></td>";
				echo "<td># $row[_rowid]<br>$row[uid]</td>";
				echo "<td>$row[ftable]</td>";
				echo "<td>$row[fdesc]</td>";
				echo "<td>$row[fselect]</td>";
				echo "<td>$row[fpublic]</td>";
				echo "</tr>";
			}
		}
		
		if (Empty($somefound)) {
			echo "<tr valign=top><td align=center><h3>No filters on file.</h3></td></tr>";
		}
		
		echo "<tr valign=top bgcolor=\"#000000\"><td align=center colspan=6>";
		PostBar("Create a new filter");
		echo "</td></tr>";
		echo "</table></td></tr>";
	} else {
		if (($filtfunc == "A") || ($filtfunc == "E")) {
			if (! Empty($f_ffrow)) {
				#
				# an edit.  Pull up the old data.
				#
			}
		}
	}
			

		
?>
