<?php
session_start();
include 'dbc.php';
$userid=$_SESSION["userid"];
$result = mysql_query("SELECT * FROM users WHERE userid  = '$userid'");
$test = mysql_fetch_array($result);
if (!$result) 
		{
		die("Error: Data not found..");
		}
		
				$accno=$test['accno'] ;
				$bankname=$test['address'] ;
				$bname=$test['bankname'] ;
				$cell=$test['cell'] ;
$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$due_date=$_POST["due_date"];
$month_perd=$_POST["month_perd"];

$class_name=$_POST["class_name"];
$std_rollno=$_POST["std_rollno"];
$monthly_fee=$_POST["monthly_fee"];
$annual_fee=$_POST["annual_fee"];
$adm_fee=$_POST["adm_fee"];
$reg_fee=$_POST["reg_fee"];
$paper_fee=$_POST["paper_fee"];
$security_fee=$_POST["security_fee"];
$others_fee=$_POST["others_fee"];

$sql = "select * from admission where std_rollno='$std_rollno' and class_name='$class_name' and user_id='$userid'";
$admission=mysql_query($sql) or die("Error : " . mysql_error());
$data=mysql_query($sql);
$found=mysql_num_rows($data);
$founddata="";
 if($found==1)
 {
 $ppp1=mysql_fetch_array($data);

$stdname=$ppp1["std_name"];
$fname=$ppp1["father_name"];
$oldbal=$ppp1["bal"];


   
   $total=$monthly_fee + $annual_fee + $adm_fee + $reg_fee + $paper_fee + $security_fee + $others_fee;
	  $bal=$oldbal + $monthly_fee + $annual_fee + $adm_fee + $reg_fee + $paper_fee + $security_fee + $others_fee;
  
	$sql2="update admission set bal='$monthly_fee',anbal='$annual_fee',admbal='$adm_fee',regbal='$reg_fee',acbal='$paper_fee',securitybal='$security_fee',othersbal='$others_fee' 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 issueslip (id,date,due_date,rollno,stdname,fname,cname,monthname,mfee,afee,total,bal,nettotal,user_id,adm_fee,reg_fee,gfee,security_fee,others_fee,month_perd) values (null,'$today','$due_date','$std_rollno','$stdname','$fname','$class_name','$month_name','$monthly_fee','$annual_fee','$total','0','$total','$userid','$adm_fee','$reg_fee','$paper_fee','$security_fee','$others_fee','$month_perd')";
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','$std_rollno','$stdname','$fname','$class_name','$month_name','$total','0','0','$userid')";
mysql_query($sql4) or die("Error : " . mysql_error());

$sql="select * from issueslip where rollno='$std_rollno' and cname='$class_name' and monthname='$month_name' and user_id='$userid'";
$issueslip=mysql_query($sql) or die("Error : " . mysql_error());
while($ppp=mysql_fetch_array($issueslip))


{


  
	echo "<table border=1 width=100% align=left bgcolor=white>";
	?>
<tr>
<td align="center" colspan="2"><img src="logo1.jpg" /></td>

</tr>
<?php
	echo "<tr>";
	echo "<td colspan=4>";
	
	echo "<h1 align=center colspan=4>$userid </h1>";
	echo "<h1 align=center colspan=4>DREAMLAND INTERNATIONAL SCHOOLS </h1>";
	 echo "<h4 align=center colspan=4>$bankname </h4>";
	 echo "<h4 align=center colspan=4>$cell </h4>";
	 echo "</td>";
echo "</tr>";
 echo "<tr>";
  echo "<th bgcolor=white align=left > Issue Date </th>";
  echo "<td>  " .$ppp["date"] . "</td>" ;
  echo "<th bgcolor=white align=center > Slip No </th>";
  echo "<td>  "  .$ppp["id"] . "</td>" ;
  echo "</tr>";

echo "<tr>";
echo "<th bgcolor=white align=left  width=30% >Bank / Branch </th>";
echo "<td bgcolor=white align=left colspan=3 width=70%> $bname </td>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left width=30% >Acc# </th>";
echo "<td bgcolor=white align=left colspan=3 width=70%> $accno </td>";
echo "</tr>";
  



echo "<tr>";
echo "<th bgcolor=white align=left> Slip No </th>";
  echo "<th colspan=3>  "  .$ppp["id"] . "</th>" ;
 echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left>Student Name </th>";
  echo "<th colspan=3>  "  .$ppp["stdname"] . "</th>" ;
  
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left>Father Name </th>";
  echo "<th colspan=3>  "  .$ppp["fname"] . "</th>" ;
  
 echo "</tr>";
echo "<tr>";
  echo "<th bgcolor=white align=left> Student ID </th>";

 echo "<th colspan=3>  "  .$ppp["rollno"] . "</th>" ;
  echo "</tr>";
  echo "<tr>";
  echo "<th bgcolor=white align=left> Portal ID </th>";

 echo "<th colspan=3>  "  .$ppp["allied_code"] . "</th>" ;
  echo "</tr>";
   echo "<tr>";
  echo "<th bgcolor=white align=left> Class  </th>";
 echo "<td colspan=3 align=center>  "  .$ppp["cname"] . "</td>" ;
  echo "</tr>";
 

 echo "<tr>";
 echo "<th bgcolor=white align=left width=30%> Fee Period </th>";
  echo "<td width=10% colspan=3>  "  .$ppp["monthname"] . "</td>" ;
 
  

echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left width=30%> Due Date </th>";
  echo "<td width=10% colspan=3>  "  .$ppp["due_date"] . "</td>" ;
 
  

echo "</tr>";
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=center colspan=3 >  Particulars </th>";
echo "<th bgcolor=white align=center >  Rs. </th>";


echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left colspan=3 > Tuition Fee </th>";
 echo "<td width=40%>  " ."Rs." .$ppp["mfee"] .".00". "</td>" ;
 
echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Admission Fee </th>";
echo "<td width=40%>  " ."Rs." .$ppp["adm_fee"] . ".00"."</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Annual Charges </th>";
 echo "<td width=40%>  " ."Rs." .$ppp["afee"] . ".00"."</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Ac Charges </th>";
 echo "<td width=40%>  " ."Rs." .$ppp["paper_fee"] . ".00"."</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Registration Fee </th>";
 echo "<td width=40%>  " ."Rs." .$ppp["reg_fee"] . ".00"."</td>" ;
 echo "</tr>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Pre. Balance </th>";
echo "<td width=40%>  " ."Rs" .$ppp["bal"] . ".00"."</td>" ;
echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left colspan=3>Security Fee  </th>";
echo "<td width=40%>  " ."Rs" .$ppp["security_fee"] . ".00"."</td>" ;
echo "</tr>";
  echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Fine </th>";
 echo "<td width=40%>  " ."Rs." .$ppp["curfine"] . ".00"."</td>" ;
 echo "</tr>";
  echo "<tr>";
echo "<th bgcolor=white align=left colspan=3> Misc fee </th>";
 echo "<td width=40%>  " . " Rs.0.00 " . "</td>" ;
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3> Net Paybale </th>";
  echo "<td width=40%>  " ."Rs." .$ppp["nettotal"] . ".00"."</td>" ;
 echo "</tr>";
 

 
 
  
 
 
 echo "<td bgcolor=white align=left colspan=4><b>Dear Parents,
<br>Due date of fee submission is 7th of every month in case of being late fine will be charged as per following procedure.
<br>Fine till 8th of the month will be Rs.50 it will be Rs.100 after 10th and till 14th fine of rs.150 will be added after 15th of that respective month and soon.
 </td>";
 echo "</tr>";
 
  echo "<tr>";
echo "<th bgcolor=white align=center colspan=4> Parents Copy </th>";
 echo "</tr>";

echo "</table>";



echo "_______________________________________________________________________________________________________________________";
}
}
else
{
echo "wrong student rollno";
}
?>
<a href="genrate_adm_feeslip.php">Back</a>