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

	#--------------------------------------------------------------------
	# $Id: accedit.php3,v 1.2 2000/12/14 19:13:42 shevett Exp $
	#--------------------------------------------------------------------
	
	#
	# Edit the accessory list for a resource
	#
	# $resource should have the tag.
	#

	LogIt("DEBUG","accedit.php3","Editing accessories for $resource. Func is $f_func, Process is $f_process");
	if ($f_func == "addacc") { ?>
	
	<form method="post" action="nbrowse.php3">
	<input type=hidden name="f_process" value="addacc">
	<input type=hidden name="resource" value="<? echo $resource ?>">
	<tr bgcolor=#BBBBBB>
	<td width=100% bgcolor=#202020 align=center>
	<table width=50% bgcolor=#bbbbbb cellspacing=2>
		<tr>
			<td bgcolor=#909090 align=center>
				<font color=#ffffff>
				Select the accessories associated with <br>
				Resource Tag <b><? echo "$resource"; ?></b>
			</td>
		</tr>
		<tr>
			<td bgcolor=#90FF90 align=center>
			<?
				$slist = db_query("select r_tag,r_model,r_desc from resources where r_multi=1");
				$nr = db_numrows($slist);
			?>
			<select name="data[]" multiple size=<? echo $nr ?>>
			<?
				while ($rinfo = db_fetch_array($slist)) {
					$val = $rinfo[$m_column];
					$check = db_query("select * from acclist where al_parent='$resource' and al_acctag='$rinfo[r_tag]'");
					$sel = (db_numrows($check) > 0) ? "selected" : "";
					echo "<option value=\"$rinfo[r_tag]\" $sel > $rinfo[r_tag] - $rinfo[r_desc]\n";
				}
			?>
			</select>
			</td>
		</tr>
		<tr><td>&nbsp;</td></tr>
		<tr bgcolor=#000000 valign=top>
			<td bgcolor=#000000 valign=top align=center>
				<input type="submit" value="Post Listing">
			</td>
		</tr>
		</form>
	</table>
	</td>
	</tr>
	
	<?
	
	} else {
	
		if ($f_process == "addacc") {
			LogIt("DEBUG","accedit.php3","Posting accessory information for $resource...");
			$gq = db_query("delete from acclist where al_parent='$resource'");
			for ($i=0;$i<SizeOf($data);$i++) {
				LogIt("DEBUG","accedit.php3","Loop on data: $i, value is $data[$i]");
				$iq = db_query("insert into acclist values ('$resource','$data[$i]')");
			}
		} else {
			#
			# We shouldn't have gotten here.
			#
			
			$lastresult[0]=1;
			$lastresult[1]="Unexpected condition occured! [accedit.php3]";
		}
	}
	
	?>
