<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php   
  
   if($_REQUEST['class_id']!=NULL){  
  
      if($_REQUEST['class_id']!=NULL){
        $m->where("class_id", $_REQUEST['class_id']);  
      }      
      if($_REQUEST['session']!=NULL){
        $m->where("session_id", $_REQUEST['session']);        
      }
      if($_REQUEST['section']!="All"){
        $m->where("section_id", $_REQUEST['section']);        
      }
     
       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);

     
       $param = array('student_id','ref_no','first_name','last_name','cell_no','branch_id','class_id','candidate_roll_no','section_id','session_id','status');
       $WorkAssignListings = $m->get("edu_student_details",null,$param);

       //print_r($WorkAssignListings);
 }
      
        $m->where("session_id", $_REQUEST['session']);
        $sessionID=$m->get("edu_session_config");


       // getting branch details

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


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>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Result Sheet</title>
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<script type="text/javascript">
// window.print();
</script>
<style type="text/css">

tr th {border:1px solid black;text-align:center;background-color:lightgray;font-size:13px;}
tr td {border-bottom:1px solid black;border-left:1px solid black;font-size:12px;}
  
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}



@media print {
    #Header, #Footer { display: none !important; }
}
@media screen
   {
      p.bodyText {font-family:verdana, arial, sans-serif;}
   }

   @media print
   {
      p.bodyText {font-family:georgia, times, serif;}
   }
   @media screen, print
   {
      p.bodyText {font-size:10pt}
   }
   @media print {
  a[href]:after {
    content: none !important;
  }
}
.center{text-align:center;}
</style>
</head>

<body style="font-size:12px;padding-right:1%;padding-left:1%;padding-top:3%;padding-bottom:1%;">

  <div style="width:20%;font-size:13px;text-align:center;float:left;height:80px;">

         <img src="<?php echo DOMAIN.AgentDirectory;?>img/<?php echo $branch[0]['logo']; ?>" style="height:85px;width:85px;margin-top: -13px;" />

  </div>

<div style="text-align:center;font-size:25px;font-weight:bold;margin:0 auto;"><?php echo $branch[0]['Branch_Name'];?> 
</div>

<br>


<div style="text-align:center;font-size:20px;font-weight:bold;"> RESULT SHEET

 </div>

<hr style="width:100%;">

<div style="width:50%;float:left;font-size:16px;">  <b> Class/Section:</b> 

<?php echo getClassName($m,$_REQUEST['class_id']);?>/<?php echo getSectionName($m,$_REQUEST['section']);?>  




</div>

<div style="width:25%; float:left;font-size:16px; "> <b> Examination:</b> <?php echo $terms[0]['term_title'];?> </div>

<div style="text-align:center;width:25%;float:left;font-size:16px;"> <b> Session:</b> <?php echo $sessionID[0]['session_year'];?> </div>






<br><br>
   


    <table style="width:100%;font-size:16px;" cellspacing="0">
          
          <thead>
            <tr>
                <th width="3%" class=" center">S.No</th>
                <th width="15%" class=" center">Student Name</th>                
                <th width="5%" class=" center" > Cell Number </th>  
             
                
         <?php 
              
              $new_counter=0;
              // printing all the relevant subjects of each class
                            
              
                $m->where("class_id", $_REQUEST['class_id']);
                $m->where("section_id", $_REQUEST['section']);
                $m->where("branch_id", $_SESSION['branch']);
                $m->where("session_id", $_REQUEST['session']);
                $Classsubjects = $m->get("eduportal_class_subjects"); 

              foreach($Classsubjects as $Classsubject) {  

                 $m->where("subject_id", $Classsubject['subject_id']);
                $subjects = $m->get("eduportal_subject_config");
               
                ?>

                 <th width="5%" class=" center"> <?php echo $subjects[0]['subject']; ?>

                 <table style="border-bottom:none;border-color: lightgray;">
                 <tr style="border-bottom:none; border-right: none;">
                    <?php
                    foreach ($_REQUEST['term_id'] as $terms) {
                        
                          $m->where("term_id", $terms);
                          $m->where("branch_id", $_SESSION['branch']);
                          $m->where("session_id", $_REQUEST['session']);
                          $TermTitles = $m->get("eduportal_exam_terms");
                          ?>

                         <th style="border-bottom:none;border-right: none;"> <?php echo $TermTitles[0]['term_title'];?> </th>
                   <?php } ?>
                   </tr>
                  </table>
             </th> 


             
             <?php  }  ?> 
       
                             
            </tr>
        </thead>
        <tbody>

 
     
       
     <?php 
     $count=1;
     $SR=1;
     $new_array = array();

     // getting all the marks of students and other data

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
     
   ?>

       <tr>   
       
                  <td class=" center" style="padding:3px;"> <?php echo $SR;  $SR++;?> </td>
                  <td style="padding-left:1%;"><?php echo $WorkAssignListVal['first_name']." / ".$WorkAssignListVal['last_name'];  ?></td>
                  <td><?php echo $WorkAssignListVal['cell_no'];?></td>
                  <?php 
                  foreach($Classsubjects as $Classsubject) {  

                 $m->where("subject_id", $Classsubject['subject_id']);
                $subjects = $m->get("eduportal_subject_config");
               
                ?>

                 <td width="5%" class=" center"> 

                 <table style="border-bottom:none;border-color: lightgray;">
                 <tr style="border-bottom:none; border-right: none;">
                    <?php
                    foreach ($_REQUEST['term_id'] as $terms) {
                        
                          $branch=$_SESSION['branch'];
                          $sesID=$_REQUEST['session'];
                          $clsID=$_REQUEST['class_id'];
                          $secID=$_REQUEST['section'];
                          $stdID=$WorkAssignListVal['student_id'];
                          $subID=$subjects[0]['subject_id'];
                          $sql = "SELECT * FROM  eduportal_exam_marksheet  WHERE branch_id='$branch' and term_id='$terms' and session_id='$sesID' and class_id='$clsID' and section_id='$secID' and student_id='$stdID' and subject_id='$subID' ";
                        
                          $marks = $m->query($sql);
                          
                          ?>
                         <td style="border-bottom:none;border-right: none;"> <?php echo $marks[0]['obtained_marks'];?> </td>
                   <?php } ?>
                   </tr>
                  </table>
             </td> 


             
             <?php  }  ?> 

                 

                                 
              </tr>

              


              <?php
      } ?>

</body>
</html>
