<?php include("../../include/dbconnect.php"); 



if ( isset($submit) && $submit == "Update")
{
	$date = us($date);
	if($type=='DR')
	{	
		$cramt = $dbamt;
	}
	elseif($type=='CR')
	{
		$dbamt= $cramt;
	}
   $result=mysqli_query($conn,"update templedger set narration = '$narration',dbamt='$dbamt',invno='$invno',date = '$date' where  trans_id='$trans_id' and type='DR' ") or die(mysqli_error());
   $result=mysqli_query($conn,"update templedger set narration = '$narration',cramt='$cramt',invno='$invno',date = '$date' where  trans_id='$trans_id' and type='CR' ") or die(mysqli_error());   
   
}
elseif (isset($submit) && $submit == "Delete")

{
	$date = us($date);
$result=mysqli_query($conn,"delete from templedger where trans_id='$trans_id' ") or die(mysqli_error());
$result=mysqli_query($conn,"delete from tranid where trans_id='$trans_id' and branch_code = '$branch' and account_year='$account_year' ") or die(mysqli_error());
}

?>
<meta http-equiv="refresh" content="0 url=editview.php?compcode=<?=$compcode?>&branch=<?=$branch?>&mdt=<?=$date?>">
