<style>
.add-exam-log-section{box-shadow:0 0 2px silver;}    
</style>
<?php 
$sub_id=$this->uri->segment('4');
$sid=$this->uri->segment('3');
$class='';
$get_student_data=$this->ExamModel->get_student_data($sid);
$exam_type = '';


$subject_title='';
$get_subject_data=$this->ExamModel->get_subject_data($sub_id);
if($get_subject_data){
foreach($get_subject_data as $subject_data){
$subject_title=$subject_data['subject'];
$exam_type=$subject_data['exam_type'];
}
}
?>

<div class="container-fluid mt-3 mb-3">
<div class="row">
<div class="col-sm-12">


<h3 class="text-center">SESSION 2020 - 21</h3>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>NAME</th>
<!--<th>ROLL NO.</th>-->
<th>CLASS-SEC</th>
<th>SCHOLAR NO.</th>
<th>D.O.B</th>
<th>HOUSE</th>
<th>ATTENDANCE</th>
</tr>
</thead>
<tbody>
<?php 
if($get_student_data){
foreach($get_student_data as $student_data){
$class=$student_data['class'];
?>
<tr>
<td><?php echo $student_data['student_name'];?></td>

<td><?php echo $student_data['class']; echo "-"; echo $student_data['section'];?></td>
<td><?php echo $student_data['sch_no'];?></td>
<td><?php echo $student_data['dob'];?></td>


<td>hh</td>
<td>##</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>

<div class="add-exam-log-section  p-3">
<form method="post" action="#">
<h3>Add Log</h3>    

<?php
if($success){
// echo '<div class="alert alert-success" role="alert">'.$success.'</div>';


echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
  <strong>'.$success.'
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>';
}

if($error){
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>'.$error.'
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>';
}

?>  

<div class="form-group">
<label>Subject</label>
<input type="text" value="<?php echo $subject_title;?>" class="form-control" readonly >
</div>







<?php
$get_exam_heads=$this->ExamModel->get_exam_heads($class);
if($get_exam_heads){
foreach($get_exam_heads as $exam_heads){

$ehid=$exam_heads['id'];
if($exam_type !='grade'){
if( $exam_heads['mm'] !=50 ){
    
$get_exam_single_log=$this->ExamModel->get_single_log($ehid,$sub_id,$sid);
$obm=''; $obg='';
if($get_exam_single_log){
foreach($get_exam_single_log as $exam_single_log){
$obm=$exam_single_log['obtained_marks'];
$obg=$exam_single_log['grade'];

?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid;?>" value="<?php if($exam_type =='marks'){echo $exam_single_log['obtained_marks'];}else if($exam_type =='grade'){echo $exam_single_log['grade'];} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>"   >    
</div>
<?php
}
}else{
?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid; ?>" value="<?php if($exam_type =='marks'){echo $obm;}else if($exam_type =='grade'){echo $obg;} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>
<?php
}

}else if($exam_heads['mm'] == 50){  
    

$get_exam_single_log=$this->ExamModel->get_single_log($ehid,$sub_id,$sid);
$obm=''; $obg='';
if($get_exam_single_log){
foreach($get_exam_single_log as $exam_single_log){
$obm=$exam_single_log['obtained_marks'];
$obg=$exam_single_log['grade'];

?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid;?>" value="<?php if($exam_type =='marks'){echo $exam_single_log['obtained_marks'];}else if($exam_type =='grade'){echo $exam_single_log['grade'];} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>
<?php
}
}else{
?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid; ?>" value="<?php if($exam_type =='marks'){echo $obm;}else if($exam_type =='grade'){echo $obg;} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>
<?php
}

    
    
}

}

else{
    
if($class=='PG' || $class=='LKG' || $class== 'UKG'){

$get_exam_single_log=$this->ExamModel->get_single_log($ehid,$sub_id,$sid);
$obm=''; $obg='';
if($get_exam_single_log){
foreach($get_exam_single_log as $exam_single_log){

$obm=$exam_single_log['obtained_marks'];
$obg=$exam_single_log['grade'];

?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid;?>" value="<?php if($exam_type =='marks'){echo $exam_single_log['obtained_marks'];}else if($exam_type =='grade'){echo $exam_single_log['grade'];} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>

<?php
}
}else{
?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid; ?>" value="<?php if($exam_type =='marks'){echo $obm;}else if($exam_type =='grade'){echo $obg;} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>
<?php
}

}else{
    

    
if($exam_heads['mm'] == 0 || $exam_heads['mm'] == 50){
$get_exam_single_log=$this->ExamModel->get_single_log($ehid,$sub_id,$sid);
$obm=''; $obg='';
if($get_exam_single_log){
foreach($get_exam_single_log as $exam_single_log){

$obm=$exam_single_log['obtained_marks'];
$obg=$exam_single_log['grade'];

?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid;?>" value="<?php if($exam_type =='marks'){echo $exam_single_log['obtained_marks'];}else if($exam_type =='grade'){echo $exam_single_log['grade'];} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>

<?php
}
}else{
?>
<div class="form-group">
<label><?php echo $exam_heads['exam_head'];  ?></label>
<input type="text" class="form-control" name="<?php echo $ehid; ?>" value="<?php if($exam_type =='marks'){echo $obm;}else if($exam_type =='grade'){echo $obg;} ?>"  placeholder="<?php echo $exam_heads['exam_head']; ?>">    
</div>
<?php
}
}

}

}    
    
}
}
?>



<!--<div class="form-group">-->
<!--<input type="text" name="max_marks" class="form-control" readonly>-->
<!--</div>-->

<!--<div class="form-group">-->
<!--<input type="text" class="form-control" name="obt_marks" placeholder="Enter Marks / Grade">-->
<!--</div>-->

<div class="form-group">
<input type="submit" name="add_marks" class="btn btn-sm btn-success" value="Update Marks">
</div>

</form>
</div>



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