<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Load extends CI_Controller {

	private $userInfo = array();

    public function __construct()
    {
        parent::__construct();
		        $this->load->model("User_model");
                $this->load->model("Teacher_model");
                $this->load->model("Performance_model");
                $this->load->model("Staff_model");
                $this->load->model("salary_model");
               // $this->load->model("user_model");
                
                 
		//$this->userInfo = $this->user_model->userInfo("first_name,last_name");
    }
    
      public function fetch_subjets_list($c="")
    {
        $result = $this->db->query("SELECT subject.id,subject.name FROM `subject`  WHERE subject.class_id='$c' AND subject.is_deleted='0'")->result_array();
            foreach ($result as $key => $value) {
               echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
    }
    
     public function exam_prev($b="1")
    {
        if(!empty($b))
        {
            $this->db->select("exam.name,exam.id");
            $this->db->from("exam");
            $this->db->join("exam_type","exam_type.id= exam.etype_id");
            $this->db->where("exam.is_delete",0);
            $this->db->where("exam_type.is_delete",0);
            $result = $this->db->get()->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }
    
     public function sectionbase($value=0,$se=0)
            {
                    $this->db->select('student.id,student.student_name,student.roll_no,student.grno,roll_no,class.class_name,section.section_name');    
                        $this->db->from('student');
                        $this->db->join('promotion pro', 'pro.student_id=student.id');
                        $this->db->join('class', 'class.class_id=pro.class_id');
                        $this->db->join('session ', 'session.id=pro.session_id');
                        $this->db->join('section', 'section.section_id=pro.section_id')
                        ->where('student.status',0)
                        ->where('pro.class_id',$value)
                        ->where('pro.is_active',1)
                        ->where('pro.is_delete',0)
                        ->where('pro.section_id',$se);
                        $result = $this->db->get()->result_array();
                                        foreach ($result as $key => $value) {
                                            echo "<option value='".$value['id']."'>".$value['student_name']."</option>";
                                        }
            }
            
 public function section_prev($branch="",$v="")
    {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' and branch='$branch' AND is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        
    }
    
    public function load_section($v="")
    {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        
    }
    
     public function studentagainstclassreport($value=0,$value2='')
    {
        $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
          
        $this->db->join('section', 'section.section_id=pro.section_id')
        ->where('student.gender',$value2)
        ->where('student.status',0)
        ->where('pro.class_id',$value);
        $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
        $query = $this->db->get()->result_array();
        $data=$this->Teacher_model->AttendanceStatus();
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['sid']."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['father_name']."</td>";
            $return .= "<td>".$value['class_name']."</td>";
            $return .= "<td>".$value['section_name']."</td>";
            $return .="<td>";
         
                $return .= "</td>";
                $return .= "</tr>"; 
                }
                echo $return;
            }
        
    public function checkall_provident($id,$ref)
    {
    $er=$this->db->where('bothid',$id)->where('refrence',$ref)->where('status',0)->get('provident_fund')->result_array();
       echo json_encode($er);

   }
   
    public function date_time($cls='',$sub='',$exam='',$brnch='')
    {
        
        
        $query=$this->db->select('*')  
                   ->from('datesheet')
                  ->where('class_id',$cls)
                ->where('subject_id',$sub)
                ->where('exam_id',$exam)
                ->where('bid',$brnch)
                ->where('is_delete',0)
                ->limit(1)
                ->order_by('datesheet_id','desc')
               ->get()->row();
        if(!empty($query))
        {
             echo json_encode($query);
        }else
        {
            echo 0;
        }
          
    }


    public function studentagainstclassattendsreport($value=0)
    {
        $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name,seat_no');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
        $this->db->join('seating_plans', 'seating_plans.student_id=student.id');
        $this->db->join('section', 'section.section_id=pro.section_id');
        $this->db->order_by('section.section_id asc');
        $this->db->where('student.status',0)
        ->where('student.is_delete',0)
        ->where('pro.class_id',$value);
        $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
        $query = $this->db->get()->result_array();
      
        $return="";
        $i=1;
        
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['father_name']."</td>";
            $return .= "<td>".$value['class_name']."</td>";
            
             $return .= "<td>".$value['seat_no']."</td>";
             $return .= "<td></td>";
            $return .="<td>";
         
                $return .= "</td>";
                $return .= "</tr>"; 
                }
                echo $return;
            }
            
    public function studentagainstclasstagsreport($valll=0,$value2='')
    {
        $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name,seat_no');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
        $this->db->join('seating_plan', 'seating_plan.student_id=student.id');
     
        $this->db->join('section', 'section.section_id=pro.section_id');
        
            $this->db->order_by('section.section_id asc');
        $this->db->where('student.branch',$valll);
        $this->db->where('seating_plan.branch',$valll)
        ->where('student.status',0)
        ->where('pro.class_id',$value);
        $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
        $query = $this->db->get()->result_array();
      
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['father_name']."</td>";
            $return .= "<td>".$value['class_name']."</td>";
            $return .= "<td>".$value['section_name']."</td>";
             $return .= "<td>".$value['seat_no']."</td>";
            $return .="<td>";
         
                $return .= "</td>";
                $return .= "</tr>"; 
                }
                echo $return;
            }


public function studentagainstsectionreport($value=0,$se=0,$value2='')
            {
        
                $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
$this->db->join('section', 'section.section_id=pro.section_id')
->where('student.gender',$value2)
->where('student.status',0)
->where('pro.class_id',$value)
            ->where('pro.section_id',$se);
                $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
                $query = $this->db->get()->result_array();
                $data=$this->Teacher_model->AttendanceStatus();
                $return="";
                $i=1;
                foreach ($query as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['sid']."</td>";
                    $return .= "<td>".$value['roll_no']."</td>";
                    $return .= "<td>".$value['student_name']."</td>";
                    $return .= "<td>".$value['father_name']."</td>";
                    $return .= "<td>".$value['class_name']."</td>";
                    $return .= "<td>".$value['section_name']."</td>";
                    $return .="<td>";
                   
                        $return .= "</td>";
                        $return .= "</tr>"; 
                        }
                        echo $return;
                    }
    
    public function studentagainstsectionattendsreport2($value=0,$se=0,$val)
    {
            $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name,seat_no');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
		$this->db->join('section', 'section.section_id=pro.section_id');
		$this->db->join('seating_plans', 'seating_plans.student_id=student.id')
		->where('student.gender',$val)
		->where('student.status',0)
		->where('pro.class_id',$value)
            ->where('pro.section_id',$se);
                $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
                $query = $this->db->get()->result_array();
                $data=$this->Teacher_model->AttendanceStatus();
                $return="";
                $i=1;
                foreach ($query as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['roll_no']."</td>";
                   
                    $return .= "<td>".$value['student_name']."</td>";
                    $return .= "<td>".$value['father_name']."</td>";
                    $return .= "<td>".$value['class_name']."</td>";
                    
                    $return .= "<td>".$value['seat_no']."</td>";
                    $return .= "<td></td>";
                    $return .="<td>";
                   
                        $return .= "</td>";
                        $return .= "</tr>"; 
                        }
                        echo $return;
    }
