<?php include 'controller/admissionCode.php' ?>
<?php  

function headRemark($total_score){
  $remark = "";
  if ($total_score>=80) {
    $remark = "An excellent performance keep it up";
  }elseif($total_score>=70){
    $remark = "Good , but could still be better";
  }elseif($total_score>=60){
    $remark = "An average performance, should work harder next semester";
  }elseif ($total_score>=50) {
    $remark = "There is more room for improvement";
  }elseif ($total_score>=40) {
    $remark = "Below average performance. Parent should contact the head master for a discussion";
  }elseif ($total_score<40) {
    $remark = "Very poor performance. Parent is invited to see the headmaster";
  }
  return $remark;
}


function grade($total_score){
  $grade = "";
  if (!$total_score) {
    $grade = "IC";
    
  }
  elseif ($total_score>=80) {
    $grade = "A1";
  }elseif($total_score>=75){
    $grade = "B2";
  }elseif($total_score>=70){
    $grade = "B3";
  }elseif($total_score>=65){
    $grade = "C4";
  }elseif($total_score>=60){
    $grade = "C5";
  }elseif($total_score>=55){
    $grade = "C6";
  }elseif($total_score>=50){
    $grade = "D7";
  }elseif($total_score>=40){
    $grade = "E8";
  }elseif($total_score>=1){
    $grade = "F9";
  }elseif($total_score==0){
    $grade = "IC";
  }
  return $grade;
  }

  function remark($total_score){
  $remark = "";
  if (!$total_score) {
    $remark = "Incomplete";
    
  }
  elseif ($total_score>=80) {
    $remark = "Exellent";
  }elseif($total_score>=75){
    $remark = "Very Good";
  }elseif($total_score>=70){
    $remark = "Good";
  }elseif($total_score>=65){
    $remark = "High Credit";
  }elseif($total_score>=60){
    $remark = "Credit";
  }elseif($total_score>=55){
    $remark = "Credit";
  }elseif($total_score>=50){
    $remark = "Average";
  }elseif($total_score>=40){
    $remark = "Pass";
  }elseif($total_score<=39){
    $remark = "Fail";
  }
  return $remark;
  }

