        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Result List</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <input type="hidden" id="clas" value="<?php echo $clas; ?>">
                  <input type="hidden" id="sec" value="<?php echo $section; ?>">
                  <input type="hidden" id="exam" value="<?php echo $examtype; ?>">
                  <div class="x_content">

                    <table class="table table-striped table-bordered" style="width:100%;"  id="datatable-buttons">
                      <thead>
                        <tr>
                        
                          <th>#</th>
                          <th>S.Id</th>
                          <th>Student Name</th>
                          <th>Parent Name</th>
                          <th>Total Marks</th>
                          <th>Obtained Marks</th>
                          <th>Action</th>
                        </tr>
                      </thead>
                      <tbody>
                          <?php $i=1;$smtot=0;$smobt=0; $results=[]; 
                         
                          foreach ($student as $key => $value) {
                              
                          $this->db->select('sum(total_marks) as tot');
                          $this->db->from('result_subject');
                          $this->db->where('result_id',$value['id']);
                          $this->db->where('subexam_id >',0);
                        //   if(!empty($sub_typeid))
                        //   {
                        //       $this->db->where('subexam_id',$sub_typeid);
                        //   }
                           
                          $this->db->where('is_delete',0);
                          $smtot=  $this->db->get()->row_array()['tot'];
                                  
                                  
                                          
                          $this->db->select('sum(obtained_marks) as obt');
                          $this->db->from('result_subject');
                          $this->db->where('result_id',$value['id']);
                          $this->db->where('subexam_id >',0);
                        // if(!empty($sub_typeid))
                        //   {
                        //       $this->db->where('subexam_id',$sub_typeid);
                        //   }
                         
                          $this->db->where('is_delete',0);
                          $smobt=$this->db->get()->row_array()['obt']; 
                          
                          ?>
                          <tr>
                            <td><?php echo $i++;?></td>
                            <td><?php echo $value['sid'];?></td>
                            <td><?php echo $value['student_name'];?></td> 
                            <td><?php echo $value['father_name'];?></td>
                            <td><?php if(empty($smtot)){ echo 0;}else{ echo $smtot;}?></td>
                            <td><?php if(empty($smobt)){ echo 0;}else{ echo $smobt;}?></td>
                            <td>
                                <?php if($smobt!=0){
                                ?>
                                <a target="_blank" href="<?php echo base_url();?>exam/assprintview/<?php echo $value['id'];?>"<i class="fa fa-eye" aria-hidden="true"></i></a>
                                <?php } ?>
                            </td>
                          </tr>
                          <?php $results[]=$value['id'];
                          } 
                          $results_encoded = base64_encode(json_encode($results));
                          ?>
                      </tbody>
                    </table>
                    <div class="row">
                      <div class="col-md-12 text-right">
                          <?php if($smobt!=0){?>
                        <a href="<?php echo base_url();?>Exam/assprintviewclass/<?php echo $results_encoded;?>" target="_blank">
                          <button class="btn btn-success">Print All</button>
                        </a>
                         <?php } ?>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
        
      </div>
    </div>
 <!-- footer content -->
        <footer>
          <div class="pull-right">
            Prudmac
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
    <!-- jQuery -->
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
<script>
        $(document).ready(function(){
            $(document).on("change","#branch",function(){
                var value = $(this).val();
                $.get("<?php echo base_url(); ?>load/classs/role/"+value,{},function(d){
                    var pre = '<option value="">Select Class</opiton>';
                    $("#class").html(pre+d);
                });
            });
            
        });
          $(document).ready(function(){
            $(document).on("change","#class",function(){
                var value = $(this).val();
                $.get("<?php echo base_url(); ?>load/section/role/"+value,{},function(d){
                    var pre = '<option value="">Select Class</opiton>';
                    $("#section").html(pre+d);
                });
            });
            
        });
          $(document).ready(function(){
            $(document).on("change","#class",function(){
                var value = $(this).val();
                $.get("<?php echo base_url(); ?>load/exam/"+value,{},function(d){
                    var pre = '<option value="">Select Exam</opiton>';
                    $("#exam").html(pre+d);
                });
            });
            
        });
    </script>



      <!-- /page content -->
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
      <script src="<?php echo base_url(); ?>assets/vendors/jszip/dist/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/vfs_fonts.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-scroller/js/datatables.scroller.min.js"></script>
  
     <script>
$(document).ready(function(){
 var clas=$('#clas').val();
var section=$('#sec').val();
var exam=$('#exam').val();
            $(document).ajaxStart(function() {
                $('#ajaxload').show();
            });
            
        // $('#datatable-buttons').DataTable();
   $.ajax({
    url: '<?php echo base_url(); ?>Exam/ClassWiseResultReport/',data: {},
         success: function (result) {
            
      $(document).ajaxStop(function() {
           $('#ajaxload').hide();
      });
        
        
             console.log(result);
              $("#datatable-buttons").dataTable().fnDestroy();
               setTimeout(function(){
               
               $("tbody.center").html(result);
                $("#datatable-buttons").DataTable({
                    dom: "lBfrtip",
              "bPaginate": true,
              "pageLength":35,
              "lengthMenu": [[35, 70, 100, -1], [35, 70, 100, "All"]],
               
             buttons: [
                 {
                  extend: "print",
                  className: "btn-sm"
                },
                {
                  extend: "copy",
                  className: "btn-sm"
                },
                {
                  extend: "csv",
                  className: "btn-sm"
                },
                {
                  extend: "excel",
                  className: "btn-sm"
                },
                {
                extend: 'pdf',
                className: "btn-sm"
                
                },
              ],
              responsive: true
            });
            },500);
           }
     });//end ajax for loading form


});
</script>
        