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


include 'dbc.php';
$rollno=$_POST["rollno"];
$fdate=$_POST["fdate"];
$tdate=$_POST["tdate"];
$sess1=$_POST["sess1"];
$userid=$_SESSION["userid"];
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		
		
		 $my=$month_name . " " . $year;
		 $sql2 = "SELECT * FROM result where  std_rollno='$rollno' and user_id='$userid'";
$result2=$conn->query($sql2);
$row2 = $result2->fetch_assoc();
$sub1=$row2['sub1'] ;
$sub2=$row2['sub2'] ;
$sub3=$row2['sub3'] ;
$sub4=$row2['sub4'] ;
$sub5=$row2['sub5'] ;
$sub6=$row2['sub6'] ;
$sub7=$row2['sub7'] ;
$sub8=$row2['sub8'] ;
$sub9=$row2['sub9'] ;
$sub10=$row2['sub10'] ;
		
?>
<!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 id="header" class="header">

            

        </header><!-- /header -->
        <!-- Header-->

        

        <div class="content mt-3">

           <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                              <strong class="card-title"> <center> <img src="logo1.jpg" align="middle" /></center></strong>
                                <strong class="card-title"> <center> <h1><? echo "" . $_SESSION["userid"]; ?></h1></center></strong>
								
								  
								   <strong class="card-title"><center><? echo $sess1; ?></center></strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';





$sql = "SELECT * FROM result where sess1='$sess1' and std_rollno='$rollno' and user_id='$userid' order by std_rollno";
$result=$conn->query($sql);


?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
							
                                    <thead>
									<?php
								
                                       echo "<tr>";

echo "<th colspan=16 bgcolor=#0099FF> Student Acdamics Records </th>";
echo "</tr>";
 echo "<tr>";
echo "<th bgcolor=#0099FF><center> $rollno </center> </th>";
echo "<th colspan=8 bgcolor=#0099FF><center> $std_name</center> </th>";
echo "<th colspan=8 bgcolor=#0099FF><center> $father_name</center> </th>";
echo "</tr>";
echo "<tr>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Term Name </font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub1</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub2</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub3</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub4</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub5</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub6</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub7</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub8</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub9</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> $sub10</th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Total Mark</font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Obt Mark</font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Per%</font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Status</font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Grade</font></th>";
echo "<th bgcolor=#0099FF><font face=arial size=3 color=white><center> Remarks</font></th>";
echo "</tr>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row = $result->fetch_assoc())
 
  {
  $id = $row['id'];	
  $productname[]  = $row['term']  ;
            $sales[] = $row['obtmark'];
   echo "<tr>";
   echo "<td>" .$row['term'] . "</td>";
echo "<td align=center>" .$row['omark1'] . "/" . $row['tmark1'] . "</td>";
echo "<td align=center>" .$row['omark2'] . "/" . $row['tmark2'] . "</td>";
echo "<td align=center>" .$row['omark3'] . "/" . $row['tmark3'] ."</td>";
echo "<td align=center>" .$row['omark4'] . "/" . $row['tmark4'] ."</td>";
echo "<td align=center>" .$row['omark5'] . "/" . $row['tmark5'] ."</td>";
echo "<td align=center>" .$row['omark6'] . "/" . $row['tmark6'] . "</td>";
echo "<td align=center>" .$row['omark7'] . "/" . $row['tmark7'] . "</td>";
echo "<td align=center>" .$row['omark8'] . "/" . $row['tmark8'] . "</td>";
echo "<td align=center>" .$row['omark9'] . "/" . $row['tmark9'] . "</td>";
echo "<td align=center>" .$row['omark10'] . "/" . $row['tmark10'] . "</td>";

echo "<td align=center>" .$row['totalmark'] . "</td>";
echo "<td align=center>" .$row['obtmark'] . "</td>";
echo "<td align=center>" .$row['per'] . "</td>";
echo "<td align=center>" .$row['status'] . "</td>";
echo "<td align=center>" .$row['grade'] . "</td>";
echo "<td align=center>" .$row['remarks'] . "</td>";
		 
		  
	
  echo "</tr>";

 
 

  }
 

         $sql11 ="SELECT * FROM result where sess1='$sess1' and std_rollno='$rollno'";
        $result11=$conn->query($sql11);
         $chart_data="";
     while($row11 = $result11->fetch_assoc())
 { 
 
          
			$std_name = $row11['std_name'];
       
 }
 

  ?>
		
		


   <div style="width:60%;hieght:20%;text-align:center">
            <h2 class="page-header" >Analytics Reports </h2>
            <div><?php
    echo $std_name;
   
