<?php
session_start();
include 'dbc.php';


$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$cname=$_POST["class_name"];
$rollno=$_POST["std_rollno"];
$sql9 = "select * from issueslip where rollno='$rollno' and cname='$cname' and monthname='$month_name' and user_id='$userid'";
   $appl1=mysql_query($sql9) or die("Error : " . mysql_error());
   $app2=mysql_fetch_array($appl1);
  
   if ($app2==0)
   {
     echo "Month does not exist <a href='del_monthly_feeslip_student.php'>Retry</a>";
   }
else
{
 $total=$app2["total"];
   
     $sql1 = "select * from std_ledger where std_rollno='$rollno' and class_name='$cname' and user_id='$userid'";
   $appl=mysql_query($sql1) or die("Error : " . mysql_error());
   $app=mysql_fetch_array($appl);
   $monthlyfee=$app["monthly_fee"];
  $bal=$monthlyfee - $total;
  
	$sql2="update std_ledger set monthly_fee='$bal' where std_rollno='$rollno' and class_name='$cname' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	$sql3 = "delete from issueslip where rollno='$rollno' and cname='$cname' and monthname='$month_name' and user_id='$userid'";
mysql_query($sql3) or die("Error : " . mysql_error());

$sql4 = "delete from std_ledger1 where rollno='$rollno' and cname='$cname' and monthname='$month_name' and user_id='$userid'";
mysql_query($sql4) or die("Error : " . mysql_error());

	
	echo "Slip Deleted Sucessfully";
	}
?>
<a href="del_monthly_feeslip_student.php">Back</a>