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

$userid=$_SESSION["userid"];
$cname=$_POST["class_name"];
$month_name=$_POST["month"];
$after1=$_POST["after1"];
$after2=$_POST["after2"];
$blnk=0;
$today=date("Y-m-d");
		$year = date("Y",strtotime($today));
		

		$sql1 = "SELECT * FROM feenote WHERE user_id  = '$userid'";
$result1=$conn->query($sql1);
$row1 = $result1->fetch_assoc();
				$accno=$row1['accno'] ;
				$address=$row1['address'] ;
				$bname=$row1['bname'] ;
				$notice=$row1['notice'] ;
			
				 
$sql="select * from issueslip where month_name='$month_name' and class_name='$cname' and user_id='$userid' ORDER BY adm_no";
$result=$conn->query($sql);
 while($ppp = $result->fetch_assoc())

{

  $paytotal1=$ppp['totalfee'] + 20 ;
$paytotal2=$ppp['totalfee'] + 100 ;
	echo "<table border=10 width=33% align=left bgcolor=white>";
	?>
<tr>
<td align="center" colspan="3"><img src="logo1.jpg" align="middle" /></td>
<td align="center" colspan="3"><img src="pgc.jpg" align="middle"/></td>

</tr>
<?php
	echo "<tr>";
	echo "<td colspan=6>";
	
	echo "<h1 align=center colspan=6>$uerid </h1>";
	echo "<h4 align=center colspan=6>No Child left behind - Project of Punjab Group of Colleges </h4>";
	 echo "<h4 align=center colspan=6> $bname : A/C # $accno </h4>";
	
	 echo "<h4 align=center colspan=6>$address</h4>";
	 
	 echo "</td>";
echo "</tr>";
 echo "<tr>";
 
echo "<th bgcolor=white align=left colspan=3><h3> Student's ID </th>";
  echo "<th colspan=3><h3> "  .$ppp["portal_id"] . "</th>" ;
 echo "</tr>";


echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Student's Name </th>";
  echo "<th colspan=3><h3> "  .$ppp["std_name"] . "</th>" ;
  
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Father's Name </th>";
  echo "<th colspan=3> <h3>"  .$ppp["fname"] . "</th>" ;
  
 echo "</tr>";
  echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3><h3> Class  </th>";
 echo "<td colspan=3 align=center><h3> "  .$ppp["class_name"] . "</td>" ;
  echo "</tr>";
 
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Fee Period </th>";
  echo "<td  colspan=3> <h3>"  .$ppp["month_period"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Issue Date </th>";
  echo "<td  colspan=3><h3> "  .$ppp["date"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3> <h3>Due Date </th>";
  echo "<td colspan=3> <h3>"  .$ppp["due_date"] . "</td>" ;
echo "</tr>";

echo "<tr>";
 echo "<th bgcolor=white align=center colspan=4 > <h3> Student Ledger Details</th>";
 echo "<th bgcolor=white align=center ><h3> Particulars </th>";
echo "<th bgcolor=white align=center ><h3> Rs. </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left rowspan=10 colspan=4 valign=top>";
$sqlled = "SELECT * FROM issueslip where  adm_no= ".$ppp["adm_no"] ."  and user_id='$userid' order by id";
$resultled=$conn->query($sqlled);
while($rowled = $resultled->fetch_assoc())
 
  { 
  $month_nameled = $rowled['month_name'];	
   $feebal = $rowled['feebal'];
    $sql2led = "SELECT * FROM rec_fee where adm_no= ".$ppp["adm_no"] ."  and month_period='$month_nameled' and user_id = '$userid'";
$result2led=$conn->query($sql2led);
$row2led = $result2led->fetch_assoc();
$feerec=$row2led['feerec'] ;
$netqty = ($feebal ) - ($feerec );
if ($netqty > 0)
{
   echo "<table border=1 width=100%>";
  echo "<tr>";
   echo "<td align=center width=25%>" .$month_nameled .  "</td>";
  echo "<td align=center width=25%>" .number_format($feebal) .  "</td>";
   echo "<td align=center width=25%>" .number_format($feerec) .  "</td>";
   echo "<td align=center width=25%>" .number_format($netqty) .  "</td>";
 echo "</tr>";
 echo "</table>";
 }
  }
  
  echo "</th>";
echo "<th bgcolor=white align=left  ><h4> Tuition Fee </th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["mfee"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc1"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee1bal"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc2"] ."</th>";
 echo "<td width=40%> <h4>" ."Rs." .$ppp["fee2bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc3"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee3bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc4"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee4bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc5"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee5bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc6"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee6bal"] .".00". "</td>" ;
 echo "</tr>";
 
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4> Current Fine </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["fine"] . ".00"."</td>" ;
 echo "</tr>";
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4>Previous Balance </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["bal"] . ".00"."</td>" ;
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left ><h4> Total Paybale </th>";
  echo "<td width=40%> <h4> " ."Rs." .$ppp["totalfee"] . ".00"."</td>" ;
 echo "</tr>";
 

 
 
 
 
  echo "<tr>";
  echo "<td bgcolor=white align=left colspan=6><b>$notice</b>
 </td>";
 echo "</tr>";
 
  echo "<tr>";
echo "<th bgcolor=white align=center colspan=6> School Copy </th>";
 echo "</tr>";

echo "</table>";
echo "<table border=10 width=33% align=left bgcolor=white>";
	?>
<tr>
<td align="center" colspan="3"><img src="logo1.jpg" align="middle" /></td>
<td align="center" colspan="3"><img src="pgc.jpg" align="middle"/></td>

</tr>
<?php
	echo "<tr>";
	echo "<td colspan=6>";
	
	echo "<h1 align=center colspan=6>$uerid </h1>";
	echo "<h4 align=center colspan=6>No Child left behind - Project of Punjab Group of Colleges </h4>";
	 echo "<h4 align=center colspan=6> $bname : A/C # $accno </h4>";
	
	 echo "<h4 align=center colspan=6>$address</h4>";
	 
	 echo "</td>";
echo "</tr>";
echo "<tr>";
 
echo "<th bgcolor=white align=left colspan=3><h3> Student's ID </th>";
  echo "<th colspan=3><h3> "  .$ppp["portal_id"] . "</th>" ;
 echo "</tr>";


echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Student's Name </th>";
  echo "<th colspan=3><h3> "  .$ppp["std_name"] . "</th>" ;
  
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Father's Name </th>";
  echo "<th colspan=3> <h3>"  .$ppp["fname"] . "</th>" ;
  
 echo "</tr>";
  echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3><h3> Class  </th>";
 echo "<td colspan=3 align=center><h3> "  .$ppp["class_name"] . "</td>" ;
  echo "</tr>";
 
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Fee Period </th>";
  echo "<td  colspan=3> <h3>"  .$ppp["month_period"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Issue Date </th>";
  echo "<td  colspan=3><h3> "  .$ppp["date"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3> <h3>Due Date </th>";
  echo "<td colspan=3> <h3>"  .$ppp["due_date"] . "</td>" ;
echo "</tr>";

echo "<tr>";
 echo "<th bgcolor=white align=center colspan=4 > <h3> Student Ledger Details</th>";
 echo "<th bgcolor=white align=center ><h3> Particulars </th>";
echo "<th bgcolor=white align=center ><h3> Rs. </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left rowspan=10 colspan=4 valign=top>";
$sqlled = "SELECT * FROM issueslip where  adm_no= ".$ppp["adm_no"] ."  and user_id='$userid' order by id";
$resultled=$conn->query($sqlled);
while($rowled = $resultled->fetch_assoc())
 
  { 
  $month_nameled = $rowled['month_name'];	
   $feebal = $rowled['feebal'];
    $sql2led = "SELECT * FROM rec_fee where adm_no= ".$ppp["adm_no"] ."  and month_period='$month_nameled' and user_id = '$userid'";
$result2led=$conn->query($sql2led);
$row2led = $result2led->fetch_assoc();
$feerec=$row2led['feerec'] ;
$netqty = ($feebal ) - ($feerec );
if ($netqty > 0)
{
   echo "<table border=1 width=100%>";
  echo "<tr>";
   echo "<td align=center width=25%>" .$month_nameled .  "</td>";
  echo "<td align=center width=25%>" .number_format($feebal) .  "</td>";
   echo "<td align=center width=25%>" .number_format($feerec) .  "</td>";
   echo "<td align=center width=25%>" .number_format($netqty) .  "</td>";
 echo "</tr>";
 echo "</table>";
 }
  }
  
  echo "</th>";
echo "<th bgcolor=white align=left  ><h4> Tuition Fee </th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["mfee"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc1"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee1bal"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc2"] ."</th>";
 echo "<td width=40%> <h4>" ."Rs." .$ppp["fee2bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc3"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee3bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc4"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee4bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc5"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee5bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc6"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee6bal"] .".00". "</td>" ;
 echo "</tr>";
 
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4> Current Fine </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["fine"] . ".00"."</td>" ;
 echo "</tr>";
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4>Previous Balance </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["bal"] . ".00"."</td>" ;
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left ><h4> Total Paybale </th>";
  echo "<td width=40%> <h4> " ."Rs." .$ppp["totalfee"] . ".00"."</td>" ;
 echo "</tr>";
 

 
 
 
 
  echo "<tr>";
  echo "<td bgcolor=white align=left colspan=6><b>$notice</b>
 </td>";
 echo "</tr>";
  
  echo "<tr>";
echo "<th bgcolor=white align=center colspan=6> Bank Copy </th>";
 echo "</tr>";

echo "</table>";
echo "<table border=10 width=33% align=left bgcolor=white>";
	?>
<tr>
<td align="center" colspan="3"><img src="logo1.jpg" align="middle" /></td>
<td align="center" colspan="3"><img src="pgc.jpg" align="middle"/></td>

</tr>
<?php
	echo "<tr>";
	echo "<td colspan=6>";
	
	echo "<h1 align=center colspan=6>$uerid </h1>";
	echo "<h4 align=center colspan=6>No Child left behind - Project of Punjab Group of Colleges </h4>";
	 echo "<h4 align=center colspan=6> $bname : A/C # $accno </h4>";
	
	 echo "<h4 align=center colspan=6>$address</h4>";
	 
	 echo "</td>";
echo "</tr>";
echo "<tr>";
 
echo "<th bgcolor=white align=left colspan=3><h3> Student's ID </th>";
  echo "<th colspan=3><h3> "  .$ppp["portal_id"] . "</th>" ;
 echo "</tr>";


echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Student's Name </th>";
  echo "<th colspan=3><h3> "  .$ppp["std_name"] . "</th>" ;
  
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3>Father's Name </th>";
  echo "<th colspan=3> <h3>"  .$ppp["fname"] . "</th>" ;
  
 echo "</tr>";
  echo "<tr>";
  echo "<th bgcolor=white align=left colspan=3><h3> Class  </th>";
 echo "<td colspan=3 align=center><h3> "  .$ppp["class_name"] . "</td>" ;
  echo "</tr>";
 
 echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Fee Period </th>";
  echo "<td  colspan=3> <h3>"  .$ppp["month_period"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3><h3> Issue Date </th>";
  echo "<td  colspan=3><h3> "  .$ppp["date"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=left colspan=3> <h3>Due Date </th>";
  echo "<td colspan=3> <h3>"  .$ppp["due_date"] . "</td>" ;
echo "</tr>";
echo "<tr>";
 echo "<th bgcolor=white align=center colspan=4 > <h3> Student Ledger Details</th>";
 echo "<th bgcolor=white align=center ><h3> Particulars </th>";
echo "<th bgcolor=white align=center ><h3> Rs. </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left rowspan=10 colspan=4 valign=top>";
$sqlled = "SELECT * FROM issueslip where  adm_no= ".$ppp["adm_no"] ."  and user_id='$userid' order by id";
$resultled=$conn->query($sqlled);
while($rowled = $resultled->fetch_assoc())
 
  { 
  $month_nameled = $rowled['month_name'];	
   $feebal = $rowled['feebal'];
    $sql2led = "SELECT * FROM rec_fee where adm_no= ".$ppp["adm_no"] ."  and month_period='$month_nameled' and user_id = '$userid'";
$result2led=$conn->query($sql2led);
$row2led = $result2led->fetch_assoc();
$feerec=$row2led['feerec'] ;
$netqty = ($feebal ) - ($feerec );
if ($netqty > 0)
{
   echo "<table border=1 width=100%>";
  echo "<tr>";
   echo "<td align=center width=25%>" .$month_nameled .  "</td>";
  echo "<td align=center width=25%>" .number_format($feebal) .  "</td>";
   echo "<td align=center width=25%>" .number_format($feerec) .  "</td>";
   echo "<td align=center width=25%>" .number_format($netqty) .  "</td>";
 echo "</tr>";
 echo "</table>";
 }
  }
  
  echo "</th>";
echo "<th bgcolor=white align=left  ><h4> Tuition Fee </th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["mfee"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc1"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee1bal"] .".00". "</td>" ;
 echo "</tr>";
echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc2"] ."</th>";
 echo "<td width=40%> <h4>" ."Rs." .$ppp["fee2bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc3"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee3bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc4"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee4bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc5"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee5bal"] .".00". "</td>" ;
 echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=white align=left ><h4>" . $ppp["feedisc6"] ."</th>";
 echo "<td width=40%><h4> " ."Rs." .$ppp["fee6bal"] .".00". "</td>" ;
 echo "</tr>";
 
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4> Current Fine </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["fine"] . ".00"."</td>" ;
 echo "</tr>";
  echo "<tr>";
echo "<th bgcolor=white align=left ><h4>Previous Balance </th>";
 echo "<td width=40%><h4>  " ."Rs." .$ppp["bal"] . ".00"."</td>" ;
 echo "</tr>";
 echo "<tr>";
 echo "<th bgcolor=white align=left ><h4> Total Paybale </th>";
  echo "<td width=40%> <h4> " ."Rs." .$ppp["totalfee"] . ".00"."</td>" ;
 echo "</tr>";
 

 
 
 
 
  echo "<tr>";
  echo "<td bgcolor=white align=left colspan=6><b>$notice</b>
 </td>";
 echo "</tr>";
   echo "<tr>";
echo "<th bgcolor=white align=center colspan=6> Parents Copy </th>";
 echo "</tr>";

echo "</table>";
echo "_______________________________________________________________________________________________________________________";

}
?>