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

	#----------------------------------------------------------------------
	# $Id: closeslip.php3,v 1.23 2000/12/19 15:44:52 shevett Exp $
	#----------------------------------------------------------------------
	
	# Close a slip.
	# $sid should have the slip id.

	if ($f_func == "closeslip") { ?>
	
	<?
		$f_sid = $sid;
		$f_date = time();
		$f_tech = $curruser ;
		$f_usergen = 1;
    if ($is_public) {
     $publicchecked = "checked";
     $privatechecked = "";
    } else {
     $publicchecked = "";
     $privatechecked = "checked";
    }

	?>
	
		<form method="post" action="nbrowse.php3">
		<input type=hidden name="f_process" value="closeslip">
		<input type=hidden name="f_sid" value="<? echo $f_sid ?>">
		<input type=hidden name="f_date" value="<? echo $f_date ?>">
		<input type=hidden name="f_tech" value="<? echo $f_tech ?>">
		<input type=hidden name="f_usergen" value="<? echo $f_usergen ?>">
		<tr bgcolor=#BBBBCB>
		<td width=100% bgcolor=#202020 colspan=2>
			<table width=100% bgcolor=#bbbbbb cellspacing=2>
			<tr>
				<td align=center>
					Close a slip
				</td>
			</tr>
			<tr bgcolor=#000000 valign=top>
				<td bgcolor=#000000>
					<?
						ShowStatusBar($f_sid);
					?>
				</td>
			</table>
		</td>
		<tr bgcolor=#bbbbbb valign=top>
			<td bgcolor=#808080>
				<i>Closing Text:</i><br>
				<font size=<? echo $sys_selfont ?>><textarea name="f_ctext" rows=10 cols=60 wrap="soft"></textarea></font>
				<hr>
				<input type=hidden name="f_oldtimespent" value="<? echo $f_oldtimespent ?> ">
				<i>Time Spent:</i><br>
                		<input type=text name="f_time" size=4 value="0">
			</td>
			<td bgcolor=#808080 valign=center>
				<i>Do you want this information to be available for public viewing?</i><br>
				<input type="radio" name="f_public" value="1" <? echo $publicchecked ?>> Public <br>
				<input type="radio" name="f_public" value="0" <? echo $privatechecked ?>> Private
				<hr>
				<? MailOptions(); ?>
			</td>
		</tr>
		<tr bgcolor=#000000><td colspan=2>
		<?
			PostBar("Close Slip");
		?>
		</tr>
		
		</form>

	<?
	
	} else {
	
		if ($f_process == "closeslip") {
		
			$f_flag="add";
			#
			# First, add the user-followup text, if any...
			#
			if ( strlen(trim($f_ctext)) ) {
				$f_text = trim($f_ctext);
			}
			#
			# Now go ahead with the system stuff.
			#
			$f_text="Status changed to Closed\n$f_text";
			$f_usergen=0;
			include "./postfoll.php3";
			
			#
			# Now close the slip
			#
			$ctime = time();
			$cinfo = db_query("update slips set status='$sys_closedflag',c_date=$ctime,c_tech='$curruser' where sid=$f_sid");
			$res = db_affected_rows($cinfo);

			#
			# Change the priority on that slip if the setting is there for it.
			#

			if ($sys_closepriority > 0) {
				$cinfo = db_query("update slips set priority=$sys_closepriority where sid=$f_sid");
			}

		} else {
			#
			# We shouldn't have gotten here.
			#
			
			$lastresult[0]=1;
			$lastresult[1]="Unexpected condition occured! [closeslip.php3]";
		}
	}
	
	?>