?> </div>
            <canvas  id="chartjs_bar"></canvas> 
        </div>
		
		<script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<script type="text/javascript">
      var ctx = document.getElementById("chartjs_bar").getContext('2d');
                var myChart = new Chart(ctx, {
                    type: 'bar',
                    data: {
                        labels:<?php echo json_encode($productname); ?>,
                        datasets: [{
                            backgroundColor: [
                               "#5969ff",
                                "#ff407b",
                                "#25d5f2",
                                "#ffc750",
                                "#2ec551",
                                "#7040fa",
                                "#ff004e"
                            ],
                            data:<?php echo json_encode($sales); ?>,
                        }]
                    },
                    options: {
                           legend: {
                        display: true,
                        position: 'bottom',
 
                        labels: {
                            fontColor: '#71748d',
                            fontFamily: 'Circular Std Book',
                            fontSize: 14,
                        }
                    },
 
 
                }
                });
    </script>


                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


          
<div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <strong class="card-title"> Student  Attendance </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';
$jan="January" ." ". $sess1;
$feb="Feburary" ." ". $sess1;
$mar="March" ." ". $sess1;
$apr="April" ." ". $sess1;
$ma="May" ." ". $sess1;
$jun="June" ." ". $sess1;
$jul="July" ." ". $sess1;
$aug="August" ." ". $sess1;
$sep="September" ." ". $sess1;
$oct="October" ." ". $sess1;
$nov="November" ." ". $sess1;
$dec="December" ." ". $sess1;
$userid=$_SESSION["userid"];
$sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$jan' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pjan=$pjan +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$jan' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $ljan=$ljan +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$jan' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $ajan=$ajan +1;
  } 
  $tjan=$ajan + $pjan + $ljan;
  
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$feb' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pfeb=$pfeb +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$feb' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lfeb=$lfeb +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$feb' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $afeb=$afeb +1;
  } 
  $tfeb=$afeb + $pfeb + $lfeb;
  
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$mar' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pmar=$pmar +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$mar' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lmar=$lmar +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$mar' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $ajan=$ajan +1;
  } 
  $tmar=$amar + $pmar + $lmar;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$apr' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $papr=$papr +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$apr' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lapr=$lapr +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$apr' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $aapr=$aapr +1;
  } 
  $tapr=$aapr + $papr + $lapr;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$ma' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pma=$pma +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$ma' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lma=$lma +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$ma' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $ama=$ama +1;
  } 
  $tma=$ama + $pma + $lma;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$jun' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pjun=$pjun +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$jun' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $ljun=$ljun +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$jun' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $ajun=$ajun +1;
  } 
  $tjun=$ajun + $pjun + $ljun;
  
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$jul' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pjul=$pjul +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$jul' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $ljul=$ljul +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$jul' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $ajul=$ajul +1;
  } 
  $tjul=$ajul + $pjul + $ljul;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$aug' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $paug=$paug +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$aug' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $laug=$laug +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$aug' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $aaug=$aaug +1;
  } 
  $taug=$aaug + $paug + $laug;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$sep' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $psep=$psep +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$sep' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lsep=$lsep +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$sep' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $asep=$asep +1;
  } 
  $tsep=$asep + $psep + $lsep;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$oct' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $poct=$poct +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$oct' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $loct=$loct +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$oct' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $aoct=$aoct +1;
  } 
  $toct=$aoct + $poct + $loct;
  
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$nov' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pnov=$pnov +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$nov' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $lnov=$lnov +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$nov' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $anov=$anov +1;
  } 
  $tnov=$anov + $pnov + $lnov;
  
  $sql3pjan = "select * from attendence where rollno='$rollno' and status='P' and month_name='$dec' and user_id='$userid'";
  $result3pjan=$conn->query($sql3pjan);
while($row3pjan = $result3pjan->fetch_assoc())
  {
 $pdec=$pdec +1;
  } 
  $sql3ljan = "select * from attendence where rollno='$rollno' and status='L' and month_name='$dec' and user_id='$userid'";
   $result3ljan=$conn->query($sql3ljan);
while($row3ljan = $result3ljan->fetch_assoc())
  {
 $ldec=$ldec +1;
  } 
  $sql3ajan = "select * from attendence where rollno='$rollno' and status='A' and month_name='$dec' and user_id='$userid'";
  $result3ajan=$conn->query($sql3ajan);
