? Fallagassrini

Fallagassrini Bypass Shell

echo"
Fallagassrini
";
Current Path : /home1/savoy/public_html/savoyglobal.net/sims/draft/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/sims/draft/school/application/models/examinationmodel.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 Examinationmodel extends Model
{
     function Examinationmodel()
     {
         parent::Model();
     }
     
     function searchexamreport($postdata,$pagenum)
     {  
         
         $data=array();

         $this->db->from('examreport');
         $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('examreport');
         $this->db->order_by('id');
         $data['results']=$this->db->get();
         return $data;
     }

     function searchgradelevel($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('gradelevel');
         $this->db->join('master','master.masterid=gradelevel.gradelevel_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('gradelevel_id,gradelevel_name,gradelevel_description,min_marks,max_marks');
         $this->db->from('gradelevel');
         $this->db->join('master','master.masterid=gradelevel.gradelevel_id');
         $this->db->where('deleted', '0');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }
     function insertgradelevel($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'gradelevel_id'=>$masterid,
                'gradelevel_name'=>$postdata['gradelevel_name'],
                'gradelevel_description'=>$postdata['gradelevel_description'],
                'gradelevel_color'=>$postdata['gradelevel_color'],
                'min_marks'=>$postdata['min_marks'],
                'max_marks'=>$postdata['max_marks']);
          $this->db->insert('gradelevel', $tbl1Values);

          $data['resfunction']='searchgradelevel';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     function updategradelevel($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $tbl2Values=array(
                'gradelevel_name'=>$postdata['gradelevel_name'],
                'gradelevel_description'=>$postdata['gradelevel_description'],
                'gradelevel_color'=>$postdata['gradelevel_color'],
                'min_marks'=>$postdata['min_marks'],
                'max_marks'=>$postdata['max_marks']);
          $this->db->where('gradelevel_id',$postdata['masterid']);
          $this->db->update('gradelevel', $tbl2Values);
          $data['resfunction']='searchgradelevel';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }
     }
     function searchexammaster($postdata,$pagenum)
     {

         $data=array();
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->from('exammaster');
         $this->db->join('master','master.masterid=exammaster.exammaster_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=="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('exammaster_id,exammaster_name,start_date,end_date');
         $this->db->from('exammaster');
         $this->db->join('master','master.masterid=exammaster.exammaster_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }
     function insertexammaster($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(
                'exammaster_id'=>$masterid,
                'exammaster_name'=>$postdata['exammaster_name'],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
          $this->db->insert('exammaster', $tbl1Values);

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

     }
     function updateexammaster($postdata)
     {
         $start_date=$this->mastermodel->convertdateformat($postdata['start_date']);
         $end_date=$this->mastermodel->convertdateformat($postdata['end_date']);
         $data=array();
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $tbl1Values=array(
                'exammaster_name'=>$postdata['exammaster_name'],
                'start_date'=>$start_date,
                'end_date'=>$end_date);
         $this->db->where('exammaster_id', $postdata['masterid']);
         $this->db->update('exammaster', $tbl1Values);

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

     }
     function searchexamtimetable($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('examtimetable');
         $this->db->join('master','master.masterid=examtimetable.examtimetable_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('examtimetable_id,exammaster_name,classlevel_code');
         $this->db->from('examtimetable');
         $this->db->join('classlevel','classlevel.classlevel_id=examtimetable.classlevel_id');
         $this->db->join('exammaster','exammaster.exammaster_id=examtimetable.exammaster_id');
         $this->db->join('master','master.masterid=examtimetable.examtimetable_id');
         $this->db->where('deleted', '0');
         
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }
     function insertexamtimetable($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'examtimetable_id'=>$masterid,
                'exammaster_id'=>$postdata['exammaster_id'],
                'classlevel_id'=>$postdata['classlevel_id']);
          $this->db->insert('examtimetable', $tbl1Values);
          
          for($i=1;$i<=$postdata['norows'];$i++)
          {
              if(isset($postdata['subject_id'.$i]))
              {
                $starttime= $postdata['start_year'.$i]."-".$postdata['start_month'.$i]."-".$postdata['start_day'.$i]." ".$postdata['start_hour'.$i].":".$postdata['start_minute'.$i].":00";
                $endtime= $postdata['start_year'.$i]."-".$postdata['start_month'.$i]."-".$postdata['start_day'.$i]." ".$postdata['start_hour'.$i].":".$postdata['start_minute'.$i].":00";
                $tbl3Values=array('examtimetable_id'=>$masterid,
                                 'subject_id'=>$postdata['subject_id'.$i],
                                 'start_time'=>$starttime,
                                 'end_time'=>$endtime,
                                 'max_marks'=>$postdata['max_marks'.$i]);
                $this->db->insert('examtimetable_subject', $tbl3Values);
              }
          }
          $data['resfunction']='searchexamtimetable';
          if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     
     function searchassignmark($postdata,$pagenum)
     {

         $data=array();
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->from('assignmark');
         $this->db->join('master','master.masterid=assignmark.assignmark_id');
         $this->db->join('classlevel','classlevel.classlevel_id=assignmark.classlevel_id');
         $this->db->join('exammaster','exammaster.exammaster_id=assignmark.exammaster_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;
         
         $this->db->select('assignmark_id,exammaster_name,classlevel_code');
         $this->db->from('assignmark');
         $this->db->join('classlevel','classlevel.classlevel_id=assignmark.classlevel_id');
         $this->db->join('exammaster','exammaster.exammaster_id=assignmark.exammaster_id');
         $this->db->join('master','master.masterid=assignmark.assignmark_id');
         $this->db->where('deleted', '0');
         $this->db->where('ayear', $ayear);
         if(!empty($postdata))
         {
             $searchtext=$postdata['searchtext'];
             $searchfield=$postdata['searchvalue'];
             $this->db->like($searchfield, $searchtext);
         }
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();


         return $data;
     }
     function insertassignmark($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('assignmark_id'=>$masterid,
                'exammaster_id'=>$postdata['exammaster_id'],
                'classlevel_id'=>$postdata['classlevel_id']);
         $this->db->insert('assignmark', $tbl1Values);
         for($i=1;$i<=$postdata['norows'];$i++)
         {
              for($j=1;$j<=$postdata['nosubj'];$j++)
              {
                if(isset($postdata[$i.'student_id'.$j]))
                {
                    $tbl3Values=array('assignmark_id'=>$masterid,
                                 'student_id'=>$postdata[$i.'student_id'.$j],
                                 'subject_id'=>$postdata[$i.'subject_id'.$j],
                                 'mark'=>$postdata[$i.'mark'.$j],
                                 'mark_classwork'=>$postdata[$i.'classmark'.$j]);
                    $this->db->insert('assignmark_student', $tbl3Values);
                }
              }
         }

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

     }
     function updateassignmark($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $this->mastermodel->updatemasterdata($postdata['masterid']);
         $this->db->where('assignmark_id',$postdata['masterid']);
         $this->db->delete('assignmark_student');
         for($i=1;$i<=$postdata['norows'];$i++)
         {
              for($j=1;$j<=$postdata['nosubj'];$j++)
              {
                    if(isset($postdata[$i.'student_id'.$j]))
                    {
                        $tbl3Values=array('assignmark_id'=>$postdata['masterid'],
                                     'student_id'=>$postdata[$i.'student_id'.$j],
                                     'subject_id'=>$postdata[$i.'subject_id'.$j],
                                     'mark'=>$postdata[$i.'mark'.$j],
                                     'mark_classwork'=>$postdata[$i.'mark_classwork'.$j]);

                        $this->db->insert('assignmark_student', $tbl3Values);
                    }
              }
          }

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

     }

     
     
     function get_subject_data($classlevel_id)
     {

         $data=array();
         $this->db->select('subject.subject_id,subject_name');
         $this->db->from('subject');
         $this->db->where('subject.classlevel_id',$classlevel_id);
         $data['results']=$this->db->get();
         return $data;
     }
     
     function get_student_data($classlevel_id)
     {

         $data=array();
         $ayear =  $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->select("CONCAT(first_name, ' ', last_name) AS name", FALSE);
         $this->db->select('student_id');
         $this->db->from('student');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->where('deleted','0');
         $this->db->where('classlevel_id',$classlevel_id);
         $this->db->where('ayear',$ayear);
         $data['results']=$this->db->get();
         return $data;
     }
     function get_subject_data_class($classlevel_id)
     {

         $data=array();
         $this->db->select('subject.subject_id,subject.subject_name');
         $this->db->from('subject');
         $this->db->where('subject.classlevel_id',$classlevel_id);
         $data['results']=$this->db->get();
         return $data;
     }

     function get_student_markunassigned($id)
     {
         $data=array();
         $classlevel_id=$this->mastermodel->getSingleFieldValue('assignmark','classlevel_id','assignmark_id',$id);
         $ayear =  $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->select("CONCAT(first_name, ' ', last_name) AS name", FALSE);
         $this->db->select('student_id');
         $this->db->from('student');
         $this->db->join('master','master.masterid=student.student_id');
         $this->db->where('deleted','0');
         $this->db->where('classlevel_id',$classlevel_id);
         $this->db->where('ayear',$ayear);
         $this->db->where("student_id not in (select distinct(student_id) from assignmark_student where assignmark_id= ".$id.")");
         $data['results']=$this->db->get();
         $data['classlevel_id']=$classlevel_id;
         return $data;
     }

     
     function get_data_assignmark($id)
     {
         $data=array();
         $this->db->select('assignmark.assignmark_id,exammaster_name,student.student_id,classlevel_code');
         $this->db->select("GROUP_CONCAT(mark order by assignmark_student.subject_id) AS mark", FALSE);
         $this->db->select("GROUP_CONCAT(mark_classwork  order by assignmark_student.subject_id) AS mark_classwork", FALSE);
         $this->db->select("GROUP_CONCAT(CAST(subject.subject_id as CHAR) order by assignmark_student.subject_id) AS subject_id", FALSE);
         $this->db->select("CONCAT(first_name, ' ', last_name) AS student_name", FALSE);
         $this->db->from('assignmark');
         $this->db->join('assignmark_student','assignmark_student.assignmark_id=assignmark.assignmark_id');
         $this->db->join('subject','subject.subject_id=assignmark_student.subject_id');
         $this->db->join('classlevel','classlevel.classlevel_id=assignmark.classlevel_id');
         $this->db->join('exammaster','exammaster.exammaster_id=assignmark.exammaster_id');
         $this->db->join('student','student.student_id=assignmark_student.student_id');
         $this->db->join('master','master.masterid=assignmark.assignmark_id');
         $this->db->where('deleted', '0');
         $this->db->where('assignmark.assignmark_id', $id);
         $this->db->groupby('student.student_id');
         $Q= $this->db->get();
         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();
         return $data;
      }
      function get_data_assignmarksubj($id)
     {
         $data=array();
         $this->db->select('subject_name,mark');
         $this->db->from('assignmark');
         $this->db->join('assignmark_student','assignmark_student.assignmark_id=assignmark.assignmark_id');
         $this->db->join('subject','subject.subject_id=assignmark_student.subject_id');
         $this->db->join('master','master.masterid=assignmark.assignmark_id');
         $this->db->where('deleted', '0');
         $this->db->where('assignmark.assignmark_id', $id);
         $this->db->groupby('subject.subject_id');
         $this->db->orderby('assignmark_student.subject_id');
         $Q= $this->db->get();
         if ($Q->num_rows() > 0)
         {
             foreach ($Q->result_array() as $row)
             {
                 $data[] = $row;
             }
         }
         $Q->free_result();
         return $data;
      }
      function searchreportcard($postdata,$studentid="",$exammasterid="",$ayear="")
      {
         if($studentid=="")
         {
             $studentid = $postdata['student_id'];
             $exammasterid = $postdata['exammaster_id'];
             $ayear =  $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         }

         $data=array();
         $query = "SELECT
                      `subject`.`subject_name`
                    , `subject`.`subject_code`
                    , `assignmark_student`.`mark`
                    , `assignmark_student`.`mark_classwork`
                    , `exammaster`.`exammaster_name`
                    , CONCAT(`student`.`first_name`,' ', `student`.`last_name`) AS NAME
                    , `classlevel`.`classlevel_code`
                    , `gradelevel`.`gradelevel_description`
                    , `gradelevel`.`gradelevel_color`
                    , `student`.`student_id`
                    , `exammaster`.`exammaster_id`
                    , ayear
                FROM
                    `subject`
                    LEFT JOIN `assignmark_student`
                        ON (`subject`.`subject_id` = `assignmark_student`.`subject_id`)
                    INNER JOIN `classlevel`
                        ON (`subject`.`classlevel_id` = `classlevel`.`classlevel_id`)
                    INNER JOIN `assignmark`
                        ON (`assignmark_student`.`assignmark_id` = `assignmark`.`assignmark_id`)
                    INNER JOIN `student`
                        ON (`assignmark_student`.`student_id` = `student`.`student_id`)
                    INNER JOIN `gradelevel`
                        ON ((`assignmark_student`.`mark` + `assignmark_student`.`mark_classwork`) BETWEEN `gradelevel`.`min_marks` AND gradelevel.max_marks)
                    INNER JOIN `exammaster`
                        ON (`assignmark`.`exammaster_id` = `exammaster`.`exammaster_id`)
                    INNER JOIN `master`
                        ON (`master`.masterid = `assignmark`.assignmark_id)
                    WHERE `exammaster`.`exammaster_id`  =". $exammasterid ." and `student`.`student_id`=". $studentid ." and ayear = ". $ayear ." and master.deleted=0;";
         $data['results']= $this->db->query($query);
         $data['tbltitle']="";
         return $data;
     }

     function searchreportcardyearly($postdata,$studentid="",$exammasterid="",$ayear="")
     {
        if($studentid=="")
         {
             $studentid = $postdata['student_id'];
             $ayear =  $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         }
         $data=array();
         $query = "SELECT
                    `subject`.`subject_name`
                    , REPLACE(REPLACE(GROUP_CONCAT('<td style=\"text-align:center\">',(`assignmark_student`.`mark` + `assignmark_student`.`mark_classwork`) ,'</td>','<td style=\"text-align:center;color:',gradelevel.gradelevel_color,';\">', gradelevel.gradelevel_description  ,'</td>'  ORDER BY exammaster.exammaster_id),'%',''),',','') AS Term
                    , CONCAT(`student`.`first_name`,' ', `student`.`last_name`) AS StudentName
                     , `exammaster`.`exammaster_name`
                     , CONCAT(`student`.`first_name`,' ', `student`.`last_name`) AS NAME
                    , `classlevel`.`classlevel_code`
                    , `student`.`student_id`
                    , `master`.`ayear`
                FROM
                    `assignmark_student`
                    INNER JOIN `assignmark`
                        ON (`assignmark_student`.`assignmark_id` = `assignmark`.`assignmark_id`)
                    INNER JOIN `exammaster`
                        ON (`assignmark`.`exammaster_id` = `exammaster`.`exammaster_id`)
                    INNER JOIN `subject`
                        ON (`assignmark_student`.`subject_id` = `subject`.`subject_id`)
                    INNER JOIN `student`
                        ON (`assignmark_student`.`student_id` = `student`.`student_id`)
                    INNER JOIN `classlevel`
                        ON (`subject`.`classlevel_id` = `classlevel`.`classlevel_id`)
                    INNER JOIN gradelevel
                        ON ((`assignmark_student`.`mark` + `assignmark_student`.`mark_classwork`) BETWEEN gradelevel.min_marks AND gradelevel.max_marks)
                     INNER JOIN `master`
                        ON (`master`.masterid = `assignmark`.assignmark_id)
                WHERE `student`.`student_id`=". $studentid ." and ayear = ". $ayear ." and master.deleted=0
                GROUP BY subject.subject_id
                ORDER BY subject.subject_id";
         $data['results']= $this->db->query($query);


         $queryTableHead="SELECT
                    exammaster.exammaster_name
                FROM
                    `assignmark_student`
                    INNER JOIN `assignmark`
                        ON (`assignmark_student`.`assignmark_id` = `assignmark`.`assignmark_id`)
                    INNER JOIN `exammaster`
                        ON (`assignmark`.`exammaster_id` = `exammaster`.`exammaster_id`)
                    INNER JOIN `subject`
                        ON (`assignmark_student`.`subject_id` = `subject`.`subject_id`)
                    INNER JOIN `student`
                        ON (`assignmark_student`.`student_id` = `student`.`student_id`)
                    INNER JOIN `classlevel`
                        ON (`subject`.`classlevel_id` = `classlevel`.`classlevel_id`)
                    INNER JOIN gradelevel
                        ON ((`assignmark_student`.`mark` + `assignmark_student`.`mark_classwork`) BETWEEN gradelevel.min_marks AND gradelevel.max_marks)
                     INNER JOIN `master`
                        ON (`master`.masterid = `assignmark`.assignmark_id)
                WHERE `student`.`student_id`=". $studentid ." and ayear = ". $ayear ." and master.deleted=0
                GROUP BY exammaster.exammaster_id";

         $data['tbltitle']= $this->db->query($queryTableHead);


         return $data;
     }

     function searchclassreportcard($postdata,$studentid="",$exammasterid="",$ayear="",$classlevelid="")
     {
       if($exammasterid=="")
         {
             $exammasterid = $postdata['exammaster_id'];
             $ayear =  $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
             $classlevelid = $postdata['classlevel_id'];
         }

         $data=array();
         $query = "SELECT
                         CONCAT(`student`.`first_name`,' ', `student`.`last_name`) AS Name
                         , REPLACE(REPLACE(GROUP_CONCAT(CONCAT('<td>',(`assignmark_student`.`mark` + `assignmark_student`.`mark_classwork`),'</td>')ORDER BY `subject`.`subject_id`),'%',''),',','') AS Mark
                    FROM
                        `subject`
                        LEFT JOIN `assignmark_student`
                            ON (`subject`.`subject_id` = `assignmark_student`.`subject_id`)
                        INNER JOIN `classlevel`
                            ON (`subject`.`classlevel_id` = `classlevel`.`classlevel_id`)
                        INNER JOIN `assignmark`
                            ON (`assignmark_student`.`assignmark_id` = `assignmark`.`assignmark_id`)
                        INNER JOIN `exammaster`
                            ON (`assignmark`.`exammaster_id` = `exammaster`.`exammaster_id`)
                        INNER JOIN `master`
                            ON (`master`.masterid = `assignmark`.assignmark_id)
                        INNER JOIN `student`
                                ON(`student`.`student_id` = `assignmark_student`.`student_id`)
                    WHERE `exammaster`.`exammaster_id`=".$exammasterid ." and ayear = ". $ayear ." and master.deleted=0 and `classlevel`.`classlevel_id`=".$classlevelid ."
                    GROUP BY `assignmark_student`.`student_id`,`exammaster`.`exammaster_id`";
         $data['results']= $this->db->query($query);

         $queryTableHead="SELECT
                             `subject`.`subject_name`
                             , `exammaster`.`exammaster_name`
                             , `classlevel`.`classlevel_code`
                             , `exammaster`.`exammaster_id`
                             ,`master`.`ayear`
                             , `classlevel`.`classlevel_id`
                        FROM
                            `subject`
                            LEFT JOIN `assignmark_student`
                                ON (`subject`.`subject_id` = `assignmark_student`.`subject_id`)
                            INNER JOIN `classlevel`
                                ON (`subject`.`classlevel_id` = `classlevel`.`classlevel_id`)
                            INNER JOIN `assignmark`
                                ON (`assignmark_student`.`assignmark_id` = `assignmark`.`assignmark_id`)
                            INNER JOIN `exammaster`
                                ON (`assignmark`.`exammaster_id` = `exammaster`.`exammaster_id`)
                            INNER JOIN `master`
                                ON (`master`.masterid = `assignmark`.assignmark_id)
                        WHERE `exammaster`.`exammaster_id`=". $exammasterid." and ayear = ". $ayear ." and master.deleted=0 and `classlevel`.`classlevel_id`=". $classlevelid ."
                        GROUP BY subject.subject_id
                        ORDER BY `subject`.`subject_id`";

         $data['tbltitle']= $this->db->query($queryTableHead);



         return $data;
     }
     
    
      

     function searchkgsettings($postdata,$pagenum)
     {
         $data=array();

         $this->db->from('kgsettings');
         $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,label,description,target');
         $this->db->from('kgsettings');
         $this->db->order_by('id');
         $data['results']=$this->db->get();
         return $data;
     }

     function searchkgcategory($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('kgcategory');
         $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('kgcategory');
         $this->db->order_by('kgcategory_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
       

     }

     function insertkgcategory($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'kgcategory_name'=>$postdata['kgcategory_name']
                );
         $this->db->insert('kgcategory', $tbl1Values);
         $data['resfunction']='searchkgcategory';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function updatekgcategory($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $tbl1Values=array(
                'kgcategory_name'=>$postdata['kgcategory_name']
                );
         $this->db->where('kgcategory_id', $postdata['kgcategory_id']);
         $this->db->update('kgcategory', $tbl1Values);
         $data['resfunction']='searchkgcategory';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     function searchkgactivity($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('kgactivity');
         $this->db->join('kgcategory','kgcategory.kgcategory_id=kgactivity.kgcategory_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('kgactivity');
         $this->db->join('kgcategory','kgcategory.kgcategory_id=kgactivity.kgcategory_id');
         $this->db->order_by('kgactivity_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
         
     }

         function insertkgactivity($postdata)
         {
             $data=array();
            // var_dump($postdata);
             $this->db->trans_begin();
             $tbl1Values=array(
                    'kgactivity_name'=>$postdata['kgactivity_name'],
                    'kgcategory_id'=>$postdata['kgcategory_id']
                    );
             $this->db->insert('kgactivity', $tbl1Values);
             $data['resfunction']='searchkgactivity';
       
              $kgactivity_id = mysql_insert_id();
              $i=1;
                while (isset($postdata['kgattainment_id_'.$i]))
                {
                    if(isset($postdata['select_attainment_'.$i]))
                    {
                        $kgattainment_id = $postdata['kgattainment_id_'.$i];
                        $tblValues=array(
                                        'kgactivity_id'=>$kgactivity_id,
                                        'kgattainment_id'=>$kgattainment_id
                                        );
                        $this->db->insert('kgactivityattainment', $tblValues);
                    }
                    $i++;
                }
                
               
                $i=1;
                while (isset($postdata['kgeffort_id_'.$i]))
                {
                    if(isset($postdata['select_effort_'.$i]))
                    {
                        $kgeffort_id = $postdata['kgeffort_id_'.$i];
                        $tblValues=array(
                                        'kgactivity_id'=>$kgactivity_id,
                                        'kgeffort_id'=>$kgeffort_id
                                        );
                        $this->db->insert('kgactivityeffort', $tblValues);
                    }
                    $i++;
                }
              $data['resfunction']='searchkgactivity';
             if ($this->db->trans_status() === FALSE)
              {
                $this->db->trans_rollback();
                return 0;
              }
              else
              {
                $this->db->trans_commit();
                $data['res']=1;
                return $data;
              }

     }
      function updatekgactivity($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         //$masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'kgactivity_name'=>$postdata['kgactivity_name'],
                'kgcategory_id'=>$postdata['kgcategory_id']
                );
         $this->db->where('kgactivity_id', $postdata['kgactivity_id']);
         $this->db->update('kgactivity', $tbl1Values);
         $data['resfunction']='searchkgactivity';
         //$kgactivity_id = mysql_insert_id();
         $this->db->where('kgactivity_id',$postdata['kgactivity_id']);
          $this->db->delete('kgactivityattainment');
          $i=1;
            while (isset($postdata['kgattainment_id_'.$i]))
            {
                if(isset($postdata['select_attainment_'.$i]))
                {
                    $kgattainment_id = $postdata['kgattainment_id_'.$i];
                    $tblValues=array(
                                    'kgactivity_id'=>$postdata['kgactivity_id'],
                                    'kgattainment_id'=>$kgattainment_id
                                    );
                    $this->db->insert('kgactivityattainment', $tblValues);
                }
                $i++;
            }
         
             $this->db->where('kgactivity_id',$postdata['kgactivity_id']);
             $this->db->delete('kgactivityeffort');
          $i=1;
            while (isset($postdata['kgeffort_id_'.$i]))
            {
                if(isset($postdata['select_effort_'.$i]))
                {
                    $kgeffort_id = $postdata['kgeffort_id_'.$i];
                    $tblValues=array(
                                    'kgactivity_id'=>$postdata['kgactivity_id'],
                                    'kgeffort_id'=>$kgeffort_id
                                    );
                    $this->db->insert('kgactivityeffort', $tblValues);
                }
                $i++;
            }
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function searchkgattainment($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('kgattainment');
         $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('kgattainment');
         $this->db->order_by('kgattainment_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     function insertkgattainment($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('kgattainment_id'=>$masterid,
                'kgattainment_name'=>$postdata['kgattainment_name']
                );
         $this->db->insert('kgattainment', $tbl1Values);
         $data['resfunction']='searchkgattainment';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function updatekgattainment($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'kgattainment_name'=>$postdata['kgattainment_name']
                );
         $this->db->where('kgattainment_id', $postdata['kgattainment_id']);
         $this->db->update('kgattainment', $tbl1Values);
         $data['resfunction']='searchkgattainment';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function searchkgeffort($postdata,$pagenum)
     {

         $data=array();

         $this->db->from('kgeffort');
         $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('kgeffort');
         $this->db->order_by('kgeffort_id');
         $this->db->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     function insertkgeffort($postdata)
     {
         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array('kgeffort_id'=>$masterid,
                'kgeffort_name'=>$postdata['kgeffort_name']
                );
         $this->db->insert('kgeffort', $tbl1Values);
         $data['resfunction']='searchkgeffort';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }
     function updatekgeffort($postdata)
     {

         $data=array();
         $this->db->trans_begin();
         $masterid = $this->mastermodel->insertmasterdata();
         $tbl1Values=array(
                'kgeffort_name'=>$postdata['kgeffort_name']
                );
         $this->db->where('kgeffort_id', $postdata['kgeffort_id']);
         $this->db->update('kgeffort', $tbl1Values);
         $data['resfunction']='searchkgeffort';
         if ($this->db->trans_status() === FALSE)
	  {
            $this->db->trans_rollback();
	    return 0;
	  }
	  else
	  {
            $this->db->trans_commit();
            $data['res']=1;
	    return $data;
	  }

     }

     //Function  by Rakesh
     function searchkgperformance($postdata,$pagenum)
     {
         $data=array();
         $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
         $this->db->from('kgperformance');
         $this->db->join('master','master.masterid=kgperformance.kgperformance_id');
         $this->db->where('deleted', '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;
         $this->db->select('*');
         $this->db->from('kgperformance');
         $this->db->join('master','master.masterid=kgperformance.kgperformance_id');
         $this->db->join('student','student.student_id=kgperformance.student_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->limit($perpage, $start);
         $data['results']=$this->db->get();
         return $data;
     }
     
     function insertkgperformance($postdata)
     {
        $data=array();
        $this->db->trans_begin();
        $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1');
        $categories=$this->mastermodel->getdatas('kgcategory');
        $attainment = $this->mastermodel->getdatas('kgattainment');
        $effort = $this->mastermodel->getdatas('kgeffort');
        $isRecordExist ="SELECT `kgperformance`.`student_id`, `master`.`ayear`, `master`.`masterid` 
                         FROM `kgperformance` 
                         INNER JOIN `master` 
                            ON (`kgperformance`.`kgperformance_id` = `master`.`masterid`)
                         WHERE `kgperformance`.`student_id`='" . $postdata['student_id'] ."' and `master`.`ayear`='". $ayear . "' and deleted = 0";
        $result= $this->db->query($isRecordExist);
        if($result->num_rows()< 1)
        {
            $masterid = $this->mastermodel->insertmasterdata();
            $tbl1Values=array('kgperformance_id'=>$masterid,'student_id'=>$postdata['student_id'],'date'=>$this->mastermodel->convertdateformat($postdata['date'])
                    ,'comments'=>$postdata['comments']);
            $this->db->insert('kgperformance', $tbl1Values);
            foreach ($categories as $cat)
            {
                $kgactivitys = $this->mastermodel->get_data('kgactivity',$cat['kgcategory_id'],'kgcategory_id');
                $kgcategory = $cat['kgcategory_id'];
                foreach ($kgactivitys as $kgact)
                {
                    $kact = "0";
                    $katt = "0";
                    $keff="0";
                    if(isset($postdata['att_'.$kgact['kgactivity_id']]))
                            $katt=$postdata['att_'.$kgact['kgactivity_id']];
                    if(isset($postdata['eff_'.$kgact['kgactivity_id']]))
                            $keff = $postdata['eff_'.$kgact['kgactivity_id']];

                    $kact = $kgact['kgactivity_id'];
                    $perfomanceDetails_tbl1Values=array(
                            'kgperfomance_id'=>$masterid,
                            'kgcategory_id'=>$kgcategory,
                            'kgactivity_id'=>$kact,
                            'kgattainment_id'=>$katt,
                            'kgeffort_id'=>$keff);
                      $this->db->insert('kgperformance_details', $perfomanceDetails_tbl1Values);
                      $perfomanceDetails_tbl1Values="";
                }
            } 

            if ($this->db->trans_status() === FALSE)
            {
                $this->db->trans_rollback();
                return 0;
            }
            else
            {
                $this->db->trans_commit();
                $data['res']=1;
                $data['resfunction']="searchkgperformance";
                return $data;
            }
        }
        else
        {
                $data['res']=1;
                $data['resfunction']="searchkgperformance";
                return 0;
        }
     }
     
     
     function updatekgperformance($postdata)
     {
        $data=array();
        $this->db->trans_begin();
        $this->mastermodel->updatemasterdata($postdata['kgperformance_id']);
        $tbl1Values=array('date'=>$this->mastermodel->convertdateformat($postdata['date'])
                    ,'comments'=>$postdata['comments']);
        $this->db->where('kgperformance_id',$postdata['kgperformance_id']);
        $this->db->update('kgperformance', $tbl1Values);
        $categories=$this->mastermodel->getdatas('kgcategory');
        $attainment = $this->mastermodel->getdatas('kgattainment');
        $effort = $this->mastermodel->getdatas('kgeffort');
        foreach ($categories as $cat)
        {
            $kgactivitys = $this->mastermodel->get_data('kgactivity',$cat['kgcategory_id'],'kgcategory_id');
            $kgcategory = $cat['kgcategory_id'];
            
            foreach ($kgactivitys as $kgact)
            {
                $kact = "0";
            $katt = "0";
            $keff="0";
                if(isset($postdata['att_'.$kgact['kgactivity_id']]))
                        $katt=$postdata['att_'.$kgact['kgactivity_id']];
                if(isset($postdata['eff_'.$kgact['kgactivity_id']]))
                        $keff = $postdata['eff_'.$kgact['kgactivity_id']];
                $kact = $kgact['kgactivity_id'];
                $this->db->query("update kgperformance_details set kgattainment_id = ". $katt .",kgeffort_id=". $keff ." where kgperfomance_id=".$postdata['kgperformance_id'] ." and kgcategory_id = ". $kgcategory." and kgactivity_id=". $kact);
            }
        } 
        if ($this->db->trans_status() === FALSE)
        {
            $this->db->trans_rollback();
            return 0;
        }
        else
        {
            $this->db->trans_commit();
            $data['res']=1;
            $data['resfunction']="searchkgperformance";
            return $data;
        }
        
     }
        
     
     function getkgperformance_attain_effort($query)
     {
         $data=$this->db->query($query);
           $result= $data->row();
           if($result)
           {
              return $result;
           }
           else
           {
               return "";
           }
     }

     function getstudentdetails($id)
     {
        $data = array();
        $this->db->select("CONCAT(first_name, ' ', last_name) AS name", FALSE);
        $this->db->select('classlevel_code');
        $this->db->where('kgperformance_id',$id);
        $this->db->join('student','student.student_id=kgperformance.student_id');
        $this->db->join('classlevel','classlevel.classlevel_id=student.classlevel_id');
        $Q= $this->db->get('kgperformance');
        $row=$Q->row();
        return $row;
     }
     
     
     //End Function by Rakesh
}

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