<?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">
						 <strong class="card-title"> <center> <img src="logo1.jpg" align="middle" /></center></strong>
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Student Ledger Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$adm_no=$_REQUEST["adm_no"];
$class_name=$_POST["class_name"];

$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 bgcolor=#0099FF colspan=6> Student Information </th>";
echo "<th colspan=3 bgcolor=#0099FF> Monthly Fee</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc1</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc2</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc3</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc4</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc5</th>";
echo "<th colspan=3 bgcolor=#0099FF> $feedisc6</th>";
echo "<th colspan=3 bgcolor=#0099FF> Items Sale</th>";


echo "</tr>";
 echo "<tr>";


echo "<th bgcolor=#0099FF> Date </th>";
echo "<th bgcolor=#0099FF> Month </th>";
echo "<th bgcolor=#0099FF> Roll# </th>";
echo "<th bgcolor=#0099FF> Studnet Name </th>";
echo "<th bgcolor=#0099FF> Father Name </th>";
echo "<th bgcolor=#0099FF> Class Name </th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Issue</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";
echo "<th  bgcolor=#0099FF>Invoice</th>";
echo "<th  bgcolor=#0099FF> Receipt</th>";
echo "<th  bgcolor=#0099FF> Bal</th>";



echo "</tr>";

?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM issueslip where  adm_no='$adm_no' and user_id='$userid' order by date desc";
$result=$conn->query($sql);
                                       while($row = $result->fetch_assoc())

 
  {
  	$netqty =0;
$qtysale=0;
$qtypur=0;
 $netqty1 =0;
$qtysale1=0;
$qtypur1=0;
 $netqty2 =0;
$qtysale2=0;
$qtypur2=0;
 $netqty3 =0;
$qtysale3=0;
$qtypur3=0;
 $netqty4 =0;
$qtysale4=0;
$qtypur4=0;
 $netqty5 =0;
$qtysale5=0;
$qtypur5=0;
 $netqty6 =0;
$qtysale6=0;
$qtypur6=0;
$netamount=0;
$netqty7 =0;
$cashrec =0;
   $month_name = $row['month_name'];	
  $qtysale= $qtysale + $row["feebal"];
  $qtysale1= $qtysale1 + $row["fee1bal"];
  $qtysale2= $qtysale2 + $row["fee2bal"];
  $qtysale3= $qtysale3 + $row["fee3bal"];
  $qtysale4= $qtysale4 + $row["fee4bal"];
  $qtysale5= $qtysale5 + $row["fee5bal"]; 
  $qtysale6= $qtysale6 + $row["fee6bal"];  
 
   
  $sql2 = "SELECT * FROM rec_fee where adm_no='$adm_no' and month_period='$month_name' and user_id = '$userid'";
$result2=$conn->query($sql2);
 while($ppp3 = $result2->fetch_assoc())
{
  $qtypur= $qtypur + $ppp3["feerec"];
  $qtypur1= $qtypur1 + $ppp3["fee1rec"];
  $qtypur2= $qtypur2 + $ppp3["fee2rec"];
  $qtypur3= $qtypur3 + $ppp3["fee3rec"];
  $qtypur4= $qtypur4 + $ppp3["fee4rec"];
  $qtypur5= $qtypur5 + $ppp3["fee5rec"];
  $qtypur6= $qtypur6 + $ppp3["fee6rec"];
  
 }
  $sql21 = "SELECT * FROM invoice where pno='$adm_no' and month_name='$month_name'  and user_id = '$userid'";
$result21=$conn->query($sql21);
 while($ppp31 = $result21->fetch_assoc())
{
  $netamount= $netamount + $ppp31["netamount"];
  $cashrec= $cashrec + $ppp31["cashrec"];
  
 } 
$netqty = ($qtysale ) - ($qtypur );
$netqty1 = ($qtysale1 ) - ($qtypur1 );
$netqty2 = ($qtysale2 ) - ($qtypur2 );
$netqty3= ($qtysale3 ) - ($qtypur3 );
$netqty4 = ($qtysale4 ) - ($qtypur4 );
$netqty5 = ($qtysale5 ) - ($qtypur5 );
$netqty6 = ($qtysale6 ) - ($qtypur6 );
$netqty7 = ($netamount ) - ($cashrec );
 
   echo "<tr>";
echo "<td>" .$row['date'] . "</td>";
echo "<td>" .$row['month_name'] . "</td>";
echo "<td>" .$row['portal_id'] . "</td>";

  echo "<td>" .$row['std_name'] .  "</td>";
 echo "<td>" .$row['fname'] . "</td>";
 echo "<td>" .$row['class_name'] . ":" .$row['cls_sec'] .  "</td>";

  echo "<td>" .number_format($qtysale) .  "</td>";
   echo "<td>" .number_format($qtypur) .  "</td>";
   echo "<td>" .number_format($netqty) .  "</td>";
    echo "<td>" .number_format($qtysale1) .  "</td>";
   echo "<td>" .number_format($qtypur1) .  "</td>";
   echo "<td>" .number_format($netqty1) .  "</td>";
    echo "<td>" .number_format($qtysale2) .  "</td>";
   echo "<td>" .number_format($qtypur2) .  "</td>";
   echo "<td>" .number_format($netqty2) .  "</td>";
      echo "<td>" .number_format($qtysale3) .  "</td>";
   echo "<td>" .number_format($qtypur3) .  "</td>";
   echo "<td>" .number_format($netqty3) .  "</td>";
   echo "<td>" .number_format($qtysale4) .  "</td>";
   echo "<td>" .number_format($qtypur4) .  "</td>";
   echo "<td>" .number_format($netqty4) .  "</td>";
   echo "<td>" .number_format($qtysale5) .  "</td>";
   echo "<td>" .number_format($qtypur5) .  "</td>";
   echo "<td>" .number_format($netqty5) .  "</td>";
   echo "<td>" .number_format($qtysale6) .  "</td>";
   echo "<td>" .number_format($qtypur6) .  "</td>";
   echo "<td>" .number_format($netqty6) .  "</td>";
    echo "<td>" .number_format($netamount) .  "</td>";
	echo "<td>" .number_format($cashrec) .  "</td>";
  echo "<td>" .number_format($netqty7) .  "</td>";
   
  echo "</tr>";
 $tfeebal=$tfeebal + $qtysale;
   $tfeerec=$tfeerec + $qtypur;
    $tnetqty=$tnetqty + $netqty;
	
	 $tfeebal1=$tfeebal1 + $qtysale1;
   $tfeerec1=$tfeerec1 + $qtypur1;
    $tnetqty1=$tnetqty1 + $netqty1;
	
	 $tfeebal2=$tfeebal2 + $qtysale2;
   $tfeerec2=$tfeerec2 + $qtypur2;
    $tnetqty2=$tnetqty2 + $netqty2;
	
	 $tfeebal3=$tfeebal3 + $qtysale3;
   $tfeerec3=$tfeerec3 + $qtypur3;
    $tnetqty3=$tnetqty3 + $netqty3;
	
	 $tfeebal4=$tfeebal4 + $qtysale4;
   $tfeerec4=$tfeerec4 + $qtypur4;
    $tnetqty4=$tnetqty4 + $netqty4;
	
	 $tfeebal5=$tfeebal5 + $qtysale5;
   $tfeerec5=$tfeerec5 + $qtypur5;
    $tnetqty5=$tnetqty5 + $netqty5;
	
	 $tfeebal6=$tfeebal6 + $qtysale6;
   $tfeerec6=$tfeerec6 + $qtypur6;
    $tnetqty6=$tnetqty6 + $netqty6;
	
	
}
 echo "<tr>";
   echo "<td  colspan=6>Total</td>" ;
    echo "<td  align=center><h5>"  .number_format($tfeebal) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal1) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec1) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty1) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal2) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec2) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty2) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal3) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec3) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty3) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal4) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec4) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty4) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal5) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec5) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty5) . "</td>" ;
	
	 echo "<td  align=center><h5>"  .number_format($tfeebal6) . "</td>" ;
   echo "<td  align=center><h5>"  .number_format($tfeerec6) . "</td>" ;
    echo "<td align=center><h5>"  .number_format($tnetqty6) . "</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
}
?>