<?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>Monthly Finance Summary Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$month=$_POST["month"];

$sql1 = "SELECT * FROM addclass where user_id = '$userid'";
$result1=$conn->query($sql1);
$row1 = $result1->fetch_assoc();
$feedisc1=$row1['feedisc1'] ;
$feedisc2=$row1['feedisc2'] ;
$feedisc3=$row1['feedisc3'] ;
$feedisc4=$row1['feedisc4'] ;
$feedisc5=$row1['feedisc5'] ;
$feedisc6=$row1['feedisc6'] ;
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";

echo "<th > Class Name </th>";
echo "<th > Total Stuents </th>";
echo "<th colspan=3> Fee Bal</th>";
echo "<th colspan=3> $feedisc1</th>";
echo "<th colspan=3> $feedisc2</th>";
echo "<th colspan=3> $feedisc3</th>";
echo "<th colspan=3> $feedisc4</th>";
echo "<th colspan=3> $feedisc5</th>";
echo "<th colspan=3> $feedisc6</th>";
echo "<th > Total Receivable </th>";
echo "<th > Total Receive </th>";
echo "<th > Remaing Bal </th>";


echo "</tr>";

echo "<tr>";

echo "<th colspan=2>  </th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th> Issue</th>";
echo "<th> Rec</th>";
echo "<th> Bal</th>";
echo "<th >  </th>";
echo "<th >  </th>";
echo "<th >  </th>";


