<?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="col-md-12">
                        <div class="card">
                            
                            <div class="card-body">
							<div class="card-header">
								<div class="page-title">
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                                <strong class="card-title"> <center>Teacher Performance Card</center></strong>
                            </div>
							
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
								
                                    <thead>
									<?php
 
							
include 'dbc.php';

$term=$_POST["term"];
$month_name=$_POST["month_name"];
$sess1=$_POST["sess1"];
$tech_name=$_POST["tech_name"];
$userid=$_SESSION["userid"];

echo "<tr>";
echo "<th colspan=2>$term </th>";
echo "<th colspan=2>$month_name </th>";
echo "<th colspan=2>$sess1 </th>";
echo "<th colspan=2>$tech_name </th>";
echo "</tr>";

 echo "<tr>";
   echo "<th colspan=8 align=center><center>Performance Details</center> </th>";
   
echo "</tr>";
echo "<tr>";
echo "<th colspan=2>Class Name </th>";
echo "<th colspan=2>Subjects Name </th>";
echo "<th colspan=2>Obtained Mark </th>";
echo "<th colspan=2>Total Mark </th>";
echo "<th colspan=2> Per%</th>";
echo "</tr>";
$sql1 = "SELECT * FROM addsubject where tech1='$tech_name' and  user_id='$userid'";
$result1=$conn->query($sql1);
while($row1 = $result1->fetch_assoc())
  {
  $class_name=$row1['class_name'] ;
$sub1=$row1['sub1'];
$tech1=$row1['tech1'];
$sqlchallan1 = "SELECT * FROM result where  term='$term' and sess1='$sess1' and class_name='$class_name' and month_name='$month_name' and tech1='$tech_name' and sub1='$sub1' and user_id='$userid'";
$resultchallan1=$conn->query($sqlchallan1);
while($rowchallan1 = $resultchallan1->fetch_assoc())
  {
 $tmark1 = $tmark1 + $rowchallan1["tmark1"];
 $omark1 = $omark1 + $rowchallan1["omark1"];
  }
  $totalper1 = $omark1 / $tmark1 * 100; 
   if ($totalper1 > 0)
  {
   echo "<tr>";
   echo "<th colspan=2>" . $class_name . "</th>";
   echo "<th colspan=2>" . $sub1 . "</th>";
echo "<td colspan=2>" .$omark1 . "</td>";
echo "<td colspan=2>" .$tmark1 . "</td>";
echo "<td colspan=2>" .$totalper1 . "%" ."</td>";
echo "</tr>";
 }
  }
  
  
  
  $sql2 = "SELECT * FROM addsubject where tech2='$tech_name' and  user_id='$userid'";
$result2=$conn->query($sql2);
while($row2 = $result2->fetch_assoc())
  {
  $class_name2=$row2['class_name'] ;
$sub2=$row2['sub2'];
$tech2=$row2['tech2'];
$sqlchallan2 = "SELECT * FROM result where  term='$term' and sess1='$sess1' and class_name='$class_name' and month_name='$month_name' and tech2='$tech_name' and sub2='$sub2' and user_id='$userid'";
$resultchallan2=$conn->query($sqlchallan2);
while($rowchallan2 = $resultchallan2->fetch_assoc())
  {
 $tmark2 = $tmark2 + $rowchallan2["tmark2"];
 $omark2 = $omark2 + $rowchallan2["omark2"];
  }
  $totalper2 = $omark2 / $tmark2 * 100; 
  if ($totalper2 > 0)
  {
   echo "<tr>";
   echo "<th colspan=2>" . $class_name2 . "</th>";
   echo "<th colspan=2>" . $sub2 . "</th>";
echo "<td colspan=2>" .$omark2 . "</td>";
echo "<td colspan=2>" .$tmark2 . "</td>";
echo "<td colspan=2>" .$totalper2 . "%" ."</td>";
echo "</tr>";
}
  }
  
  
   $sql3 = "SELECT * FROM addsubject where tech3='$tech_name' and  user_id='$userid'";
$result3=$conn->query($sql3);
while($row3 = $result3->fetch_assoc())
  {
  $class_name3=$row3['class_name'] ;
$sub3=$row3['sub3'];
$tech3=$row3['tech3'];
$sqlchallan3 = "SELECT * FROM result where  term='$term' and sess1='$sess1' and class_name='$class_name' and month_name='$month_name' and tech3='$tech_name' and sub2='$sub2' and user_id='$userid'";
$resultchallan3=$conn->query($sqlchallan3);
while($rowchallan3 = $resultchallan3->fetch_assoc())
  {
 $tmark3 = $tmark3 + $rowchallan3["tmark3"];
 $omark3 = $omark3 + $rowchallan3["omark3"];
  }
  $totalper3 = $omark3 / $tmark3 * 100; 
  if ($totalper3 > 0)
  {
   echo "<tr>";
   echo "<th colspan=2>" . $class_name3 . "</th>";
   echo "<th colspan=2>" . $sub3 . "</th>";
echo "<td colspan=2>" .$omark3 . "</td>";
echo "<td colspan=2>" .$tmark3 . "</td>";
echo "<td colspan=2>" .$totalper3 . "%" ."</td>";
echo "</tr>";
}
  }
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
            


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

    <!-- Right Panel -->

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

</body>

</html>
<?php
}
?>