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





$month_name=$_POST["month_name"];
$recdate=$_POST["recdate"];
$acc_name_dr=$_POST["acc_name_dr"];
if($_POST['delete']) // from button name="delete"
	{
		$checkbox = $_POST['checkbox']; //from name="checkbox[]"
		$countCheck = count($_POST['checkbox']);
		
		for($i=0;$i<$countCheck;$i++)
		{
			$del_id  = $checkbox[$i];
			$userid=$_SESSION["userid"];
			$today=date("d-m-Y");
			$sqlp14 = "select * from admission where id='$del_id' and user_id='$userid'";
 							$finishstock=mysql_query($sqlp14) or die("Error : " . mysql_error());
   							$app1=mysql_fetch_array($finishstock);
   							$std_rollno=$app1["std_rollno"];
							$std_name=$app1["std_name"];
							$class_name=$app1["class_name"];
							$bal=$app1["bal"];
							$fname=$app1["father_name"];
							$mfee=$app1["monthly_fee"];
							
							
						
$tbal=0;
  
  
			
			 
		$sql2="update admission set bal='$tbal' where std_rollno='$std_rollno' and class_name='$class_name' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	$sql3 = "Insert into rec_fee (id,date,std_rollno,std_name,class_name,month_name,total_fee,paid_fee,bal_fee,user_id,rt) values (null,'$recdate','$std_rollno','$std_name','$class_name','$month_name','$bal','$bal','$tbal','$userid','Bank')";
mysql_query($sql3) or die("Error : " . mysql_error());
	$sql13 = "Insert into acc_ledger (id,date,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$rec_date','$std_rollno','$acc_name_dr','$std_name','$acc_name_dr','$bal','0','0','$userid')";
mysql_query($sql13) or die("Error : " . mysql_error());
			
		}
			if($result)
		{	
				header('Location: t_r_fee.php');
			}
			else
			{
				echo "Record Save";
			}
	}
  
	
	

// do the update and print out some info just to provide some visual feedback





?>
<a href="rec_fee.php"> Back </a>