<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

   <!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        
        <!-- Header-->

        

        <div class="content mt-3">
            <div class="animated fadeIn">
                <div class="row">

                    <div class="col-md-14">
                        <div class="card">
						<div class="page-title">
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Total Receivable Summary Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$cname=$_POST["cname"];
$sql11 = "SELECT * FROM addclass where user_id = '$userid'";
$result11=$conn->query($sql11);
$row11 = $result11->fetch_assoc();
$feedisc1=$row11['feedisc1'] ;
$feedisc2=$row11['feedisc2'] ;
$feedisc3=$row11['feedisc3'] ;
$feedisc4=$row11['feedisc4'] ;
$feedisc5=$row11['feedisc5'] ;
$feedisc6=$row11['feedisc6'] ;

?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       
echo "<tr>";
 echo "<th width=30% colspan=6>" ."Class Name". "</th>";
 echo "<th width=30% colspan=6>" ."Total Students". "</th>";
  echo "<th width=30% colspan=6>" ."Fee Balance". "</th>";
  
   echo "<th width=30% colspan=6>" .$feedisc1. "</th>";
   echo "<th width=30% colspan=6>" .$feedisc2. "</th>";
   echo "<th width=30% colspan=6>" .$feedisc3. "</th>";
   echo "<th width=30% colspan=6>" .$feedisc4. "</th>";
   echo "<th width=30% colspan=6>" .$feedisc5. "</th>";
   echo "<th width=30% colspan=6>" .$feedisc6. "</th>";
 echo "</tr>";
$sql = "SELECT * FROM addclass where  user_id='$userid'";
$result=$conn->query($sql);
  while($row = $result->fetch_assoc())
   {
   $cname=$row["cname"];
  $trecord1=0;

$netqty = 0;
$netqty1 = 0;
$netqty2 = 0;
$netqty3= 0;
$netqty4 = 0;
$netqty5 = 0;
$netqty6 = 0;
$qtysale= 0;
  $qtysale1= 0;
  $qtysale2= 0;
  $qtysale3= 0;
  $qtysale4= 0;
  $qtysale5= 0; 
  $qtysale6= 0;  
  $qtypur= 0;
  $qtypur1= 0;
  $qtypur2= 0;
  $qtypur3= 0;
  $qtypur4= 0;
  $qtypur5= 0;
  $qtypur6= 0;
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                     
 
  $sql1 = "SELECT * FROM admission where class_name = '$cname' and user_id='$userid'";
$result1=$conn->query($sql1);
while($row1 = $result1->fetch_assoc())
   {
$trecord1=$trecord1 + 1;

  }
  $sql2 = "select * from issueslip where class_name = '$cname' and user_id='$userid'";
$result2=$conn->query($sql2);
while($ppp1 = $result2->fetch_assoc())
{
  $qtysale= $qtysale + $ppp1["feebal"];
  $qtysale1= $qtysale1 + $ppp1["fee1bal"];
  $qtysale2= $qtysale2 + $ppp1["fee2bal"];
  $qtysale3= $qtysale3 + $ppp1["fee3bal"];
  $qtysale4= $qtysale4 + $ppp1["fee4bal"];
  $qtysale5= $qtysale5 + $ppp1["fee5bal"]; 
  $qtysale6= $qtysale6 + $ppp1["fee6bal"];  
 } 
  
$sql3 = "select * from rec_fee where class_name = '$cname' and user_id='$userid'";
$result3=$conn->query($sql3);
while($ppp3 = $result3->fetch_assoc())
{
  $qtypur= $qtypur + $ppp3["feerec"];
  $qtypur1= $qtypur1 + $ppp3["feerec1"];
  $qtypur2= $qtypur2 + $ppp3["feerec2"];
  $qtypur3= $qtypur3 + $ppp3["feerec3"];
  $qtypur4= $qtypur4 + $ppp3["feerec4"];
  $qtypur5= $qtypur5 + $ppp3["feerec5"];
  $qtypur6= $qtypur6 + $ppp3["feerec6"];
 } 
 
 
 

$netqty = ($qtysale ) - ($qtypur );
$netqty1 = ($qtysale1 ) - ($qtypur1 );
$netqty2 = ($qtysale2 ) - ($qtypur2 );
$netqty3= ($qtysale3 ) - ($qtypur3 );
$netqty4 = ($qtysale4 ) - ($qtypur4 );
$netqty5 = ($qtysale5 ) - ($qtypur5 );
$netqty6 = ($qtysale6 ) - ($qtypur6 );


   echo "<tr>";
    echo "<th width=30% colspan=6>" .$cname. "</th>";
   echo "<th width=30% colspan=6>" .$trecord1. "</th>";
 echo "<td width=10% colspan=6>"  .number_format($netqty) . "</td>" ;
 
   echo "<td width=10% colspan=6>"  .number_format($netqty1) . "</td>" ;
   echo "<td width=10% colspan=6>"  .number_format($netqty2) . "</td>" ;
   echo "<td width=10% colspan=6>"  .number_format($netqty3) . "</td>" ;
   echo "<td width=10% colspan=6>"  .number_format($netqty4) . "</td>" ;
   echo "<td width=10% colspan=6>"  .number_format($netqty5) . "</td>" ;
   echo "<td width=10% colspan=6>"  .number_format($netqty6) . "</td>" ;
 echo "</tr>";
 $tnetqty=$tnetqty + $netqty;
   $tnetqty1=$tnetqty1 + $netqty1;
    $tnetqty2=$tnetqty2 + $netqty2;
	 $tnetqty3=$tnetqty3 + $netqty3;
	  $tnetqty4=$tnetqty4 + $netqty4;
	   $tnetqty5=$tnetqty5 + $netqty5;
	    $tnetqty6=$tnetqty6 + $netqty6;
 $tstd=$tstd + $trecord1;
 
  }
   $totalbal = $tnetqty + $tnetqty1 + $tnetqty2 + $tnetqty3 + $tnetqty4 + $tnetqty5 + $tnetqty6; 
   $total= $total + $tstd;
   echo "<tr>";
  
 echo "<th width=30% colspan=6>" ."Total". "</th>";
   echo "<th width=30% colspan=6>" .$tstd. "</th>";
    echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty) . "</td>" ;
    echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty1) . "</td>" ;
	 echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty2) . "</td>" ;
	  echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty3) . "</td>" ;
	   echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty4) . "</td>" ;
	    echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty5) . "</td>" ;
		 echo "<td width=25% colspan=6><h5>"  .number_format($tnetqty6) . "</td>" ;
 echo "</tr>";
  echo "<tr>";
	echo "<td colspan=2 align=right><b>" ."Total Balance:" ."</b></td>";
	echo "<td colspan=7 align=left><b>" . $total ."</b></td>";
	echo "<td colspan=7 align=right><b>" . $totalbal ."</b></td>";
	  echo "</tr>";
  ?>
  
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


                </div>
            </div><!-- .animated -->
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>