public function studentagainstsectionattendsreport($value=0,$se=0)
            {
        
                $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name,seat_no');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
		$this->db->join('section', 'section.section_id=pro.section_id');
		$this->db->join('seating_plans', 'seating_plans.student_id=student.id')
		->where('student.status',0)
		->where('pro.class_id',$value)
            ->where('pro.section_id',$se);
                $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
                $query = $this->db->get()->result_array();
                $data=$this->Teacher_model->AttendanceStatus();
                $return="";
                $i=1;
                foreach ($query as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['roll_no']."</td>";
                   
                    $return .= "<td>".$value['student_name']."</td>";
                    $return .= "<td>".$value['father_name']."</td>";
                    $return .= "<td>".$value['class_name']."</td>";
                    
                    $return .= "<td>".$value['seat_no']."</td>";
                    $return .= "<td></td>";
                    $return .="<td>";
                   
                        $return .= "</td>";
                        $return .= "</tr>"; 
                        }
                        echo $return;
                    }                
                    

         public function TeacherdeductSerch($id='')
    {
            $branch=$this->user_model->getbranch();
        
        $this->db->select('deduction.id,teacher.firstname,teacher.lastname,deduction.refrence,deduction.reason,deduction.amount,deduction.month');    
        $this->db->from('deduction');
        $this->db->join('teacher', 'teacher.id=deduction.bothid');
        $this->db->where('deduction.status',0)->where('deduction.is_delete',0)->where('deduction.refrence','teacher')->where('teacher.branch',$branch);
            $query = $this->db->like('teacher.firstname',$id)->limit(20,0)->get()->result();
           echo json_encode($query);
    }
     public function staffdeductSerch($id='')
    {
            $branch=$this->user_model->getbranch();
        
        $this->db->select('deduction.id,staff.firstname,staff.lastname,deduction.refrence,deduction.reason,deduction.amount,deduction.month');    
        $this->db->from('deduction');
        $this->db->join('staff', 'staff.id=deduction.bothid');
        $this->db->where('deduction.status',0)->where('deduction.is_delete',0)->where('deduction.refrence','staff')->where('staff.branch',$branch);
            $query = $this->db->like('teacher.firstname',$id)->limit(20,0)->get()->result();
           echo json_encode($query);
    }




      public function StaffSecurtySerch($id='')
    {
            $branch=$this->user_model->getbranch();
            $this->db->select('security_deduct.id,staff.firstname,staff.lastname,security_deduct.refrence,security_deduct.security_amount,security_deduct.detuct_amount,security_deduct.remendar_amount,security_deduct.month');    
            $this->db->from('security_deduct');
            $this->db->join('staff', 'staff.id=security_deduct.bothid');
            $this->db->where('security_deduct.status',0)->where('security_deduct.is_delete',0)->where('staff.branch',$branch)->where('security_deduct.refrence','staff');
            $query = $this->db->like('staff.firstname',$id)->limit(20,0)->get()->result();
           echo json_encode($query);
    }

       public function TeacherSecurtySerch($id='')
    {
            $branch=$this->user_model->getbranch();
            $this->db->select('security_deduct.id,teacher.firstname,teacher.lastname,security_deduct.refrence,security_deduct.security_amount,security_deduct.detuct_amount,security_deduct.remendar_amount,security_deduct.month');    
            $this->db->from('security_deduct');
            $this->db->join('teacher', 'teacher.id=security_deduct.bothid');
            $this->db->where('security_deduct.status',0)->where('teacher.branch',$branch)->where('security_deduct.is_delete',0)->where('security_deduct.refrence','teacher');
            $query = $this->db->like('teacher.firstname',$id)->limit(20,0)->get()->result();
            echo json_encode($query);
    }

    public function user($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`first_name`,`last_name` FROM `admin` WHERE `role_id`='$v' AND is_delete ='0' ")->result_array();
                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['first_name'].' '.$value['last_name'].'</option>';
                }
            }
            else
                echo "";
        }
    }
        public function user1($v="")
    {
        
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`first_name`,`last_name` FROM `admin` WHERE `id`='$v' AND is_delete ='0' ")->result_array();
                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['first_name'].' '.$value['last_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
    
    public function student($cl=0,$se=0)
    {
        
            if(!empty($cl && $se))
            {
                $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cl' and promotion.section_id='$se' AND promotion.is_active='1' AND student.status='0' AND student.is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
    
     public function student_left($cl=0,$se=0,$ses=0)
    {
        $branch=$this->user_model->getbranch();
        if($branch==1)
        {
            $st_status=21;
        }else{
            $st_status=23;
        }
        
            if(!empty($cl && $se && $ses))
            {
                $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cl' and promotion.section_id='$se' and promotion.session_id='$ses' AND promotion.is_active='1' AND student.status='$st_status'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
    
    public function student_session($cl=0,$se=0,$session)
    {
        
            if(!empty($cl && $se && $session))
            {
                $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cl' and promotion.section_id='$se' AND promotion.session_id='$session' AND student.status='0' AND student.is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
     public function student1($se=0)
    {
        
            if(!empty($se))
            {
                $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.section_id='$se' AND promotion.is_active='1' AND student.status='0' AND student.is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }

    public function studentClassWise($cl='')
    {
        
            if(!empty($cl))
            {
                    $branch=$this->user_model->getbranch();
               $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cl' AND promotion.is_active='1' AND student.status='0' AND student.is_delete='0' AND student.branch='$branch'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
     public function teacherWise()
    {
        
            
                    $branch=$this->user_model->getbranch();
               $result = $this->db->query("SELECT teacher.id,teacher.firstname,teacher.lastname,teacher.designation,teacher.contact,teacher.qualification,teacher.doj,teacher.dob,teacher.salery,teacher.specialization ,status.name FROM `teacher` inner join `status` on teacher.status = status.id   WHERE teacher.branch = '$branch' AND teacher.is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'"> .'.$value['firstname'].'</option>';
                }
            
            
        
    }
    
       public function staffWise()
    {
        
            
                    $branch=$this->user_model->getbranch();
               $result = $this->db->query("SELECT staff.id,staff.firstname,staff.lastname,staff.designation,staff.contact,staff.qualification,staff.doj,staff.dob,staff.salery,staff.specialization ,status.name FROM `staff` inner join `status` on staff.status = status.id   WHERE staff.branch = '$branch' AND staff.is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'"> .'.$value['firstname'].'</option>';
                }
            
            
        
    }
    
     public function get_section_students($cl,$se,$date)
            {
                $branch=$this->user_model->getbranch();
$result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no
                           from `student` inner join `promotion` on student.id=promotion.student_id 
                           where promotion.class_id='$cl'AND promotion.section_id='$se' AND promotion.is_active='1' AND student.status='0' AND student.is_delete='0'
                            AND student.branch='$branch'")->result_array();
        foreach ($result as $key => $value) {
     $emppp=$value['id'];  
                       $query1122=$this->db->where('student_id',$emppp)
                       ->where('date',$date)
                       ->get('studentatt')->row();
                      if(count($query1122)==0){

     echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';

                }
            
        }
            }
            
     
  public function teachersms($id) 
        {
          //var_dump($id);

         $data=$this->db->select('*')->from('teacher')->where('branch',$id)->where('is_delete',0)->where('status',0)->get()->result(); 
       
      
             $return="";
             foreach ($data as $key => $value) {
                
                $return.="<option value='$value->id'>".$value->firstname." " .$value->lastname."
</option>";  
             }
        echo $return;

        }

  public function staffsms($id) 
        {
          //var_dump($id);

         $data=$this->db->select('*')->from('staff')->where('branch',$id)->where('is_delete',0)->where('status',0)->get()->result(); 
       
      
             $return="";
             foreach ($data as $key => $value) {
                
                $return.="<option value='$value->id'>".$value->firstname." " .$value->lastname."</option>";  
             }
        echo $return;

        }



public function students($branch='',$class='',$section='',$session='')
    {
        
            if(!empty($branch) && !empty($class) && !empty($section) && !empty($session))
            {
               $result = $this->db->query("select promotion.id,student.sid,student.student_name,student.roll_no from `promotion` inner join `student` on student.id=promotion.student_id where promotion.class_id='$class' and promotion.section_id='$section' AND promotion.session_id=$session AND promotion.is_active='1' AND promotion.is_delete='0' AND student.branch='$branch'")->result_array();

                foreach ($result as $key => $value) {
                    echo '<option value="'.$value['id'].'" >'.$value['roll_no']." - ".$value['student_name'].'</option>';
                }
            }
            else
                echo "";
        
    }
    
      public function classs_seating2($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v' and orderr<=5  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }
            }
            else
                echo "";
        }
    }
    
      public function classs_seating($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    
                    $check_pln=$this->db->select('*')
                                        ->from('promotion')
                                        ->where('class_id',$value['class_id'])
                                        ->where('is_active',1)
                                        ->where('is_delete',0)
                                        ->get()->result_array();
                        if(!empty($check_pln)) 
                        {
                            $count=0;
                            foreach($check_pln as $row=>$ro){
                                $check_status=$this->db->select('*')
                                                       ->from('seating_plans')
                                                       ->where('student_id',$ro['student_id'])
                                                       ->where('is_delete',0)
                                                       ->get()->row_array();
                                        if(!empty($check_status))
                                        {
                                            $count=$count+1;
                                        }
                            }
                            if($count==0)
                            {
                                echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                            }
                        }
                    
                }
            }
            else
                echo "";
        }
    }
    
    public function classss($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    
                    $check_pln=$this->db->select('*')
                                        ->from('promotion')
                                        ->where('class_id',$value['class_id'])
                                        ->where('is_active',1)
                                        ->where('is_delete',0)
                                        ->get()->result_array();
                        if(!empty($check_pln)) 
                        {
                            $count=0;
                            foreach($check_pln as $row=>$ro){
                                $check_status=$this->db->select('*')
                                                       ->from('seating_plan')
                                                       ->where('student_id',$ro['student_id'])
                                                       ->where('is_delete',0)
                                                       ->get()->row_array();
                                        if(!empty($check_status))
                                        {
                                            $count=$count+1;
                                        }
                            }
                            if($count==0)
                            {
                                echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                            }
                        }
                    
                }
            }
            else
                echo "";
        }
    }
    public function student_classs($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $student_id =$this->user_model->userInfo('student_id')['student_id'];
                $result = $this->db->query("SELECT class.`class_id`,`class_name`  FROM `class` JOIN promotion ON class.class_id = promotion.class_id WHERE promotion.student_id = '$student_id' AND `branch`='$v'  AND class.is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                    
                }
            }
            else
                echo "";
        }
    }
    public function classs($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                    
                }
            }
            else
                echo "";
        }
    }
    public function classs_defaulter($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $month = date("Y-m");
			    $date = date("Y-m-d");
			    $this->db->select("invoice.id as invoice_id,student.father_contact,student.grno,roll_no,student.student_name")
                    			 ->from("student")
                    			 ->join("promotion","promotion.student_id=student.id")
                    			 ->join("invoice","invoice.student_id=promotion.id")
                    			 ->where("student.status","0")
                    			 ->where("promotion.is_delete","0")
                    			 ->where("promotion.is_active","1")
                    			 ->where("invoice.is_delete","0")
                    			 ->where("invoice.branch_id",$v)
                    			 ->where("invoice.status","0")
                    			 ->where("LEFT(invoice.date,7)",$month);
                echo $students =count($this->db->get()->result());
            }
            else
                echo "";
        }
    }
    public function classs_defaulter_sclass($condition="",$class_id="")
    {
        if($condition=="role")
        {
                $month = date("Y-m");
			    $date = date("Y-m-d");
			    $this->db->select("invoice.id as invoice_id,student.father_contact,student.grno,roll_no,student.student_name")
                    			 ->from("student")
                    			 ->join("promotion","promotion.student_id=student.id")
                    			 ->join("invoice","invoice.student_id=promotion.id")
                    			 ->where("student.status","0")
                    			 ->where("promotion.is_delete","0")
                    			 ->where("promotion.is_active","1")
                    			 ->where("invoice.is_delete","0")
                    			 ->where("invoice.status","0")
                    			 ->where("LEFT(invoice.date,7)",$month)
                    			 ->where("promotion.class_id",$class_id);
                echo $students =count($this->db->get()->result());
            
        }
    }
    public function classs_defaulter_ssection($condition="",$section_id="")
    {
        if($condition=="role")
        {
                $month = date("Y-m");
			    $date = date("Y-m-d");
			    $this->db->select("invoice.id as invoice_id,student.father_contact,student.grno,roll_no,student.student_name")
                    			 ->from("student")
                    			 ->join("promotion","promotion.student_id=student.id")
                    			 ->join("invoice","invoice.student_id=promotion.id")
                    			 ->where("student.status","0")
                    			 ->where("promotion.is_delete","0")
                    			 ->where("promotion.is_active","1")
                    			 ->where("invoice.is_delete","0")
                    			 ->where("invoice.status","0")
                    			 ->where("LEFT(invoice.date,7)",$month)
                    			 ->where("promotion.section_id",$section_id);
                echo $students =count($this->db->get()->result());
            
        }
    }
    
   public function classs_att($condition="",$v="")
    {
        $teacher_id =$this->user_model->userInfo('teacher_id')['teacher_id'];
        if($teacher_id>0)
        {
          $check_inchrg=$this->db->select('*')
                                 ->from('teacher')
                                 ->where('id',$teacher_id)
                                 ->get()->row_array();
            if(!empty($check_inchrg['class_incharge']))
            {
                $cls=$check_inchrg['class_incharge'];
              if($condition=="role")
               {
               if(!empty($v))
                {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' AND class_id=$cls ORDER BY orderr ASC")->row_array();
                //foreach ($result as $key => $value) {
                    echo "<option value='".$result['class_id']."'>".$result['class_name']."</option>";
                // }
                }
               else
                  echo "";
                }
            }else
            {
              if($condition=="role")
                {
               if(!empty($v))
                 {
                  $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                  foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                  }
                 }
                else
                  echo "";
                 }
            }
            
        }else
        {
          if($condition=="role")
            {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }
            }
            else
                echo "";
            }
        }
       
    }
    
    public function classs_teacher($condition="",$v="")
    {
        $teacher_id =$this->user_model->userInfo('teacher_id')['teacher_id'];
       
        if($teacher_id>0)
        {
          if($condition=="role")
           {
            if(!empty($v))
            {
               $result = $this->db->query("SELECT class.class_id,class.class_name  FROM `class` inner join teacheralloc on teacheralloc.class_id=class.class_id WHERE `branch`='$v' AND `teacher_id`='$teacher_id' AND class.is_delete='0' AND teacheralloc.is_deleted='0' group by teacheralloc.class_id ORDER BY orderr ASC")->result_array();
             
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }
            }
            else
                echo "";
           }
        }else
        {
             if($condition=="role")
           {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `class_id`,`class_name`  FROM `class` WHERE `branch`='$v'  AND is_delete='0' ORDER BY orderr ASC")->result_array();
              foreach ($result as $key => $value) {
                    echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }
            }
            else
                echo "";
           }
        }
      
    }
    
    public function subject_sectionwiseteacher($c="",$s="")
    {
      $teacher_id =$this->user_model->userInfo('teacher_id')['teacher_id'];  
      if($teacher_id>0)
      {
       if(!empty($c) && !empty($s))
        {
           $result = $this->db->query("SELECT subject.id,subject.name FROM `subject` inner join teacheralloc on teacheralloc.subject_id=subject.id WHERE subject.class_id='$c' AND subject.is_deleted='0' AND teacheralloc.is_deleted='0' AND teacheralloc.section_id='$s' AND `teacher_id`='$teacher_id'")->result_array();
          
            foreach ($result as $key => $value) {
               echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
           echo "";
      }else
      {
          if(!empty($c) && !empty($s))
        {
           $result = $this->db->query("SELECT subject.id,subject.name FROM `subject`  WHERE subject.class_id='$c' AND subject.is_deleted='0'")->result_array();
            foreach ($result as $key => $value) {
               echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
           echo "";
      }
    }
    
    public function subject_sectionwise($c="",$s="")
    {
       if(!empty($c) && !empty($s))
        {
           $result = $this->db->query("SELECT `id`,`name` FROM `subject` WHERE `class_id`='$c' AND `is_deleted`='0'")->result_array();
            foreach ($result as $key => $value) {
               echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
           echo "";
    }
    
      public function status($v="")
    {
       
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`name` FROM `status` WHERE `class_id`='$v'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['city_id']."'>".$value['city_name']."</option>";
                }
            }
            else
                echo "";
        }
    
    
     public function exams($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`name` FROM `exam_type` WHERE `branch_id`='$v'  AND is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['id']."'>".$value['name']."</option>";
                    
                }
            }
            else
                echo "";
        }
    }
    
     public function t_exams($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`name` FROM `exam` WHERE `etype_id`='$v'  AND is_delete='0'")->result_array();
                // var_dump($result);
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['id']."'>".$value['name']."</option>";
                    
                }
            }
            else
                echo "";
        }
    }
	
	public function get_date_from_duty_roster($condition="",$exam="")
    {
        if($condition=="exam")
        {
            $branch=$this->user_model->getbranch();
            if(!empty($exam))
            {  
                $result = $this->db->query("SELECT `date` FROM `duty_roster` WHERE `branch`='$branch' and `exam` = $exam  AND is_delete='0'")->result_array();

                foreach ($result as $key => $value) {
                    echo "<option value='".$value['date']."'>".$value['date']."</option>";
                }
            }
         }
         
     } 
	public function get_block($condition="",$exam="", $b="")
    {
        $branch=$this->user_model->getbranch();
        if($condition=="block")
        {
			if(!empty($b) && !empty($exam))
            {    
				$keys=array();
                $result = $this->db->query("select distinct(block) as id from seating_plans where branch ='$b' and exam ='$exam' and is_delete=0")->result_array();
				$query =$this->db->query("select distinct(block) as id from seating_plans where branch ='$b' and exam ='$exam' and is_delete=0")->num_rows();
				
			
				
				if($query >0)
				{
				
					foreach($result as $value)
					{
						$rslt[] = $value['id'];
					}
					
					$block = $this->db->query("select id from block where is_delete=0 and branch = $branch" )->result_array();
					foreach($block as $value)
					{
						$blck[] = $value['id'];
					}
					
				    $r =  array_diff($blck,$rslt);
					
					if(!empty($r))
					{
					   foreach($r as $key=>$values){
    					 $keys[] =$this->db->query("select * from block where id = '$values' and is_delete=0 and branch = $branch")->row();
    					} 
					}else{
					    foreach($blck as $key=>$values){
    					 $keys[] =$this->db->query("select * from block where id = '$values' and is_delete=0 and branch = $branch")->row();
    					}
					}
					
			
				
					$row = '';

					foreach ($keys as $key => $value) {
						
						$row .="<option value='$value->id'>$value->name</option>";
					}
					
					echo $row;
				}
				else
				{
					$this->db->select('*')->where('is_delete',0)->where('branch',$branch);
					$query= $this->db->get('block');
					$data= $query->result();
					$return="";
                    foreach ($data as $key => $value) {
                    $return.="<option value='$value->id'>$value->name</option>"; 
                    }
                    echo $return;
				}
			}
				else 
				echo "";

            }
            else
			 echo "";
        
    }
	
	
	public function get_blocks($condition="",$exam="")
    {
        if($condition=="block")
        {
			if(!empty($exam))
            {    
				$branch=$this->user_model->getbranch();
                $data = $this->db->query("select distinct(block) as id , block.name from `seating_plans`
				inner join `block` on block.id = seating_plans.block 
				where seating_plans.branch ='$branch' 
				and  seating_plans.exam ='$exam' 
				and seating_plans.is_delete=0")->result_array();
				$return="";
                    foreach ($data as $key => $value) {
                    $return.="<option value='".$value['id']."'>".$value['name']."</option>"; 
                    }
                    echo $return;
			}
		}
		
	}
	
	
	
	public function get_assign_block($condition="block",$exam="5", $date="2018-02-08")
    {
        if($condition=="block")
        {
			if(!empty($exam) && !empty($date))
            {    
				$b=$this->user_model->getbranch();
				$keys;
                $result = $this->db->query("select distinct(block_id) as id from duty_roster where branch ='$b' and exam ='$exam' and date ='$date' and is_delete=0")->result_array();
				
				$query =$this->db->query("select distinct(block_id) as id from duty_roster where branch ='$b' and exam ='$exam' and date ='$date' and is_delete=0")->num_rows();
				
				if($query > 0)
				{
				
					foreach($result as $value)
					{
						$rslt[] = $value['id'];
					}
					
					$block = $this->db->query("select distinct(block) as id from seating_plans where exam='$exam' and is_delete=0")->result_array();
					foreach($block as $value)
					{
						$blck[] = $value['id'];
					}
					
					$r =  array_diff($blck,$rslt);
					foreach($r as $key=>$values){
						
						
					$keys[] =$this->db->query("select block.name, block.id,seating_plans.gender 
						from block 
						inner join seating_plans on seating_plans.block = block.id
						where block.id= $values 
						and seating_plans.exam = $exam
						and seating_plans.is_delete =0 ")->row();
					}
					
					$row = '';
					foreach ($keys as $key => $value) {
						
						$row .="<option value='$value->id'>$value->name ($value->gender)</option>";
					}
					
					echo $row;
				}
				else
				{		
					$this->db->select('distinct(block.id), block.name, seating_plans.gender');    
        			$this->db->from('block');
        			$this->db->join('seating_plans', 'seating_plans.block=block.id')->where('seating_plans.exam',$exam)->where('block.is_delete',0);
        			$data = $this->db->get()->result();					
					
					$return="";
                    foreach ($data as $key => $value) {
                    $return.="<option value='$value->id'>$value->name ($value->gender)</option>"; 
                    }
                    echo $return;
				}
			}
				else 
				echo "";     
            }
            else
			 echo "";
        
    }
	
	public function get_exam_sitting_plan($condition="",$c="")
    {
        if($condition=="class")
        {
         if(!empty($c))
            {
           $class_order=$this->db->select('orderr')
                                         ->from('class')
                                         ->where('class_id',$c)
                                         ->get()->row_array()['orderr'];
		 if($class_order<=5)
         {
               $result2 = $this->db->select('exam.*')
                    					->from('seating_plans')
                    					->join('exam', 'exam.id = seating_plans.exam')
                    					->join('exam_type', 'exam_type.id = exam.etype_id')
                    					->join('student', 'student.id = seating_plans.student_id')
                    					->join('promotion', 'promotion.student_id = student.id')
                    					->where('seating_plans.is_delete',0)
                    					->where('student.is_delete',0)
                    					->where('promotion.is_delete',0)
                    					->where('student.status',0)
                    					->where('exam.is_delete',0)
                    					->where('promotion.class_id',$c)
                    					->where('promotion.is_active',1)
                    					->distinct('exam.id')
                    					->get()->result_array();
                if(!empty($result2))
                {
                     foreach ($result2 as $key => $value) {
                        echo '<option value="'.$value['id'].'">'.$value['name'].'</option>';
                    }
                    
                }else{
    			   echo ""; 
    			}
                    
         }
         else{
             $result = $this->db->select('exam.*')
					->from('seating_plans')
					->join('exam', 'exam.id = seating_plans.exam')
					->join('exam_type', 'exam_type.id = exam.etype_id')
					->where('seating_plans.is_delete',0)
					->where('exam.is_delete',0)
					->where('seating_plans.class_id',$c)
					->distinct('exam.id')
					->get()->result_array();
			if(!empty($result))
    			{
    			     foreach ($result as $key => $value) {
                        echo '<option value="'.$value['id'].'">'.$value['name'].'</option>';
                    }
    			}
    			else{
    			   echo ""; 
    			}
         }
			 
		
        }
    }
	
}	
	public function get_assign_block_teacher($condition="")
    {
        if($condition=="teacher")
        {
			   	 $b=$this->user_model->getbranch();
				 $total_teacher = $this->db->query("SELECT * FROM `teacher` where status='0' AND branch=$b AND is_delete='0'")->result();
				 //var_dump("<pre>", $total_teacher);die;
            
				
				$query =$this->db->query("SELECT * FROM `teacher` where status='0' AND branch=$b AND is_delete='0'")->num_rows();
				
				if($query > 0)
				{
				   //var_dump("<pre>", $total_teacher);die;
					$row = '';
					foreach ($total_teacher as $key => $value) {
						
						$row .="<option value='$value->id'>$value->firstname $value->lastname</option>";
					}
					
					echo $row;
				}
				else
				{
					
                    echo "";
				}
			
            }
            else
			 echo "";
        
    }
	
	
	public function check_assign_teacher($condition="",$exam="", $date="", $teacher="")
    {
        if($condition=="teacher")
        {
			if(!empty($exam) && !empty($date) && !empty($teacher))
			{
			   	 $b=$this->user_model->getbranch();
				 $total_teacher = $this->db->query("SELECT * FROM `duty_roster` where branch=$b AND exam=$exam and teacher_id=$teacher and date='$date' and is_delete=0")->num_rows();
				if($total_teacher > 0)
				{
				   
					echo "1";
					
				}
				else
				{
					
                    echo "0";
				}
			}
			else
			{
				echo "1";	
			}
			
            }
            else
			 echo "1";
        
    }
	
	
	public function check_assign_teacher_record( $condition="",$exam="", $date="", $teacher="")
	{
		if($condition=="teacher")
        {
			
			if(!empty($exam) && !empty($date) && !empty($teacher))
			{
              $branch=$this->user_model->getbranch();				
			  $this->db->select("teacher.firstname, duty_roster.date, block.name");
			  $this->db->from('duty_roster');
			  $this->db->join('teacher' , 'teacher.id = duty_roster.teacher_id');
			  $this->db->join('block', 'block.id = duty_roster.block_id');
              $this->db->where('duty_roster.is_delete',0)->where('duty_roster.branch',$branch)->where('duty_roster.teacher_id',$teacher);
            $query = $this->db->get()->result();
		    	$row = '';
					foreach ($query as $key => $value) {
						
						$row .="<option value='$value->id'>$value->firstname ($value->name) $value->date</option>";
					}
					echo $row;
			}
			else
			{
				echo "";
			}
		}
		else
		{
			echo "";
		}	
	}
	
	public function getBlock($condition="", $b="")
    {
        if($condition=="block")
        {
            if(!empty($b))
            {
                $result = $this->db->query("SELECT `max_len`,`min_len`,`name` FROM `block` WHERE `id`='$b'  AND is_delete='0'")->result_array();
				$row = '';
                foreach ($result as $key => $value) {
					
                    $row .="<input class='form-control col-md-2 col-xs-12'  type='text' value='Maximum Sitting Capacity ".$value['max_len']." In Block ".$value['name']."' readonly> <input class='form-control col-md-2 col-xs-12' id='max'  type='hidden' value='".$value['max_len']."' readonly>";
//$row .="<input class='form-control col-md-2 col-xs-12' id='max_val' type='hidden' value='".$value['max_len']." ' readonly>";

$row .="<input class='form-control col-md-2 col-xs-12'  type='text' value='Minimum Sitting Capacity ".$value['min_len']." In Block ".$value['name']."' readonly><input class='form-control col-md-2 col-xs-12' id='min'  type='hidden' value='".$value['min_len']."' readonly>";
//$row .="<input class='form-control col-md-2 col-xs-12' id='min_val' type='hidden' value='".$value['min_len']." ' readonly>";
                }
				echo $row;
            }
            else
                echo "";
        }
    }
	
	public function count_S_classs($condition="",$b="",$c="",$e="")
    {
        if($condition=="1")
        {
            if(!empty($b) && !empty($c) && !empty($e))
            {
				
                $students_male=$this->db->select('count(student.id) as totals')
                 ->from('student')
                 ->join('promotion','promotion.student_id=student.id')
                 ->join('section','section.section_id=promotion.section_id')
                 ->where('status',0)
                 ->where('student.branch',$b)
                 ->where('section.branch',$b)
                 ->where('student.gender','male')
                 ->where('promotion.is_active',1)
                 ->where('section.is_delete',0)
                 ->where('promotion.class_id',$c)
                 ->get()->row();
				 $t_s =  $students_male->totals;
				 
				 $students_male_seat=$this->db->select('count(seating_plans.student_id) as total')
                 ->from('seating_plans')
                 ->where('is_delete',0)
                 ->where('branch',$b)
				 ->where('exam',$e)
                 ->where('seating_plans.gender','male')
                 ->where('class_id',$c)
                 ->get()->row();
				$t_ss =  $students_male_seat->total;
				 echo $totalss = $t_s - $t_ss;
                /*foreach ($students_male as $key => $value) {
                    //echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }*/
            }
            else{
                echo "";
			}
			
			}
		
		if($condition=="2")
        {
			
            if(!empty($b) && !empty($c))
            {
				
                $students_male=$this->db->select('count(student.id) as totals')
                 ->from('student')
                 ->join('promotion','promotion.student_id=student.id')
                 ->join('section','section.section_id=promotion.section_id')
                 ->where('status',0)
                 ->where('student.branch',$b)
                 ->where('section.branch',$b)
                 ->where('student.gender','female')
                 ->where('promotion.is_active',1)
                 ->where('section.is_delete',0)
                 ->where('promotion.class_id',$c)
                 ->get()->row();
				 $t_s =  $students_male->totals;
				 // var_dump($t_s);die;
				 $students_male_seat=$this->db->select('count(seating_plans.student_id) as total')
                 ->from('seating_plans')
                 ->where('is_delete',0)
                 ->where('branch',$b)
				 ->where('exam',$e)
                 ->where('seating_plans.gender','fe-male')
                 ->where('class_id',$c)
                 ->get()->row();
				$t_ss =  $students_male_seat->total;
				 echo $totalss = $t_s - $t_ss;
                /*foreach ($students_male as $key => $value) {
                    //echo "<option value='".$value['class_id']."'>".$value['class_name']."</option>";
                }*/
            }
            else{
                echo "";
			}
		
    }
	}
	
	public function get_duty_roster_teacher($condition="",$exam="")
    {
        if($condition=="teacher")
        {
            if(!empty($exam))
            {
				$result = $this->db->select('distinct(teacher.firstname),duty_roster.teacher_id')
				->from('duty_roster')
				->join('teacher', 'teacher.id= duty_roster.teacher_id')
				->where('duty_roster.exam',$exam)
				->where('duty_roster.is_delete',0)
				->get()->result_array();
               
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['teacher_id']."'>".$value['firstname']."</option>";
                }
            }
            else
                echo "";
        }
    }

public function section_according_allocation($condition="",$v="",$section=0)
{
    $teacher_id =$this->user_model->userInfo('teacher_id')['teacher_id'];
    if($teacher_id>0)
    {
         if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT section.section_id,`section_name` FROM `section` inner join teacheralloc on teacheralloc.section_id=section.section_id WHERE section.class_id='$v' and teacher_id='$teacher_id' AND section.is_delete='0' AND teacheralloc.is_deleted='0' group by teacheralloc.section_id order by teacheralloc.section_id asc")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        }
        
    }else
    {
         if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        }
        if(!empty($v) AND !empty($section))
            {
                $disabled_check = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                if($disabled_check>0)
                echo 1;
            else
                echo 0;
                }
    }
}
    public function section($condition="",$v="",$section=0)
    {
        
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        }
        if(!empty($v) AND !empty($section))
            {
                $disabled_check = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                if($disabled_check>0)
                echo 1;
            else
                echo 0;
                }
    }
    public function student_section($condition="",$v="",$section=0)
    {
        
        if($condition=="role")
        {
            if(!empty($v))
            {
                
                $student_id =$this->user_model->userInfo('student_id')['student_id'];
                $result = $this->db->query("SELECT section.`section_id`,`section_name` FROM `section` JOIN promotion ON section.section_id = promotion.section_id WHERE promotion.student_id = '$student_id' AND section.`class_id`='$v' AND section.is_delete='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['section_id']."'>".$value['section_name']."</option>";
                }
            }
            else
                echo "";
        }
        if(!empty($v) AND !empty($section))
            {
                $disabled_check = $this->db->query("SELECT `section_id`,`section_name` FROM `section` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
                if($disabled_check>0)
                echo 1;
            else
                echo 0;
                }
    }
    
    
    public function taluka($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `city_id`,`city_name` FROM `city` WHERE `district_id`='$v'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['city_id']."'>".$value['city_name']."</option>";
                }
            }
            else
                echo "";
        }
    }


    public function province($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `province_id`,`province_name` FROM `province` WHERE `country_id`='$v' AND `is_delete`='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['province_id']."'>".$value['province_name']."</option>";
                }
            }
            else
                echo "";
        }
    }

        public function district($condition="",$v="")
    {
        if($condition=="role")
        {
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`name` FROM `district` WHERE `province_id`='$v' AND `is_delete`='0'")->result_array();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['id']."'>".$value['name']."</option>";
                }
            }
            else
                echo "";
        }
    }
     public function againstdatestaffatt($value,$br)
    {
        if ($value == '0')
        {
            $this->db->select('staff.firstname, branch.name as b_name, staff.lastname,staff.contact,staff.designation,leave_types.name as status,staff.id,staffatt.date');    
            $this->db->from('staffatt');
            $this->db->join('staff', 'staffatt.staff_id = staff.id');
            $this->db->join('branch', 'branch.id = staff.branch');
            $this->db->join('leave_types', 'leave_types.id = staffatt.status_id');
            $this->db->where('is_deleted',0 )->where('leave_types.branch', $br)->where('staffatt.branch', $br)->where('staff.status', '0');
            $query = $this->db->get();
        }
        else
        {
            $newval= date("Y-m-d", strtotime($value));
            if($this->user_model->is_super()){
                $this->db->select('staff.firstname, branch.name as b_name, staff.lastname,staff.contact,staff.designation,leave_types.name as status,staff.id,staffatt.date');    
            $this->db->from('staffatt');
            $this->db->join('staff', 'staffatt.staff_id = staff.id');
            $this->db->join('branch', 'branch.id = staff.branch');
            $this->db->join('leave_types', 'leave_types.id = staffatt.status_id');
            $this->db->where('is_deleted',0 )->where('leave_types.branch', $br)->where('staffatt.branch', $br)->where('date',$newval);
            $query = $this->db->get();
                }
            else{
            $this->db->select('staff.firstname,staff.lastname,staff.contact,staff.designation,staff.branch as b_name,leave_types.name as status,staffatt.id ,staffatt.date');    
            $this->db->from('staffatt');
            $this->db->join('staff', 'staffatt.staff_id = staff.id');
            $this->db->join('branch', 'staff.branch = branch.id');
            $this->db->join('leave_types', 'leave_types.id = staffatt.status_id');
            $this->db->where('is_deleted',0 )->where('leave_types.branch', $br)->where('staff.branch', $br)->where('date',$newval);
            $query = $this->db->get();
                }
        }
        $staffatt = $query->result_array();
        // var_dump("<pre>",$staffatt);exit;
        $return = "";
        $i = 1;
        foreach ($staffatt as $key => $value) {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['firstname']." ".$value['lastname']."</td>";
            $return .= "<td>".$value['contact']."</td>";
            $newdate= date("d-m-Y", strtotime($value['date']));
            $return .= "<td>".$newdate."</td>";
            $return .= "<td>".$value['designation']."</td>";
            
            $return .= "<td>".$value['status']."</td>";
            if(!$this->user_model->is_super()){
            $return .= "<td><a href='' onclick='edit($value[id],event)'><i class='fa fa-edit'></i></a>
                            </td>";//<a href='' onclick='delete_att($value[id],event)'><i class='fa fa-trash'></i></a>
            }
             if($this->user_model->is_super()){ 
            $return .= "<td>".$value['b_name']."</td>";
            }
            $return .= "</tr>";
        }
        echo $return;
    }
    public function teacheragainstbranch($branch)
    {
        $query=$this->db->where('branch',$branch)->where('status',0)->get('teacher')->result_array();
        $data=$this->Teacher_model->AttendanceStatus();
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['firstname']." ".$value['firstname']."</td>";
            $return .= "<td>".$value['specialization']."</td>";
            $return .= "<td>".$value['contact']."</td>";
            
            $return .="<td>";
            $return .='<div>';
                foreach ($data as $key => $dt) 
                {
                        $return .='<input type="radio"';
                        if($dt["status"]=="P"){ 
                            $return .= "checked ";
                            }
                        $return .='name="status['.$value['id'].']" id= "'.$value['id'].'"  value="'. $dt['id'].'"/> '.$dt['status'].'</label>';
                        $return .= "<br>";
                }
                        $return .= "</div>";
                        $return .= "</td>";
                        $return .= "</tr>"; 
            }
    }
    
      public function holiday($value=0)
    {
            $query = $this->db->query("SELECT student.id,student.student_name,student.roll_no,student.roll_no,class.class_name,section.section_name FROM student JOIN promotion ON promotion.student_id=student.id JOIN class ON promotion.class_id=class.class_id JOIN section ON promotion.section_id=section.section_id WHERE student.branch = '$value' AND student.status='0' AND student.is_delete='0'AND class.is_delete='0'AND promotion.is_active='1' order by class.orderr asc")->result_array();
        // $data=$this->Teacher_model->AttendanceStatus();
        $data = $this->db->select()->where('id', '7')->get('attendancestatus')->result_array();
        // var_dump($data);die;
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            // $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['class_name']."</td>";
            $return .= "<td>".$value['section_name']."</td>";
            $return .="<td>";
            foreach ($data as $key => $dt) 
            {
                $return .='<input type="checkbox"';
                if($dt["status"]=="HD")
                { 
                    $return .= "checked ";
                }
                $return .='name="status['. $value['id'].']"  value="'. $dt['id'].'"/>&nbsp;<span style="color:black;font-size:15px">'. $dt['status'].'</span>&nbsp;';
                }
                $return .= "</td>";
                $return .= "</tr>"; 
                }
                echo $return;
            }
    
     public function studentagainstbranch($br)
    {
        $this->db->select('student.id,student.student_name,student.branch,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->where('student.status','0');
         $this->db->where('student.is_delete','0');
        $this->db->where('student.branch',$br)->where('pro.is_active',1)->where('pro.is_delete',0);
        $query = $this->db->get()->result_array();
        // var_dump("<pre>", $query);exit;
        $data=$this->Teacher_model->AttendanceStatus();
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['sid']."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['father_name']."</td>";
            $return .="<td>";
            $return .='<div class="btn-group" data-toggle="buttons">';
                foreach ($data as $key => $dt) 
                {
                    if($dt["status"]=="P"){ 
                            $return .='<label class="btn btn-success btn-default active">';
                        }
                        else{
                            $return .='<label class="btn btn-default">';
                        }
                        $return .='<input type="radio"';
                        if($dt["status"]=="P"){ 
                            $return .= "checked ";
                            }
                        $return .='name="status['.$value['id'].']" id= "'.$value['id'].'"  value="'. $dt['id'].'"/> '.$dt['status'].'</label>';
                        $return .= "<br>";
                }
                        $return .= "</div>";
                        $return .= "</td>";
                        $return .= "</tr>"; 
            }
                        echo $return;
        
        }
    public function studentagainstclass($value=0, $br)
    {
        $this->db->select('student.id,student.student_name,student.branch,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
          
        $this->db->join('section', 'section.section_id=pro.section_id');
        $this->db->where('student.status','0');
         $this->db->where('student.is_delete','0');
        $this->db->where('pro.class_id',$value);
        $this->db->where('student.branch',$br)->where('pro.is_active',1)->where('pro.is_delete',0);
        $query = $this->db->get()->result_array();
        // var_dump("<pre>", $query);exit;
        $data=$this->Teacher_model->AttendanceStatus();
        $return="";
        $i=1;
        foreach ($query as $key => $value) 
        {
            $return .= "<tr>";
            $return .= "<td>".$i++."</td>";
            $return .= "<td>".$value['sid']."</td>";
            $return .= "<td>".$value['roll_no']."</td>";
            $return .= "<td>".$value['student_name']."</td>";
            $return .= "<td>".$value['father_name']."</td>";
            $return .="<td>";
            $return .='<div class="btn-group" data-toggle="buttons">';
                foreach ($data as $key => $dt) 
                {
                    if($dt["status"]=="P"){ 
                            $return .='<label class="btn btn-success btn-default active">';
                        }
                        else{
                            $return .='<label class="btn btn-default">';
                        }
                        $return .='<input type="radio"';
                        if($dt["status"]=="P"){ 
                            $return .= "checked ";
                            }
                        $return .='name="status['.$value['id'].']" id= "'.$value['id'].'"  value="'. $dt['id'].'"/> '.$dt['status'].'</label>';
                        $return .= "<br>";
                }
                        $return .= "</div>";
                        $return .= "</td>";
                        $return .= "</tr>"; 
            }
                        echo $return;
        
        }
             
   public function studentagainstsection($value=0,$se=0, $br)
            {
        
                $this->db->select('student.id,student.student_name,student.father_name,student.roll_no,student.sid,student.branch,class.class_name,section.section_name');    
        $this->db->from('student');
        $this->db->join('promotion pro', 'pro.student_id=student.id');
        $this->db->join('class', 'class.class_id=pro.class_id');
        $this->db->join('session ', 'session.id=pro.session_id');
$this->db->join('section', 'section.section_id=pro.section_id')->where('student.branch',$br)->where('student.status',0)->where('student.is_delete',0)->where('pro.class_id',$value)
            ->where('pro.section_id',$se);
                $this->db->where('pro.is_active',1)->where('pro.is_delete',0);
                $this->db->order_by("student.roll_no", "asc");
                $query = $this->db->get()->result_array();
                $data=$this->Teacher_model->AttendanceStatus();
                $return="";
                $i=1;
                foreach ($query as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['sid']."</td>";
                    $return .= "<td>".$value['roll_no']."</td>";
                    $return .= "<td>".$value['student_name']."</td>";
                    $return .= "<td>".$value['father_name']."</td>";
                    $return .="<td>";
                    $return .='<div class="btn-group" data-toggle="buttons">';
                    foreach ($data as $key => $dt) {
                        if($dt["status"]=="P"){ 
                            $return .='<label class="btn btn-success btn-default active">';
                        }
                        else{
                            $return .='<label class="btn btn-default">';
                        }
                        $return .='<input type="radio"';
                        if($dt["status"]=="P"){ 
                            $return .= "checked ";
                            }
                        $return .='name="status['.$value['id'].']" id= "'.$value['id'].'"  value="'. $dt['id'].'"/> '.$dt['status'].'</label>';
                        $return .= "<br>";
                        }
                        $return .= "</div>";
                        $return .= "</td>";
                        $return .= "</tr>"; 
                        }
                        echo $return;
                    }
                    
      
            public function getstudentagainstsection($value=0,$se=0)
            {
        
                $this->db->select('student.id,pro.id as p_id,student.student_name,student.father_name,student.roll_no,student.sid,class.class_name,section.section_name,arrears.amount,arrears.add_month,arrears.for_month');    
                $this->db->from('student');
                $this->db->join('promotion pro', 'pro.student_id=student.id');
                $this->db->join('class', 'class.class_id=pro.class_id');
                $this->db->join('session ', 'session.id=pro.session_id');
                $this->db->join('section', 'section.section_id=pro.section_id');
                $this->db->join('arrears', 'arrears.promotion_id=pro.id','LEFT');
                $this->db->where('student.status',0)->where('pro.class_id',$value)
                ->where('student.is_delete',0)
                ->where('pro.section_id',$se)
                ->where('pro.is_active','1');
                $query = $this->db->get()->result_array();
                $return="";
                $i=1;
                foreach ($query as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['id']."</td>";
                    $return .= "<td>".$value['student_name']."</td>";
                    $return .= "<td>".$value['father_name']."</td>";
                    $amount = empty($value['amount']) ? '0': $value['amount'];
                    $return .='<td><input type="hidden" name="promotion_id['.$value['p_id'].']" value="'.$value['sid'].'" required="required"/><input type="text" class="form-control col-md-1 col-sm-2 col-xs-2" name="arrear['.$value['p_id'].']" value="'.$amount.'" required="required"/>';
                        
                        $return .= "</td>";
                        $return .= "</tr>"; 
                        }
                        echo $return;
            }
            
            public function getdateagainstarrear($value=0,$se=0)
            {
        
                $this->db->select('arrears.add_month,arrears.for_month');    
                $this->db->from('student');
                $this->db->join('promotion pro', 'pro.student_id=student.id');
                $this->db->join('class', 'class.class_id=pro.class_id');
                $this->db->join('session ', 'session.id=pro.session_id');
                $this->db->join('section', 'section.section_id=pro.section_id');
                $this->db->join('arrears', 'arrears.promotion_id=pro.id','LEFT');
                $this->db->where('student.status',0)->where('pro.class_id',$value)
                ->where('pro.section_id',$se);
                $return = @$this->db->get()->result_array()[0];
                echo json_encode($return);
            }
            
            public function againstdatestudentatt_teacher($value,$br)
            {
                if($value == '0')
                {
                    $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and promotion.is_delete=0 and student.is_delete=0 AND student.branch='$br' ");
                }
                else{
                     $newval= date("Y-m-d", strtotime($value));
                     if(!$this->user_model->is_super()){
                          $teacher_id =$this->user_model->userInfo('teacher_id')['teacher_id'];
                          if($teacher_id>0)
                          {
                              $cls_inchrg=$this->db->select('*')
                                   ->from('teacher')
                                   ->where('id',$teacher_id)
                                   ->get()->row_array();
                                  if(!empty($cls_inchrg['class_incharge']))  
                                     {  
                                         $cc_ls=$cls_inchrg['class_incharge'];
                                $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            inner join `teacher` on teacher.class_incharge = class.class_id
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' AND promotion.class_id='$cc_ls' ");
                                     }else
                                     {
                                $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' ");
                                     }
                          }else
                          {
                             $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' "); 
                          }
  
                     }
                     if($this->user_model->is_super()){
                         $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' ");
                     }
                }
            $studentatt = $query->result_array();
                //var_dump($staffatt);
                //die();
                $return = "";
                $i = 1;
                    foreach ($studentatt as $key => $value) 
                    {
                            $return .= "<tr>";
                            $return .= "<td>".$i++."</td>";
                            $return .= "<td>".$value['roll_no']."</td>";
                            $return .= "<td>".$value['student_name']."</td>";
                            $return .= "<td>".$value['class_name']."</td>";
                            $return .= "<td>".$value['section_name']."</td>";
                            $date = date('d-m-Y', strtotime($value['date']));
                            $return .= "<td>".$date."</td>";
                            if($this->user_model->is_super()){ 
                                $return .= "<td>".$value['b_name']."</td>";
                            }
                            $return .= "<td>".$value['status']."</td>";
                            if(!$this->user_model->is_super()){
                               $return .= "<td><a href='' onclick='edit($value[id],event)'><i class='fa fa-edit'></i></a>
                            </td>";// <a href='' onclick='delete_att($value[id],event)'><i class='fa fa-trash'></i></a>
                            }
                            $return .= "</tr>";
                    }
                  echo $return;
            }
            
            public function againstdatestudentatt_student($value,$br=NULL){
                $newval= date("Y-m-d", strtotime($value));
                $student_id =$this->user_model->userInfo('student_id')['student_id'];
                $studentatt = array();
                if($student_id>0){
                    $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                    FROM `studentatt` 
                    inner join `student` on studentatt.student_id = student.id
                    inner join `branch` on branch.id = student.branch
                    inner join `promotion` on promotion.student_id = student.id 
                    inner join `class` on promotion.class_id = class.class_id 
                    inner join `section` on promotion.section_id = section.section_id 
                    inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                    WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.id='$student_id' AND studentatt.date='$newval' ");
                    $studentatt = $query->result_array();
                }
                $return = "";
                $i = 1;
                foreach ($studentatt as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['roll_no']."</td>";
                        $return .= "<td>".$value['student_name']."</td>";
                        $return .= "<td>".$value['class_name']."</td>";
                        $return .= "<td>".$value['section_name']."</td>";
                        $date = date('d-m-Y', strtotime($value['date']));
                        $return .= "<td>".$date."</td>";
                        $return .= "<td>".$value['b_name']."</td>";
                        $return .= "<td>".$value['status']."</td>";
                        $return .= "</tr>";
                }
              echo $return;
            }
            public function againstdatestudentatt($value,$br)
            {
                if($value == '0')
                {
                    $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and promotion.is_delete=0 and student.is_delete=0 AND student.branch='$br' ");
                }
                else{
                     $newval= date("Y-m-d", strtotime($value));
                     if(!$this->user_model->is_super()){
                        $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' ");
                     }
                     if($this->user_model->is_super()){
                         $query = $this->db->query("SELECT studentatt.id,branch.name as b_name,student.student_name,student.sid,student.roll_no,class.class_name,section.section_name,studentatt.date,attendancestatus.status
                            FROM `studentatt` 
                            inner join `student` on studentatt.student_id = student.id
                            inner join `branch` on branch.id = student.branch
                            inner join `promotion` on promotion.student_id = student.id 
                            inner join `class` on promotion.class_id = class.class_id 
                            inner join `section` on promotion.section_id = section.section_id 
                            inner join `attendancestatus` on attendancestatus.id = studentatt.status_id  
                            WHERE is_deleted='0' AND promotion.is_active='1' and student.is_delete=0 and promotion.is_delete=0 AND student.branch='$br' AND studentatt.date='$newval' ");
                     }
                }
            $studentatt = $query->result_array();
                //var_dump($staffatt);
                //die();
                $return = "";
                $i = 1;
                    foreach ($studentatt as $key => $value) 
                    {
                            $return .= "<tr>";
                            $return .= "<td>".$i++."</td>";
                            $return .= "<td>".$value['roll_no']."</td>";
                            $return .= "<td>".$value['student_name']."</td>";
                            $return .= "<td>".$value['class_name']."</td>";
                            $return .= "<td>".$value['section_name']."</td>";
                            $date = date('d-m-Y', strtotime($value['date']));
                            $return .= "<td>".$date."</td>";
                            if($this->user_model->is_super()){ 
                                $return .= "<td>".$value['b_name']."</td>";
                            }
                            $return .= "<td>".$value['status']."</td>";
                            if(!$this->user_model->is_super()){
                               $return .= "<td><a href='' onclick='edit($value[id],event)'><i class='fa fa-edit'></i></a>
                            </td>";// <a href='' onclick='delete_att($value[id],event)'><i class='fa fa-trash'></i></a>
                            }
                            $return .= "</tr>";
                    }
                  echo $return;
            }

              public function subagainstclass($id=0,$sec=0)
            {
                $this->db->select('subject.id, subject.name,class.class_name')->from('subject')
                ->join('class','class.class_id=subject.class_id')
                ->where('is_deleted',0)->where('subject.class_id',$id);
                $data=$this->db->get()->result_array();
                $return="";
                $i=1;
                foreach ($data as $key => $value) 
                {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['name']."</td>";
                    $return .= "<td>".$value['class_name']."</td>";
                   
                    $return .= "<td><a href='subject/actions/edit/".base64_encode(json_encode($value['id'].SALT))."'><i class='fa fa-edit'></i></a>
                    <a href='subject/actions/delete/".base64_encode(json_encode($value['id'].SALT))."'><i class='fa fa-trash'></i></a></td>";
                    $return .= "</tr>";
                }
                echo $return;
            }
			
			
    public function package($v="")
    {
        if(!empty($v))
        {
            $result = $this->db->query("SELECT `tution_fee` FROM `class` WHERE `class_id`='$v' AND is_delete='0'")->result_array();
            echo $result[0]['tution_fee'];
        }
        else
            echo 0;
    }
    
    public function admission_fee($v="")
    {
        if(!empty($v))
        {
            $branch = $this->user_model->getBranch();
            $result = $this->db->query("SELECT `admin_fee` FROM `class` WHERE `class_id`='$v' AND `is_delete`='0'")->result_array();
            echo $result[0]['admin_fee'];
        }
        else
            echo 0;
    }

   
    public function sibling($v="")
    {
        if(!empty($v))
        {

                $branch = $this->user_model->getBranch();
                $this->db->select('student.sid,student.student_name, student.father_name , class.class_name,branch.name')->from('student')
                ->join('promotion','promotion.student_id=student.id')
                ->join('class','class.class_id=promotion.class_id')
                ->join('branch', 'branch.id = student.branch')
                ->where('student.is_delete',0)
                ->where('promotion.is_active',1)
                ->where('student.father_cnic',$v)
                ->order_by('student.branch','asc');
                $result = $this->db->get()->result_array();    
            
           // var_dump("<pre>" , $result);die;
           $return="";
                    $i=1;
                    foreach ($result as $key => $value) {
                    $return.="<tr>";
                    $return.="<td>$i</td>"; 
                    $return.="<td>$value[sid]</td>";
                    $return.="<td>$value[student_name]</td>";
                   $return.="<td> $value[father_name] </td>";
                    $return.="<td> $value[class_name] </td>";
                    $return.="<td> $value[name] </td>";
                    $return.="</tr>";
                    $i++;
                    }
                    
            echo $return;
        }
        else
            echo 0;
    }    

    public function fee_type($v="")
    {
        if(!empty($v))
        {
            $result = $this->db->query("SELECT `id`,`name` FROM `fee_def` WHERE `class_id`='$v'  AND `is_delete`='0'")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "0";
    }
    
    public function fee_type_amount($v="")
    {
        
        if(!empty($v))
        {
            $result = @$this->db->query("SELECT `amount` FROM `fee_def` WHERE `id`='$v' AND `is_delete`='0'")->row()->amount;
            echo $result;
        }
        else
            echo "No Rrespose";
         
       
    }
     public function staff($v=0)
                {
                     if(!empty($v))
                        {
                            $result = $this->db->query("SELECT staff.id,staff.firstname,staff.lastname FROM `staff` WHERE staff.branch=$v AND staff.is_delete=0 AND staff.status=0 ")->result_array();
                            if(!empty($result)){
                                foreach ($result as $key => $value) 
                                {
                                echo "<option value='".$value['id']."'>".$value['firstname'].''.$value['lastname']."</option>";
                                }
                            }
                            else
                            {
                                echo "";
                            }
                        }
                        else
                             echo "";
                }
    
      public function teacher($v=0)
                {
                     if(!empty($v))
                        {
                            $result = $this->db->query("SELECT teacher.id,teacher.firstname,teacher.lastname FROM `teacher` WHERE teacher.branch=$v AND teacher.is_delete=0 AND teacher.status=0 ")->result_array();
                            if(!empty($result)){
                                foreach ($result as $key => $value) 
                                {
                                echo "<option value='".$value['id']."'>".$value['firstname'].''.$value['lastname']."</option>";
                                }
                            }
                            else
                            {
                                echo "";
                            }
                        }
                        else
                             echo "";
                }
                  public function role($v='')
                {
                     if(!empty($v))
                        {
                            $result = $this->db->query("SELECT role.id,role.title FROM `role` WHERE role.branch_id=$v AND role.is_delete=0 ")->result_array();
                            if(!empty($result)){
                                foreach ($result as $key => $value) 
                                {
                                echo "<option value='".$value['id']."'>".$value['title']."</option>";
                                }
                            }
                            else
                            {
                                echo "";
                            }
                        }
                        else
                             echo "";
                }
                
                
            public function subjectagainstclasssection($c=0,$se=0)
                {
                    $subjects=array();
                    $allocated_subjects=$this->db->select('subject_id')
                                                 ->from('teacheralloc')
                                                 ->where('class_id',$c)
                                                 ->where('section_id',$se)
                                                 ->where('is_deleted',0)
                                                 ->get()->result_array();
         
                     if(!empty($allocated_subjects))
                     {
                         foreach($allocated_subjects as $row){
                            $subjects[]=$row['subject_id'];
                         }
                         
                         $data=$this->db->select('id,name')
                                        ->from('subject')
                                        ->where('class_id',$c)
                                        ->where('is_deleted',0)
                                        ->where_not_in('id',$subjects)
                                        ->get()->result_array();
                         foreach ($data as $key => $value) {
                        echo "<input type='checkbox' id='termsChkbx' value='".$value['id']."' class='subjects chkbx'  name='subject[]'  />".$value['name']."   "."<span id='hit$value[id]' style='color:red'></span>"."<br>";
                            }
                     }else
                     {
                          $data=$this->db->select('id,name')
                                        ->from('subject')
                                        ->where('class_id',$c)
                                        ->where('is_deleted',0)
                                        ->get()->result_array();
                        foreach ($data as $key => $value) {
                        echo "<input type='checkbox' id='termsChkbx' value='".$value['id']."' class='subjects chkbx'  name='subject[]'  />".$value['name']."   "."<span id='hit$value[id]' style='color:red'></span>"."<br>";
                            }                
                     }
                }
                
                public function subjectagainstsection($cl=0)
                {
                    
                    $data=$this->db->query("SELECT id,name FROM `subject` WHERE class_id='$cl' AND `is_deleted`='0'")->result_array();
                   
                    foreach ($data as $key => $value) {
                        echo "<input type='checkbox' id='termsChkbx' value='".$value['id']."' class='subjects chkbx'  name='subject[]'  />".$value['name']."   "."<span id='hit$value[id]' style='color:red'></span>"."<br>";
                    }
                }
                
                
                
                
 public function subject_class($c="")
    {
        if(!empty($c))
        {
            $result = $this->db->query("SELECT `id`,`name` FROM `subject` WHERE `class_id`='$c' AND `is_deleted`='0'")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }
                public function viewagainstteacher($value=0)
                {
                    
                    $this->db->select("teacheralloc.id,teacher.firstname,teacher.lastname,class.class_name,subject.name as subname"); 
                    $this->db->from('teacheralloc');
                    $this->db->join('teacher', 'teacheralloc.teacher_id=teacher.id');
                    $this->db->join('class', 'class.class_id=teacheralloc.class_id');
                    $this->db->join('subject', 'subject.id=teacheralloc.subject_id');
                    $this->db->where('teacheralloc.is_deleted',0)->where('subject.is_deleted',0)->where('teacheralloc.teacher_id',$value);
                    $query = $this->db->get()->result_array();
                    $return="";
                    $i=1;
                    foreach ($query as $key => $value) 
                    {
                            $return .= "<tr>";
                            $return .= "<td>".$i++."</td>";
                            $return .= "<td>".$value['firstname']." ".$value['lastname']."</td>";
                            $return .= "<td>".$value['subname']."</td>";
                            $return .= "<td>".$value['class_name']."</td>";
                            $return .= "<td><a href='actionsalloc/edit/".$value['id']."'<i class='fa fa-edit'></i></a>
                            <a href='actionsalloc/del/".$value['id']."'<i class='fa fa-trash'></i></a></td>";
                            $return .= "</tr>";
                            
                    }
                    echo $return;


                }
                
                public function suballocagainstteacher($value=0,$class=0)
                {
                    
                    $this->db->select("subject.id"); 
                    $this->db->from('teacheralloc');
                    $this->db->join('teacher', 'teacheralloc.teacher_id=teacher.id');
                    $this->db->join('class', 'class.class_id=teacheralloc.class_id');
                    $this->db->join('subject', 'subject.id=teacheralloc.subject_id');
                    $this->db->where('teacheralloc.is_deleted',0)->where('subject.is_deleted',0)->where('teacheralloc.teacher_id',$value)->where('teacheralloc.class_id',$class);
                    $query = $this->db->get()->result_array();
                    echo json_encode($query);

                }
                
                public function suballocagainstteachersesstion($value=0,$class=0,$sec=0)
                {
                    $this->db->select("subject.id"); 
                    $this->db->from('teacheralloc');
                    $this->db->join('teacher', 'teacheralloc.teacher_id=teacher.id');
                    $this->db->join('class', 'class.class_id=teacheralloc.class_id');
                    $this->db->join('subject', 'subject.id=teacheralloc.subject_id');
                    $this->db->where('teacheralloc.is_deleted',0)->where('subject.is_deleted',0)->where('teacheralloc.teacher_id',$value)->where('teacheralloc.class_id',$class)->where('teacheralloc.section_id',$sec);
                    $query = $this->db->get()->result_array();
                    echo json_encode($query);
                }
                
                

    public function other_fee($v="")
    {
        if(!empty($v))
        {
            //$branch = $this->user_model->getBranch();
            $result = $this->db->query("SELECT `id`,`name`,`amount` FROM `fee_def` WHERE `class_id`='$v'  AND `is_delete`='0'")->result_array();
            foreach ($result as $key => $value) {
                echo '<div class="item form-group">
                        <label class=" col-md-1 col-sm-1 col-xs-6" for="other_fee"><input type="checkbox" name="fee['.$value['id'].'][name]" value="'.$value['name'].'"></span>
                        </label>
                        <label class=" col-md-2 col-sm-2 col-xs-6" for="other_fee">'.$value['name'].'</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="other_fee" class="form-control col-md-7 col-xs-12" name="fee['.$value['id'].'][value]" required="required" type="number" value="'.$value['amount'].'" min="0">
                        </div>
                      </div>';
            }
        }
        else
            echo "";
    }

 
 //=======================================================================Load subject according to class======================================
    public function subject($c="")
    {
      
        if(!empty($c))
        {
             $section = $this->db->query("SELECT * FROM `section` WHERE `class_id`='$c' AND `is_delete`=0 limit 1")->row_array();
                 $sid=$section['section_id'];

            $result = $this->db->query("SELECT `id`,`name` FROM `subject` WHERE `class_id`='$c' AND `is_deleted`=0")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }
    
    public function subjects($c="", $b="")
    {
      
        if(!empty($c) && !empty($b))
        {
             $section = $this->db->query("SELECT * FROM `section` WHERE `class_id`='$c' AND `is_delete`=0 limit 1")->row_array();
                 $sid=$section['section_id'];

            $result = $this->db->query("SELECT `subject`.`id`,`subject`.`name` FROM `subject` inner join `class` on class.class_id=subject.class_id  WHERE `subject`.`class_id`='$c' AND class.branch='$b'  AND `subject`.`is_deleted`=0")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }

    public function exam($b="")
    {
        if(!empty($b))
        {
           // $result = $this->db->query("SELECT `id`,`name` FROM `exam` WHERE `class_id`='$c' AND is_delete=0")->result_array();
            $this->db->select("exam.name,exam.id");
            $this->db->from("exam");
            $this->db->join("exam_type","exam_type.id= exam.etype_id");
            $this->db->where("exam_type.branch_id",$b);
            $this->db->where("exam.is_delete",0);
            $this->db->where("exam_type.is_delete",0);
            $result = $this->db->get()->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }
    
     public function check_exam_exist_dates($exam="")
    {
        $cur=date('Y-m-d');
        if(!empty($exam))
        {
           
            $this->db->select("*");
            $this->db->from("exam");
            $this->db->where("id",$exam);
            $this->db->where("start <=",$cur);
            $this->db->where("end >=",$cur);
            $this->db->where("is_delete",0);
            $result = $this->db->get()->row();
          
            if(!empty($result))
			{
				 $end=$result->end;
				  $start =  str_replace('/', '-', $end);
                $s_date= date('d/m/Y', strtotime($start));
				 $data =$s_date;
				 echo $data;
			}
		else{
		   
		    $data =  0;
		    echo $data;
		    }
	       
        }
        
    }
    
    public function check_exam_exist($exam="",$b="",$class="",$sub="")
    {
        if(!empty($b) && !empty($exam) && !empty($class) && !empty($sub))
        {
           
            $this->db->select("*");
            $this->db->from("datesheet");
            $this->db->where("bid",$b);
            $this->db->where("exam_id",$exam);
            $this->db->where("class_id",$class);
             $this->db->where("subject_id",$sub);
            $this->db->where("is_delete",0);
            $result = $this->db->get();
            
            if($result->num_rows() > 0)
			{
				 
				 $data =  1;
			}
		else{
		   
		    $data =  0;
		    }
		echo json_encode($data);        
        }
        
    }
    
     public function session($c="")
    {
        if(!empty($c))
        {
            $result = $this->db->query("SELECT `id`,`name` FROM `session` WHERE  is_delete=0")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }

   public function load_exams($b="")
    {
        if(!empty($b))
        {
            $exam = $this->db->select("exam.name,exam.id")->from("exam")->join("exam_type","exam_type.id= exam.etype_id")->where("exam.is_delete",0 )->where("exam_type.is_delete",0)->where("exam_type.branch_id",$b)->get()->result_array();
            if(!empty($exam))
            {
                 foreach ($exam as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
                }
            }
        }
        else
            echo "";
    }
    
    public function exam_json($b="")
    {
        if(!empty($b))
        {
            $exam = $this->db->select("exam.name,exam.id")->from("exam")->join("exam_type","exam_type.id= exam.etype_id")->where("exam.is_delete",0 )->where("exam_type.is_delete",0)->where("exam_type.branch_id",$b)->get()->result_array();
            echo json_encode($exam);
        }
        else
            echo "";
    }

    public function per_menu($v="")
    {
        echo $this->load_model->per_menu($v);
    }
    
    public function getemp($va="")
    {
        $branch=$this->user_model->getbranch();
            if(!empty($va))
            {
                    if($va=="teacher")
                    {
                        $data=$this->db->query("SELECT teacher.id,teacher.firstname,teacher.lastname,teacher.designation,teacher.qualification FROM `teacher` where branch=$branch and status=0 and is_delete=0 ")->result_array();
                        
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['id']."'>".$value['firstname'].' '.$value['lastname']." (".$value['designation'].' '.$value['qualification'].")</option>";
                        }
                        }else{
                            echo "";
                        }

                    }else if($va=="staff")
                    {
                        $data=$this->db->query("SELECT staff.id,staff.firstname,staff.lastname,staff.designation,staff.qualification FROM `staff`  where branch=$branch and status=0 ")->result_array();
                        
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['id']."'>".$value['firstname'].' '.$value['lastname']." (".$value['designation'].' '.$value['qualification'].")</option>";
                        }
                        }else{
                            echo "";
                        }
                    }
                 }
            }
            
             public function getemp1($va="")
    {
        $branch=$this->user_model->getbranch();
            if(!empty($va))
            {
                    if($va=="teacher")
                    {
                        $data=$this->db->query("SELECT teacher.id,teacher.firstname,teacher.lastname,teacher.designation,teacher.qualification FROM `teacher` where branch=$branch and status=0 and is_delete=0 ")->result_array();
                        
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['id']."'>".$value['firstname'].' '.$value['lastname']." </option>";
                        }
                        }else{
                            echo "";
                        }

                    }else if($va=="staff")
                    {
                        $data=$this->db->query("SELECT staff.id,staff.firstname,staff.lastname,staff.designation,staff.qualification FROM `staff`  where branch=$branch and status=0 ")->result_array();
                        
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['id']."'>".$value['firstname'].' '.$value['lastname']." </option>";
                        }
                        }else{
                            echo "";
                        }
                    }
                 }
            }
                public function getemp_infodata($va="")
             {
                if(!empty($va))
                {
                    if($va=="teacher")
                    {
                         
                        
                        $data=$this->db->query("SELECT emp_info.id as empid ,teacher.id,teacher.firstname,teacher.lastname,teacher.designation,teacher.qualification FROM `emp_info` inner join teacher on teacher.id=emp_info.employe_id WHERE type='$va' ")->result_array();
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['empid']."'>".$value['firstname'].' '.$value['lastname']." (".$value['designation'].' '.$value['qualification'].")</option>";
                        }
                        }else{
                            echo "";
                        }

                    }else if($va=="staff")
                    {
                        $data=$this->db->query("SELECT emp_info.id as empid ,staff.id,staff.firstname,staff.lastname,staff.designation,staff.qualification FROM `emp_info` inner join staff on staff.id=emp_info.employe_id WHERE type='$va' ")->result_array();
                        
                        if($data!=null){
                        foreach ($data as $key => $value) 
                        {
                        echo "<option value='".$value['empid']."'>".$value['firstname'].' '.$value['lastname']." (".$value['designation'].' '.$value['qualification'].")</option>";
                        }
                        }else{
                            echo "";
                        }
                    }
                 }   
             }
            public function getempinfo($ref='',$val=0)
            {


                if(!empty($ref && $val))
                {
                    $chk= $this->Performance_model->checkteacher($ref,$val);
                    //var_dump($chk);

                    $chck= $this->Performance_model->checkstaff($ref,$val);
                    if($ref=="teacher")
                    {
                        $data=$this->Teacher_model->id($val)[0];
                        //if($chk==true){
                        echo json_encode($data);
                        //else{echo json_encode(null);}
                     }else if($ref=="staff")
                    {
                        $data=$this->Staff_model->id($val)[0];
                        //if($chck==true)
                        echo json_encode($data);
                     //else{ echo json_encode(null);}
                 }
            }
}
            public function get_employee($ref='',$val=0)
            {
  if(!empty($ref) && $val!=0)
                {

               
                    if($ref=="teacher")
                    {
                        
                        $data=@$this->Performance_model->Get_info_teacher($ref,$val);
                     
                      echo json_encode($data);
                    // var_dump($data);
                     }else if($ref=="staff")
                    {

                        $data=@$this->Performance_model->Get_info_staff($ref,$val)[0];
                       // var_dump($data);
                        echo json_encode($data);
                     }
                     
                 }
            }
            public function viewperformance($ref="")
            {
                
                $data=$this->Performance_model->getteacher($ref);
                $return="";
                $i=1;
               // var_dump($data);
               if($data!=null){
                foreach ($data as $key => $value) 
                {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['firstname']." ".$value['lastname']."</td>";
                    $return .= "<td>".$value['designation']."</td>";
                    $return .= "<td>".$value['attritotalgrade']."</td>";
                    $return .= "<td>".$value['keytotalgrade']."</td>";
                    $return .= "<td>".$value['Aggregatescore']."</td>";
                     $return .= "<td>".$value['finalgrade']."</td>";
                     $return .= "<td><a href='".base_url()."performance/single_performance/".$value['type']."/".$value['id']."'><i class='fa fa-eye'></i></a>
                            <a href='".base_url()."performance/Appraise_del/".$value['id']."'><i class='fa fa-trash'></i></a></td>";
                    $return .="<tr>";
                    }
                echo $return;}else{
                    echo $return;
                }
            }

