?
Current Path : /home1/savoy/public_html/savoyglobal.net/simsdemo/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 |
Current File : /home1/savoy/public_html/savoyglobal.net/simsdemo/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'], 'gender'=>$postdata['gender'], 'dob'=>$dob, 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'classlevel_id'=>$postdata['classlevel_id']); $this->db->insert('student', $tbl1Values); $tbl2Values=array('student_id'=>$masterid, 'state'=>$postdata['state'], 'country'=>$postdata['country']); $this->db->insert('student_address', $tbl2Values); $computer = isset($postdata['computer']) ? 1 : 0; $internet = isset($postdata['internet']) ? 1 : 0; $printer = isset($postdata['printer']) ? 1 : 0; $tbl3Values=array('student_id'=>$masterid, 'community'=>$postdata['community'], 'ipp_no'=>$postdata['ipp_no'], 'tc'=>$postdata['tc'], 'school_previous'=>$postdata['school_previous'], 'illness'=>$postdata['illness'], 'allergy'=>$postdata['allergy'], 'transport'=>$postdata['transport'], 'computer'=>$computer, 'internet'=>$internet, 'printer'=>$printer); $this->db->insert('student_otherinfo', $tbl3Values); if($postdata['new_parent']=="yes") { $masterid1 = $this->mastermodel->insertmasterdata(); $tbl1Values=array('parent_id'=>$masterid1, 'name'=>$postdata['father_name'], 'relationship_type'=>'father', 'email'=>$postdata['father_email'], 'mobile_no'=>$postdata['father_mobile'] ); $this->db->insert('parent', $tbl1Values); $tbl2Values=array('parent_id'=>$masterid1, 'address'=>$postdata['present_address'], ); $this->db->insert('parent_address', $tbl2Values); $masterid2 = $this->mastermodel->insertmasterdata(); $tbl1Values=array('parent_id'=>$masterid2, 'name'=>$postdata['mother_name'], 'relationship_type'=>'mother', 'email'=>$postdata['mother_email'], 'mobile_no'=>$postdata['mother_mobile'] ); $this->db->insert('parent', $tbl1Values); $tbl2Values=array('parent_id'=>$masterid2, 'address'=>$postdata['present_address'], ); $this->db->insert('parent_address', $tbl2Values); $tbl3Values=array('parent_id'=>$masterid1, 'student_id'=>$masterid); $this->db->insert('parent_student', $tbl3Values); $tbl3Values=array('parent_id'=>$masterid2, 'student_id'=>$masterid); $this->db->insert('parent_student', $tbl3Values); } else { $tbl3Values=array('parent_id'=>$postdata['parentf_id'], 'student_id'=>$masterid); $this->db->insert('parent_student', $tbl3Values); $tbl3Values=array('parent_id'=>$postdata['parentm_id'], 'student_id'=>$masterid); $this->db->insert('parent_student', $tbl3Values); } $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('student.student_id,student.first_name,student.last_name,student.reg_no,classlevel.classlevel_code'); $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'], 'gender'=>$postdata['gender'], 'dob'=>$dob, 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'classlevel_id'=>$postdata['classlevel_id']); $this->db->insert('student', $tbl1Values); $tbl2Values=array('student_id'=>$masterid, 'address'=>$postdata['address'], 'state'=>$postdata['state'], 'country'=>$postdata['country']); $this->db->insert('student_address', $tbl2Values); $computer = isset($postdata['computer']) ? 1 : 0; $internet = isset($postdata['internet']) ? 1 : 0; $printer = isset($postdata['printer']) ? 1 : 0; $tbl3Values=array('student_id'=>$masterid, 'community'=>$postdata['community'], 'ipp_no'=>$postdata['ipp_no'], 'tc'=>$postdata['tc'], 'school_previous'=>$postdata['school_previous'], 'illness'=>$postdata['illness'], 'allergy'=>$postdata['allergy'], 'transport'=>$postdata['transport'], 'computer'=>$computer, 'internet'=>$internet, 'printer'=>$printer); $this->db->insert('student_otherinfo', $tbl3Values); 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']='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']); $tbl2Values=array( 'reg_no'=>$postdata['reg_no'], 'first_name'=>$postdata['first_name'], 'last_name'=>$postdata['last_name'], 'gender'=>$postdata['gender'], 'dob'=>$dob, 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'classlevel_id'=>$postdata['classlevel_id']); $this->db->where('student_id',$postdata['masterid']); $this->db->update('student', $tbl2Values); $tbl2Values=array( 'address'=>$postdata['address'], 'state'=>$postdata['state'], 'country'=>$postdata['country']); $this->db->where('student_id',$postdata['masterid']); $this->db->update('student_address', $tbl2Values); $computer = isset($postdata['computer']) ? 1 : 0; $internet = isset($postdata['internet']) ? 1 : 0; $printer = isset($postdata['printer']) ? 1 : 0; $tbl3Values=array( 'community'=>$postdata['community'], 'ipp_no'=>$postdata['ipp_no'], 'tc'=>$postdata['tc'], 'school_previous'=>$postdata['school_previous'], 'illness'=>$postdata['illness'], 'allergy'=>$postdata['allergy'], 'transport'=>$postdata['transport'], 'computer'=>$computer, 'internet'=>$internet, 'printer'=>$printer); $this->db->where('student_id',$postdata['masterid']); $this->db->update('student_otherinfo', $tbl3Values); if(isset($postdata['create_user'])) { $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); } else if($postdata['username'] != '') { $tbl2Values=array( 'username'=>$postdata['username']); $this->db->where('linkedto_id', $postdata['masterid']); $this->db->update('user', $tbl2Values); if($postdata['password']!='') { $password=md5($postdata['password']); $tbl2Values=array('password'=>$password); $this->db->where('linkedto_id', $postdata['masterid']); $this->db->update('user', $tbl2Values); } } $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'], '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, 'address'=>$postdata['address'], 'country'=>$postdata['country']); $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'], '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( 'address'=>$postdata['address'], 'country'=>$postdata['country']); $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; } }