<?php ob_start(); session_start(); ?>
<?php
include "layouts/db_connect.php";

		 if(isset($_SESSION['code'])) {
	  $code = $_SESSION['code'];
	  $scode = $_SESSION['code'];
	   $mfin = $_SESSION['mfin'];
		$staff = $_SESSION['name'];
		 $postt = $_SESSION['postt'];
	}
	
$fid = $_GET['fid'];
$sql = mysqli_query($conn, "select * from net where mfin='$mfin' && id = '$fid'");
$row2 = mysqli_fetch_array($sql);
$roll = $row2['rrno'];
$cdate = date("d-m-Y H:i:s");
$insert=mysqli_query($conn, "insert into cancels(cby,cdate,remarks,dueamount,hlrmk,hloan,mfin,scode,hpl,name,dueamt,amt,fine,tot,rno,rrno,mode,paydate,paydate2,bmnt)
values('$scode','$cdate','".$row2['remarks']."','".$row2['urname']."','".$row2['hlrmk']."','".$row2['hloan']."','".$row2['mfin']."','".$row2['scode']."','".$row2['hpl']."','".$row2['name']."','".$row2['pass']."','".$row2['amt']."','".$row2['fine']."','".$row2['urname']."','".$row2['roll']."','".$row2['roll']."','".$row2['mode']."','".$row2['paydate']."','".$row2['paydate2']."','".$row2['paydate']."')");		$hpl = $row2['hpl'];			    
//$insert=mysqli_query($conn, "insert into cancel(cby,cdate,remarks,vno,hlrmk,hloan,mfin,scode,hpl,name,no,dueamount,paydate,paymnt,fine,urname,roll,pass,rno,bil,mode)
//values('$scode','$cdate','".$row2['remarks']."','".$row2['$vno']."','".$row2['hlrmk']."','".$row2['hloan']."','".$row2['mfin']."','".$row2['scode']."','".$row2['hpl']."','".$row2['name']."','".$row2['no']."','".$row2['dueamount']."','".$row2['paydate']."','".$row2['paymnt']."','".$row2['fine']."','".$row2['urname']."','".$row2['roll']."','".$row2['pass']."','".$row2['rno']."','".$row2['bil']."','".$row2['mode']."')");
mysqli_query($conn, "DELETE FROM roll where mfin='$mfin' && rno = '$roll'");						
mysqli_query($conn, "DELETE FROM net where mfin='$mfin' && id = '$fid'");

$update=mysqli_query($conn, "update customerdetails set status='Active' where hpl='$hpl' && mfin='$mfin'");	
   
echo "<script>alert('Cancelled successfully');window.location.href='billrep.php'</script><br>";

?>