echo "</tr>";
$sql2 = "SELECT * FROM addclass where  user_id='$userid'";
$result2=$conn->query($sql2);
  while($row2 = $result2->fetch_assoc())
   {
   $cname=$row2["cname"];
   $trecord=0;
$tbal=0;
$tfeerec=0;
$tfeebal=0;
$tfee1=0;
$tfee1rec=0;
$tfee1bal=0;

$tfee2=0;
$tfee2rec=0;
$tfee2bal=0;

$tfee3=0;
$tfee3rec=0;
$tfee3bal=0;

$tfee4=0;
$tfee4rec=0;
$tfee4bal=0;

$tfee5=0;
$tfee5rec=0;
$tfee5bal=0;

$tfee6=0;
$tfee6rec=0;
$tfee6bal=0;

$ttotalfee=0;
$ttotalfeerec=0;
$ttotalfeebal=0;
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM issueslip where  month_name='$month' and class_name='$cname' and user_id='$userid'";
$result=$conn->query($sql);
                                       while($row = $result->fetch_assoc())
 
  {
 
  

$trecord=$trecord + 1;
$tbal=$tbal + $row['mfee'];
$tfeerec=$tfeerec + $row['feerec'];
$tfeebal=$tfeebal + $row['feebal'];
$tfee1=$tfee1 + $row['fee1'];
$tfee1rec=$tfee1rec + $row['fee1rec'];
$tfee1bal=$tfee1bal + $row['fee1bal'];

$tfee2=$tfee2 + $row['fee2'];
$tfee2rec=$tfee2rec + $row['fee2rec'];
$tfee2bal=$tfee2bal + $row['fee2bal'];

$tfee3=$tfee3 + $row['fee3'];
$tfee3rec=$tfee3rec + $row['fee3rec'];
$tfee3bal=$tfee3bal + $row['fee3bal'];

$tfee4=$tfee4 + $row['fee4'];
$tfee4rec=$tfee4rec + $row['fee4rec'];
$tfee4bal=$tfee4bal + $row['fee4bal'];

$tfee5=$tfee5 + $row['fee5'];
$tfee5rec=$tfee5rec + $row['fee5rec'];
$tfee5bal=$tfee5bal + $row['fee1ba5'];

$tfee6=$tfee6 + $row['fee6'];
$tfee6rec=$tfee6rec + $row['fee6rec'];
$tfee6bal=$tfee6bal + $row['fee1ba6'];

$ttotalfee=$ttotalfee + $row['totalfee'];
$ttotalfeerec=$ttotalfeerec + $row['totalfeerec'];
$ttotalfeebal=$ttotalfeebal + $row['totalfeebal'];
  }
   echo "<tr>";
   echo "<td>" .$cname .  "</td>";
 echo "<td>" .$trecord . "</td>";
 echo "<td>" .$tbal .  "</td>";
  echo "<td>" .$tfeerec .  "</td>";
   echo "<td>" .$tfeebal .  "</td>";
   
  echo "<td>" .$tfee1 .  "</td>";
  echo "<td>" .$tfee1rec .  "</td>";
  echo "<td>" .$tfee1bal .  "</td>";
  
   echo "<td>" .$tfee2 .  "</td>";
  echo "<td>" .$tfee2rec .  "</td>";
  echo "<td>" .$tfee2bal .  "</td>";
  
   echo "<td>" .$tfee3 .  "</td>";
  echo "<td>" .$tfee3rec .  "</td>";
  echo "<td>" .$tfee3bal .  "</td>";
  
   echo "<td>" .$tfee4 .  "</td>";
  echo "<td>" .$tfee4rec .  "</td>";
  echo "<td>" .$tfee4bal .  "</td>";
  
   echo "<td>" .$tfee5 .  "</td>";
  echo "<td>" .$tfee5rec .  "</td>";
  echo "<td>" .$tfee5bal .  "</td>";
  
   echo "<td>" .$tfee6 .  "</td>";
  echo "<td>" .$tfee6rec .  "</td>";
  echo "<td>" .$tfee6bal .  "</td>";
  
  echo "<td>" .$ttotalfee .  "</td>";
  echo "<td>" .$ttotalfeerec .  "</td>";
  echo "<td>" .$ttotalfeebal .  "</td>";
    
 echo "</tr>";
 $netrecord = $netrecord + $trecord;
 $ttbal=$ttbal + $tbal;
 $ttfeerec=$ttfeerec + $tfeerec;
 $ttfeebal=$ttfeebal + $tfeebal;
 
 $ttfee1=$ttfee1 + $tfee1;
 $ttfee1rec=$ttfee1rec + $tfee1rec;
 $ttfee1bal=$ttfee1bal + $tfee1bal;
 
 $ttfee2=$ttfee2 + $tfee2;
 $ttfee2rec=$ttfee2rec + $tfee2rec;
 $ttfee2bal=$ttfee2bal + $tfee2bal;
 
 $ttfee3=$ttfee3 + $tfee3;
 $ttfee3rec=$ttfee3rec + $tfee3rec;
 $ttfee3bal=$ttfee3bal + $tfee3bal;
 
 $ttfee4=$ttfee4 + $tfee4;
 $ttfee4rec=$ttfee4rec + $tfee4rec;
 $ttfee4bal=$ttfee4bal + $tfee4bal;
 
 $ttfee5=$ttfee5 + $tfee5;
 $ttfee5rec=$ttfee5rec + $tfee5rec;
 $ttfee5bal=$ttfee5bal + $tfee5bal;
 
 $ttfee6=$ttfee6 + $tfee6;
 $ttfee6rec=$ttfee6rec + $tfee6rec;
 $ttfee6bal=$ttfee6bal + $tfee6bal;
 
 $netttotalfee=$netttotalfee + $ttotalfee;
 $netttotalfeerec=$netttotalfeerec + $ttotalfeerec;
 $netttotalfeebal=$netttotalfeebal + $ttotalfeebal;
  }
  
  echo "<tr>";

echo "<th > Net Total </th>";
echo "<th> $netrecord </th>";
echo "<th>  $ttbal</th>";
echo "<th> $ttfeerec</th>";
echo "<th> $ttfeebal</th>";
echo "<th> $ttfee1</th>";
echo "<th> $ttfee1rec</th>";
echo "<th> $ttfee1bal</th>";
echo "<th> $ttfee2</th>";
echo "<th> $ttfee2rec</th>";
echo "<th> $ttfee2bal</th>";
echo "<th> $ttfee3</th>";
echo "<th> $ttfee3rec</th>";
echo "<th> $ttfee3bal</th>";
echo "<th> $ttfee4</th>";
echo "<th> $ttfee4rec</th>";
echo "<th> $ttfee4bal</th>";
echo "<th> $ttfee5</th>";
echo "<th> $ttfee5rec</th>";
echo "<th> $ttfee5bal</th>";
echo "<th> $ttfee6</th>";
echo "<th> $ttfee6rec</th>";
echo "<th> $ttfee6bal</th>";
echo "<th >$netttotalfee  </th>";
echo "<th >$netttotalfeerec  </th>";
echo "<th >$netttotalfeebal  </th>";


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
}
?>