//==================================Short Questions filtration part=========================================
    public function questionagainstclass($id=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT short_questions.id,short_questions.question,short_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `short_questions` INNER JOIN class ON short_questions.class=class.class_id INNER JOIN subject ON short_questions.subject=subject.id INNER JOIN  chapters on chapters.id=short_questions.chapter WHERE short_questions.is_delete='0' AND short_questions.class=$id")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
              $return .= "<td><a href='".base_url()."autopaper/delete_question/short_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_shortquestions/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=====================short question subject wise filteration====================
 public function questionagainstsubject($id=0,$idsub=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT short_questions.id,short_questions.question,short_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `short_questions` INNER JOIN class ON short_questions.class=class.class_id INNER JOIN subject ON short_questions.subject=subject.id INNER JOIN  chapters on chapters.id=short_questions.chapter WHERE short_questions.is_delete='0' AND short_questions.class='$id' AND short_questions.subject='$idsub'")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {

                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['question']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/short_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_shortquestions/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//======================================short question filtarion on change of chapter=======================
    public function questionagainstchpter($id=0,$idsub=0,$idchap=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT short_questions.id,short_questions.question,short_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `short_questions` INNER JOIN class ON short_questions.class=class.class_id INNER JOIN subject ON short_questions.subject=subject.id INNER JOIN  chapters on chapters.id=short_questions.chapter WHERE short_questions.is_delete='0' AND short_questions.class=$id AND short_questions.subject=$idsub AND short_questions.chapter=$idchap")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/short_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_shortquestions/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//======================================short question filtarion on change of level=======================
    public function questionagainstlevel($id=0,$idsub=0,$idchap=0,$level="")
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                 $result = $this->db->query("SELECT short_questions.id,short_questions.question,short_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `short_questions` INNER JOIN class ON short_questions.class=class.class_id INNER JOIN subject ON short_questions.subject=subject.id INNER JOIN  chapters on chapters.id=short_questions.chapter WHERE short_questions.is_delete='0' AND short_questions.class=$id AND short_questions.subject=$idsub AND short_questions.chapter=$idchap AND short_questions.level='$level'")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/short_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_shortquestions/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
/*===================================================================================================*/
public function subjectforpaper($c="")
    {
        if(!empty($c))
        {
            $section = $this->db->query("SELECT * FROM `section` WHERE `class_id`='$c' AND `is_delete`=0 ORDER BY section_id DESC limit 1")->row_array();
                 $sid=$section['section_id'];

            $result = $this->db->query("SELECT `id`,`name` FROM `subject` WHERE `class_id`='$c'  AND `is_deleted`=0")->result_array();
            foreach ($result as $key => $value) {
                echo "<option value='".$value['id']."'>".$value['name']."</option>";
            }
        }
        else
            echo "";
    }
//==============================================Load chapters=================================================
public function chapter($v="", $class="")
    {
        
            if(!empty($v))
            {
                $result = $this->db->query("SELECT `id`,`name`,`chapterNo` FROM `chapters` WHERE `subject_id`='$v'  AND `class_id`=$class AND `chapters`.`is_delete`= '0' ")->result_array();
                //var_dump($result);die();
                foreach ($result as $key => $value) {
                    echo "<option value='".$value['id']."'>".$value['name']."-".$value['chapterNo']."</option>";
                }
            }
            else
                echo "";
    }
//=======================================================Long Questions filtrations process===============================================================
public function long_questionagainstclass($id=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT long_questions.id,long_questions.question,long_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `long_questions` INNER JOIN class ON long_questions.class=class.class_id INNER JOIN subject ON long_questions.subject=subject.id INNER JOIN  chapters on chapters.id=long_questions.chapter WHERE long_questions.is_delete='0' AND long_questions.class=$id")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/long_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_longquestion/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }

//=======================Load view of Long questions against subject================================
    public function long_questionagainstsubject($id=0,$idsub=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT long_questions.id,long_questions.question,long_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `long_questions` INNER JOIN class ON long_questions.class=class.class_id INNER JOIN subject ON long_questions.subject=subject.id INNER JOIN  chapters on chapters.id=long_questions.chapter WHERE long_questions.is_delete='0' AND long_questions.class='$id' AND long_questions.subject='$idsub'")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {

                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['question']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/long_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_longquestion/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//======================================longquestion filtarion on change of level=======================
    public function longquestionagainstlevel($id=0,$idsub=0,$idchap=0,$level="")
    {
            if(!empty($id))
             {
                 $level=urldecode($level);
                 $result = $this->db->query("SELECT long_questions.id,long_questions.question,long_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `long_questions` INNER JOIN class ON long_questions.class=class.class_id INNER JOIN subject ON long_questions.subject=subject.id INNER JOIN  chapters on chapters.id=long_questions.chapter WHERE long_questions.is_delete='0' AND long_questions.class=$id AND long_questions.subject=$idsub AND long_questions.chapter=$idchap AND long_questions.level='$level'")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/long_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_longquestion/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================fill class wise Questions filtration part=========================================
    public function fill_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.fill_blank_ans as ans,general_questions.id,general_questions.fill_blank_question as question,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',4);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['ans']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
              $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_fill/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================fill subject wise Questions filtration part=========================================
    public function fill_questionagainstsubject($classid=0,$sub=0,$type=0)
    {
            if(!empty($classid))
             {
                $this->db->select('general_questions.fill_blank_ans as ans,general_questions.id,general_questions.fill_blank_question as question,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',4);
                $this->db->where('general_questions.class',$classid);
                $this->db->where('general_questions.subject',$sub);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['ans']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_fill/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================fill chapter wise Questions filtration part=========================================
    public function fill_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.fill_blank_ans as ans,general_questions.id,general_questions.fill_blank_question as question,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',4);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['ans']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_fill/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================fill level wise Questions filtration part=========================================
    public function fill_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
        //var_dump($id,$sub,$chapter,$type,$level);die();
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.fill_blank_ans as ans,general_questions.id,general_questions.fill_blank_question as question,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',4);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['ans']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_fill/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=========================================load class wise paragraph===================================================
public function paragraph_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.paragraph,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['paragraph']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
              $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_paragraph/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Load view of Paragraph Subject wise questions================================
    public function paragraph_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.paragraph,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['paragraph']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_paragraph/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Paragraph chapter wise Questions filtration part=========================================
    public function paragraph_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.paragraph,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['paragraph']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
              $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_paragraph/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Chapter level wise Questions filtration part=========================================
    public function paragraph_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
        //var_dump($id,$sub,$chapter,$type,$level);die();
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.paragraph,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['paragraph']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_paragraph/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================load class wise Letter===================================================
public function letter_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.letter,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['letter']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Subject wise Load view of Letter questions================================
    public function letter_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.letter,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['letter']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Letter chapter wise Questions filtration part=========================================
    public function letter_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.letter,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['letter']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Level wise Letter=========================================
    public function letter_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.letter,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['letter']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";    
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise application===================================================
public function application_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.application,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['application']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_application/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Subject wise application view================================
    public function application_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.application,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['application']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_application/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Chapter wise Application=========================================
    public function application_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.application,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['application']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_application/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Level wise Application=========================================
    public function application_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.application,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['application']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_application/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Summary===================================================
public function summary_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.summary,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['summary']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_summary/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Subject wise summary================================
    public function summary_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.summary,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['summary']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_summary/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Chapter wise Summary=========================================
    public function summary_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.summary,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['summary']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_summary/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Level wise Summary=========================================
    public function summary_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.summary,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['summary']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_summary/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Essay===================================================
public function essay_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.essay,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['essay']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_essay/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Subject wise Essay questions================================
    public function essay_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                $result = $this->db->query("SELECT general_questions.id,general_questions.essay,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                $return="";
                $i=1;
                foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['essay']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_essay/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise essay=========================================
    public function essay_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.essay,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['essay']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_essay/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Level wise Essay=========================================
    public function Essay_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.essay,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['essay']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_essay/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Poem===================================================
public function poem_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.poem,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['poem']." </td>";
             
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
              $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_poem/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//=======================Subject wise of Poem questions================================
    public function poem_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.poem,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['poem']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_poem/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Chapter wise Poem=========================================
    public function poem_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.poem,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['poem']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_poem/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Level wise Poem=========================================
    public function poem_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.poem,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['poem']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_poem/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise English Translation===================================================
public function englishtranslation_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.translate_english,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['translate_english']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_translateintoeng/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of English Translation questions================================
    public function englishtranslation_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.translate_english,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['translate_english']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_translateintoeng/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
//==================================Chapter wise Translation in Egnlish=========================================
    public function englishtranslation_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.translate_english,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['translate_english']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_translateintoeng/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise Translate Into English=========================================
    public function englishtranslation_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.translate_english,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['translate_english']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_translateintoeng/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";    
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Make Sentence===================================================
public function sentence_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordforsentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['wordforsentence']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of sentence questions================================
    public function sentence_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.wordforsentence,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['wordforsentence']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise Sentence=========================================
    public function sentence_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordforsentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordforsentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise make Sentence=========================================
    public function sentence_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.wordforsentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordforsentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise centeral idea===================================================
public function centeralidea_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.centeral_idea,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['centeral_idea']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_centeralidea/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise marks the sign===================================================
public function mark_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.mark_sign,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['mark_sign']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mark_sign/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=======================Subject wise of Centeral Idea questions================================
    public function centeralidea_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.centeral_idea,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['centeral_idea']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_centeralidea/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise of mark sign questions================================
    public function mark_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.mark_sign,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['mark_sign']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mark_sign/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise Centeral Idea=========================================
    public function centeralidea_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.centeral_idea,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['centeral_idea']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_centeralidea/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Chapter wise mark_sign=========================================
    public function marl_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.mark_sign,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['mark_sign']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mark_sign/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise Centeral Idea=========================================
    public function centeralidea_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.centeral_idea,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['centeral_idea']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_centeralidea/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
                        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise mark sign=========================================
    public function mark_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.mark_sign,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['mark_sign']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mark_sign/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
                        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=========================================Class wise Ideoms===================================================
public function ideoms_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.ideoms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['ideoms']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                     $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ideoms/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of Ideoms questions================================
    public function ideoms_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.ideoms,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['ideoms']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ideoms/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise Ideoms=========================================
    public function ideoms_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.ideoms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['ideoms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ideoms/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise ideoms=========================================
    public function ideoms_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.ideoms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['ideoms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                          $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ideoms/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";   
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise sp===================================================
public function sp_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.singular,general_questions.plural,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['singular']." </td>";
                    $return .= "<td>".$value['plural']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                      $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sp/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of sp questions================================
    public function sp_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.singular,general_questions.plural,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['singular']." </td>";
                $return .= "<td>".$value['plural']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sp/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise sp=========================================
    public function sp_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.singular,general_questions.plural,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['singular']." </td>";
                        $return .= "<td>".$value['plural']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                          $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sp/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise sp=========================================
    public function sp_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.singular,general_questions.plural,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['singular']." </td>";
                        $return .= "<td>".$value['plural']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sp/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";  
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Opposites===================================================
public function opposites_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.opposites,general_questions.opposites_ans,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['opposites']." </td>";
                    $return .= "<td>".$value['opposites_ans']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_opposites_ans/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of Opposites questions================================
    public function opposites_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.opposites,general_questions.opposites_ans,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['opposites']." </td>";
                $return .= "<td>".$value['opposites_ans']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_opposites_ans/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise Opposites=========================================
    public function opposites_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.opposites,general_questions.opposites_ans,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['opposites']." </td>";
                        $return .= "<td>".$value['opposites_ans']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_opposites_ans/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise opposites========================================
    public function opposites_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.opposites,general_questions.opposites_ans,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['opposites']." </td>";
                        $return .= "<td>".$value['opposites_ans']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_opposites_ans/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
                         
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise Wordsmeanings===================================================
public function wm_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.words,general_questions.meanings,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['words']." </td>";
                    $return .= "<td>".$value['meanings']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wm/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise Masculine===================================================
public function mf_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.masculine,general_questions.feminine,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['masculine']." </td>";
                    $return .= "<td>".$value['feminine']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise Words/synonyms===================================================
public function wsys_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordsforsynonyms,general_questions.synonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['wordsforsynonyms']." </td>";
                    $return .= "<td>".$value['synonyms']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wsys/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }


//=========================================Class wise Words anto===================================================
public function wanto_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordsforantonyms,general_questions.antonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['wordsforantonyms']." </td>";
                    $return .= "<td>".$value['antonyms']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wd_ant/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise Rearrange===================================================
public function re_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.Rearrange_Sentence,general_questions.Arrange_Sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['Rearrange_Sentence']." </td>";
                    $return .= "<td>".$value['Arrange_Sentence']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_re/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }


//=========================================Class wise verbs===================================================
public function vrb_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.verb,general_questions.2nd_form,general_questions.3rd_form,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['verb']." </td>";
                    $return .= "<td>".$value['2nd_form']." </td>";
                    $return .= "<td>".$value['3rd_form']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_vrb/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise underline question===================================================
public function un_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.underline_word,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['underline_word']." </td>";
                   
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_un/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }




//=========================================Class wise match_column question===================================================
public function match_column_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.match_column_1,general_questions.match_column_2,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['match_column_1']." </td>";
                    $return .= "<td>".$value['match_column_2']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_column/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise active wise question===================================================
public function active_wise_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['active_wise']." </td>";
                    $return .= "<td>".$value['passive_wise']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_active_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise direct question===================================================
public function direct_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.direct_sentence,general_questions.indirect_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['direct_sentence']." </td>";
                    $return .= "<td>".$value['indirect_sentence']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_direct_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }



//=========================================Class wise indirect question===================================================
public function indirect_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.indirect_sentence,general_questions.direct_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['indirect_sentence']." </td>";
                    $return .= "<td>".$value['direct_sentence']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_indirect_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }

//=========================================Class wise remove too question===================================================
public function remove_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.remove_sentence,general_questions.removed_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['remove_sentence']." </td>";
                    $return .= "<td>".$value['removed_sentence']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_remove_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }


//=========================================Class wise passive wise question===================================================
public function passive_wise_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['passive_wise']." </td>";
                    $return .= "<td>".$value['active_wise']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_passive_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }


//=======================Subject wise of Words meanings questions================================
    public function wm_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.words,general_questions.meanings,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['words']." </td>";
                $return .= "<td>".$value['meanings']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wm/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise of underline questions================================
    public function un_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.underline_word,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['underline_word']." </td>";
                
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_un/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of matchcolumn questions================================
    public function match_column_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.match_column_1,general_questions.match_column_2,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['match_column_1']." </td>";
                $return .= "<td>".$value['match_column_2']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_column/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }



//=======================Subject wise of active wise questions================================
    public function active_wise_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.active_wise,general_questions.passive_wise,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['active_wise']." </td>";
                $return .= "<td>".$value['passive_wise']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_active_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }



//=======================Subject wise of direct sentence  questions================================
    public function direct_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.direct_sentence,general_questions.indirect_sentence,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['direct_sentence']." </td>";
                $return .= "<td>".$value['indirect_sentence']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_direct_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }



//=======================Subject wise of indirect sentence  questions================================
    public function indirect_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.indirect_sentence,general_questions.direct_sentence,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['indirect_sentence']." </td>";
                $return .= "<td>".$value['direct_sentence']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_indirect_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise of remove sentence  questions================================
    public function remove_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.remove_sentence,general_questions.removed_sentence,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['remove_sentence']." </td>";
                $return .= "<td>".$value['removed_sentence']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_remove_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of passive wise questions================================
    public function passive_wise_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.active_wise,general_questions.passive_wise,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['passive_wise']." </td>";
                $return .= "<td>".$value['active_wise']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_passive_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of matchword questions================================
    public function match_word_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.match_word_1,general_questions.match_word_2,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['match_word_1']." </td>";
                $return .= "<td>".$value['match_word_2']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_word/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of masculine questions================================
    public function mf_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.masculine,general_questions.feminine,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['masculine']." </td>";
                $return .= "<td>".$value['feminine']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise of Words sysnony questions================================
    public function wsys_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.wordsforsynonyms,general_questions.synonyms,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['wordsforsynonyms']." </td>";
                $return .= "<td>".$value['synonyms']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wsys/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of Words antonyms questions================================
    public function wanto_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.wordsforantonyms,general_questions.antonyms,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['wordsforantonyms']." </td>";
                $return .= "<td>".$value['antonyms']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wd_ant/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise of rearrange questions================================
    public function re_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.Rearrange_Sentence,general_questions.Arrange_Sentence,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['Rearrange_Sentence']." </td>";
                $return .= "<td>".$value['Arrange_Sentence']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_re/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//=======================Subject wise of verb questions================================
    public function vrb_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.verb,general_questions.2nd_form,general_questions.3rd_form,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['verb']." </td>";
                $return .= "<td>".$value['2nd_form']." </td>";
               $return .= "<td>".$value['3rd_form']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_vrb/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Chapter wise WM=========================================
    public function wm_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.words,general_questions.meanings,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['words']." </td>";
                        $return .= "<td>".$value['meanings']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wm/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise underline=========================================
    public function un_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.underline_word,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['underline_word']." </td>";
                       
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_un/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise matchcolumn=========================================
    public function match_column_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.match_column_1,general_questions.match_column_2,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['match_column_1']." </td>";
                       $return .= "<td>".$value['match_column_2']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_column/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Chapter wise active wise=========================================
    public function active_wise_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['active_wise']." </td>";
                       $return .= "<td>".$value['passive_wise']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_active_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Chapter wise direct sentence=========================================
    public function direct_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.direct_sentence,general_questions.indirect_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['direct_sentence']." </td>";
                       $return .= "<td>".$value['indirect_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_direct_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise indirect sentence=========================================
    public function indirect_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.indirect_sentence,general_questions.direct_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['indirect_sentence']." </td>";
                       $return .= "<td>".$value['direct_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_indirect_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Chapter wise remove sentence=========================================
    public function remove_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.remove_sentence,general_questions.removed_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['remove_sentence']." </td>";
                       $return .= "<td>".$value['removed_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_remove_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }




//==================================Chapter wise passive wise=========================================
    public function passive_wise_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['passive_wise']." </td>";
                       $return .= "<td>".$value['active_wise']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_passive_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }



//==================================Chapter wise matchword=========================================
    public function match_word_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.match_word_1,general_questions.match_word_2,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['match_word_1']." </td>";
                       $return .= "<td>".$value['match_word_2']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_word/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise Masculine=========================================
    public function mf_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.masculine,general_questions.feminine,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['masculine']." </td>";
                        $return .= "<td>".$value['feminine']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise words sysnony=========================================
    public function wsys_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordsforsynonyms,general_questions.synonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordsforsynonyms']." </td>";
                        $return .= "<td>".$value['synonyms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wsys/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise Words antonyms=========================================
    public function wanto_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.wordsforantonyms,general_questions.antonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordsforantonyms']." </td>";
                        $return .= "<td>".$value['antonyms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wd_ant/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Chapter wise Rearrange=========================================
    public function re_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.Rearrange_Sentence,general_questions.Arrange_Sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['Rearrange_Sentence']." </td>";
                        $return .= "<td>".$value['Arrange_Sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_re/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }



//=========================================Class wise homophone===================================================
public function homo_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.homo_word1,general_questions.homo_word2,general_questions.homo_word3,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();

                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['homo_word1']." </td>";
                    $return .= "<td>".$value['homo_word2']." </td>";
                    $return .= "<td>".$value['homo_word3']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                    $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ho/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }




//=======================Subject wise of homophone questions================================
    public function homo_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.homo_word1,general_questions.homo_word2,general_questions.homo_word3,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' AND general_questions.is_delete=0 ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
               
                $return .= "<td>".$value['homo_word1']." </td>";
                $return .= "<td>".$value['homo_word2']." </td>";
                $return .= "<td>".$value['homo_word3']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ho/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }





//==================================Chapter wise homophone=========================================
    public function homo_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.homo_word1,general_questions.homo_word2,general_questions.homo_word3,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['homo_word1']." </td>";
                        $return .= "<td>".$value['homo_word2']." </td>";
                         $return .= "<td>".$value['homo_word3']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ho/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise homo========================================
    public function homo_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.homo_word1,general_questions.homo_word2,general_questions.homo_word3,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['homo_word1']." </td>";
                        $return .= "<td>".$value['homo_word2']." </td>";
                          $return .= "<td>".$value['homo_word3']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_ho/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }




//==================================Chapter wise verb=========================================
    public function vrb_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.verb,general_questions.2nd_form,general_questions.3rd_form,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['verb']." </td>";
                        $return .= "<td>".$value['2nd_form']." </td>";
                        $return .= "<td>".$value['3rd_form']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_vrb/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise WM========================================
    public function wm_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.words,general_questions.meanings,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['words']." </td>";
                        $return .= "<td>".$value['meanings']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wm/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise underline========================================
    public function un_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.underline_word,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['underline_word']." </td>";
                      
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_un/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise matchcolumn========================================
    public function match_column_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.match_column_1,general_questions.match_column_2,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['match_column_1']." </td>";
                        $return .= "<td>".$value['match_column_2']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_column/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise active wise========================================
    public function active_wise_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['active_wise']." </td>";
                        $return .= "<td>".$value['passive_wise']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_active_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise direct sentence========================================
    public function direct_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.direct_sentence,general_questions.indirect_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['direct_sentence']." </td>";
                        $return .= "<td>".$value['indirect_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_direct_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise indirect sentence========================================
    public function indirect_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.indirect_sentence,general_questions.direct_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['indirect_sentence']." </td>";
                        $return .= "<td>".$value['direct_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_indirect_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise remove sentence========================================
    public function remove_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.remove_sentence,general_questions.removed_sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['remove_sentence']." </td>";
                        $return .= "<td>".$value['removed_sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_remove_sentence/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise passive wise========================================
    public function passive_wise_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.active_wise,general_questions.passive_wise,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['passive_wise']." </td>";
                        $return .= "<td>".$value['active_wise']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_passive_wise/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise matchword========================================
    public function match_word_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.match_word_1,general_questions.match_word_2,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['match_word_1']." </td>";
                        $return .= "<td>".$value['match_word_2']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_match_word/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }



//==================================Level wise re========================================
    public function re_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.Rearrange_Sentence,general_questions.Arrange_Sentence,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['Rearrange_Sentence']." </td>";
                        $return .= "<td>".$value['Arrange_Sentence']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_re/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise Words antonyms========================================
    public function wanto_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.wordsforantonyms,general_questions.antonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordsforantonyms']." </td>";
                        $return .= "<td>".$value['antonyms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wd_ant/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }


//==================================Level wise masculine========================================
    public function mf_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.masculine,general_questions.feminine,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['masculine']." </td>";
                        $return .= "<td>".$value['feminine']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise Words sysnony========================================
    public function wsys_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.wordsforsynonyms,general_questions.synonyms,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['wordsforsynonyms']." </td>";
                        $return .= "<td>".$value['synonyms']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_wsys/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//==================================Level wise verb========================================
    public function vrb_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.verb,general_questions.2nd_form,general_questions.3rd_form,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
 $this->db->where('general_questions.is_delete',0);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['verb']." </td>";
                        $return .= "<td>".$value['2nd_form']." </td>";
                        $return .= "<td>".$value['3rd_form']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
  $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_vrb/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>"; 
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=========================================Class wise sd===================================================
public function sd_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.postive,general_questions.coparative,general_questions.superlative,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['postive']." </td>";
                    $return .= "<td>".$value['coparative']." </td>";
                    $return .= "<td>".$value['superlative']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sd/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of SD questions================================
    public function sd_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.postive,general_questions.coparative,general_questions.superlative,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['postive']." </td>";
                $return .= "<td>".$value['coparative']." </td>";
                $return .= "<td>".$value['superlative']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sd/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise SD=========================================
    public function sd_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.postive,general_questions.coparative,general_questions.superlative,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                         $return .= "<td>".$value['postive']." </td>";
                        $return .= "<td>".$value['coparative']." </td>";
                        $return .= "<td>".$value['superlative']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sd/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise SD========================================
    public function sd_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.postive,general_questions.coparative,general_questions.superlative,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['postive']." </td>";
                         $return .= "<td>".$value['coparative']." </td>";
                        $return .= "<td>".$value['superlative']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_sd/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
                       
                 }
                 echo $return;
            }
            else
                echo "";
    }
//=========================================Class wise tf===================================================
public function tf_questionagainstclass($id=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.true_words,general_questions.false_words,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                    $return .= "<tr>";
                    $return .= "<td>".$i++."</td>";
                    $return .= "<td>".$value['true_words']." </td>";
                    $return .= "<td>".$value['false_words']." </td>";
                    $return .= "<td>".$value['class_name']." </td>";
                    $return .= "<td>".$value['sub']." </td>";
                    $return .= "<td>".$value['chap']."</td>";
                    $return .= "<td>".$value['level']."</td>";
                     $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_tf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo ""; 
    }
//=======================Subject wise of tf questions================================
    public function tf_questionagainstsubject($id=0,$idsub=0, $type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.true_words,general_questions.false_words,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['true_words']." </td>";
                $return .= "<td>".$value['false_words']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                 $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_tf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Chapter wise tf=========================================
    public function tf_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.true_words,general_questions.false_words,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['true_words']." </td>";
                        $return .= "<td>".$value['false_words']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_tf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }
//==================================Level wise tf========================================
    public function tf_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.true_words,general_questions.false_words,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['true_words']." </td>";
                        $return .= "<td>".$value['false_words']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                         $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_tf/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";

 
                 }
                 echo $return;
            }
            else
                echo "";
    }















    public function long_questionagainstchpter($id=0,$idsub=0,$idchap=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT long_questions.id,long_questions.question,long_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `long_questions` INNER JOIN class ON long_questions.class=class.class_id INNER JOIN subject ON long_questions.subject=subject.id INNER JOIN  chapters on chapters.id=long_questions.chapter WHERE long_questions.is_delete='0' AND long_questions.class=$id AND long_questions.subject=$idsub AND long_questions.chapter=$idchap")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td>
             <a href='".base_url()."autopaper/delete_question/".$value['id']."'><i class='fa fa-trash'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }

    public function mcq_questionagainstclass($id=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT mcq_questions.correct_answer,mcq_questions.option1,mcq_questions.option2,mcq_questions.option3,mcq_questions.option4, mcq_questions.id ,mcq_questions.question,mcq_questions.level,class.class_name,subject.name AS subj,chapters.name as chap,mcq_questions.correct_answer 
FROM mcq_questions   INNER JOIN class on class.class_id=mcq_questions.class INNER JOIN subject ON subject.id=mcq_questions.subject INNER JOIN chapters on chapters.id=mcq_questions.chapter WHERE  mcq_questions.is_delete='0' AND mcq_questions.class=$id")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['option1']." </td>";
             $return .= "<td>".$value['option2']." </td>";
             $return .= "<td>".$value['option3']." </td>";
             $return .= "<td>".$value['option4']." </td>";
             $return .= "<td>".$value['correct_answer']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['subj']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/mcq_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mcq/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }


    public function mcq_questionagainstsubject($id=0,$idsub=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT mcq_questions.correct_answer,mcq_questions.option1,mcq_questions.option2,mcq_questions.option3,mcq_questions.option4, mcq_questions.id ,mcq_questions.question,mcq_questions.level,class.class_name,subject.name AS subj,chapters.name as chap,mcq_questions.correct_answer 
FROM mcq_questions   INNER JOIN class on class.class_id=mcq_questions.class INNER JOIN subject ON subject.id=mcq_questions.subject INNER JOIN chapters on chapters.id=mcq_questions.chapter WHERE  mcq_questions.is_delete='0' AND mcq_questions.class=$id AND mcq_questions.subject=$idsub")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['option1']." </td>";
             $return .= "<td>".$value['option2']." </td>";
             $return .= "<td>".$value['option3']." </td>";
             $return .= "<td>".$value['option4']." </td>";
             $return .= "<td>".$value['correct_answer']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['subj']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/mcq_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mcq/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }

    public function mcq_questionagainstchpter($id=0,$idsub=0,$idchap=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT mcq_questions.correct_answer,mcq_questions.option1,mcq_questions.option2,mcq_questions.option3,mcq_questions.option4, mcq_questions.id ,mcq_questions.question,mcq_questions.level,class.class_name,subject.name AS subj,chapters.name as chap,mcq_questions.correct_answer 
FROM mcq_questions   INNER JOIN class on class.class_id=mcq_questions.class INNER JOIN subject ON subject.id=mcq_questions.subject INNER JOIN chapters on chapters.id=mcq_questions.chapter WHERE  mcq_questions.is_delete='0' AND mcq_questions.class=$id AND mcq_questions.subject=$idsub AND mcq_questions.chapter=$idchap")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['option1']." </td>";
             $return .= "<td>".$value['option2']." </td>";
             $return .= "<td>".$value['option3']." </td>";
             $return .= "<td>".$value['option4']." </td>";
             $return .= "<td>".$value['correct_answer']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['subj']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
            $return .= "<td><a href='".base_url()."autopaper/delete_question/mcq_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mcq/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 //var_dump($return);die();
                 echo $return;
            }
            else
                echo "";
        
    }
