Location: PHPKode > projects > ERPSOD > erpsod/trans_edit.php
<?PHP
include_once("config.php");

$form1=$_GET["form"];
$action=$_POST["command"];
$id=$_POST["translist"] ;

$tasktel=0;

if ($form1=="trans_edit"){

	if ($action == "Cancel") {
		header('Location: trans_list.php');
	} else{
		$id=$_POST["id"] ;
		$transname = $_POST["transname"] ;
		$transdesc = $_POST["transdesc"] ;
		$error_txt = '';
		if ($taskname =="" ){
			$error_txt = "Transaction-name can not be blank";
		} else{
			if ($id==0){
				$sql = "select * from erptrans where upper(transname)=upper('$transname')" ;
				$result = mysql_query($sql);
				$num_rows = mysql_num_rows($result);

				if ($num_rows ==0){
					$sql="INSERT INTO erptrans (transname,transdesc) VALUES ( '$transname','$transdesc')";
					$result = mysql_query($sql);
				}
			} else{
				$sql="UPDATE erptrans SET transname='$transname', transdesc='$transdesc' WHERE transid = $id";
				$result = mysql_query($sql);
			} 
		}
		header('Location: trans_list.php');
	}
} else {
	if ($form1<>"trans_list"){
		header('Location: trans_list.php');
	}

	if ($action == "New"){
		$id = 0;
		$transname= "";
		$transdesc="";
	}
	if ($action == "Delete"){
		$sql="DELETE FROM erptrans WHERE transid = $id";
		$result = mysql_query($sql);
		$sql="delete from tasktrans where transid = $id";
		$result = mysql_query($sql);
		header('Location: trans_list.php');
	}
	if ($action == "Edit"){
		$sql="SELECT * FROM erptrans WHERE transid = $id";
		$result = mysql_query($sql);
		$num_rows = mysql_num_rows($result);
		if ($num_rows <>0){
			$row = mysql_fetch_row($result);
			$id = $row[0];
			$transname= $row[1];
			$transdesc = $row[2];
			$sql1 ="select taskname from erptask,tasktrans where tasktrans.taskid=erptask.taskid and tasktrans.transid=$id";
			$result1 = mysql_query($sql1);
			$tasktel = mysql_num_rows($result1);
		}
	}
}
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="<?PHP echo $style ?>">
<script language="JavaScript1.2" src="js/coolmenus4.js">
</script>
</HEAD>
<body bgcolor="#ffffff">
<script language="JavaScript1.2" src="js/erpsod.js">
</script><br><br><center>
<h3>Transactions</h3>
<?php
if ($error_txt <>""){
	echo $error_txt ;
	echo "<br>";
}
?>
<FORM ACTION="trans_edit.php?form=trans_edit" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $id ?>">
<table border=0 cellpadding=4 cellspacing=0 bgcolor="AQUA"><tr><td>
<tr>
<td>Transaction name</td>
<td><Input Name="transname" MaxLength="50" Size="50" Value="<?php echo $transname ?>"></td>
</tr>
<tr>
<td>Transaction description</td>
<td colspan=2><textarea rows="2" name="transdesc" cols="75"><?php echo $transdesc ?></textarea></td>
</tr>
<br>

<?php 
if ($id <>0){ 
If ($tasktel>0){
?>

<tr>
<td><b>This transaction is part of the following tasks:</b></td></tr>
<?PHP } 
	while ($row1 = mysql_fetch_array($result1, MYSQL_NUM)) {
		?>
		<tr><td>
		<?php
		echo $row1[0];
		?>
		</td></tr>
		<?PHP
	}
}
?>
<br>
<tr>
<td colspan=2 align="center">
<INPUT TYPE="SUBMIT" NAME="command" VALUE="Submit">
<INPUT TYPE="SUBMIT" NAME="command" VALUE="Cancel">
</td></tr>
</table>
</td></tr></table></center>
</FORM>
</BODY>
<?php
include_once("footer.php");
?>
</HTML>
Return current item: ERPSOD