$postion_in_class = $admission->postion_in_class($kid,$semester_id,$a_year_id);
if ($postion_in_class) {
  
	// $m=0;
 //  $count = count($all_class_students);
foreach ($postion_in_class as $student) {
	// $m++;
 // //  //to print in bits start 0-11, 10 -21, 30 -41.....higlight onif to break and press ctr+/
	// if($m<=60){
	// 	continue;
	// }
	// if($m>=81){
	// 	break;
	//  }
  $class_name  = $admission->get_all_class_students($student['class']);
  // $subject = $admission->get_subject($student['subject_id']);
  // $subject_name = $subject[0]['subject_name'];
 $student_pic = "Male.png";
 


  $class_name = $class_name[0]['class_name'];
  ?>
  <style type="text/css">
    <?php include '../inc/media_bootstrap.php' ?>
    <?php include '../inc/print_css.php' ?>
    @media print{
    <?php include '../inc/media_bootstrap.php' ?>
    <?php include '../inc/print_css.php' ?>
    body{
      margin: 0px !important;

    }
    footer{
      page-break-after: always;

    }

    .line_sig{
      height: 1px;
      background:#000;
    }
    .mailto{
       /*height: 90% !important;*/
      /*margin-bottom: 5px !important;*/
      /*margin-top: 5px !important;*/
      outline-style: solid !important;
        outline-color: blue !important;
        border: 3px solid lightblue !important;
        /*padding-top: 10px !important;*/
        padding-bottom: 0px !important;
        height: 15% !important;
    }


     .main_ibox{
  position: relative;
}

.main_ibox:after{
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top:0px;
  left:0px;
  background-image:url(../img/OT-Crest.fw_.png)!important;
  background-size: cover;
  background-position: center !important;
  background-repeat: no-repeat !important;
  opacity: 0.1;
}


    .basic_info td{
      font-size:14px !important;
    }
    .address{
      margin:10px !important;
      margin-top: 1px !important;

    }
    .main_ibox{
      /*height: 90% !important;*/
      /*margin-bottom: 5px !important;*/
      /*margin-top: 5px !important;*/
      outline-style: solid !important;
        outline-color: blue !important;
        border: 3px solid lightblue !important;
        /*padding-top: 10px !important;*/
        padding-bottom: 0px !important;
        /*background-size: 50px !important;*/
        /*background: url('../img/photo.png') !important;*/
        /*background-attachment: fixed !important;*/
        background-size: 500px 500px !important;
        background-position: bottom  !important;
        background-repeat: no-repeat !important;

    }
    
    /*.table,.m-t,.m-t th,.m-t td,.table-bordered th,.table-bordered td{
     background-color: red !important: 
    }*/
    .table-bordered > thead > tr > th,
.table-bordered > tbody > tr > td {
  background-color: transparent !important;
  border-bottom-width: 1px;
  border: 1px solid #000 !important;

}

.main> thead > tr >th{
  font-size: 12px !important;
  text-align: center !important;
  padding: 1px !important;
}

.grade> thead > tr >th{
  padding: 2px !important;
}
.main> tbody > tr >td{
  font-size: 16px !important;
  text-align: center !important;
}
/*.table-bodered{
  border-color: 2px solid #000 !important;
}*/
p{
  line-height: 0.5;
}
h3{
  line-height: 0.5;
  
}
    th{
      font-size: 14px !important;
      background-color:transparent !important;
      padding-top: 1px !important;
      padding-bottom: 0px !important;
      
    }
    td{
      background-color:transparent !important;
      font-size: 18px !important;
      padding-top: 1px !important;
      padding-bottom: 1px !important;
      border-color: 1px solid #000 !important;
    }

 .main_ibox{
  position: relative;
}

.main_ibox:after{
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top:0px;
  left:0px;
  background-image:url(../img/OT-Crest.fw_.png)!important;
  background-size: cover;
  background-position: center !important;
  background-repeat: no-repeat !important;
  opacity: 0.1;
}
}

  </style>
<body class="white-bg">
                <div class="wrapper wrapper-content p-xl">
                    <div class="ibox-content main_ibox">
                      <div class="green">
                    <!--  <center><h3></h3></center> -->
                          <table>
                              <tr>
                              <td style="width: 10%;text-align: left !important;"><img src="../img/OT-Crest.fw_.png" style="width: 100% !important"></td>
                          <td style="text-align: center !important;width: 70%  !important"><h3 style="font-weight:bolder;">OSEI TUTU SENIOR HIGH SCHOOL</h3>
                           <p class="head"> </p>

                            <p class="head"> </p>
                            <h4>AKROPONG ASHANTI</h4>
                             <p class="head"> </p>
                            <h4>TEL: +233 547472237 Email: otshs1940@gmail.com</h4>
                             <p class="head"> </p>
                             <?php 
                              $sem_name = "";
                             if ($semester_id==5) {
                               $sem_name = "2";
                             }elseif ($semester_id0==4) {
                               $sem_name = "1";
                             }

                              ?>
                            <h5>SESSION: <?php $a_year = $admission->get_a_year_name($a_year_id); echo $a_year[0]['a_year'] ?> SEM  <?php echo $sem_name ?></h5>
                          </td>
                         
                          <td style="width: 20%;text-align: right !important;"> <?php
                             if($student_pic){


                          ?>

                            <?php 
                            if ($student['student_picture']) {
                               $ext_1 = explode('.', basename($student['student_picture']));
                               $file_extension_1 = end($ext_1);
                            
                             ?>
                           <?php 
                    if($ext_1[count($ext_1) - 1]=="JPG"){
                     ?>
                    <img style="width:100px;height:100px;" src="../student_pics/<?php echo $student['student_picture']; ?>">
                    <?php }else{?>
                    <img style="width:100px;height:100px;" src="../student_pics/<?php echo $student['student_picture']; ?>.JPG">
                    <?php } ?>
                 
                    
                      
                      <?php
                    }else{
                      ?>
                       <img style="width:100%;" src="../img/avatars/male.png">
                      <?php
                    }
                    
                    ?></td>
                           <?php
                             }
                           ?>
                            </tr>
                          </table>
                          <table style="width: 100% !important;" class="basic_info">
                           <tr>
                             <td>Name: <?php echo $student['student_name'] ?></td>
                             <td style="width: 30%"></td>
                             <td>Position in Class: <?php $position_in_class = $admission->postion_in_class($student['class'],$semester_id,$a_year_id);
                                          if ($position_in_class) {
                                            $i=0;
                                            foreach ($position_in_class as $position_in_class) {
                                              $i++;
                                            if ($position_in_class['student_id']==$student['student_id']) {
                                              $roll = $admission->class_noOf_stds($student['class']);
                                             echo $i.'/'.$roll;
                                            }
                                          }
                                          }
                                           ?>
                                        </span></td>
                           </tr>
                            <tr>
                             <td>Class: Form <?php echo $class_name; ?></td>
                             <td style="width: 10%"></td>
                          <td>Overall Position: <?php
                                          $over_all_position = $admission->overall_position($student['form_id'],$semester_id,$a_year_id);
                                          if ($over_all_position) {
                                            $i=0;
                                            foreach ($over_all_position as $over_all_position) {
                                              $i++;
                                            if ($over_all_position['student_id']==$student['student_id']) {
                                              $no_on_roll = $admission->form_noOf_stds($student['form_id']);
                                             echo $i.'/'.$no_on_roll;
                                            }
                                          }
                                          }
                                           ?>
                                        </span></td>
                           </tr>
                            <tr>
                             <?php 
						
						 ?>
                             <td>Closing Date: <?php echo $vacation[0]['end'] ?></td>
                             <td style="width: 30%"></td>
                             <td>Overall Grade: <?php
                                          $over_all_position = $admission->overall_position($student['form_id'],$semester_id,$a_year_id);
                                          if ($over_all_position) {
                                            $i=0;
                                            foreach ($over_all_position as $over_all_position) {
                                              $i++;
                                            if ($over_all_position['student_id']==$student['student_id']) {
                                             echo grade(round(($over_all_position['total_score']/900)*100));
                                            }
                                          }
                                          }
                                           ?></td>
                           </tr>
                           <tr>
                              <td>Next Term Begins: <?php echo $vacation[0]['next'] ?></td>
                              <?php 
                              $get_student_house = $admission->get_student_house($student['student_id']);
                              $get_house = $admission->get_house($get_student_house[0]['house_id']);
                               ?>
                              <td></td>
                              <td>
                              House: <?php echo $get_house[0]['house_name'] ?>
                              </td>
                           </tr>

                          </table>
                            <div class="table-responsive m-t">
                                <table class="table-bordered invoice-table main" style="background-color:transparent !important;width: 100%;">
                                    <thead>
                                    <tr>
                                      <th style="width: 100px !important;">SUBJECT</th>
                                      <th>CLASS SCORE</th>
                                      <th>EXAM SCORE</th>
                                      <th>TOAL SCORE</th> 
                                      <th>GRADE</th>
                                      <th>CLASS AVERAGE</th>
                                      <th>SUBJECT CLASS POSITION</th>
                                      <th>OVERALL SUBJECT POSITION</th>

                                      
                                     <!-- <th>ANNUAL AVERAGE</th> -->
                                      <th style="width: 20px !important">REMARKS</th>
                                      <th>TEACHER</th>

                                    </tr>
                                    </thead>
                                    <tbody>
                                      <?php 
                                      // if ($student['student_id']) {
                                      //   $student_student_core = $admission->student_student_core($student['student_id'],$student['class_id'],$student['semester_id'],$student['a_year_id']);
                                      //   $student_student_elective = $admission->student_student_elective($student['student_id'],$student['class_id'],$student['track_id'],$student['semester_id'],$student['a_year_id']);
                                      //   if ($student_student_core) {
                                          ?>
          <!--  <tr>
                                      <td colspan="<?php //echo $colspan ?>" style="background-color: #ccc !important;"><b style="float: left;">CORE</b></td>
                                      
                                    </tr> -->
                                            <?php
                                  //           foreach($student_student_core as $rpt){
                                  // $subject_position = $admission->subject_position($rpt['subject_id'],$student['class_id'],$student['track_id'],$student['semester_id'],$student['a_year_id']);
                                  // $over_all_subject_position = $admission->over_all_subject_position($rpt['subject_id'],$student['form_id'],$student['track_id'],$student['semester_id'],$student['a_year_id']);

                                  // $last_sem_subject_position = $admission->subject_position($rpt['subject_id'],$student['class_id'],$student['track_id'],$sem_id,$student['a_year_id']);
                                              
                                             ?>
                                            <!--   <tr>
                                      <td><?php //echo $rpt['subject_name']; ?></td>
                                      <td><?php //echo $rpt['class_score']; ?></td>
                                      <td><?php //echo $rpt['exam_score']; ?></td>
                                      <td><?php //echo $rpt['total_score']; ?></td>
                                      <td><?php //echo grade($rpt['total_score']); ?></td>
                                      <td>  -->
                                        <?php 
                                        // if ($subject_position) {
                                        //   $i=0;
                                        //   $subject_total = "";
                                        //   foreach($subject_position as $position){
                                        //     $i++;
                                        //     $subject_total += $position['total_score'];
                                           
                                        //   }
                                          
                                        //   echo round($subject_total/$i);
                                        // }
                                         ?>

                                      <!-- </td>
                                      <td> --> <?php 
                                        // if ($subject_position) {
                                        //   $i=0;
                                        //   foreach($subject_position as $position){
                                        //     $i++;
                                        //    if ($rpt['student_id']==$position['student_id']) {
                                        //       echo $i; echo position($i);
                                        //    }
                                        //   }
                                        // }
                                         ?><!-- </td>
                                      <td> -->
                                         <?php 
                                        // if ($over_all_subject_position) {
                                        //   $i=0;
                                        //   foreach($over_all_subject_position as $position){
                                        //     $i++;
                                        //    if ($rpt['student_id']==$position['student_id']) {
                                        //       echo $i; echo position($i);
                                        //    }
                                        //   }
                                        // }
                                         ?>
                                    <!--   </td> -->
                                      <?php 
                                      // if ($globals) {
                                      //   foreach($globals as $global){
                                      //     $is_term = $setup->get_semester($global['semester_id']);
                                      //     if ($is_term[0]['sem_name']=="Second Semester") {
                                         ?>
                                         <!-- <td> -->
                                            <?php 

                                        //     if ($last_sem_subject_position) {
                                        //     $j=0;
                                        //    foreach($last_sem_subject_position as $position){
                                        //     $j++;
                                        //    if ($rpt['student_id']==$position['student_id']) {
                                        //      echo $position['total_score'];
                                        //    }
                                           
                                        //   }
                                        // }
                                            ?>
                                         <!-- </td> -->
                                         <?php
                                      //     }
                                      //   }
                                      // }

                                       ?>
                                       <?php 
                                      // if ($globals) {
                                      //   foreach($globals as $global){
                                      //     $is_term = $setup->get_semester($global['semester_id']);
                                      //     if ($is_term[0]['sem_name']=="Third Semester") {
                                         ?>
                                        <!--  <td>

                                         </td> -->
                                         <?php
                                      //     }
                                      //   }
                                      // }

                                       ?>
                                      <!-- <td> --> <?php 
                                      // $i=0;
                                      // $j=0;
                                      //   if ($subject_position) {
                                      //     $i=0;
                                      //     $subject_total = "";
                                      //     $last_sem_subject_total = "";
                                      //     foreach($subject_position as $position){
                                      //       $i++;
                                      //       $subject_total += $position['total_score'];
                                           
                                      //     }
                                      //     if ($last_sem_subject_position) {
                                      //       $j=0;
                                      //      foreach($last_sem_subject_position as $position){
                                      //       $j++;
                                      //       $last_sem_subject_total += $position['total_score'];
                                           
                                      //     }
                                      //     }
                                      //     $avg1 = 0;
                                      //     $avg2 = 2;
                                      //     if ($subject_total!=0) {
                                      //      $avg1 = $subject_total/$i;
                                      //     }else{
                                      //        $avg1 = $subject_total;
                                      //     }
                                      //     if ($last_sem_subject_total!=0) {
                                      //       $avg2 = $last_sem_subject_total/$j;
                                      //     }else{
                                      //       $avg2 = $last_sem_subject_total;
                                      //     }
                                      //     $sum = $avg1+$avg2;
                                      //     if ($avg1!=0&&$avg2!=0) {
                                      //       echo round(($sum)/2);
                                      //     }elseif($avg1!=0&&$avg2==0){
                                      //       echo round(($sum));
                                      //     }else{
                                      //       echo round($avg1);
                                      //     }
                                      //   }
                                         ?><!-- </td>
                                      <td style="font-size: 9px !important;"> --><?php //echo remark($rpt['total_score']); ?><!-- </td>
                                      <td style="font-size: 8px !important;text-align: left !important;padding-left: 3px !important">Ms PATIENCE ABONGO TENI</td>
                                    </tr> -->
                                             <?php
                                          //   }
                                          // }
                                          // if ($student_student_elective) {
                                            ?>
                                            <!-- <tr>
                                      <td colspan="<?php //echo $colspan ?>" style="background-color: #ccc !important;"><b style="float: left;">ELECTIVE</b></td>
                                      
                                    </tr> -->
                                            <?php
                                  //           foreach($student_student_elective as $rpt){
                                  // $subject_position = $admission->subject_position($rpt['subject_id'],$student['class_id'],$student['track_id'],$student['semester_id'],$student['a_year_id']);
                                  // $over_all_subject_position = $admission->over_all_subject_position($rpt['subject_id'],$student['form_id'],$student['track_id'],$student['semester_id'],$student['a_year_id']);

                                  //  $last_sem_subject_position = $admission->subject_position($rpt['subject_id'],$student['class_id'],$student['track_id'],$sem_id,$student['a_year_id']);
                                              
                                             ?>
                                             <!--  <tr>
                                      <td><?php //echo $rpt['subject_name']; ?></td>
                                      <td><?php //echo $rpt['class_score']; ?></td>
                                      <td><?php //echo $rpt['exam_score']; ?></td>
                                      <td><?php //echo $rpt['total_score']; ?></td>
                                      <td><?php //echo grade($rpt['total_score']); ?></td>
                                      <td>  -->
                                        <?php 
                                        // if ($subject_position) {
                                        //   $i=0;
                                        //   $subject_total = "";
                                        //   foreach($subject_position as $position){
                                        //     $i++;
                                        //     $subject_total += $position['total_score'];
                                           
                                        //   }
                                        //  echo round($subject_total/$i);
                                        // }
                                         ?>

                                      <!-- </td>
                                      <td> --> <?php 
                                        // if ($subject_position) {
                                        //   $i=0;
                                        //   foreach($subject_position as $position){
                                        //     $i++;
                                        //    if ($rpt['student_id']==$position['student_id']) {
                                        //       echo $i; echo position($i);
                                        //    }
                                        //   }
                                        // }
                                         ?><!-- </td>
                                      <td> -->
                                         <?php 
                                        // if ($over_all_subject_position) {
                                        //   $i=0;
                                        //   foreach($over_all_subject_position as $position){
                                        //     $i++;
                                        //    if ($rpt['student_id']==$position['student_id']) {
                                        //       echo $i; echo position($i);
                                        //    }
                                        //   }
                                        // }
                                         ?>
<!--                                       </td> -->
                                      <?php 
                                      // if ($globals) {
                                      //   foreach($globals as $global){
                                      //     $is_term = $setup->get_semester($global['semester_id']);
                                      //     if ($is_term[0]['sem_name']=="Second Semester") {
                                         ?>
                                         <!-- <td>
                                          
                                         </td> -->
                                         <?php
                                      //     }
                                      //   }
                                      // }

                                       ?>
                                       <?php 
                                      // if ($globals) {
                                      //   foreach($globals as $global){
                                      //     $is_term = $setup->get_semester($global['semester_id']);
                                      //     if ($is_term[0]['sem_name']=="Third Semester") {
                                         ?>
                                        <!--  <td>
                                           

                                         </td> -->
                                         <?php
                                      //     }
                                      //   }
                                      // }

                                       ?>
                                      <!-- <td> -->
                                         <?php 
                                      // $i=0;
                                      // $j=0;
                                      //   if ($subject_position) {
                                      //     $i=0;
                                      //     $subject_total = "";
                                      //     $last_sem_subject_total = "";
                                      //     foreach($subject_position as $position){
                                      //       $i++;
                                      //       $subject_total += $position['total_score'];
                                           
                                      //     }
                                      //     if ($last_sem_subject_position) {
                                      //       $j=0;
                                      //      foreach($last_sem_subject_position as $position){
                                      //       $j++;
                                      //       $last_sem_subject_total += $position['total_score'];
                                           
                                      //     }
                                      //     }
                                      //     $avg1 = 0;
                                      //     $avg2 = 2;
                                      //     if ($subject_total!=0) {
                                      //      $avg1 = $subject_total/$i;
                                      //     }else{
                                      //        $avg1 = $subject_total;
                                      //     }
                                      //     if ($last_sem_subject_total!=0) {
                                      //       $avg2 = $last_sem_subject_total/$j;
                                      //     }else{
                                      //       $avg2 = $last_sem_subject_total;
                                      //     }
                                      //     $sum = $avg1+$avg2;
                                      //     if ($avg1!=0&&$avg2!=0) {
                                      //       echo round(($sum)/2);
                                      //     }elseif($avg1!=0&&$avg2==0){
                                      //       echo round(($sum));
                                      //     }else{
                                      //       echo round($avg1);
                                      //     }
                                      //   }
                                         ?>
                                    <!--   </td>
                                      <td style="font-size: 9px !important;"><?php //echo remark($rpt['total_score']); ?></td>
                                      <td style="font-size: 8px !important;text-align: left !important;padding-left: 3px !important">Ms PATIENCE ABONGO TENI</td>
                                    </tr> -->
                                             <?php
                                          //   }
                                          // }
                                         
                                  

                                          // }
                                             ?>
                                              <tr>
                                                 <td colspan="<?php echo $colspan ?>" style="background-color: #ccc !important;"><b style="float: left;">CORE</b></td>
                                      
                                                  </tr> 

                                             <?php
                                             $student_report_core = $admission->student_report_core($student['student_id'],$student['class'],$semester_id,$a_year_id);
                                             if ($student_report_core) {

                                              foreach ($student_report_core as $key) {
                                                if ($key['core_elective_name']=="CORE") {

                                  $subject_position = $admission->subject_position($key['subject_id'],$student['class'],$semester_id,$a_year_id);
                                  $over_all_subject_position = $admission->over_all_subject_position($key['subject_id'],$student['form_id'],$semester_id,$a_year_id);

                                   $last_sem_subject_position = $admission->subject_position($key['subject_id'],$student['class'],$semester_id,$a_year_id);
                                                 ?>
                                                 <tr>
                                                 <td  style="background-color: #fff !important;text-align: left !important;"><b style="float: left;"><?php echo $key['subject_name'] ?></b></td>
                                                 <td><?php echo round($key['class_score']*(30/100)); ?></td>
                                      <td><?php echo round($key['exam_score']*(70/100)); ?></td>
                                      <td><?php echo round($key['total_score']); ?></td>
                                      <td><?php echo grade(round($key['total_score'])); ?></td>
                                      <td>  
                                        <?php 
                                        if ($subject_position) {
                                          $i=0;
                                          $subject_total = 0;
                                          foreach($subject_position as $position){
                                            $i++;
                                            $subject_total += $position['total_score'];
                                           
                                          }
                                         echo round($subject_total/$i);
                                        }
                                         ?>

                                      </td>
                                      <td> <?php 
                                        if ($subject_position) {
                                          $i=0;
                                          foreach($subject_position as $position){
                                            $i++;
                                           if ($student['student_id']==$position['student_id']) {
                                              echo $i; echo position($i);
                                           }
                                          }
                                        }
                                         ?></td>
                                      <td>
                                         <?php 
                                        if ($over_all_subject_position) {
                                          $i=0;
                                          foreach($over_all_subject_position as $position){
                                            $i++;
                                           if ($student['student_id']==$position['student_id']) {
                                              echo $i; echo position($i);
                                           }
                                          }
                                        }
                                         ?>
                                      </td>


                                      <td style="font-size: 11px !important;"><?php echo remark($key['total_score']); ?></td>
                                      <?php 
                                       $get_teacher = $admission->get_teacher($key['subject_id'],$key['class_id']);
                                       $teacher_details = $admission->get_teacher_details($get_teacher[0]['staff_id']);
                                       ?>
                                      <?php 
                                       $get_teacher = $admission->get_teacher($key['subject_id'],$key['class_id']);
                                       $teacher_details = $admission->get_teacher_details($get_teacher[0]['staff_id']);
                                       ?>
                                      <td style="font-size: 11px !important;"><?php echo $teacher_details[0]['first_name'].' '.$teacher_details[0]['last_name'] ?></td>

                                    </tr>
                                             <?php
                                            }
                                          }
                                         
                                  

                                          }
                                             ?>
                                      
                                                 
                                                
                                           <tr>
                                                 <td colspan="<?php echo $colspan ?>" style="background-color: #ccc !important;"><b style="float: left;">ELECTIVE</b></td>
                                      
                                                  </tr> 

                                             <?php
                                              $student_report_elective = $admission->student_report_elective($student['student_id'],$student['class'],$semester_id,$a_year_id);
                                             if ($student_report_elective) {
                                              foreach ($student_report_elective as $key) {
                                                if ($key['core_elective_name']=="ELECTIVE") {

                                  $subject_position = $admission->subject_position($key['subject_id'],$student['class'],$semester_id,$a_year_id);
                                  $over_all_subject_position = $admission->over_all_subject_position($key['subject_id'],$student['form_id'],$semester_id,$a_year_id);

                                   $last_sem_subject_position = $admission->subject_position($key['subject_id'],$student['class'],$semester_id,$a_year_id);
                                                 ?>
                                                 <tr>
                                                 <td  style="background-color: #fff !important;"><b style="float: left;"><?php echo $key['subject_name'] ?></b></td>
                                                  <td><?php echo round($key['class_score']*(30/100)); ?></td>
                                      <td><?php echo round($key['exam_score']*(70/100)); ?></td>
                                      <td><?php echo round($key['total_score']); ?></td>
                                      <td><?php echo grade(round($key['total_score'])); ?></td>
                                      <td>  
                                        <?php 
                                        if ($subject_position) {
                                          $i=0;
                                          $subject_total = 0;
                                          foreach($subject_position as $position){
                                            $i++;
                                            $subject_total += $position['total_score'];
                                           
                                          }
                                         echo round($subject_total/$i);
                                        }
                                         ?>

                                      </td>
                                      <td> <?php 
                                        if ($subject_position) {
                                          $i=0;
                                          foreach($subject_position as $position){
                                            $i++;
                                           if ($student['student_id']==$position['student_id']) {
                                              echo $i; echo position($i);
                                           }
                                          }
                                        }
                                         ?></td>
                                      <td>
                                         <?php 
                                        if ($over_all_subject_position) {
                                          $i=0;
                                          foreach($over_all_subject_position as $position){
                                            $i++;
                                           if ($student['student_id']==$position['student_id']) {
                                              echo $i; echo position($i);
                                           }
                                          }
                                        }
                                         ?>
                                      </td>
                                      <?php 
                                      if ($globals) {
                                        foreach($globals as $global){
                                          $is_term = $setup->get_semester($global['semester_id']);
                                          if ($is_term[0]['sem_name']=="Second Semester") {
                                         ?>
                                         <td>
                                          
                                         </td>
                                         <?php
                                          }
                                        }
                                      }

                                       ?>
                                       <?php 
                                      if ($globals) {
                                        foreach($globals as $global){
                                          $is_term = $setup->get_semester($global['semester_id']);
                                          if ($is_term[0]['sem_name']=="Third Semester") {
                                         ?>
                                         <td>
                                           

                                         </td>
                                         <?php
                                          }
                                        }
                                      }

                                       ?>
                                      <!--<td>-->
                                         <?php
                                     /* $i=0;
                                      $j=0;
                                        if ($subject_position) {
                                          $i=0;
                                          $subject_total = "";
                                          $last_sem_subject_total = "";
                                          foreach($subject_position as $position){
                                            $i++;
                                            $subject_total += $position['total_score'];
                                           
                                          }
                                          if ($last_sem_subject_position) {
                                            $j=0;
                                           foreach($last_sem_subject_position as $position){
                                            $j++;
                                            $last_sem_subject_total += $position['total_score'];
                                           
                                          }
                                          }
                                          $avg1 = 0;
                                          $avg2 = 2;
                                          if ($subject_total!=0) {
                                           $avg1 = $subject_total/$i;
                                          }else{
                                             $avg1 = $subject_total;
                                          }
                                          if ($last_sem_subject_total!=0) {
                                            $avg2 = $last_sem_subject_total/$j;
                                          }else{
                                            $avg2 = $last_sem_subject_total;
                                          }
                                          $sum = $avg1+$avg2;
                                          if ($avg1!=0&&$avg2!=0) {
                                            echo round(($sum)/2);
                                          }elseif($avg1!=0&&$avg2==0){
                                            echo round(($sum));
                                          }else{
                                            echo round($avg1);
                                          }
                                        }    */
                                         ?>
                                      <!--</td>-->
                                      <td style="font-size: 11px !important;"><?php echo remark($key['total_score']); ?></td>
                                      <?php 
                                       $get_teacher = $admission->get_teacher($key['subject_id'],$key['class_id']);
                                       $teacher_details = $admission->get_teacher_details($get_teacher[0]['staff_id']);
                                       ?>
                                      <td style="font-size: 11px !important;"><?php echo $teacher_details[0]['first_name'].' '.$teacher_details[0]['last_name'] ?></td>


                                    </tr>
                                           
                                                   
                                                 <?php
                                                }
                                              }
                                             }
                                          ?>

                                  

                                    </tbody>
                                </table>
                            </div><!-- /table-responsive -->
                            <table style="width: 100%">
                              <tr>
                                <td>
                                 <p></p>
                                 <span style="font-size: 16px !important;font-weight: bold !important;">Attendance : <?php 
                                 $attendance = $admission->get_attendance($student['student_id'],$kid,$semester_id,$a_year_id);
                                 echo $attendance[0]['attendance'].' out of '.$no_of_days;

                                  ?></span>
                                  <p></p>
                          <span style="font-size: 16px !important;font-weight: bold !important;">Form Master/Madam 's Comment</span>
                          <table class="table-responsive" style="margin-left: 50px !important">
                            <tr>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;">Conduct:</td>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;"><?php  echo $attendance[0]['conduct'] ?></td>
                            </tr>
                            <tr>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;">Interest:</td>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;"><?php echo $attendance[0]['interest'] ?></td>
                            </tr>
                            <tr>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;">Attitude:</td>
                              <td style="font-size: 15px !important;text-align: left !important;width: 100px;"><?php echo $attendance[0]['attitude'] ?></td>
                            </tr>
                          </table>
                          <span style="font-size: 16px !important;font-weight: bold !important;">Headmaster's Comment</span><br>
                         <?php  
                              $over_all_position = $admission->overall_position($student['form_id'],$semester_id,$a_year_id);
                              if ($over_all_position) {
                                  $i=0;
                                  foreach ($over_all_position as $over_all_position) {
                                  $i++;
                                  if ($over_all_position['student_id']==$student['student_id']) {
                                  echo headRemark(round(($over_all_position['total_score']/900)*100));
                                  }
                                  }
                                }
                               ?><br>
                          <span style="font-size: 16px !important;font-weight: bold !important;">Mr. Asare Yeboah (Head Master)
                                </span>
                                <p></p>
                                <img src="../student_pics/sign.jpg" style="width: 120px;margin-left: 50px;height: 50px;"><p></p>
                                <!-- <hr style="width: 250px !important;float:left;height: 1px;background:#000 !important;" class="line_sig"> -->

                                </td>
                                <td>
                          <table class="table-bordered grade pull-right">
                            <thead>
                              <th>Grading Code</th>
                              <th>Grade</th>
                              <th>Remarks</th>
                            </thead>
                            <tbody>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">80-100</td>
                                <td style="text-align: center !important;font-size: 10px !important;">A1</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Excellent</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">75-79</td>
                                <td style="text-align: center !important;font-size: 10px !important;">B2</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Very Good</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">70-74</td>
                                <td style="text-align: center !important;font-size: 10px !important;">B3</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Good</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">65-69</td>
                                <td style="text-align: center !important;font-size: 10px !important;">C4</td>
                                <td style="text-align: center !important;font-size: 10px !important;">High Credit</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">60-64</td>
                                <td style="text-align: center !important;font-size: 10px !important;">C5</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Credit</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">55-59</td>
                                <td style="text-align: center !important;font-size: 10px !important;">C6</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Average</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">50-54</td>
                                <td style="text-align: center !important;font-size: 10px !important;">D7</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Pass</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">40-49</td>
                                <td style="text-align: center !important;font-size: 10px !important;">E8</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Weak Pass</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;">0-39</td>
                                <td style="text-align: center !important;font-size: 10px !important;">F9</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Fail</td>
                              </tr>
                              <tr>
                                <td style="text-align: center !important;font-size: 10px !important;"></td>
                                <td style="text-align: center !important;font-size: 10px !important;">IC</td>
                                <td style="text-align: center !important;font-size: 10px !important;">Incomplete</td>
                              </tr>
                            </tbody>
                          </table>
                                </td>
                              </tr>
                            </table>
                            <br>
                       

                        

                        </div>
                    </div>
                            <br/>
                     <!-- <div class="mailto ibox-content" >
                      <table style="width: 100% !important;" class="address">
                        <tr>
                          <td style="font-weight: bolder !important;font-size: 16px !important;text-align: left !important;"><?php echo $student['student_name'] ?> </td>
                          <td></td>
                          <td></td>
                        </tr>
                         <tr>
                          <td></td>
                          <td style="font-weight: bolder !important;font-size: 14px !important;text-align: center !important;">to</td>
                          <td></td>
                        </tr>
                         <tr>
                          <td></td>
                          <td></td>
                          <td style="font-weight: bolder !important;font-size: 16px !important;text-align: right !important;width: 50% !important; ">
                           <?php 
                          
                            // echo $student['postal_address'];
                          

                            ?>

                          </td>
                        </tr>
                      </table>
                    </div> -->

    </div>
    <footer></footer>
<script type="text/javascript">
  window.print();
</script>

</body>


<?php
}
}

 ?>