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

	#----------------------------------------------------------------------------
	# $Id: postver.php3,v 1.2 2000/12/14 19:13:58 shevett Exp $
	#----------------------------------------------------------------------------
	
	#----------------------------------------------------------------------------
	# Post an added or modified slip.  (f_flag will tell 'mod' or 'add')
	#----------------------------------------------------------------------------

	$flist = "v_prod, v_mod, v_plat, v_foundin, v_target, v_verify, v_resolve";
	$vlist = "'$a_v_prod','$a_v_mod','$a_v_plat','$a_v_foundin','$a_v_target','$a_v_verify','$a_v_resolve'";

	LogIt("DEBUG","postver.php3","flist is $flist");
	LogIt("DEBUG","postver.php3","vlist is $vlist");

	# If there isn't a slipver record for this slip, make one.
	$osv = db_query("select v_id from slipver where v_id=$a_v_id");
	if (! db_numrows($osv)) {
		$sv = db_query("insert into slipver (v_id) values ($a_v_id)");
	}
	$osv = db_query("select * from slipver where v_id=$a_v_id");
	$osvdata = db_fetch_array($osv) ;
	
	#
	# find out what changed.
	#
		
	$chstring = "";
	$chstring	=	($a_v_prod <> $osvdata[v_prod]) 				? 
		"${chstring}Product changed from $osvdata[v_prod] to $a_v_prod\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_mod <> $osvdata[v_mod]) 				? 
		"${chstring}Module version changed from $osvdata[v_mod] to $a_v_mod\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_plat <> $osvdata[v_plat]) 				? 
		"${chstring}Platform changed from $osvdata[v_plat] to $a_v_plat\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_foundin <> $osvdata[v_foundin]) 				? 
		"${chstring}Found in version changed from $osvdata[v_foundin] to $a_v_foundin\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_target <> $osvdata[v_target]) 				? 
		"${chstring}Target version changed from $osvdata[v_target] to $a_v_target\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_verify <> $osvdata[v_verify]) 				? 
		"${chstring}Verification version changed from $osvdata[v_verify] to $a_v_verify\n"	: 
		"$chstring" ;
	$chstring	=	($a_v_resolve <> $osvdata[v_resolve]) 				? 
		"${chstring}Resolution changed from $osvdata[v_resolve] to $a_v_resolve\n"	: 
		"$chstring" ;

	#
	# Pick a followup number and post the data.
	#

	$highseq = CalcHighSeq($a_v_id) + 1;
		
	if(!empty($chstring)) {
		$chstring	=	addslashes($chstring);
		$flist	= "f_sid,f_date,f_tech,f_text,f_seq,f_public,f_usergen,f_time";
		$now		= time();
		$vlist	=	"$a_v_id,$now,'$curruser','$chstring',$highseq";
		switch ($sys_switch_followpub) {
			case 0 : { 
				$vlist="$vlist,0";
				break;;
			}
			case 1 : {
				$vlist="$vlist,1";
				break;;
			}
			case 2 : {
				$vlist="$vlist,$a_public";
				break;;
			}
		}
		$vlist="$vlist,0,NULL";
		$result = db_query("insert into followups ($flist) values ($vlist)");
	}
		
	$result = db_query("update slipver set " .
		"v_id=$a_v_id,  ".
		"v_prod='$a_v_prod',".
		"v_mod='$a_v_mod',".
		"v_plat='$a_v_plat',".
		"v_foundin='$a_v_foundin',".
		"v_target='$a_v_target',".
		"v_verify='$a_v_verify',".
		"v_resolve='$a_v_resolve' where v_id=$a_v_id");
		$lastresult[0] = 0;
		$lastresult[1] = "Slipver $a_v_id updated successfully.";
		
	# make sure counters are reset
	RecalcSlip($a_v_id);

	#
	# Generate mail if someone asks... 
	#

	if (($chstring) || ($f_flag=="add")) {
		$sid=$a_v_id;
		$f_process="sendmail";
		include "./genmail.php3";
	}

?>

