? Fallagassrini

Fallagassrini Bypass Shell

echo"
Fallagassrini
";
Current Path : /home1/savoy/public_html/savoyglobal.net/koolkids/school/application/models/

Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
Upload File :
Current File : /home1/savoy/public_html/savoyglobal.net/koolkids/school/application/models/settingsmodel.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 class Settingsmodel extends Model
{
     function Settingsmodel()
     {
         parent::Model();
     }

    function get_timetable_by_classlevel_id($classlevelid)
    {
        $data = array();
        $this->db->select('period_no,subject_id,day');
        $this->db->where('classlevel_id',$classlevelid);
        $Q= $this->db->get('timetable_settings');

         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();

         return $data;

    }

    function get_teacher_timetable_by_id($teacher_id)
    {
        $data = array();
        $this->db->select('classlevel.classlevel_code
                            , subject.subject_code
                            , timetable_settings.period_no
                            , timetable_settings.day
                            , teacher_subject.teacher_id');
        $this->db->from('`timetable_settings`');
        $this->db->join('classlevel','timetable_settings.classlevel_id = classlevel.classlevel_id');
        $this->db->join('subject','timetable_settings.subject_id = subject.subject_id');
        $this->db->join('teacher_subject','teacher_subject.subject_id = subject.subject_id','left');
        $this->db->where('teacher_id',$teacher_id);
        $Q= $this->db->get();

         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();

         return $data;
    }



    function add($postdata)
    {
        $data=array();
        $data['resfunction']=$postdata['resfunction'];
        $table = $postdata['tab_name'];
        unset ($postdata['tab_name']);
        unset ($postdata['resfunction']);
        $res=$this->db->insert($table,$postdata);
        $cnt=$this->db->insert_id();
        if($res>0)
        {
            $data['res']=1;
            $data['msg']='Record Added Successfully';
        }
        else
        {
            $data['res']=0;
            $data['msg']='Erron On Adding Record';
        }
        return $data;
    }

     function update($postdata)
     {
        $data=array();
        $data['resfunction']=$postdata['resfunction'];
        $table = $postdata['tab_name'];
        $field = $postdata['tab_field'];
        $id= $postdata['tab_id'];
        unset ($postdata['resfunction']);
        unset ($postdata['tab_name']);
        unset ($postdata['tab_field']);
        unset ($postdata['tab_id']);
        $this->db->where($field, $id);
        $res=$this->db->update($table,$postdata);
        if($res>0)
        {
            $data['res']=1;
            $data['msg']='Record Updated Successfully';
        }
        else
        {
            $data['res']=0;
            $data['msg']='Erron On updating Record';
        }
        return $data;
     }
    
     function searchuser($postdata,$pagenum)
     {

         $data=array();
         $this->db->from('user');
         $this->db->join('user_profiles','user_profiles.profile_id=user.profile_id');
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select("username,user_id,user_profiles.name");
         $this->db->select("IFNULL(CONCAT(teacher.first_name,' ',teacher.last_name),
            IFNULL(staff.name,
            IFNULL(CONCAT(student.first_name,' ' , student.last_name),
            IFNULL(parent.name,' ')))) AS emp_name",false);
         $this->db->from('user');
         $this->db->join('user_profiles','user_profiles.profile_id=user.profile_id');
         $this->db->join('staff','staff.staff_id=user.linkedto_id','left');
         $this->db->join('teacher','teacher.teacher_id=user.linkedto_id','left');
         $this->db->join('student','student.student_id=user.linkedto_id','left');
         $this->db->join('parent','parent.parent_id=user.linkedto_id','left');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function insertuser($postdata)
     {
         $password=md5($postdata['password']);
         $data=array();
         $this->db->trans_begin();
         $tbl2Values=array(
              'username'=>$postdata['username'],
              'password'=>$password,
              'profile_id'=>$postdata['profile_id']);
          $this->db->insert('user', $tbl2Values);
          $data['resfunction']='searchuser';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function updateuser($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $tbl2Values=array(
             'username'=>$postdata['username'],
             'profile_id'=>$postdata['profile_id']);
          $this->db->where('user_id', $postdata['user_id']);
          $this->db->update('user', $tbl2Values);
          $data['resfunction']='searchuser';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function updatepassword($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         if($postdata['password'] == $postdata['password1'])
	 {
             $password=md5($postdata['password']);
             $tbl2Values=array(
                 'password'=>$password);
              $this->db->where('user_id', $postdata['user_id']);
              $this->db->update('user', $tbl2Values);
              $data['resfunction']='searchuser';
              if ($this->db->trans_status() === FALSE)
              {
                $this->db->trans_rollback();
                return 0;
              }
              else
              {
                $this->db->trans_commit();
                $data['res']=1;
                 $data['msg']='Record Updated Successfully';
                return $data;
              }
         }
         else
         {
             $this->db->trans_rollback();
             return 0;
         }

     }

     function searchuserprofile($postdata,$pagenum)
     {

         $data=array();
         $this->db->from('user_profiles');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('user_profiles.profile_id,user_profiles.name,profile_user_type');
         $this->db->from('user_profiles');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

    function insertuserprofile($postdata)
    {
        $data=array();
        $this->db->trans_begin();
        $tbl1Values=array(
        'name'=>$postdata['profile_name'],
        'modules'=>$postdata['role_permission'],
        'profile_user_type'=>$postdata['profile_user_type'],
        'permissions'=>$postdata['role_edit_del_permission']);
        $this->db->insert('user_profiles', $tbl1Values);
        $data['resfunction']='searchuserprofile';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            return 0;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            return $data;
        }
    }

    function updateuserprofile($postdata)
    {
        $count=$postdata['countrow'];
        $modulestr="";
        $profilestr="";
        for($i=0;$i<$count;$i++)
        {
            $num=0;
            if(isset($postdata['view_'.$i]))
            $num+=4;
            if(isset($postdata['edit_'.$i]))
            $num+=2;
            if(isset($postdata['delete_'.$i]))
            $num+=1;

            $profilestr.= $num;
            $modulestr.= $postdata['module_'.$i];
            if($i!=($count-1))
            {
                $profilestr.=",";
                $modulestr.=",";
            }
        }
        $data=array();
        $this->db->trans_begin();
        $tbl2Values=array(
        'name'=>$postdata['profile_name'],
        'modules'=>$modulestr,
        'permissions'=>$profilestr);
        $this->db->where('profile_id',$postdata['profile_id']);
        $this->db->update('user_profiles', $tbl2Values);
        $data['resfunction']='searchuserprofile';
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            return 0;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
             $data['msg']='Record Updated Successfully';
            return $data;
        }
     }

     function searchemployeemaster($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('employeemaster');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         $this->db->select('id,report_label,description,target');
         $this->db->from('employeemaster');
         $data['results']=$this->db->get();
         return $data;
     }

     function searchdepartment($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('department');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('department');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function searchdesignation($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('designation');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('designation');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     
     function searchabsentreason($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('absentreason');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('absentreason');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }
     
     function searchacademicyear($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('academicyear');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="start_date" || $searchfield=="end_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="start_date" || $searchfield=="end_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
         }
         $this->db->select('academicyear.ayear,academicyear.start_date,academicyear.end_date,current');
         $this->db->from('academicyear');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function insertacademicyear($postdata)
     {
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'ayear'=>$postdata['ayear'],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
          $this->db->insert('academicyear', $tbl1Values);

          $i=1;
          while($postdata['vacation_name'.$i]!="")
          {
            $masterid = $this->mastermodel->insertmasterdata($postdata['ayear']);
            $start_date=$this->mastermodel->convertdateformat($postdata['vacation_start_date'.$i]);
            $end_date=$this->mastermodel->convertdateformat($postdata['vacation_end_date'.$i]);
            $tbl1Values=array(
                'id'=>$masterid,
                'title'=>$postdata['vacation_name'.$i],
                'start_date'=>$start_date,
                'end_date'=>$end_date,
                'vacation'=>'1');
            $this->db->insert('calendar', $tbl1Values);
            $i++;
            
              if(isset($postdata['vacation_name'.$i]))
              continue;
              else
              break;
          }
          $data['resfunction']='searchacademicyear';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function updateacademicyear($postdata)
     {
         
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'start_date'=>$start_date,
                'end_date'=>$end_date);
         $this->db->where('ayear',$postdata['ayear']);
         $this->db->update('academicyear', $tbl1Values);
         
         $i=1;
         while($postdata['vacation_name'.$i]!="")
         {
            
            $masterid = $this->mastermodel->insertmasterdata($postdata['ayear']);
            $start_date=$this->mastermodel->convertdateformat($postdata['vacation_start_date'.$i]);
            $end_date=$this->mastermodel->convertdateformat($postdata['vacation_end_date'.$i]);
            $tbl1Values=array(
                'id'=>$masterid,
                'title'=>$postdata['vacation_name'.$i],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
            $this->db->insert('calendar', $tbl1Values);
            $i++;
            $tbl1Values=array(
                'vacationid'=>$masterid,
                'ayear'=>$postdata['ayear'],
                );
                $this->db->insert('ayear_vacation', $tbl1Values);
              if(isset($postdata['vacation_name'.$i]))
              continue;
              else
              break;
          }
          $data['resfunction']='searchacademicyear';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
             $data['msg']='Record Updated Successfully';
	    return $data;
	  }

     }
     
     function searchterm($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('term');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="start_date" || $searchfield=="end_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext, 'before');
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="start_date" || $searchfield=="end_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext, 'before');
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
         }
         $this->db->select('term_id,term_name,start_date,end_date,ayear');
         $this->db->from('term');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     
     function insertterm($postdata)
     {
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'term_name'=>$postdata['term_name'],
                'ayear'=>$postdata['ayear'],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
          $this->db->insert('term', $tbl1Values);

          $data['resfunction']='searchterm';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     
     function updateterm($postdata)
     {
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'term_name'=>$postdata['term_name'],
                'ayear'=>$postdata['ayear'],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
         $this->db->where('term_id',$postdata['term_id']);
         $this->db->update('term', $tbl1Values);

          $data['resfunction']='searchterm';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
             $data['msg']='Record Updated Successfully';
	    return $data;
	  }

     }

     function searchclasslevel($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('classlevel');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('classlevel');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function updateclasslevel($postdata)
     {
         $data=array();
         $this->db->trans_begin();       
         $tbl1Values=array(
                'classlevel_name'=>$postdata['classlevel_name'],
                'classlevel_section'=>$postdata['classlevel_section'],
                'classlevel_code'=>$postdata['classlevel_code'],
                'nextclasslevel_id'=>$postdata['nextclasslevel_id']);
          $this->db->where('classlevel_id', $postdata['classlevel_id']);
          $this->db->update('classlevel', $tbl1Values);

       
          $data['resfunction']='searchclasslevel';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     

    function searchschoolsetup($postdata,$pagenum)
    {
        $data=array();
        $arr=$this->fpaginate->paginate($pagenum,1);
        $data['startpage']=$arr[0];
        $data['endpage']=$arr[1];
        $start=$arr[2];
        $perpage=$arr[3];
        $data['count']=1;
        
        $this->db->select('*');
        $this->db->from('schoolsetup');
        $this->db->limit($perpage, $start);
        $data['results']=$this->db->get();
        return $data;
    }
     
     function insertschoolsetup($postdata)
     {
        
         $data=array();
         $this->db->trans_begin();
         $this->db->truncate('schoolsetup');
         $i = 1;
         $searchstr='';
         for($i=1;$i<=7;$i++)
         {
            if(isset($postdata['day_'.$i]))
            {
                $searchstr .= $postdata['day_'.$i].",";
            }
         }
         $searchstr = substr($searchstr, 0, -1);
         $tbl1Values=array(
                'name'=>$postdata['name'],
                'phone'=>$postdata['phone'],
                'email'=>$postdata['email'],
                'website'=>$postdata['website'],
                'address'=>$postdata['address'],
                'alert_days'=>$postdata['alert_days'],
                //'no_periods'=>$postdata['no_periods'],
                //'holidays'=>$searchstr,
                'logo'=>$postdata['logo']);
          $this->db->insert('schoolsetup', $tbl1Values);
         
          $data['resfunction']='searchschoolsetup';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
   
     
    function searchsubject($postdata,$pagenum)
     {

         $data=array();
         $this->db->from('classlevel');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->where('kg !=', '1');
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('classlevel');
         $this->db->where('kg !=', '1');
         $this->db->order_by('classlevel.classlevel_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
   
     
         function searchsubjectmasterdetails($postdata,$pagenum)
     {

         $data=array();
         $this->db->from('subject_master');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('subject_master');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }



     function subjectsearch($value,$field,$pagenum)
     {

         $data=array();
         $this->db->from('subject');
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;

         $searchtext=$value;
         $searchfield=$field;
         $this->db->like($searchfield, $searchtext);

         $this->db->select('subject.subject_name, classlevel.classlevel_code,subject.subject_id,subject.subject_code');
         $this->db->join('classlevel','classlevel.classlevel_id = subject.classlevel_id');
         $this->db->from('subject');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function searchfeemaster($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('feemaster');
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         $this->db->select('id,report_label,description,target');
         $this->db->from('feemaster');
         $data['results']=$this->db->get();


         return $data;
     }

     function searchsubjectmaster($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('subjectmaster');
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         $this->db->select('id,report_label,description,target');
         $this->db->from('subjectmaster');
         $data['results']=$this->db->get();


         return $data;
     }

     function searchfeecategory($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('feecategory');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('feecategory');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function searchfeecreate($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('feecreate');
         $this->db->join('classlevel','classlevel.classlevel_id=feecreate.feecreate_classlevel_id');
         $this->db->join('feeterm','feeterm.feeterm_id=feecreate.feeterm_id');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('feecreate');
         $this->db->join('classlevel','classlevel.classlevel_id=feecreate.feecreate_classlevel_id');
         $this->db->join('feeterm','feeterm.feeterm_id=feecreate.feeterm_id');
         $this->db->order_by('feeterm.feeterm_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function insertfeecreate($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'feeterm_id'=>$postdata['feecreate_feeterm_id'],
                'feecreate_classlevel_id'=>$postdata['feecreate_classlevel_id']);
          $this->db->insert('feecreate', $tbl1Values);
          $feecreate_id = mysql_insert_id();
          $i=1;
          while(isset($postdata['feecategory_id'.$i]))
          {
              $tbl1Values=array(
                'feecreate_id'=>$feecreate_id,
                'feecategory_id'=>$postdata['feecategory_id'.$i],
                'amount'=>$postdata['amount'.$i]);
              $this->db->insert('feecreate_category', $tbl1Values);
             $i++;
          }
          $data['resfunction']='searchfeecreate';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function updatefeecreate($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'feeterm_id'=>$postdata['feecreate_feeterm_id']);
          $this->db->where('feecreate_id', $postdata['feecreate_id']);
          $this->db->update('feecreate', $tbl1Values);

          $this->db->where('feecreate_id', $postdata['feecreate_id']);
          $this->db->delete('feecreate_category');
          $i=1;
          while(isset($postdata['feecategory_id'.$i]))
          {
              $tbl1Values=array(
                'feecreate_id'=>$postdata['feecreate_id'],
                'feecategory_id'=>$postdata['feecategory_id'.$i],
                'amount'=>$postdata['amount'.$i]);
              $this->db->insert('feecreate_category', $tbl1Values);
             $i++;
          }
          $data['resfunction']='searchfeecreate';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function searchfeecollection($postdata,$pagenum)
     {
         $data=array();
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->from('feecollection');
         $this->db->join('feecreate','feecreate.feecreate_id=feecollection.feecollection_feecreate_id');
         $this->db->join('feeterm','feeterm.feeterm_id=feecreate.feeterm_id');
         $this->db->join('master','master.masterid=feecollection.feecollection_id');
         $this->db->join('classlevel','classlevel.classlevel_id=feecreate.feecreate_classlevel_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('feecollection');
         $this->db->join('feecreate','feecreate.feecreate_id=feecollection.feecollection_feecreate_id');
         $this->db->join('master','master.masterid=feecollection.feecollection_id');
         $this->db->join('feeterm','feeterm.feeterm_id=feecreate.feeterm_id');
         $this->db->join('classlevel','classlevel.classlevel_id=feecreate.feecreate_classlevel_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function insertfeecollection($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         
          foreach($postdata['feecollection_feecreate_id'] as $feecreate_id)
          {
            $masterid = $this->mastermodel->insertmasterdata();
            $tbl1Values=array(
                'feecollection_id'=>$masterid,
                'feecollection_feecreate_id'=>$feecreate_id,
                'feecollection_due_date'=>$this->mastermodel->convertdateformat($postdata['feecollection_due_date']));
             $this->db->insert('feecollection', $tbl1Values);
          }
          $data['resfunction']='searchfeecollection';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     function updatefeecollection($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['feecollection_id']);
         $tbl1Values=array(
                'feecollection_due_date'=>$this->mastermodel->convertdateformat($postdata['feecollection_due_date']));
          $this->db->where('feecollection_id', $postdata['feecollection_id']);
          $this->db->update('feecollection', $tbl1Values);
          $data['resfunction']='searchfeecollection';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     function setayear($ayear)
     {
         $tbl1Values=array(
                'current'=>'0');
         $this->db->update('academicyear', $tbl1Values);
         $tbl1Values=array(
                'current'=>'1');
          $this->db->where('ayear', $ayear);
          $this->db->update('academicyear', $tbl1Values);
     }

     function get_vacation_list($ayear)
     {
        $data = array();
        $this->db->join('master',"calendar.id=master.masterid");
        $this->db->where('deleted','0');
        $this->db->where('vacation','1');
        $this->db->where('ayear',$ayear);
        $Q= $this->db->get('calendar');
        if ($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $Q->free_result();
        return $data;
     }
     function searchfeeterm($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('feeterm');
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $count= $this->db->count_all_results();
         $arr=$this->fpaginate->paginate($pagenum,$count);
         $data['startpage']=$arr[0];
	 $data['endpage']=$arr[1];
         $start=$arr[2];
         $perpage=$arr[3];
         $data['count']=$count;
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->select('*');
         $this->db->from('feeterm');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function insert_subject_class($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         if(isset($postdata['subject_id']))
         {
          foreach($postdata['subject_id'] as $subject)
          {
                $subj=  explode('~', $subject);
                $tbl1Values=array(
                        'subject_name'=>$subj[0],
                        'subject_code'=>$subj[1],
                        'classlevel_id'=>$postdata['classlevel_id']
                );
                $this->db->insert('subject', $tbl1Values);
          }
         }
          $data['resfunction']='searchsubject';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     
     function updatesubjectmaster($postdata)
     {
         $data=array();
         $this->db->trans_begin();
            $subject = $this->mastermodel->get_data_srow('subject_master',$postdata['subject_master_id'],'subject_master_id');
                $tbl1Values=array(
                        'subject_master_name'=>$postdata['subject_master_name'],
                        'subject_master_code'=>$postdata['subject_master_code']
                );
                $this->db->where('subject_master_id', $postdata['subject_master_id']);
                $this->db->update('subject_master', $tbl1Values);
                
                $tbl1Values=array(
                        'subject_name'=>$postdata['subject_master_name'],
                        'subject_code'=>$postdata['subject_master_code']
                );
                $this->db->where('subject_name', $subject->subject_master_name);
                $this->db->where('subject_code', $subject->subject_master_code);
                $this->db->update('subject', $tbl1Values);
       
          $data['resfunction']='searchsubjectmasterdetails';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     
     function remove_subject($subject_id)
     {
         $this->db->where('subject_id', $subject_id);
         $res=$this->db->delete('subject');
         return $res;
     }
     
     function insertfeeterm($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array('feeterm_name'=>$postdata['feeterm_name']);
         $this->db->insert('feeterm', $tbl1Values);
         $feeterm_id=  mysql_insert_id();
         $classlevel=  $this->mastermodel->getdatas('classlevel','sort');
         foreach($classlevel as $class)
         {
            $tbl1Values=array('feeterm_id'=>$feeterm_id,'feecreate_classlevel_id'=>$class['classlevel_id']);
            $this->db->insert('feecreate', $tbl1Values);
         }
         $data['resfunction']='searchfeeterm';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
    function checkclassfee($feeterm_id,$classlevel_id)
    {
         
         $this->db->from('feecreate');
         $this->db->where('feeterm_id', $feeterm_id);
         $this->db->where('feecreate_classlevel_id', $classlevel_id);
         $count= $this->db->count_all_results();
         //echo $this->db->last_query();
         return $count;
    }
     function searchalert($postdata,$pagenum)
    {
        $data=array();
        $arr=$this->fpaginate->paginate($pagenum,1);
        $data['startpage']=$arr[0];
        $data['endpage']=$arr[1];
        $start=$arr[2];
        $perpage=$arr[3];
        $data['count']=1;
        
        $this->db->select('*');
        $this->db->from('student');
        $this->db->join('master','master.masterid=student.student_id');
        $this->db->where('student_id not in(select student_id from age_alert)');
        $this->db->where('deleted','0');
        $this->db->limit($perpage, $start);
        $data['results']=$this->db->get();
        return $data;
    }
    function insertalert($id)
     {         
         $data=array();
         $this->db->trans_begin();                 
               $tbl1Values=array('student_id'=>$id); 
               $this->db->insert('age_alert',$tbl1Values);          
          $data['resfunction']='searchalert';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function get_student_datas($table,$sortfield="")
     {
         $sortfield='student.student_id';
         $data = array();
         if(!empty ($sortfield))
         {
         $this->db->order_by($sortfield, "asc");
         }
//         $this->db->join('age_alert','student.student_id=age_alert.student_id');
         $Q = $this->db->get($table);
         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();
         return $data;
     }
}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net