while($row3ajan = $result3ajan->fetch_assoc())
  {
 $adec=$adec +1;
  } 
  $tdec=$adec + $pdec + $ldec;
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
								
                                    </thead>
									
                                    <tbody>
									<?php
                               
    echo "<tr>";
 echo "<th  colspan=4 bgcolor=#0099FF align=center><center>Month Name</th>";
  echo "<th  colspan=4 bgcolor=#0099FF align=center><center>Toatl Days  </th>";
   echo "<th  colspan=4 bgcolor=#0099FF align=center><center>Present Days</th>";
    echo "<th  colspan=4 bgcolor=#0099FF align=center><center>Absent Days</th>";
	echo "<th  colspan=4 bgcolor=#0099FF align=center><center>Leave Days</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$jan</th>";
  echo "<th  colspan=4><center> $tjan </th>";
   echo "<th  colspan=4><center>$pjan</th>";
    echo "<th  colspan=4><center>$ajan</th>";
	echo "<th  colspan=4><center>$ljan</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$feb</th>";
 echo "<th  colspan=4><center> $tfeb </th>";
   echo "<th  colspan=4><center>$pfeb</th>";
    echo "<th  colspan=4><center>$afeb</th>";
	echo "<th  colspan=4><center>$lfeb</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$mar</th>";
 echo "<th  colspan=4><center> $tmar </th>";
   echo "<th  colspan=4><center>$pmar</th>";
    echo "<th  colspan=4><center>$amar</th>";
	echo "<th  colspan=4><center>$lmar</th>";
 echo "</tr>";
  echo "<tr>";
 echo "<th  colspan=4><center>$apr</th>";
 echo "<th  colspan=4><center> $tapr </th>";
   echo "<th  colspan=4><center>$papr</th>";
    echo "<th  colspan=4><center>$aapr</th>";
	echo "<th  colspan=4><center>$lapr</th>";
 echo "</tr>";
 
 echo "<tr>";
 echo "<th  colspan=4><center>$ma</th>";
 echo "<th  colspan=4><center> $tma </th>";
   echo "<th  colspan=4><center>$pma</th>";
    echo "<th  colspan=4><center>$ama</th>";
	echo "<th  colspan=4><center>$lma</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$jun</th>";
 echo "<th  colspan=4><center> $tjun </th>";
   echo "<th  colspan=4><center>$pjun</th>";
    echo "<th  colspan=4><center>$ajun</th>";
	echo "<th  colspan=4><center>$ljun</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$jul</th>";
 echo "<th  colspan=4><center> $tjul </th>";
   echo "<th  colspan=4><center>$pjul</th>";
    echo "<th  colspan=4><center>$ajul</th>";
	echo "<th  colspan=4><center>$ljul</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$aug</th>";
  echo "<th  colspan=4><center> $taug </th>";
   echo "<th  colspan=4><center>$paug</th>";
    echo "<th  colspan=4><center>$aaug</th>";
	echo "<th  colspan=4><center>$laug</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$sep</th>";
  echo "<th  colspan=4><center> $tsep </th>";
   echo "<th  colspan=4><center>$psep</th>";
    echo "<th  colspan=4><center>$asep</th>";
	echo "<th  colspan=4><center>$lsep</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$oct</th>";
 echo "<th  colspan=4><center> $toct </th>";
   echo "<th  colspan=4><center>$poct</th>";
    echo "<th  colspan=4><center>$aoct</th>";
	echo "<th  colspan=4><center>$loct</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$nov</th>";
 echo "<th  colspan=4><center> $tnov </th>";
   echo "<th  colspan=4><center>$pnov</th>";
    echo "<th  colspan=4><center>$anov</th>";
	echo "<th  colspan=4><center>$lnov</th>";
 echo "</tr>";
 echo "<tr>";
 echo "<th  colspan=4><center>$dec</th>";
  echo "<th  colspan=4><center> $tdec </th>";
   echo "<th  colspan=4><center>$pdec</th>";
    echo "<th  colspan=4><center>$adec</th>";
	echo "<th  colspan=4><center>$ldec</th>";
 echo "</tr>";
   echo "</table>";


	
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
            
			
			<div class="col-md-14">
                        <div class="card">
						
                            <div class="card-header">
							
                                <strong class="card-title">Student Ledger </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


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

$sql1l = "SELECT * FROM addclass where user_id = '$userid'";
$result1l=$conn->query($sql1l);
$row1l = $result1l->fetch_assoc();
$feedisc1=$row1l['feedisc1'] ;
$feedisc2=$row1l['feedisc2'] ;
$feedisc3=$row1l['feedisc3'] ;
$feedisc4=$row1l['feedisc4'] ;
$feedisc5=$row1l['feedisc5'] ;
$feedisc6=$row1l['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 "</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 "</tr>";

?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sqll = "SELECT * FROM issueslip where  adm_no='$rollno' and user_id='$userid' order by id";
$resultl=$conn->query($sqll);
                                       while($rowl = $resultl->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;

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

  	echo "<td>" .$rowl['std_name'] .  "</td>";
 	echo "<td>" .$rowl['fname'] . "</td>";
 	echo "<td>" .$rowl['class_name'] . ":" .$rowl['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 "</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> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

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

</body>

</html>
<?php
}

?>