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

$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$due_date=$_POST["due_date"];
$hmmf=$_POST["hmmf"];
$months=$_POST["months"];
$sql = "select * from admission where user_id='$userid'";
$admission=mysql_query($sql) or die("Error : " . mysql_error());
    
while($ppp=mysql_fetch_array($admission))
{
$rollno=$ppp["std_rollno"];
$stdname=$ppp["std_name"];
$fname=$ppp["father_name"];
$cname=$ppp["class_name"];
$code=$ppp["code"];
$mfee=$ppp["monthly_fee"];
$afee=$ppp["annual_fee"];
$bal=$ppp["bal"];
$camp=$ppp["camp"];
     $gfee=$ppp["sec_fee"];
  $totalfee=$mfee * $hmmf;
   $tbal=$totalfee + $bal ;
   $netfee=$totalfee + $afee ;
   $nettbal=$totalfee + $bal + $afee ;
 
  
	$sql2="update admission set bal='$tbal',anbal='$afee' where std_rollno='$rollno' and class_name='$cname' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	$sql3 = "Insert into issueslip (id,date,due_date,rollno,stdname,fname,cname,monthname,mfee,afee,total,bal,nettotal,user_id,months,code,camp) values (null,'$today','$due_date','$rollno','$stdname','$fname','$cname','$month_name','$totalfee','$afee','$netfee','$bal','$nettbal','$userid','$months','$code','$camp')";
mysql_query($sql3) or die("Error : " . mysql_error());
$sql4 = "Insert into std_ledger1 (id,date,rollno,stdname,fname,cname,monthname,issue,rec,balacne,user_id) values (null,'$today','$rollno','$stdname','$fname','$cname','$month_name','$totalfee' + '$afee','0','0','$userid')";
mysql_query($sql4) or die("Error : " . mysql_error());

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