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

	#--------------------------------------------------------------------
	# $Id: phonemaint.php3,v 1.13 2000/12/27 18:21:43 nclemons Exp $
	#--------------------------------------------------------------------

	$qstring = "select * from phones where tag='$f_contact' and label='$f_label'";
	LogIt("DEBUG","phonemaint.php3","query is $qstring");
	$result = db_query("$qstring");
	$currow = db_fetch_array($result);

?>

	<form method="post" action="nbrowse.php3">
	<input type=hidden name="f_process" value="phonepost">
	<input type=hidden name="a_tag" value="<? echo $f_contact ?>">
	<tr bgcolor=#000000>
		<td align=center colspan=3>
		<table bgcolor=#000000 cellspacing=2>
			<tr>
				<td bgcolor=#bbbbbb align=center>
				<?
					if ($currow && $currow[tag]) {
						echo "Modify phone number <b>$f_label</b> for contact <b>$f_contact</b>";
						echo "<input type=hidden name=\"f_flag\" value=\"modify\">";
						echo "<input type=hidden name=\"a_main\" value=\"$currow[main]\">";
						echo "<input type=hidden name=\"o_number\" value=\"$currow[number]\">";
						echo "<input type=hidden name=\"o_label\" value=\"$currow[label]\">";
					} else {
						echo "Add new phone number to contact <b>$f_contact</b>";
						echo "<input type=hidden name=\"f_flag\" value=\"add\">";
						# This forces $currow to be an array with all the expected elements are empty.
						unset ($currow);
						$currow[0] = "";
					}
				?>
				</td>
			</tr>
			<tr>
				<td bgcolor=#808080>
				<table><tr><td bgcolor=#808080>
					<i>Label</i><br>
					<select name="a_label">
					<?
					$labelquery = db_query("select tag,descrip from contactlabel where ltype='P' order by tag");
					while ($row=db_fetch_array($labelquery)) {
						if ($row[tag] == $currow[label]) {
							$sel = "selected";
							$selcount = 1;
						} else {
							$sel ="";
						}
						echo "<option value=\"$row[tag]\" $sel> $row[tag] - $row[descrip]";
					}
					$sel = "";
					if ($currow[label] && $selcount == 0) {
						$sel = "selected";
					}
					echo "<option value=\"userwritein\" $sel> Write in your own in the next column";
					?>
				</select>
				</td>
				<td bgcolor=#808080>
					<i>User Write-In</i><br>
					<input type=text name=a_writeinvalue size=10 value="<? echo $selcount ? "" : $currow[label] ?>"><br>
				</td>
				</td></tr></table>
			</tr>
			<tr>
				<td bgcolor=#808080>
					<i>Phone Number</i><br>
					<!-- FIXME: needs maxsize based on database query -->
					<input type=text name=a_number size=50 value="<? echo $currow[number] ?>"><br>
				</td>
			</tr>
			<tr bgcolor=#000000><td>
			<?
				PostBar("Post Phone Information");
			?>
			</td>
			</tr>
		</table>
		</td>
	</tr>
	
	
	</form>
