<?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;
$tfeebal=0;
$feebal1=0;
$feebal2=0;
$feebal3=0;
$feebal4=0;
$feebal5=0;
$feebal6=0;
$bal=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;
$bal=$bal + $row1['bal'];
$feebal1=$feebal1 + $row1['feebal1'];
$feebal2=$feebal2 + $row1['feebal2'];
$feebal3=$feebal3 + $row1['feebal3'];
$feebal4=$feebal4 + $row1['feebal4'];
$feebal5=$feebal5 + $row1['feebal5'];
$feebal6=$feebal6 + $row1['feebal6'];

  }
   echo "<tr>";
    echo "<th width=30% colspan=6>" .$cname. "</th>";
   echo "<th width=30% colspan=6>" .$trecord1. "</th>";
 echo "<th width=30% colspan=6>" .$bal. "</th>";
  echo "<th width=30% colspan=6>" .$feebal1. "</th>";
   echo "<th width=30% colspan=6>" .$feebal2. "</th>";
    echo "<th width=30% colspan=6>" .$feebal3. "</th>";
	 echo "<th width=30% colspan=6>" .$feebal4. "</th>";
	  echo "<th width=30% colspan=6>" .$feebal5. "</th>";
	   echo "<th width=30% colspan=6>" .$feebal6. "</th>";
 echo "</tr>";
 $tbal=$tbal + $bal;
  $tfeebal1=$tfeebal1 + $feebal1;
  $tfeebal2=$tfeebal2 + $feebal2;
   $tfeebal3=$tfeebal3 + $feebal3;
	 $tfeebal4=$tfeebal4 + $feebal4;
	 $tfeebal5=$tfeebal5 + $feebal5;
	  $tfeebal6=$tfeebal6 + $feebal6;
 $tstd=$tstd + $trecord1;
 
  }
   $totalbal = $tbal + $tfeebal1 + $tfeebal2 + $tfeebal3 + $tfeebal4 + $tfeebal5 + $tfeebal6; 
   $total= $total + $tstd;
   echo "<tr>";
  
 echo "<th width=30% colspan=6>" ."Total". "</th>";
   echo "<th width=30% colspan=6>" .$tstd. "</th>";
   echo "<th width=30% colspan=6>" .$tbal. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal1. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal2. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal3. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal4. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal5. "</th>";
   echo "<th width=30% colspan=6>" .$tfeebal6. "</th>";
 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
}
?>