<html>
    <head>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
        <title><?php echo $b_header['title']; ?></title>
      <style>
            @media print
            {
                * {-webkit-print-color-adjust:exact;}
                @page {margin:0in 0.10in 0in 0in; }
                .super_container
                {
                    page-break-after: always;
                    margin-top:0.25in;
                    position:relative;
                    width:100vw;
                    height:710px;
                }
                .no-print
    {
        display: none !important;
    }
            }
            body {margin: 0.25in 0.25in 0.63in 0.25in; box-sizing:border-box;width:100vw; height:100vh;padding-bottom:0.63in;}
            *{margin:0;padding:0;font-family:calibri;}
            .clear:after{content:"";clear:both;display:block;}
            .left{float:left;}
            .right{float:right;}
            .wd-10{width:10%;}
            .wd-20{width:20%;}
            .wd-30{width:30%;}
            .wd-40{width:40%;}
            .wd-50{width:50%;}
            .wd-60{width:60%;}
            .wd-70{width:70%;}
            .wd-80{width:80%;}
            .wd-90{width:90%;}
            .wd-100{width:100%;}
            .wd-15{width:15%;}
            .wd-25{width:25%;}
            .wd-35{width:35%;}
            .wd-45{width:45%;}
            .wd-55{width:55%;}
            .wd-65{width:65%;}
            .wd-75{width:75%;}
            .wd-85{width:85%;}
            .wd-95{width:95%;}
            .wd-100{width:100%;}
            .title{font-size:35px;}
            .super_container
            {
                margin-bottom:200px;
                position:relative;
                width:100vw;
                height:710px;
            }
            .wrapper{
                border:4px transparent #3e5367;
                
                box-sizing: border-box;
                padding:5px;
            }
            .super_wrapper
            {
                position:absolute;
                top:0;
                left:0;
                width:100%;
                z-index:120;
                margin:0;
                padding:0;
            }
         
            .watermark_wrapper
            {
                height:470px;
                width:100%;
                margin-top:50px;
                display:inline-flex;
                display:-webkit-inline-flex;
             }
            .wrapper.left2{
                width: calc(90vw);
                margin-right: 20px;
                margin-left: 20px;
            }
            h1,h2,h3{
                color:#A3CC26;
                font-family:calibri;
                text-align:center;
            }
            .boxed{width:80%;margin:0 auto;}
            .header{
                width:100%;
                border-bottom:4px solid #A3CC26;            
            }
            .body{
                padding:10px;
            }
            .row{
                width:100%;
                margin: 0px auto;  
            }
            .text-center{text-align:center;}
            .bold{font-weight:bold;}
            .b-u-l{
                border-bottom: 1px solid #3e5367;
                height:inherit;
            }
            .x-small{
                font-size: 12px;
            }
            .x-x-small{
                font-size: 9px;
            }
            .page_break{
                width: 100vw;
                height: 100vh;
                padding: 10px 0px;
                box-sizing: border-box;
            }
            .tbl1
            {
                border: 2px solid #3e5367;
                text-align:center;
                width:100%;
                min-height:20px;
            }
            th{
                border: 2px solid #3e5367;
                border-right: 0px;
                border-bottom: 0px;
                background-color:#ccccb3;
                
                padding: 3px !important;
            }
            td{
                border: 2px solid #3e5367;
                text-align: left;
                 border-right: 0px;
                border-bottom: 0px;
                padding: 2px !important;
            }
            .normal{
                font-weight: normal !important;
            }
            .text-right{
                text-align: right !important;
            }
            .text-left{
                text-align: left !important;
            }
            .margin-a{margin: 30px auto 0px auto;}
        </style>
        <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    </head>
    <body class="clear">
        <?php date_default_timezone_set("Asia/Karachi"); ?>
        <div class="super_container">
            <div class="page_break clear">
                <div class="watermark_wrapper">
                    <div class="watermark"></div>
                </div>
                <div class="super_wrapper">
                    <div class="wrapper left2 left">
                        <div class="header">
                            <div class="wd-100 clear">
                                <div class=" text-left left ">
                                    <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div class=" text-left right ">
                                    <img src="<?php echo base_url().$b_header['logo2']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div style="">
                                    <center><h1><?php echo $b_header['title']; ?></h1></center>
                                    <center><h3 style="color:#000 !important;"><i><?php echo $b_header['tagline']; ?></i></h3></center>
                                    <center><i><h3 style="color:#000 !important;font-weight:normal;"><?php echo $b_header['short_address']; ?></h3></i></center>
                                    <center><u><b><h4 class="boxed" style="font-size:18px;margin-top:0px !important;font-size:23px;"><?php echo @$ad_exm['name']." "."Report";?></h4></b></u></center>
                                </div>
                            </div>
                   </div>
        <?php
        if(empty(@$tot_att[0]->att))
        {
            @$tot_att[0]->att=1;
        }
        ?>
                        <div class="body">
                            <div class="container">
            <!--Upper Portion Data-->
                            <div class="row">
                                <div class="col-md-4"><strong>Name: <u><?php echo $students; ?></u></strong></div>
                                <div class="col-md-3"><strong>Class: <u><?php echo $class_name; ?></u></strong></div>
                                <div class="col-md-3"><strong>Section: <u><?php echo $section_name; ?></u></strong></div>
                            </div>
                            <hr>
                            <div class="row">
                                <div class="col-md-2"><strong>Term Dates: </strong></div>
                                <div class="col-md-3"><strong>From: <u><?php echo date('d-m-Y',strtotime($ad_exm['start']));?></u></strong></div>
                                <div class="col-md-3"><strong>To: <u><?php echo date('d-m-Y',strtotime($ad_exm['end']));?></u></strong></div>
                                <div class="col-md-4"><strong>No of Students: <u><?php echo $tot_stds;?></u></strong></div>
                            </div>
                            <br>
                            <div class="row">
                               
                                <div class="col-md-4"><strong>Percentage Of Attendance: <u>
                                       <?php
                               $getall_status=$this->db->select('*')
                                                  ->from('rept_crd')
                                                  ->where('mystd_id',$stdd_id)
                                                  ->where('myexm_id',$exam_id)
                                                  ->where('myaddexam_id',$addexam_id)
                                               ->where('sessoin_id',$session_id)
                                                 ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                                // var_dump('<pre>',$getall_status);
                                // die();
                                    if(!empty($getall_status))
                                    {
                                    
                                      if($getall_status['attend']==10)
                                       {
                                           $att=100;
                                       }
                                       if($getall_status['attend']==8)
                                       {
                                           $att=95;
                                       }
                                        if($getall_status['attend']==7)
                                       {
                                           $att=85;
                                       }
                                        if($getall_status['attend']==0)
                                       {
                                           $att=75;
                                       }
                                    
                                    
                                    
                                    
                                    
                                    //$att=$getall_status['attend'];
                                   }
                                            ?>
                                <?php if(!empty($att)){
                                             echo  round($att,2)."%";
                                               }else{
                                              
                                   $ab=(@$get_att[0]->att/@$tot_att[0]->att)*100;
                                               echo round($ab,2)."%";
                                               }?>
                                </u></strong></div>
                                <div class="col-md-4"><strong>Date Of Birth: <u><?php echo date('d-m-Y',strtotime($dob)); ?></u></strong></div>
                                <div class="col-md-4"><strong>Average Age Of Students: <u><?php if(!empty($avg_age)){ echo $avg_age;}?></u></strong></div>
                                
                            </div>
                            
            <!--Ended Upper Portion Data-->
                            </div>
                            <hr>
         <!--Start Table-->
         <form method="post" id="frm_rep" action="<?php echo base_url();?>Report/save_rep">
    <input type="hidden" name="mystd_id" value="<?php echo $stdd_id;?>">
    <input type="hidden" name="myexm_id" value="<?php echo $exam_id;?>">
    <input type="hidden" name="myaddexam_id" value="<?php echo $addexam_id;?>">
    <input type="hidden" name="sessoin_id" value="<?php echo $session_id;?>">
    
                            <table class="table table-bordered">
                                <thead style="text-align:center;">
                                    <tr>
                                        <th>Subjects</th>
                                        <th>Total Marks</th>
                                        <th>Coursework Ave. (15)</th>
                                        <th>1st Term Marks</th>
                                        <th>Total Marks Obtained</th>
                                        <th>Target Grade</th>
                                        <th>Achieved Grade</th>
                                        <th>%age</th>
                                        <th>Class Highest %age</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    $cls_wrktot=0;
                                    $sum_of_subj=0;
                                    $sum_of_obj1=0;
                                    $sum_of_obj2=0;
                                    $lowest_marks=0;
                                    $lowest_total = 0;
                                    $highest_marks=0;
                                    $highest_total = 0;
                                    $overall_obtained=0;
                                    $overall_marks=0;
                                    $percent=0;$t=0;
                                    $gain=0;
                                    $ts=0;
                                    $gains=0;
                                    $first_term;
                                    $firs_total= 0;
                                    $second_total= 0;
                                    if(!empty($student[0])){
                                       $firs_total=@$student[0]->obtained_marks;
                                     $second_total=@$first_term[0]->obtained_marks;
                                       
                                        $subjectss = $this->report_model->getSubjectNames(@$first_term[0]->result_id);
                                        
                                        $markss = $this->report_model->getSubjectMarks(@$first_term[0]->result_id);
                                        
                                            $subjects = $this->report_model->getSubjectNames(@$student[0]->result_id);
                                            
                                            $marks = $this->report_model->getSubjectMarks(@$student[0]->result_id);
                                            
                                            $marksss = $this->report_model->getSubjectMarks(@$highest_grade[0]->result_id);
                                            
                                            $markssss = $this->report_model->getSubjectMarks(@$lowest_grade['result_id']);
                                        
                                       // var_dump('<pre>',$subjects);die;
                                            if(!empty($subjects))
                                            {
                                            $cls_wrktot=0;
                                            $sum_status=0;
                                                foreach ($subjects as $key => $value) {?>
                                         <tr>
                                        <td><input type="hidden" name="subj_ids[]" value="<?php echo $value->subject_id; ?>"><?php echo $value->name; ?></td>
                                        <td><?php 
                                        echo $value->total_marks; 
                                        $t =$value->total_marks;
                                        $sum_of_subj=$sum_of_subj+$t;
                                        $overall_marks =$overall_marks+$t;
                                        ?></td>
                                        <td>
                                        <?php
                                        $cls_wrk=0;
                                          $getmrks=$this->db->select('*')
                                            ->from('rept_crd')
                                            ->where('mystd_id',$stdd_id)
                                            ->where('myexm_id',$exam_id)
                                            ->where('myaddexam_id',$addexam_id)
                                            ->where('sessoin_id',$session_id)
                                            ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                               
                                 if(!empty($getmrks)) 
                                 {
                                     $getcoursr_mrks=$this->db->select('*')
                                                              ->from('report_subj')
                                                              ->where('report_id',$getmrks['id'])
                                                              ->where('subject_id',$value->subject_id)
                                                              ->order_by('id','desc')
                                                              ->limit(1)
                                                              ->get()->row_array();
                                    if(!empty($getcoursr_mrks))  
                                    {
                                        $cls_wrk=$getcoursr_mrks['class_mrks'];
                                        $cls_wrktot=$cls_wrktot+$cls_wrk;
                                    }
                                 }else
                                 {
                                     @$gtrs_id=$this->db->select('*')
                                                  ->from('result')
                                                  ->where('exam_id',$exam_id)
                                                  ->where('is_delete',0)
                                                  ->where('promotion_id',$dastudent)
                                                  ->order_by('id','desc')
                                                  ->limit(1)
                                                  ->get()->row_array();
                                   $io=@$gtrs_id['id'];  
                                   if(!empty($io))
                                   {
                                       $subbsj=@$this->db->select('sum(obtained_marks) as obtained_marks')
                                                       ->from('result_subject')
                                                       ->where('result_id',$io)
                                                       ->where('subexam_id >',0)
                                                       ->where('subject_id',$value->subject_id)
                                                       ->where('is_delete',0)
                                                       ->get()->row_array()['obtained_marks'];
                                    if($tot_subj==0)
                                    {
                                        $tot_subj=1;
                                    }else{
                                        $tot_subj=$tot_subj;
                                    }
                                      $cls_wrk=@$subbsj/$tot_subj;
                                      $cls_wrktot=$cls_wrktot+$cls_wrk;                   
                                   }
                                 }
                                
                                 ?>
                                 <?php echo @round($cls_wrk,2);?></td>
                                                    
                                          <td>
                                           <?php 
                                        echo @$markss[$key]->obtained_marks;
                                        $up=@$markss[$key]->obtained_marks;
                                        $sum_of_obj1=$sum_of_obj1+$up;
                                        ?>
                                        </td>
                                        <td><?php 
                                        echo $marks[$key]->obtained_marks;
                                         $up2=@$marks[$key]->obtained_marks;
                                        $sum_of_obj2=$sum_of_obj2+$up2;
                                        $gain = $marks[$key]->obtained_marks; $overall_obtained = $overall_obtained+$gain;?>
                                          </td>
                                            <td>
                                                <?php 
                                                    $grade = round(($gain*100 / $t));
                                                   
                                                    if($grade >= 90){
                                                        echo "A+";
                                                    }
                                                    if($grade >= 80 && $grade <= 89){
                                                        echo "A+";
                                                    }
                                                    if($grade >= 70 && $grade <= 79){
                                                        echo "A";
                                                    }
                                                    if($grade >= 60 && $grade <= 69){
                                                        echo "B";
                                                    }
                                                    if($grade >= 50 && $grade <= 59){
                                                        echo "C";
                                                    }
                                                    if($grade <= 49 ){
                                                        echo "D";
                                                    }
                                                    
                                                    ?>
                                                    
                                                    </td>
                                                    <td><?php 
                                                    $grade = round( ($gain*100 / $t));
                                                    // var_dump($grade);die;
                                                    if($grade >= 90){
                                                        echo "A+";
                                                    }
                                                    if($grade >= 80 && $grade <= 89){
                                                        echo "A";
                                                    }
                                                    if($grade >= 70 && $grade <= 79){
                                                        echo "B";
                                                    }
                                                    if($grade >= 60 && $grade <= 69){
                                                        echo "C";
                                                    }
                                                    if($grade >= 50 && $grade <= 59){
                                                        echo "D";
                                                    }
                                                    if($grade <= 49 ){
                                                        echo "F";
                                                    }
                                                    
                                                    ?></td>
                                                    <td><?php echo round(($gain*100 / $t)); ?>%</td>
                                                    <td>
                                                        <?php 
                                                        
                                                       $gains =  @$marksss[$key]->obtained_marks;
                                                       $highest_marks= $highest_marks+$gains;
                                                      $ts = @$marksss[$key]->total_marks;
                                                        $highest_total = $highest_total +$ts;
                                                        
                                        $lowest_marks= $lowest_marks+@$markssss[$key]->obtained_marks;
                                                    
                                                        $lowest_total = $lowest_total +@$markssss[$key]->total_marks;               
                                            // var_dump(@$markssss[$key]->obtained_marks);die;
                                                    $grades = round(($gains*100 / $ts));
                                                    $res=@$this->db->select('max(result_subject.obtained_marks) as obt_mrks,result_subject.total_marks')
                                                                   ->from('promotion')
                                                                   ->join('result','result.promotion_id=promotion.id')
                                                                   ->join('result_subject','result_subject.result_id=result.id')
                                                                   ->where('promotion.class_id',$cc)
                                                                   ->where('promotion.section_id',$ccsec)
                                                                   ->where('promotion.session_id',$session_id)
                                                                   ->where('result.exam_id',$exam_id)
                                                                   ->where('promotion.is_active',1)
                                                                    ->where('result_subject.subexam_id',0)
                                                                    ->where('result_subject.subject_id',$value->subject_id)
                                                                   ->get()->result_array()[0];
                                                       if(!empty($res))
                                                       {
                                                           $pers=($res['obt_mrks']/$res['total_marks'])*100;
                                                           echo round($pers,2)."%";
                                                       }
                                                    
                                                    
                                                    ?>
                                                    </td>
                                                </tr>    
                                            <?php       }
                                            }
                                        } ?>
                                                    
                                    
                                    
                                    <tr>
                                        <td><b>Total (A)</b></td>
                                        <td><b><?php 
                                       // echo $firs_total;
                                       echo $sum_of_subj;
                                        ?></b><input type="hidden" id="g_total" value="<?php 
                                        echo $sum_of_subj;
                                        //echo $firs_total; 
                                        ?>"  ></td>
                                        <td><b>
                                            <?php 
                                            
                                            $ass_res=$this->db->select('sum(obtained_marks) as 	obtained_marks,sum(total_marks) as total_marks')
                                                              ->from('result_subject')
                                                              ->where('result_id',$rs)
                                                              ->where('subexam_id >',0)
                                                              ->where('is_delete',0)
                                                              ->get()->row_array();
                                                   
                                                   if(!empty($ass_res))
                                                   {
                                                       if($ass_res['total_marks']==0)
                                                       {
                                                           $ass_res['total_marks']=1;
                                                       }else{
                                                           $ass_res['total_marks']=$ass_res['total_marks'];
                                                       }
                                                      $cls_wrktot=($ass_res['obtained_marks']/$ass_res['total_marks'])*15;
                                                   }
                                            echo @round($cls_wrktot,2);
                                            ?>
                                            </b></td>
                                        <td><b><?php echo @round($sum_of_obj1,2);?></b></td>
                                        <td><b><?php echo @round($sum_of_obj2,2);?></b></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                        
                                        <td></td>
                                        <td><b></b></td>
                                    </tr>
                                    <tr>
                                        <td>Attendance</td>
                                        <td><?php echo "10";
                                        ?></td>
                                        <td>
                                            <?php
                               $getall_status=$this->db->select('*')
                                                  ->from('rept_crd')
                                                  ->where('mystd_id',$stdd_id)
                                                  ->where('myexm_id',$exam_id)
                                                  ->where('myaddexam_id',$addexam_id)
                                            ->where('sessoin_id',$session_id)
                                            ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                                    if(!empty($getall_status))
                                    {
                                    $att=$getall_status['attend'];
                                    $absnt=$getall_status['absent'];
                                    $class_parti=$getall_status['class_parti'];
                                    $homework=$getall_status['homework'];
                                    $classwork=$getall_status['classwork'];
                                    $Behaviour=$getall_status['Behaviour'];
                                    $Uniform=$getall_status['Uniform'];
                                    $HHW=$getall_status['HHW'];
                                    $teacher_st=$getall_status['teacher_st'];
                                    $art=$getall_status['art'];
                                    $PE=$getall_status['PE'];
                                    $Music=$getall_status['Music'];
                                    }?>
                                   <input type="hidden" name="attend" value="<?php if(!empty($att)){echo $att;}else{
                $curr_att=round((@$get_att[0]->att/@$tot_att[0]->att)*100,2);
                                       if($curr_att>=100)
                                       {
                                           $att_mrks=10;
                                       }
                                       if($curr_att>=90 && $curr_att<100)
                                       {
                                           $att_mrks=8;
                                       }
                                        if($curr_att>=80 && $curr_att<90)
                                       {
                                           $att_mrks=7;
                                       }
                                        if($curr_att<80)
                                       {
                                           $att_mrks=0;
                                       }
                                       echo $att_mrks;
                                      // $sum_status=@$sum_status+@$att_mrks;
                                       }?>">
                                       <?php 
                                       if(!empty($att)){
                                           $sum_status=$sum_status+$att;
                                       echo $att;
                                       }else{
          // echo "dfgvefv";
            //   die();
                $curr_att=round((@$get_att[0]->att/@$tot_att[0]->att)*100,2);
               
                                       if($curr_att>=100)
                                       {
                                           $att_mrks=10;
                                       }
                                       if($curr_att>=90 && $curr_att<100)
                                       {
                                           $att_mrks=8;
                                       }
                                        if($curr_att>=80 && $curr_att<90)
                                       {
                                           $att_mrks=7;
                                       }
                                        if($curr_att<80)
                                       {
                                           $att_mrks=0;
                                       }
                                       echo @$att_mrks;
                                    //   var_dump($sum_status);
                                    //   die();
                                       $sum_status=@$sum_status+@$att_mrks;
                                      
                                       }
                                       ?>
                                       </td>
                                        
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Tardy (Late)</td>
                                        <td>
                                        <?php  echo "10";
                                        //@$get_absent[0]->late; 
                                        ?></td>
                                        <td>
                                            <input type="hidden" name="absent" value=" <?php if(!empty($absnt)){echo $absnt;}else{
             $get_absent[0]->late=@$get_absent[0]->late;
                                            if(@$get_absent[0]->late==4){ echo "-1";} if(@$get_absent[0]->late==5){ echo "-5";} if(@$get_absent[0]->late>8){ echo "-10";} if(@$get_absent[0]->late==0){ echo "0";}}?>">
                                        <?php if(!empty($absnt)){
                                            $sum_status=$sum_status+$absnt;
                                        echo $absnt;
                                        }else{
                                            $abs_tot=$get_absent[0]->late;
                                            if($abs_tot==4)
                                            {
                                               $trdi=-1; 
                                            }
                                             if($abs_tot==6)
                                            {
                                               $trdi=-2; 
                                            }
                                             if($abs_tot==5)
                                            {
                                               $trdi=-5; 
                                            }
                                             if($abs_tot==7)
                                            {
                                               $trdi=-8; 
                                            }
                                             if($abs_tot>=8)
                                            {
                                               $trdi=-10; 
                                            }
                                            echo @$trdi;
                                            $sum_status=$sum_status+@$trdi;
                                        
                                        }?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Class Participation</td>
                                        <td>5</td>
                                        <td><?php if(!empty($class_parti)){$sum_status=$sum_status+$class_parti; echo $class_parti;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Homework Presentation</td>
                                        <td>5</td>
                                        <td><?php if(!empty($homework)){$sum_status=$sum_status+$homework;echo $homework;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Classwork Presentation</td>
                                        <td>5</td>
                                        <td><?php if(!empty($classwork)){$sum_status=$sum_status+$classwork;echo $classwork;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Discipline/Behaviour</td>
                                        <td>10</td>
                                        <td><?php if(!empty($Behaviour)){$sum_status=$sum_status+$Behaviour;echo $Behaviour;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>Uniform/Cleanliness</td>
                                        <td>5</td>
                                        <td><?php if(!empty($Uniform)){$sum_status=$sum_status+$Uniform;echo $Uniform;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>HHW</td>
                                       <td>30</td>
                                        <td><?php if(!empty($HHW)){$sum_status=$sum_status+$HHW;echo $HHW;}?></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td><b>Total (B)</b></td>
                                        <td><b>80
                                        <!--<input type="number" id="total" readonly style="width:100%;border: none;
border-color: transparent;">-->
</b></td>
                                        <td><b><?php echo $sum_status;?></b></td>
                                        <td><b></b></td>
                                        <td></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                    </tr>
                                    <tr>
                                        
                                        <td><b>Grand Total (A+B)</b></td>
                                        <td><?php echo @round($sum_of_subj+80+15,2);?></td>
                                        <td><b><?php echo @round($sum_status+@$cls_wrktot+@$sum_of_obj2,2);?></b></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                        <td></td>
                                        <td><b></b></td>
                                        <td><b></b></td>
                                    </tr>
                                </tbody>
                            </table>
            <!--Dable Data Ended-->
                            <table class="table table-bordered">
                                <thead style="text-align:center;">
                                    <tr>
                                    
                                        <th colspan="10">Rubric Course/work</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        
                                        <td style="text-align:center !important">Subject</td>
                                        <?php 
                                        if(!empty($getnew))
                                        {
                                            foreach($getnew as $rpc=>$vcc)
                                            {?>
                                                <td  style="text-align:center !important"><?php echo $vcc['name'];?></td>
                                         <?php   }
                                        }?>    
                                      <td style="text-align:center !important">Average</td>
                                     </tr>
                                     
                                           <?php 
                                    if(!empty($subjects_cls))
                                    {
                                      
                                    foreach($subjects_cls as $check_sub=>$sub_ids)
                                        {
                                             
                                    if(!empty($getnew))
                                        {
                                            $gtrs_id=$this->db->select('*')
                                                              ->from('result')
                                                              ->where('exam_id',$exam_id)
                                                              ->where('is_delete',0)
                                                              ->where('promotion_id',$dastudent)
                                                              ->order_by('id','desc')
                                                              ->limit(1)
                                                              ->get()->row_array();
                                                $io=$gtrs_id['id']; 
                                                
                                        if(!empty($io)) 
                                        {?>
                                          <tr>
                                        <td  style="text-align:center !important"><?php echo $sub_ids['name'];?></td> 
                                      <?php
                                      $tot_mkks=0;
                                      foreach($getnew as $rp=>$vc)
                                            {
                                                 $subbs=$this->db->select('*')
                                                                 ->from('result_subject')
                                                                 ->where('result_id',$io)
                                                                 ->where('subexam_id',$vc['id'])
                                                                 ->where('subject_id',$sub_ids['id'])
                                                                 ->where('is_delete',0)
                                                                 ->get()->row_array();
                                                   
                                                        if(!empty($subbs)) 
                                                        { 
                                                            $tot_mkks=$tot_mkks+$subbs['obtained_marks'];
                                                        ?> 
                                                        
                                                                 
                                                <td style="text-align:center !important"><?php echo $subbs['obtained_marks'];?></td>
                                          <?php   }else{?>
                                         <td style="text-align:center !important">0</td>
                                        <?php } }?>
                                        <td  style="text-align:center !important"><?php echo @round($tot_mkks/$tot_subj,2);?></td>
                                        </tr>
                                    <?php     }
                                    }//foreachsubjts
                                         }//forsubjects
                                    }//forsubjects
                                         ?> 
                                         
                                     
                                    
                                </tbody>
                            </table>
                            
                            <table class="table table-bordered">
                                    
                                    <tr>
<td>Overall Percentage:<b>
<?php 
$vagmax=0;
$vagmin=0;
if(!empty($percn)){
    $wthoutass_res=$this->db->select('sum(obtained_marks) as obtained_marks,sum(total_marks) as total_marks')
                            ->from('result_subject')
                            ->where('result_id',$rs)
                            ->where('subexam_id',0)
                            ->where('is_delete',0)
                            ->get()->row_array();
   if(!empty($wthoutass_res))
   {
      @$percn['total_marks']=@$wthoutass_res['total_marks']+80+15;
      @$percn['obtained_marks']=@$wthoutass_res['obtained_marks']+$sum_status+@$cls_wrktot; 
   }
    
   echo  number_format((@$percn['obtained_marks']/@$percn['total_marks'] )*100,2); 
}else
{
    echo "0";
}
 ?>%</b>
</td>
<td>Overall Grade: <b>
<?php
@$final = round((@$percn['obtained_marks'] / @$percn['total_marks']) * 100);
            if(@$final>=80){ $data1['grade'] = "A";}
            else if(@$final>=70){ @$data1['grade'] = "B";}
            else if(@$final>=60){ @$data1['grade'] = "C";}
            else if(@$final>=50){ @$data1['grade'] = "D";}
            else if(@$final>=40){ @$data1['grade'] = "E";}
            else if(@$final<40){  @$data1['grade'] = "F";}
            
            echo @$data1['grade'];
//echo @$student[0]->grade; 
?>
</b></td>
<td>Position In Class:<b>
    <?php 
                                        $vagmax=0;
                                        $vagmin=0;
                                        $obtan_all=array();
                                        $studentss=array();
                                        $res=@$this->db->select('total_marks,obtained_marks,student_id,promotion_id,result.id as rid')
                                                                   ->from('promotion')
                                                                   ->join('result','result.promotion_id=promotion.id')
                                                                   ->where('promotion.class_id',$cc)
                                                                   ->where('promotion.section_id',$ccsec)
                                                                   ->where('promotion.session_id',$session_id)
                                                                   ->where('result.exam_id',$exam_id)
                                                                   ->where('promotion.is_active',1)
                                                                   ->get()->result_array();
                                            //   var_dump('<pre>',$res);
                                            //   die();
                                    if(!empty($res))
                                    {
                                        foreach($res as $over=>$overall)
                                        {
                                              $tot_att="";
                                              $get_absent="";
                                              $get_att="";
                                              $sumass=0;
                                              $remov_assgmt=$this->db->select('sum(obtained_marks) as obtained_marks,sum(total_marks) as total_marks')
                                                                  ->from('result_subject')
                                                                  ->where('result_id',$overall['rid'])
                                                                  ->where('subexam_id >',0)
                                                                  ->where('is_delete',0)
                                                                  ->get()->row_array();
                                                // var_dump('<pre>',$remov_assgmt);
                                                // die();
                                            if(!empty($remov_assgmt))
                                            {
                                                if($remov_assgmt['total_marks']==0)
                                                {
                                                    $remov_assgmt['total_marks']=1;
                                                }
                                              $temp=number_format(($remov_assgmt['obtained_marks']/$remov_assgmt['total_marks'])*15,2);
                                              $myobtan=($overall['obtained_marks']-$remov_assgmt['obtained_marks'])+@$temp;
                                              
                                            }else
                                            {
                                                $myobtan=$overall['obtained_marks'];
                                            }
                                               $tot_att=$this->report_model->Studentattot($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               $get_absent=$this->report_model->StudentattAbsent($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               $get_att=$this->report_model->Studentatt($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               
                            $getall_status=$this->db->select('*')
                                             ->from('rept_crd')
                                            ->where('mystd_id',$overall['promotion_id'])
                                            ->where('myexm_id',$exam_id)
                                           ->where('sessoin_id',$session_id)
                                            ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                                    // var_dump('<pre>',$getall_status); 
                                    // die();
                                    if(!empty($getall_status))
                                    {
                                    $att=$getall_status['attend'];
                                    $absnt=$getall_status['absent'];
                                    $class_parti=$getall_status['class_parti'];
                                    $homework=$getall_status['homework'];
                                    $classwork=$getall_status['classwork'];
                                    $Behaviour=$getall_status['Behaviour'];
                                    $Uniform=$getall_status['Uniform'];
                                    $HHW=$getall_status['HHW'];
                                   $sumass=$att+$absnt+$class_parti+$homework+$classwork+$Behaviour+$Uniform+$HHW;
                                   $myobtan=$myobtan+@$sumass;
                                    }else
                                    {
                                   if(empty(@$tot_att[0]->att)) 
                                   {
                                       @$tot_att[0]->att=1;
                                   }
                $curr_att=round((@$get_att[0]->att/@$tot_att[0]->att)*100,2);
              
                                       if($curr_att>=100)
                                       {
                                           $att_mrks=10;
                                       }
                                       if($curr_att>=90 && $curr_att<100)
                                       {
                                           $att_mrks=8;
                                       }
                                        if($curr_att>=80 && $curr_att<90)
                                       {
                                           $att_mrks=7;
                                       }
                                        if($curr_att<80)
                                       {
                                           $att_mrks=0;
                                       }
                                    $myobtan=$myobtan+@$att_mrks;
                                     $abs_tot=@$get_absent[0]->late;
                                     
                                            if($abs_tot==4)
                                            {
                                               $trdi=-1; 
                                            }
                                             if($abs_tot==6)
                                            {
                                               $trdi=-2; 
                                            }
                                             if($abs_tot==5)
                                            {
                                               $trdi=-5; 
                                            }
                                             if($abs_tot==7)
                                            {
                                               $trdi=-8; 
                                            }
                                             if($abs_tot>8)
                                            {
                                               $trdi=-10; 
                                            }
                                            $myobtan=$myobtan+@$trdi;
                                          
                                          
                                    }  
                                    
                                    $obtan_all[$over]['id']=$overall['promotion_id'];
                                    $obtan_all[$over]['mrk']=$myobtan;
                                    
                                    
                                        }
                                        
                                        // var_dump('<pre>',$obtan_all);
                                           function build_sorter($key) {
                                             return function ($a, $b) use ($key) {
                                              return strnatcmp($a[$key], $b[$key]);
                                            };
                                             }
                                             $lastar=array();
                                             usort($obtan_all, build_sorter('mrk'));
                                             foreach ($obtan_all as $in=>$item) {
                                                 $lastar[$in]['id']=$item['id'];
                                                 $lastar[$in]['mrk']=$item['mrk'];
                                                  
                                                   }
                                                   $lastar=array_reverse($lastar);
                                        //             var_dump('<pre>',$lastar);
                                        //   die();
                                        if(!empty($lastar))
                                        {
                                            $i = 1;
                                            $prev_obtain_marks = "1st"; 
                                             $arr=array();
                                               foreach($lastar as $k=>$v)
                                                {
            if($prev_obtain_marks=="1st" OR $prev_obtain_marks!=$v["mrk"])
            {
                $p = $i;
                $i++;
            }else{
                $p = $i - 1;
            }
            if($p==1 OR $p==21 OR $p==31)
                $subfix = "st";
            else if($p==2 OR $p==22 OR $p==32 OR $p==42 OR $p==52 OR $p==62 OR $p==72 OR $p==82 OR $p==92)
                $subfix = "nd";
            else if($p==3 OR $p==23 OR $p==33 OR $p==43 OR $p==53 OR $p==63 OR $p==73 OR $p==83 OR $p==93)
                $subfix = "rd";
            else
                $subfix = "th";
            
            $arr[$k]['pos']=$p.$subfix; 
            $arr[$k]['id']=$v['id']; 
            
        }
        
         if(!empty($arr))
       {
           foreach($arr as $row=>$ky)
           {
             if($ky['id']==$stdd_id) 
             {
                 echo $ky['pos'];
             }
           }
           
       }
                                        }
                                  }
                                       ?>
    </b></td>
                                        
                                        
                                    </tr>
                                    <tr>
                                        <td>Class Highest %age: <b><?php 
                                        $vagmax=0;
                                        $vagmin=0;
                                        $obtan_all=array();
                                        
                                        $res=@$this->db->select('total_marks,obtained_marks,student_id,promotion_id,result.id as rid')
                                                                   ->from('promotion')
                                                                   ->join('result','result.promotion_id=promotion.id')
                                                                   ->where('promotion.class_id',$cc)
                                                                   ->where('promotion.section_id',$ccsec)
                                                                   ->where('promotion.session_id',$session_id)
                                                                   ->where('result.exam_id',$exam_id)
                                                                   ->where('promotion.is_active',1)
                                                                   ->get()->result_array();
                                            //   var_dump('<pre>',$res);
                                            //   die();
                                    if(!empty($res))
                                    {
                                        foreach($res as $over=>$overall)
                                        {
                                            $myobtan=0;
                                              $tot_att="";
                                              $get_absent="";
                                              $get_att="";
                                              $sumass=0;
                                                      $remov_ass=$this->db->select('sum(obtained_marks) as obtained_marks,sum(total_marks) as total_marks')
                                                                  ->from('result_subject')
                                                                  ->where('result_id',$overall['rid'])
                                                                  ->where('subexam_id >',0)
                                                                  ->where('is_delete',0)
                                                                  ->get()->row_array();
                                            if(!empty($remov_ass))
                                            {
                                                 if($remov_ass['total_marks']==0)
                                                {
                                                    $remov_ass['total_marks']=1;
                                                }
                                             $temp=number_format(($remov_ass['obtained_marks']/$remov_ass['total_marks'])*15,2);
                                              $myobtan=($overall['obtained_marks']-$remov_ass['obtained_marks'])+@$temp;
                                              
                                            }else
                                            {
                                                $myobtan=$overall['obtained_marks'];
                                            }
                                               $tot_att=$this->report_model->Studentattot($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               $get_absent=$this->report_model->StudentattAbsent($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               $get_att=$this->report_model->Studentatt($b,$cc,$ccsec,$overall['student_id'],$session_id);
                                               
                            $getall_status=$this->db->select('*')
                                             ->from('rept_crd')
                                            ->where('mystd_id',$overall['promotion_id'])
                                            ->where('myexm_id',$exam_id)
                                           ->where('sessoin_id',$session_id)
                                            ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                                    // var_dump('<pre>',$getall_status); 
                                    // die();
                                    if(!empty($getall_status))
                                    {
                                    $att=$getall_status['attend'];
                                    $absnt=$getall_status['absent'];
                                    $class_parti=$getall_status['class_parti'];
                                    $homework=$getall_status['homework'];
                                    $classwork=$getall_status['classwork'];
                                    $Behaviour=$getall_status['Behaviour'];
                                    $Uniform=$getall_status['Uniform'];
                                    $HHW=$getall_status['HHW'];
                                   $sumass=$att+$absnt+$class_parti+$homework+$classwork+$Behaviour+$Uniform+$HHW;
                               
                                   $myobtan=$myobtan+@$sumass;
                                    }else
                                    {
                                   if(empty(@$tot_att[0]->att)) 
                                   {
                                       @$tot_att[0]->att=1;
                                   }
                $curr_att=round((@$get_att[0]->att/@$tot_att[0]->att)*100,2);
              
                                       if($curr_att>=100)
                                       {
                                           $att_mrks=10;
                                       }
                                       if($curr_att>=90 && $curr_att<100)
                                       {
                                           $att_mrks=8;
                                       }
                                        if($curr_att>=80 && $curr_att<90)
                                       {
                                           $att_mrks=7;
                                       }
                                        if($curr_att<80)
                                       {
                                           $att_mrks=0;
                                       }
                                    $myobtan=$myobtan+@$att_mrks;
                                     $abs_tot=@$get_absent[0]->late;
                                     
                                            if($abs_tot==4)
                                            {
                                               $trdi=-1; 
                                            }
                                             if($abs_tot==6)
                                            {
                                               $trdi=-2; 
                                            }
                                             if($abs_tot==5)
                                            {
                                               $trdi=-5; 
                                            }
                                             if($abs_tot==7)
                                            {
                                               $trdi=-8; 
                                            }
                                             if($abs_tot>8)
                                            {
                                               $trdi=-10; 
                                            }
                                        
                                            $myobtan=$myobtan+@$trdi;
                                             
                                    }  
                                    
                                    $obtan_all[]=$myobtan;
                                        }
                                        $maxval = max($obtan_all);
                                        $minval = min($obtan_all);
                                         if(!empty($percn)){
                                         @$percn['total_marks']=@$percn['total_marks'];
                                         @$percn['obtained_marks']=$maxval;
                                        //  var_dump($percn['total_marks']);
                                        //   var_dump($percn['obtained_marks']);
                                        //      die();
                                         echo  number_format((@$percn['obtained_marks']/@$percn['total_marks'] )*100,2); 
                                         $vagmax=number_format((@$percn['obtained_marks']/@$percn['total_marks'] )*100,2); 
                                         $minval=number_format((@$minval/@$percn['total_marks'] )*100,2); 
                                         }else
                                         {
                                             echo "0";
                                         }
                                    }
                                       ?>%</b></td>
                                        <td>Class Lowest %age: <b>
                                            
                                        <?php
                                        
                                         if(!empty($lowes))
                                         {
                                          echo @$minval; 
                                         }
                                      
                                        ?>%
                                        </b></td>
                                        <td>Class Average %age: <b><?php 
                                       $su=@$vagmax+@$minval;
                                       
                                        echo number_format(@$su/2); ?>%</b></td>
                                        
                                        
                                    </tr>
                                    
                               
                            </table>
                            
                            <table class="table table-bordered">
                        <?php
                               $getall_status=$this->db->select('*')
                                                  ->from('rept_crd')
                                                  ->where('mystd_id',$stdd_id)
                                                  ->where('myexm_id',$exam_id)
                                                  ->where('myaddexam_id',$addexam_id)
                                            ->where('sessoin_id',$session_id)
                                            ->order_by('id','desc')
                                            ->limit(1)
                                            ->get()->row_array();
                                    if(!empty($getall_status))
                                    {
                                 
                                    $teacher_st=$getall_status['teacher_st'];
                                    $art=$getall_status['art'];
                                    $PE=$getall_status['PE'];
                                    $Music=$getall_status['Music'];
                                    }else
                                    {
                                      $teacher_st="";
                                      $art="";
                                      $PE="";
                                      $Music="";  
                                    }
                        ?>                   
                                   
                       <tr>
                                        <td>Art</td>
                                      
                                        <td style="width:20%;">
                                 <?php if($art=="A+"){echo "A+";}?>
                                 <?php if($art=="A"){echo "A";}?>
                                 <?php if($art=="B"){echo "B";}?>
                                 <?php if($art=="C"){echo "C";}?>
                                 <?php if($art=="D"){echo "D";}?>
                                 <?php if($art=="F"){echo "F";}?>
                                        </td>
                                        <td>PE</td>
                                        <td style="width:20%;">
                         <?php if($PE=="A+"){echo "A+";}?>
                                 <?php if($PE=="A"){echo "A";}?>
                                 <?php if($PE=="B"){echo "B";}?>
                                 <?php if($PE=="C"){echo "C";}?>
                                 <?php if($PE=="D"){echo "D";}?>
                                 <?php if($PE=="F"){echo "F";}?>
                                        </td>
                                        <td>Music</td>
                                        <td style="width:20%;">
                                 <?php if($Music=="A+"){echo "A+";}?>
                                 <?php if($Music=="A"){echo "A";}?>
                                 <?php if($Music=="B"){echo "B";}?>
                                 <?php if($Music=="C"){echo "C";}?>
                                 <?php if($Music=="D"){echo "D";}?>
                                 <?php if($Music=="F"){echo "F";}?>
                                        </td>
                                        
                                        
                                    </tr>
                            </table>
                            <p><strong>Class Teacher's Statement</strong></p>
                            <textarea readonly class="form-control" name="teacher_stement"><?php if(!empty($teacher_st)){ echo $teacher_st;}?></textarea>
                            <div class="row">
                                <div class="col-md-4"><strong>Class Teacher: <u>______________</u></strong></div>
                                <div class="col-md-4"><strong>Coordinator: <u>______________</u></strong></div>
                                <div class="col-md-4"><strong>Principal: <u>______________</u></strong></div>
                                
                            </div>
                            <br>
                            <table class="table table-bordered">
                                <thead style="text-align:center;">
                                    <tr>
                                        <th colspan="4">Rubric-Marks & Grade</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td style="text-align:center !important">90% And Above</td>
                                        <td style="width:30%;text-align:center !important"> A+</td>
                                        <td style="width:20%;text-align:center !important"></td>
                                        
                                    </tr>
                                    <tr>
                                        <td style="text-align:center !important">80% to 89%</td>
                                        <td style="width:30%;text-align:center !important">A</td>
                                        <td></td>
                                       
                                        
                                    </tr>
                                    <tr>
                                        <td style="text-align:center !important">70% to 79%</td>
                                        <td style="width:30%;text-align:center !important">B</td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td style="text-align:center !important">60% to 69%</td>
                                        <td style="width:30%;text-align:center !important">C</td>
                                        <td></td>
                                       
                                        
                                    </tr>
                                    <tr>
                                        <td style="text-align:center !important">50% to 59%</td>
                                        <td style="width:30%;text-align:center !important">D</td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td style="text-align:center !important">Below 50%</td>
                                        <td style="width:30%;text-align:center !important">F</td>
                                        <td></td>
                                        
                                        
                                    </tr>
                                    
                                </tbody>
                            </table>
                            
                        </div>
                </div>
              </div>

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

     <script>
      $(document).ready(function(){
        window.print();
      });
    </script>
    <script>
      
            $(document).on("keyup","#class_participation",function(){
                var val = parseInt($(this).val());
                var homework_presentation = parseInt($("#homework_presentation").val());
                var classwork_presentation = parseInt($("#classwork_presentation").val());
                var discipline = parseInt($("#discipline").val());
                var uniform = parseInt($("#uniform").val());
                var hhw = parseInt($("#hhw").val());
                 if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(homework_presentation))
                {
                    homework_presentation =0;
                }
                if(isNaN(classwork_presentation))
                {
                    classwork_presentation =0;
                }
                if(isNaN(discipline))
                {
                    discipline =0;
                }
                if(isNaN(uniform))
                {
                    uniform =0;
                }
                if(isNaN(hhw))
                {
                    hhw =0;
                }
                var total = val +classwork_presentation+homework_presentation+discipline+uniform+hhw;
              
                var  g_total = $("#g_total").val();
               
                
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                
                $("#grand_total").val(g_totals);
                
            });
             $(document).on("keyup","#homework_presentation",function(){
                var val = parseInt($(this).val());
                var class_participation = parseInt($("#class_participation").val());
                var classwork_presentation = parseInt($("#classwork_presentation").val());
                var discipline = parseInt($("#discipline").val());
                var uniform = parseInt($("#uniform").val());
                var hhw = parseInt($("#hhw").val());
                if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(class_participation))
                {
                    class_participation =0;
                }
                if(isNaN(classwork_presentation))
                {
                    classwork_presentation =0;
                }
                if(isNaN(discipline))
                {
                    discipline =0;
                }
                if(isNaN(uniform))
                {
                    uniform =0;
                }
                if(isNaN(hhw))
                {
                    hhw =0;
                }
                var total = val +classwork_presentation+class_participation+discipline+uniform+hhw;
                var  g_total = $("#g_total").val();
               
                
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                 $("#grand_total").val(Math.abs(g_totals));
            });
             $(document).on("keyup","#classwork_presentation",function(){
                var val = parseInt($(this).val());
                var homework_presentation = parseInt($("#homework_presentation").val());
                var class_participation = parseInt($("#class_participation").val());
                var discipline = parseInt($("#discipline").val());
                var uniform = parseInt($("#uniform").val());
                var hhw = parseInt($("#hhw").val());
                 if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(class_participation))
                {
                    class_participation =0;
                }
                if(isNaN(homework_presentation))
                {
                    homework_presentation =0;
                }
                if(isNaN(discipline))
                {
                    discipline =0;
                }
                if(isNaN(uniform))
                {
                    uniform =0;
                }
                if(isNaN(hhw))
                {
                    hhw =0;
                }
                var  g_total = $("#g_total").val();
                var total = val +class_participation+homework_presentation+discipline+uniform+hhw;
                
                
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                 $("#grand_total").val(Math.abs(g_totals));
                
            });
             $(document).on("keyup","#discipline",function(){
                var val = parseInt($(this).val());
                var homework_presentation = parseInt($("#homework_presentation").val());
                var classwork_presentation = parseInt($("#classwork_presentation").val());
                var class_participation = parseInt($("#class_participation").val());
                var uniform = parseInt($("#uniform").val());
                var hhw = parseInt($("#hhw").val());
                 if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(class_participation))
                {
                    class_participation =0;
                }
                if(isNaN(homework_presentation))
                {
                    homework_presentation =0;
                }
                if(isNaN(classwork_presentation))
                {
                    classwork_presentation =0;
                }
                if(isNaN(uniform))
                {
                    uniform =0;
                }
                if(isNaN(hhw))
                {
                    hhw =0;
                }
                var  g_total = $("#g_total").val();
                var total = val +classwork_presentation+homework_presentation+class_participation+uniform+hhw;
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                 $("#grand_total").val(Math.abs(g_totals));
            });
            
            $(document).on("keyup","#uniform",function(){
                var val = parseInt($(this).val());
                var homework_presentation = parseInt($("#homework_presentation").val());
                var classwork_presentation = parseInt($("#classwork_presentation").val());
                var class_participation = parseInt($("#class_participation").val());
                var discipline = parseInt($("#discipline").val());
                var hhw = parseInt($("#hhw").val());
                if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(class_participation))
                {
                    class_participation =0;
                }
                if(isNaN(homework_presentation))
                {
                    homework_presentation =0;
                }
                if(isNaN(classwork_presentation))
                {
                    classwork_presentation =0;
                }
                if(isNaN(discipline))
                {
                    discipline =0;
                }
                if(isNaN(hhw))
                {
                    hhw =0;
                }
                var  g_total = $("#g_total").val();
                var total = val +classwork_presentation+homework_presentation+class_participation+discipline+hhw;
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                 $("#grand_total").val(Math.abs(g_totals));
            });
            $(document).on("keyup","#hhw",function(){
                var val = parseInt($(this).val());
                var homework_presentation = parseInt($("#homework_presentation").val());
                var classwork_presentation = parseInt($("#classwork_presentation").val());
                var class_participation = parseInt($("#class_participation").val());
                var uniform = parseInt($("#uniform").val());
                var discipline = parseInt($("#discipline").val());
                 if(isNaN(val))
                {
                    val =0;
                }
                if(isNaN(class_participation))
                {
                    class_participation =0;
                }
                if(isNaN(homework_presentation))
                {
                    homework_presentation =0;
                }
                if(isNaN(classwork_presentation))
                {
                    classwork_presentation =0;
                }
                if(isNaN(discipline))
                {
                    discipline =0;
                }
                if(isNaN(uniform))
                {
                    uniform =0;
                }
                
                var total = val +classwork_presentation+homework_presentation+class_participation+uniform+discipline;
                
                var  g_total = $("#g_total").val();
                
                $("#total").val(Math.abs(total));
                var g_totals = +total + +g_total;
                 $("#grand_total").val(Math.abs(g_totals));
            });
            
            var number = document.getElementById('homework_presentation');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
             var number = document.getElementById('uniform');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
             var number = document.getElementById('classwork_presentation');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
             var number = document.getElementById('discipline');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
             var number = document.getElementById('class_participation');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
             var number = document.getElementById('hhw');
            number.onKeydown = function(e)
            {
                if(!((e.keyCode>95 && e.keyCode<106) || (e.keyCode>47 && e.keyCode<58) || e.keyCode== 8)){
                    return false;
                }
            }
    </script>
  </body>
</html>