//=============================Load MCQs level wise
    public function mcq_questionagainstlevel($id=0,$idsub=0,$idchap=0,$level="")
    {
            if(!empty($id))
             {
                 $level=urldecode($level);
                 $result = $this->db->query("SELECT mcq_questions.correct_answer,mcq_questions.option1,mcq_questions.option2,mcq_questions.option3,mcq_questions.option4, mcq_questions.id ,mcq_questions.question,mcq_questions.level,class.class_name,subject.name AS subj,chapters.name as chap,mcq_questions.correct_answer 
FROM mcq_questions   INNER JOIN class on class.class_id=mcq_questions.class INNER JOIN subject ON subject.id=mcq_questions.subject INNER JOIN chapters on chapters.id=mcq_questions.chapter WHERE  mcq_questions.is_delete='0' AND mcq_questions.class=$id AND mcq_questions.subject=$idsub AND mcq_questions.chapter=$idchap AND mcq_questions.level='$level' ")->result_array();
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['question']." </td>";
             $return .= "<td>".$value['option1']." </td>";
             $return .= "<td>".$value['option2']." </td>";
             $return .= "<td>".$value['option3']." </td>";
             $return .= "<td>".$value['option4']." </td>";
             $return .= "<td>".$value['correct_answer']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['subj']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
            $return .= "<td><a href='".base_url()."autopaper/delete_question/mcq_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_mcq/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 //var_dump($return);die();
                 echo $return;
            }
            else
                echo "";   
    }
//=========================================Class wise grammer===================================================
public function grammer_questionagainstclass($id=0,$type=0)
    {
           if(!empty($id))
             {
                $this->db->select('general_questions.grammer,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {

             $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['grammer']." </td>";
             $return .= "<td>".$value['class_name']." </td>";
             $return .= "<td>".$value['sub']." </td>";
             $return .= "<td>".$value['chap']."</td>";
             $return .= "<td>".$value['level']."</td>";
             $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
    }

//=======================Subject wise Load view of grammer questions================================
    public function grammer_questionagainstsubject($id=0,$idsub=0,$type=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT general_questions.id,general_questions.grammer,general_questions.level,class.class_name,subject.name as sub,chapters.name as chap FROM `general_questions` INNER JOIN class ON general_questions.class=class.class_id INNER JOIN subject ON general_questions.subject=subject.id INNER JOIN  chapters on chapters.id=general_questions.chapter WHERE general_questions.is_delete='0' AND general_questions.class='$id'  AND general_questions.subject='$idsub' AND general_questions.question_type='$type' ")->result_array();
                 $return="";

                 $i=1;
                 foreach ($result as $key => $value) {
                $return .= "<tr>";
                $return .= "<td>".$i++."</td>";
                $return .= "<td>".$value['grammer']." </td>";
                $return .= "<td>".$value['class_name']." </td>";
                $return .= "<td>".$value['sub']." </td>";
                $return .= "<td>".$value['chap']."</td>";
                $return .= "<td>".$value['level']."</td>";
                $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }


//==================================grammer chapter wise Questions filtration part=========================================
    public function grammer_questionagainstchapter($id=0,$sub=0,$chapter=0,$type=0)
    {
            if(!empty($id))
             {
                $this->db->select('general_questions.grammer,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $result=$this->db->get()->result_array();
                $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['grammer']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a><a href='".base_url()."autopaper/edit_letter/".$value['id']."'><i class='fa fa-edit'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }

//==================================Level wise grammer=========================================
    public function grammer_questionagainstlevel($id=0,$sub=0,$chapter=0,$level="",$type=0)
    {
            if(!empty($id))
             {
                $level=urldecode($level);
                $this->db->select('general_questions.grammer,general_questions.id,general_questions.level,class.class_name,subject.name as sub, chapters.name as chap');
                $this->db->from('general_questions');
                $this->db->join('class','general_questions.class=class.class_id');
                $this->db->join('chapters','general_questions.chapter=chapters.id');
                $this->db->join('subject','general_questions.subject=subject.id');
                $this->db->where('general_questions.question_type',$type);
                $this->db->where('general_questions.class',$id);
                $this->db->where('general_questions.subject',$sub);
                $this->db->where('general_questions.chapter',$chapter);
                $this->db->where('general_questions.level',$level);
                $result=$this->db->get()->result_array();
                $return="";
                $i=1;
                 foreach ($result as $key => $value) {
                        $return .= "<tr>";
                        $return .= "<td>".$i++."</td>";
                        $return .= "<td>".$value['grammer']." </td>";
                        $return .= "<td>".$value['class_name']." </td>";
                        $return .= "<td>".$value['sub']." </td>";
                        $return .= "<td>".$value['chap']."</td>";
                        $return .= "<td>".$value['level']."</td>";
                        $return .= "<td><a href='".base_url()."autopaper/delete_question/general_questions/".$value['id']."'><i class='fa fa-trash'></i></a></td>";
             $return .= "</tr>";    
                 }
                 echo $return;
            }
            else
                echo "";
    }

        public function questionagainstchpter_checkbox($id=0,$idsub=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT `id`,`name`,`chapterNo` FROM `chapters` WHERE `class_id`='$id' AND subject_id='$idsub' AND is_delete=0")->result_array();
                
                 $return="";
                 $i=1;
                 if(!empty($result))
                 {
                      $return.="<input type='checkbox' id='all_check'>All";
                     foreach ($result as $key => $value) {
    
                        $return .= "<div id='chapter' name='chapter' class='form-control'>
                        <input name='chapter[]' class='ch' type='checkbox' value=".$value['id'].">".$value['name']."     --".$value['chapterNo']." </div>";
                 
                     }
                 }
                echo $return;
            }
            else
                echo "";
        
    }
    
    
    
     public function search_sid($sid="", $br="")
    {
     //$branch = $this->user_model->getBranch();  
    $result = $this->db->select('sid')->from('student')->where('sid', $sid)
                                        ->where('branch',$br)->get()->row();

    // var_dump($result);die();

    if ($result) {
       echo "true"; 
    }
    
    }
    
     public function search_lastsid($br="")
    {
     //$branch = $this->user_model->getBranch();  
    $sid = @$this->db->select('sid')->from('student')
                                        ->where('branch',$br)->order_by('id','DESC')->get()->row()->sid;

    // var_dump($result);die();

    if ($sid) {
    $result = "";
    $result .= "<p class='text-danger' style='font-size:11px;font-weight:bolder'>";
    if($sid){
        $result .= "(Last SID:  ".$sid.")</p>";
	}                       
       echo $result; 
    }
    
    }

public function getstop($id=0)
    {
            if(!empty($id))
             {
                 
                 $branch=$this->user_model->getbranch();
                 $result = $this->db->query("SELECT stop.id,stop.name,city.city_name,stop.fee FROM `stop` inner JOIN `city` ON city.city_id=stop.city_id WHERE stop.city_id='$id' AND stop.is_delete='0' AND stop.branch='$branch'")->result_array();
                 // var_dump($result);
                 $return="";
                 $i=1;
                 foreach ($result as $key => $value) {
                     // echo "<option value='".$value['city_id']."'>".$value['city_name']."</option>";

                         $return .= "<tr>";
             $return .= "<td>".$i++."</td>";
             $return .= "<td>".$value['name']." </td>";
             $return .= "<td>".$value['city_name']." </td>";
             $return .= "<td>".$value['fee']."</td>";
             $return .= "<td><a href='".base_url()."staff/actions/edit/".$value['id']."'><i class='fa fa-edit'></i></a>
             <a href='".base_url()."staff/actions/del/".$value['id']."'><i class='fa fa-trash'></i></a></td>";
             $return .= "</tr>";
        
                 }
                 echo $return;
            }
            else
                echo "";
        
    }
       public function pass_student($branch=0,$cl=0)
    {   
        if(!empty($cl))
        {
            $result = $this->db->query("select student.id,student.student_name,student.grno from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cl' AND student.status!='0'  AND student.is_delete='0' AND student.branch='$branch'")->result_array();

            foreach ($result as $key => $value) {
                echo '<option value="'.$value['id'].'">'.$value['grno'].' .'.$value['student_name'].'</option>';
            }
        }
        else
            echo "";
        
    }
     
/*==================================================================================================*/

  public function stop_student($id=0)
    {
            if(!empty($id))
             {
                 $result = $this->db->query("SELECT stop.id,stop.name,city.city_name,stop.fee FROM `stop` inner JOIN `city` ON city.city_id=stop.city_id WHERE stop.city_id='$id' AND stop.is_delete='0'")->result_array();
                 // var_dump($result);
                 $return="";
                 
                 foreach ($result as $key => $value) {
                     // echo "<option value='".$value['city_id']."'>".$value['city_name']."</option>";
                    echo "<option value='".$value['id']."'>".$value['name']."</option>";
            
                 }
            }
            else
                echo "";
        
    }

    public function getemp_advance($value='')
    {
        if(!empty($value))
             {
                 if($value=="teacher")
                 {
                     $data=$this->salary_model->Advance_teacher($value);
                      $return="";
                        $i=1;
                 foreach ($data as $key => $value) {

                         $return .= "<tr>";
               $return .= "<td>".$i++."</td>";
               $return .= "<td>".$value['firstname']."".$value['lastname']." </td>";
               $return .= "<td>".$value['refrence']." </td>";
               $return .= "<td>".$value['Amount']." </td>";
             $return .= "<td>".$value['month']." </td>";
             $return .= "<td><a href='".base_url()."salary/actions/del/".$value['id']."'><i class='fa fa-trash'></i></a>
             <a href='".base_url()."salary/actions/edit/".$value['id']."'><i class='fa fa-pencil'></i></a>
             </td>";
            $return .= "</tr>";
        
                 }
                 echo $return;
            
                 }else if($value=="staff"){
                     $data=$this->salary_model->Advance_staff($value);
                      $return="";
                        $i=1;
                 foreach ($data as $key => $value) {

                         $return .= "<tr>";
               $return .= "<td>".$i++."</td>";
               $return .= "<td>".$value['firstname']."".$value['lastname']." </td>";
               $return .= "<td>".$value['refrence']." </td>";
               $return .= "<td>".$value['Amount']." </td>";
             $return .= "<td>".$value['month']." </td>";
             $return .= "<td><a href='".base_url()."salary/actions/del/".$value['id']."'><i class='fa fa-trash'></i></a>
             <a href='".base_url()."salary/actions/edit/".$value['id']."'><i class='fa fa-pencil'></i></a>
             </td>";
            $return .= "</tr>";
        
                 }
                 echo $return;
                 }else{
                     echo "";
                 }
             }
    }
    public function getemp_advance1($val,$ref='')
    {
        if(!empty($ref && $val))
             {
                  if($ref=="teacher" && $val!=0)
                 {
                     $data=$this->salary_model->advance1_teacher($ref,$val);
                     echo json_encode($data);
                 }else if($ref=="staff" && $val!=0){
                     $data=$this->salary_model->advance1_staff($ref,$val);
                     echo json_encode($data);
                 }else{
                     echo "";
                 }
             }
    }
    
          public function checkall_deduction($id,$ref)
    {
    $er=$this->db->where('bothid',$id)->where('refrence',$ref)->where('status',0)->get('deductions_assigned')->result_array();
       echo json_encode($er);

   }
       public function checkallowan($id,$ref)
    {
    $er=$this->db->where('bothid',$id)->where('refrence',$ref)->where('status',0)->get('assign_allowance')->result_array();
       echo json_encode($er);

   }
   
     public function checkval1($id) 
        {
          
         $data = $this->Staff_model->matches($id);       
             $return="";
             foreach ($data as $key => $value) {
               
                $return.="<option value='$value->id'>$value->firstname $value->lastname</option>";  
             }
        echo $return;
     }
     
        public function checkval1_security($id) 
        {
          
         $data = $this->Staff_model->matches_security($id);       
             $return="";
              
             foreach ($data as $key => $value) {
                
                $return.="<option value='$value->id'>$value->firstname $value->lastname</option>";  
             }
        echo $return;
     }
        
      public function checkval($id) 
        {
          
         $data = $this->Teacher_model->matches($id);     
        $return="";
         $return.="<option value=''>Select Employee</option>";
             foreach ($data as $key => $value) {
               $return.="<option value='$value->id'>$value->firstname $value->lastname</option>"; 
                   }
        echo $return;
      }
      
       public function checkval_security($id) 
        {
          
         $data = $this->Teacher_model->matches_security($id);     
        $return="";
             foreach ($data as $key => $value) {
               $return.="<option value='$value->id'>$value->firstname $value->lastname</option>"; 
                   }
        echo $return;
      }
        
    public function data_emp($ref="",$val="")
    {
        $branch=$this->user_model->getbranch();
        if($ref=="teacher"){
            
            $this->db->select("id,CONCAT(firstname,' ', lastname) as name");
            $this->db->from('teacher');
            $this->db->where('branch',$branch)->where('is_delete',0)->where('status',0);
            $this->db->like('firstname',$val);
            $data=$this->db->get()->result_array();
            echo json_encode($data);
        }else if($ref=="staff"){
            $this->db->select("id,CONCAT(firstname,' ', lastname) as name");
            $this->db->from('staff');
            $this->db->where('branch',$branch)->where('status',0);
            $this->db->like('firstname',$val);
            $data=$this->db->get()->result_array();
            echo json_encode($data);
        }else{echo "";}
    }
    
    public function id_security($ref="",$id="")
    {

       $detuct=0;$security=0;
        if($ref=="teacher"){
            
            $this->db->select("security");
            $this->db->from('teacher');
            $this->db->where('is_delete',0)->where('id',$id);
            $security= $this->db->get()->result_array()[0]['security'];
            $this->db->select('detuct_amount');
            $this->db->from('security_deduct');
            $this->db->where('status',0)->where('is_delete',0)->where('bothid',$id)->where('refrence',$ref);
            $data=$this->db->get()->result_array();
            foreach ($data as $key => $value) {
                $detuct=$value['detuct_amount']+$detuct;
            }
            if($detuct!=$security){
                $se=(int)$security - $detuct;
                $data=array('security' => $se );
                echo json_encode($data);
            }else if($detuct==$security){
                $data=array('security'=>0);
                echo json_encode($data);
            }else{
                $data=array('security'=>$security);
                echo json_encode($data);
            }
            
        }else if($ref=="staff"){
           $this->db->select("security");
            $this->db->from('staff');
            $this->db->where('status',0)->where('id',$id);
            $security= $this->db->get()->result_array()[0]['security'];
            $this->db->select('detuct_amount');
            $this->db->from('security_deduct');
            $this->db->where('status',0)->where('is_delete',0)->where('bothid',$id)->where('refrence',$ref);
            $data=$this->db->get()->result_array();
            foreach ($data as $key => $value) {
                $detuct=$value['detuct_amount']+$detuct;
            }
            if($detuct!=$security){
                $se=(int)$security - $detuct;
                $data=array('security' => $se );
                echo json_encode($data);
            }else{
                $data=array('security'=>$security);
                echo json_encode($data);
            }
        }else{echo "";}
        
    }

    public function check_voucher($cid="",$sid="",$date="")
    {
        if(!empty($cid) && !empty($sid) && !empty($date))
        {
            date_default_timezone_set("Asia/Karachi");
        $ym = date("Y-m",strtotime($date));
		$disabled_check = $this->db->select('invoice.student_id')
		                           ->from("invoice")
		                           ->join("promotion","promotion.id=invoice.student_id")
		                           ->where("promotion.is_delete","0")
		                           ->where("promotion.is_active","1")
		                           ->where("promotion.class_id",$cid)
		                           ->where("promotion.section_id",$sid)
		                           ->where("LEFT(`invoice`.`date`,7)",$ym)
		                           ->get()->result_array();
        //echo "<pre>";print_r($disabled_check);die();
		$add_month_fee_check=$this->db->select('invoice.student_id')
		                              ->from("invoice")
		                              ->join("promotion","promotion.id=invoice.student_id")
		                              ->join("fee_add_months","fee_add_months.invoice_id=invoice.id")
		                              ->where("promotion.is_delete","0")
		                              ->where("promotion.is_active","1")
		                              ->where("promotion.class_id",$cid)
		                              ->where("promotion.section_id",$sid)
		                              ->where('fee_add_months.month',$ym)
		                              ->where('fee_add_months.is_delete',0)
		                              ->where('invoice.is_delete',0)
		                              ->get()->result_array();
		foreach($disabled_check as $key=>$val){
		    $students[] = $val['student_id']; 
		    }
        foreach($add_month_fee_check as $key=>$val){
		    $students[] = $val['student_id']; 
		    }
        }
		if(!empty($cid) && !empty($sid) && !empty($date))
        {
            $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cid' and promotion.section_id='$sid' AND promotion.is_active='1' AND student.status='0' AND student.is_delete='0' AND promotion.id NOT IN ( '" . implode( "', '" , $students ) . "' )")->result_array();
            foreach ($result as $key => $value) {
                echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
            }
        }
        else
        echo "No Student Found";
	}
    
    public function check_voucher_left($cid="",$sid="",$date="",$ses="")
    {
        $branch=$this->user_model->getbranch();
        if($branch==1)
        {
            $st_status=21;
        }else{
            $st_status=23;
        }
        
        if(!empty($cid) && !empty($sid) && !empty($date) && !empty($ses))
        {
            date_default_timezone_set("Asia/Karachi");
        $ym = date("Y-m",strtotime($date));
		$disabled_check = $this->db->select('invoice.student_id')
		                           ->from("invoice")
		                           ->join("promotion","promotion.id=invoice.student_id")
		                           ->where("promotion.is_delete","0")
		                           ->where("promotion.is_active","1")
		                           ->where("promotion.class_id",$cid)
		                           ->where("promotion.section_id",$sid)
		                           ->where("promotion.session_id",$ses)
		                           ->where("LEFT(`invoice`.`date`,7)",$ym)
		                           ->get()->result_array();
        //echo "<pre>";print_r($disabled_check);die();
		$add_month_fee_check=$this->db->select('invoice.student_id')
		                              ->from("invoice")
		                              ->join("promotion","promotion.id=invoice.student_id")
		                              ->join("fee_add_months","fee_add_months.invoice_id=invoice.id")
		                              ->where("promotion.is_delete","0")
		                              ->where("promotion.is_active","1")
		                              ->where("promotion.class_id",$cid)
		                              ->where("promotion.section_id",$sid)
		                              ->where("promotion.session_id",$ses)
		                              ->where('fee_add_months.month',$ym)
		                              ->where('fee_add_months.is_delete',0)
		                              ->where('invoice.is_delete',0)
		                              ->get()->result_array();
		foreach($disabled_check as $key=>$val){
		    $students[] = $val['student_id']; 
		    }
        foreach($add_month_fee_check as $key=>$val){
		    $students[] = $val['student_id']; 
		    }
        }
		if(!empty($cid) && !empty($sid) && !empty($date))
        {
            
            $result = $this->db->query("select student.id,student.student_name,student.sid,student.roll_no from `student` inner join `promotion` on student.id=promotion.student_id where promotion.class_id='$cid' and promotion.section_id='$sid' and promotion.session_id='$ses' AND promotion.is_active='1' AND student.status='$st_status' AND promotion.id NOT IN ( '" . implode( "', '" , $students ) . "' )")->result_array();
            foreach ($result as $key => $value) {
                echo '<option value="'.$value['id'].'">'.$value['roll_no'].' .'.$value['student_name'].'</option>';
            }
        }
        else
        echo "No Student Found";
	}
	
	
    public function CheckTeacherAllocation($class=0,$subject=0)
    {
        if(!empty($class) AND !empty($subject))
        {
		    $disabled_check = $this->db->where("is_deleted","0")->where("class_id",$class)->where("subject_id",$subject)->from("teacheralloc")->count_all_results();
            if($disabled_check>0)
                echo 1;
            else
                echo 0;
        }
    }
    
       public  function countDays($year, $month, $ignore) {
    $count = 0;
    $counter = mktime(0, 0, 0, $month, 1, $year);
    while (date("n", $counter) == $month) {
        if (in_array(date("w", $counter), $ignore) == false) {
            $count++;
        }
        $counter = strtotime("+1 day", $counter);
    }
    return $count;
}
     public function emp_depart($type,$mnth)
    {
      
     
     
      
        $branch=$this->user_model->getbranch();
          
        $dpt['cls']=$this->db->query("SELECT * FROM `teacher` WHERE 
         `branch`=$branch and `status`=0 and `is_delete`=0")->result_array();
        $lev_types=$this->db->select('*')
                               ->from('leave_types')
                               ->where('branch',$branch)
                               ->where('name!=',"A")
                               ->order_by('id',"ASC")
                               ->get()->result_array();

      if(!empty($dpt['cls']))
     {             
                 
  foreach ($dpt['cls'] as $key => $value) 
    { 

       $emppp=$value['id'];  
       $query1122=$this->db->where('bothid',$emppp)
                           ->where('refrence',$type)
                           ->where('month',$mnth)
                           ->get('salary')->row();
       if(count($query1122)==0){
           $acc_sum=0;
           $acc_absnt=0;
           $no_mark=0;
           $bouns=0;
     
     echo "<tr>
        <td><input type='checkbox' name='check[$value[id]]' class='chek_me'  value='$value[id]' checked></td>
        <td>$value[firstname] $value[lastname]</td>";
        if(!empty($lev_types))
        {
            
            foreach($lev_types as $lev)
            {
                 $check_allocation=$this->db->select('*')
                                           ->from('leave_allocation')
                                           ->where('type',"teacher")
                                           ->where('branch',$branch)
                                           ->where('status',0)
                                           ->where('is_delete',0)
                                           ->where('leave_id',$lev['id'])
                                           ->where('bothid',$value['id'])
                                           ->limit('1')
                                           ->order_by('id','desc')
                                           ->get()->row_array()['total_leave'];
                   var_dump('<pre>',$check_allocation);
                //   die();
                if(!empty($check_allocation))
                {
                    if($lev['mode']=="Monthly")
                    {
                        $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('teacherattendance')
                                            ->where('teacher_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                        $acc_sum=$acc_sum+$fetch_att_teacher;                     
                        if($fetch_att_teacher>$check_allocation) 
                        {
                            $acc_absnt=$fetch_att_teacher-$check_allocation;
                        }
                    }else
                    {
                        $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('teacherattendance')
                                            ->where('teacher_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                        $acc_sum=$acc_sum+$fetch_att_teacher;                     
                                            
                        $fetch_att_all=$this->db->select('count(id) as id')
                                            ->from('teacherattendance')
                                            ->where('teacher_id',$value['id'])
                                            ->where('left(date,7)<=',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                         if($fetch_att_all>$check_allocation) 
                        {
                            $acc_absnt=$fetch_att_all-$check_allocation;
                        }                    
                    }
                    
                }else{
                    $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('teacherattendance')
                                            ->where('teacher_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                  
                 if($lev['name']=="P") 
                 {
                    $bouns+=$fetch_att_teacher;
                 }elseif($lev['name']=="HD")
                 {
                    $bouns+=$fetch_att_teacher; 
                 }
                 
                    $acc_sum=$acc_sum+$fetch_att_teacher;                 
                }
            
               
         echo" <td>
           <input type='text' readonly style='width: 80%;'  value='$fetch_att_teacher'> 
         </td>";  
            }
        }
        $year=date('Y',strtotime($mnth));
         $month=substr($mnth,-2);
       $d=$this->countDays($year,$month, array(0, 7));
    //   var_dump($d);
    //   die();
       //For Bouns
       $yr=date('Y',strtotime($mnth));
       $monthly=substr($month,-2);
       $dc= cal_days_in_month(CAL_GREGORIAN,$monthly,$yr);
    
        $fetch_absents=$this->db->select('count(teacherattendance.id) as id')
                                            ->from('teacherattendance')
                                            ->join('leave_types','leave_types.id=teacherattendance.status_id')
                                            ->where('teacher_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('leave_types.name',"A")
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id']; 
        $acc_sum=$acc_sum+$fetch_absents; 
        $no_mark=$d-$acc_sum;
        if(!empty($fetch_absents)) 
        {
            $fetch_absents=$fetch_absents+$acc_absnt+$no_mark;
        }else
        {
            $fetch_absents=$acc_absnt+$no_mark;
        }
        
          echo" <td>
           <input type='text' readonly style='width: 80%;' name='absnt[$value[id]]'  value='$fetch_absents'> 
         </td>"; 
                          $re=0;
                                     
                                        
                                        $this->db->select('salery')->from('teacher');
                                        $this->db->where('is_delete',0)->where('status',0)->where('id',$value['id']);                                        
                                        $re=$this->db->get()->row_array()['salery'];
       
                                   //Increments
                                    $increments=$this->db->select('sum(amount) as amount')
                                                                   ->from('increments')
                                                                   ->where('refrence',"teacher")
                                                                   ->where('bothid',$value['id'])
                                                                   ->where('month <=',$mnth)
                                                                   ->where('is_del',0)
                                                                   ->get()->row_array()['amount'];
                                            if(!empty($increments)) 
                                            {
                                                $re=$re+$increments;
                                            }else
                                            {
                                                $re=$re;
                                            }


                                            $sal_day = $re/date('t',strtotime($mnth));//one day salary
                                            $bns=$re/$dc;
                                            $sal = $fetch_absents*date('t',strtotime($mnth));;
                                           
                                            $amount=round($sal, 2);
                                            $sal_day=round($sal_day, 2);
                                            $bns=round($bns,2);
         if($bouns==$d){
             echo "<td><input type='number' style='width: 100%;'  value='$sal_day' readonly   name='bouns[$value[id]]'></td>"; 
         }else
         {
            echo "<td><input type='number' style='width: 100%;'  value='0' readonly   name='bouns[$value[id]]'></td>";  
         }
                                     
         echo "<td><input type='number' style='width: 100%;'  value='$sal_day' readonly   name='per_day[$value[id]]'></td>
         <td><input type='number' style='width: 100%;'   value='".($sal_day*$fetch_absents)."' readonly   name='total[$value[id]]'></td>
        
             </tr>"; 
          }
            }


             }
             echo "record not found..";
    }
    
//      public function emp_depart($type,$mnth)
//     {
      
//           $branch=$this->user_model->getbranch();
          
//         $dpt['cls']=$this->db->query("SELECT * FROM `teacher` WHERE 
//          `branch`=$branch and `status`=0 and `is_delete`=0")->result_array();
        
//       if(!empty($dpt['cls']))
//      {             
                 
//   foreach ($dpt['cls'] as $key => $value) 
//         { 

//   $emppp=$value['id'];  
//       $query1122=$this->db->where('bothid',$emppp)
//       ->where('refrence',$type)
//       ->where('month',$mnth)
//       ->get('salary')->row();
//       if(count($query1122)==0){
     
//      echo "<tr>
//         <td><input type='checkbox' name='check[$value[id]]' value='$value[id]'></td>
//         <td>$value[firstname] $value[lastname]</td>
//          <td>
//          <input type='text' onkeyup='return pr_fun($value[id],event)' value='' id='pr$value[id]' name='pr[$value[id]]'> 
//          </td>
//          <td><input type='text'  onkeyup='return ab_fun($value[id],event)' id='ab$value[id]' value='' name='ab[$value[id]]'></td>
//          <td><input type='number' value='0' readonly   id='per_day$value[id]' name='per_day[$value[id]]'></td>
//          <td><input type='number'  value='0' readonly  id='total$value[id]' name='total[$value[id]]'></td>
        
//              </tr>"; 
//           }
//             }


//              }
//              echo "record not found..";
//     }
    
    
    
  public function emp_depart_staff($type,$mnth)
    {
       
        $branch=$this->user_model->getbranch();
        $dpt['cls']=$this->db->query("SELECT * FROM `staff` WHERE 
         `branch`=$branch and `status`=0 and `is_delete`=0")->result_array();
        $lev_types=$this->db->select('*')
                               ->from('leave_types')
                               ->where('branch',$branch)
                               ->where('name!=',"A")
                               ->order_by('id',"ASC")
                               ->get()->result_array();
      if(!empty($dpt['cls']))
     {             
                 
  foreach ($dpt['cls'] as $key => $value) 
        { 
  
  $emppp=$value['id'];  
       $query1122=$this->db->where('bothid',$emppp)
                           ->where('refrence',$type)
                           ->where('month',$mnth)
                           ->get('salary')->row();
       if(count($query1122)==0){
           $acc_sum=0;
           $acc_absnt=0;
           $no_mark=0;
           $bouns=0;
           $absentt=0;
           
           
     echo "<tr>
        <td><input type='checkbox' name='check[$value[id]]' class='chek_me'  value='$value[id]' checked></td>
        <td>$value[firstname] $value[lastname]</td>";
        if(!empty($lev_types))
        {
            
       
            foreach($lev_types as $lev)
            {
                
                
                $check_allocation=$this->db->select('*')
                                           ->from('leave_allocation')
                                           ->where('type',"staff")
                                           ->where('branch',$branch)
                                           ->where('status',0)
                                           ->where('is_delete',0)
                                           ->where('leave_id',$lev['id'])
                                           ->where('bothid',$value['id'])
                                           ->limit('1')
                                           ->order_by('id','desc')
                                           ->get()->row_array()['total_leave'];
                                           
                if(!empty($check_allocation))
                {
                    if($lev['mode']=="Monthly")
                    {
                        $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('staffatt')
                                            ->where('staff_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                        $acc_sum=$acc_sum+$fetch_att_teacher;                     
                        if($fetch_att_teacher>$check_allocation) 
                        {
                            $acc_absnt=$fetch_att_teacher-$check_allocation;
                        }
                    }else
                    {
                        $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('staffatt')
                                            ->where('staff_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                        $acc_sum=$acc_sum+$fetch_att_teacher;                     
                                            
                        $fetch_att_all=$this->db->select('count(id) as id')
                                            ->from('staffatt')
                                            ->where('staff_id',$value['id'])
                                            ->where('left(date,7)<=',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                         if($fetch_att_all>$check_allocation) 
                        {
                            $acc_absnt=$fetch_att_all-$check_allocation;
                        }                    
                    }
                    
                }else{
                    $fetch_att_teacher=$this->db->select('count(id) as id')
                                            ->from('staffatt')
                                            ->where('staff_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('status_id',$lev['id'])
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id'];
                                            
                     if($lev['name']=="P") 
                 {
                    $bouns+=$fetch_att_teacher;
                 }
                 elseif($lev['name']=="HD")
                 {
                    $bouns+=$fetch_att_teacher; 
                 }
                 
                    $acc_sum=$acc_sum+$fetch_att_teacher;                 
                }
            
               
               
         echo" <td>
           <input type='text' readonly style='width: 80%;'  value='$fetch_att_teacher'> 
         </td>"; 
         
             if($lev['name']=="CL" || $lev['name']=="RL"){
           $absentt+=$fetch_att_teacher;
             }
         
            }
        }
        $year=date('Y',strtotime($mnth));
        $month=substr($mnth,-2);
        $d=$this->countDays($year,$month, array(0, 7));
       
        $fetch_absents=$this->db->select('count(staffatt.id) as id')
                                            ->from('staffatt')
                                            ->join('leave_types','leave_types.id=staffatt.status_id')
                                            ->where('staff_id',$value['id'])
                                            ->where('left(date,7)',$mnth)
                                            ->where('leave_types.name',"A")
                                            ->where('is_deleted',0)
                                            ->get()->row_array()['id']; 
        $acc_sum=$acc_sum+$fetch_absents; 
        $no_mark=$d-$acc_sum;
        if(!empty($fetch_absents)) 
        {
            $fetch_absents=$fetch_absents+$acc_absnt+$no_mark;
        }else
        {
            $fetch_absents=$acc_absnt+$no_mark;
        }
        
          echo" <td>
           <input type='text' readonly style='width: 80%;' name='absnt[$value[id]]'  value='$fetch_absents'> 
         </td>"; 
                          $re=0;
                                     
                                        
                                        $this->db->select('salery')->from('staff');
                                        $this->db->where('is_delete',0)->where('status',0)->where('id',$value['id']);                                        
                                        $re=$this->db->get()->row_array()['salery'];
       
                                   //Increments
                                    $increments=$this->db->select('sum(amount) as amount')
                                                                   ->from('increments')
                                                                   ->where('refrence',"staff")
                                                                   ->where('bothid',$value['id'])
                                                                   ->where('month <=',$mnth)
                                                                   ->where('is_del',0)
                                                                   ->get()->row_array()['amount'];
                                            if(!empty($increments)) 
                                            {
                                                $re=$re+$increments;
                                            }else
                                            {
                                                $re=$re;
                                            }


                                            $sal_day = $re/date('t',strtotime($mnth));//one day salary
                                            $sal = $fetch_absents*$sal_day;
                                           
                                            $amount=round($sal, 2);
                                            $sal_day=round($sal_day, 2);
      if($bouns==$d){
             echo "<td><input type='number' style='width: 100%;'  value='".$sal_day."' readonly   name='bouns[$value[id]]'></td>"; 
         }else
         {
            echo "<td><input type='number' style='width: 100%;'  value='0' readonly   name='bouns[$value[id]]'></td>";  
         }
         
         echo "<td><input type='number' style='width: 100%;'  value='$sal_day' readonly   name='per_day[$value[id]]'></td>
         <td><input type='number' style='width: 100%;'   value='".($sal_day*$fetch_absents)."' readonly   name='total[$value[id]]'></td>
        
             </tr>"; 
          }
            }


             }
             echo "record not found..";
    }
    
    
//      public function emp_depart_staff($type,$mnth)
//     {
      
//           $branch=$this->user_model->getbranch();
          
//         $dpt['cls']=$this->db->query("SELECT * FROM `staff` WHERE 
//          `branch`=$branch and `status`=0 and `is_delete`=0")->result_array();
                     
                
//              //var_dump();
//              //die();     
//                   //$id=$class['cls']['class_id']; 
//       if(!empty($dpt['cls']))
//      {             
                 
//   foreach ($dpt['cls'] as $key => $value) 
//         {        
// $emppp=$value['id'];  
//                       $query1122=$this->db->where('bothid',$emppp)
//                       ->where('refrence',$type)
//                       ->where('month',$mnth)
//                       ->get('salary')->row();
//       if(count($query1122)==0){
     
//     echo "<tr>
//         <td><input type='checkbox' name='check[$value[id]]' value='$value[id]'></td>
//         <td>$value[firstname] $value[lastname]</td>
//          <td>
//          <input type='text'  onkeyup='return pr_fun($value[id],event)' value=''  id='pr$value[id]' name='pr[$value[id]]'> 
//          </td>
//          <td><input type='text'  onkeyup='return ab_fun($value[id],event)' value='' id='ab$value[id]' name='ab[$value[id]]'></td>
//          <td><input type='number' value='0' readonly   id='per_day$value[id]' name='per_day[$value[id]]'></td>
//          <td><input type='number'  value='0' readonly  id='total$value[id]' name='total[$value[id]]'></td>
        
//              </tr>"; 
          
//             }

//               }
//              }
//              echo "record not found..";
//     }
    
      public function checkall_expense_month($id,$ref,$month)
    {
    $er=$this->db->where('bothid',$id)
                 ->where('refrence',$ref)
                 ->where('month',$month)
                 ->where('status',0)
                 ->where('is_delete',0)
                 ->get('expense_assign')->result_array();
       echo json_encode($er);

   }
  public function checkdate($val="0000-00")
    {
        $date=date('Y-m');
        //var_dump($val,$date);
        if($val<$date){
            echo "true";
        }else{
            echo "false";
        }
    }
    
    public function questions_checked($class=0,$branch=0,$subject=0,$level=0)
    {
        $chapter=$this->input->get('ch_checked');

        $this->db->select("question_type as type,count(id) AS total");
        $this->db->from('general_questions');
        $this->db->where('class',$class);
        $this->db->where('subject',$subject);
        $this->db->where('branch',$branch);
        $this->db->where('level',$level);
        $this->db->group_by('question_type');
        $this->db->where_in('chapter',$chapter);
        $general=$this->db->get()->result_array();
    //=====================long=======================
        $this->db->select("count(id) AS total_long");
        $this->db->from('long_questions');
        $this->db->where('class',$class);
        $this->db->where('subject',$subject);
        $this->db->where('branch',$branch);
        $this->db->where('level',$level);
        $this->db->where_in('chapter',$chapter);
        $long=$this->db->get()->row_array();
        //======================short=================
        $this->db->select("count(id) AS total_short");
        $this->db->from('short_questions');
        $this->db->where('class',$class);
        $this->db->where('subject',$subject);
        $this->db->where('branch',$branch);
        $this->db->where('level',$level);
        $this->db->where_in('chapter',$chapter);
        $short=$this->db->get()->row_array();
        //======================mcq=================
        $this->db->select("count(id) AS total_mcq");
        $this->db->from('mcq_questions');
        $this->db->where('class',$class);
        $this->db->where('subject',$subject);
        $this->db->where('branch',$branch);
        $this->db->where('level',$level);
        $this->db->where_in('chapter',$chapter);
        $mcq=$this->db->get()->row_array();
        //======================mcq=================
        $this->db->select("count(id) AS total_dra");
        $this->db->from('drawing_question');
        $this->db->where('class',$class);
        $this->db->where('subject',$subject);
        $this->db->where('branch',$branch);
        $this->db->where('level',$level);
        $this->db->where_in('chapter',$chapter);
        $dra=$this->db->get()->row_array();
        
        //var_dump('<pre>',$long);die();
        $data=array();
        
        if(count($data) == 0 && $mcq['total_mcq'] == 0 && $short['total_short'] == 0 && $long['total_long'] == 0 && count($general) == 0 && $dra['total_dra'] == 0)
        {
            echo "";
              
        }else{
            array_push($data,$mcq,$short,$long,$general,$dra);
             echo json_encode($data);
        }
        
        //var_dump('<pre>',$data);die();
             
        
    }

//Set Roles Dropdown
    public function setRoles()
    {
        if(isset($_POST['branch']))
       {
            $branch_id = $this->input->post('branch');
            $roles = $this->db->order_by('title','ASC')
                                  ->where('is_delete',0)
                                    ->get_where('role', array('branch_id'=> $branch_id))->result();

            if($roles)
            {
                $pro_select_box = "";
                $pro_select_box .= '<option value="">Select Role</option>';
                foreach ($roles as $roles) {
                    $pro_select_box .= '<option value="'.$roles->id.'">'.$roles->title.'</option>';

                }
            echo $pro_select_box;
            }
        }
    }



}
