?
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 |
Current File : /home1/savoy/public_html/savoyglobal.net/koolkids/school/application/models/teachermodel.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 Teachermodel extends Model { function Teachermodel() { parent::Model(); } function searchteacher($postdata,$pagenum) { $data=array(); $this->db->from('teacher'); $this->db->join('master','master.masterid=teacher.teacher_id'); $this->db->join('teacher_address','teacher_address.teacher_id=teacher.teacher_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('teacher.teacher_id,teacher.first_name,teacher.last_name,teacher_no,teacher.mobile_no'); $this->db->from('teacher'); $this->db->join('master','master.masterid=teacher.teacher_id'); $this->db->join('teacher_address','teacher_address.teacher_id=teacher.teacher_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 insertteacher($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array('teacher_id'=>$masterid, 'teacher_no'=>$postdata['teacher_no'], 'first_name'=>$postdata['first_name'], 'last_name'=>$postdata['last_name'], 'gender'=>$postdata['gender'], 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'passport_no'=>$postdata['passport_no'], 'qatar_id'=>$postdata['qatar_id'], 'sponsorship'=>$postdata['sponsorship']); $this->db->insert('teacher', $tbl1Values); $tbl2Values=array('teacher_id'=>$masterid, 'address_permanent'=>$postdata['address_permanent'], 'country_permanent'=>$postdata['country_permanent'], 'address_present'=>$postdata['address_present'], 'country_present'=>$postdata['country_present']); $this->db->insert('teacher_address', $tbl2Values); $i=1; while($postdata['course'.$i]!="") { $tbl3Values=array('teacher_id'=>$masterid, 'course'=>$postdata['course'.$i], 'university'=>$postdata['university'.$i], 'passing_year'=>$postdata['passing_year'.$i]); $this->db->insert('teacher_qualification', $tbl3Values); $i++; if(isset($postdata['course'.$i])) continue; else break; } $i=1; while($postdata['employer'.$i]!="") { $tbl4Values=array('teacher_id'=>$masterid, 'employer'=>$postdata['employer'.$i], 'designation'=>$postdata['designation'.$i], 'period'=>$postdata['period'.$i]); $this->db->insert('teacher_work_experience', $tbl4Values); $i++; if(isset($postdata['employer'.$i])) continue; else break; } $i=0; while (isset ($postdata['subject_id'][$i])) { $tbl3Values=array('teacher_id'=>$masterid, 'subject_id'=>$postdata['subject_id'][$i]); $this->db->insert('teacher_subject', $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']='searchteacher'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updateteacher($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl2Values=array( 'teacher_no'=>$postdata['teacher_no'], 'first_name'=>$postdata['first_name'], 'last_name'=>$postdata['last_name'], 'gender'=>$postdata['gender'], 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'passport_no'=>$postdata['passport_no'], 'qatar_id'=>$postdata['qatar_id'], 'sponsorship'=>$postdata['sponsorship']); $this->db->where('teacher_id',$postdata['masterid']); $this->db->update('teacher', $tbl2Values); 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); } } $tbl2Values=array( 'address_permanent'=>$postdata['address_permanent'], 'country_permanent'=>$postdata['country_permanent'], 'address_present'=>$postdata['address_present'], 'country_present'=>$postdata['country_present']); $this->db->where('teacher_id',$postdata['masterid']); $this->db->update('teacher_address', $tbl2Values); $this->db->where('teacher_id',$postdata['masterid']); $this->db->delete('teacher_subject'); $i=0; while (isset ($postdata['subject_id'][$i])) { $tbl3Values=array('teacher_id'=>$postdata['masterid'], 'subject_id'=>$postdata['subject_id'][$i]); $this->db->insert('teacher_subject', $tbl3Values); $i++; } $this->db->delete('teacher_qualification',array('teacher_id'=>$postdata['masterid'])); $i=1; while($postdata['course'.$i]!="") { $tbl4Values=array('teacher_id'=>$postdata['masterid'], 'course'=>$postdata['course'.$i], 'university'=>$postdata['university'.$i], 'passing_year'=>$postdata['passing_year'.$i]); $this->db->insert('teacher_qualification', $tbl4Values); $i++; if(isset($postdata['course'.$i])) continue; else break; } $this->db->delete('teacher_work_experience',array('teacher_id'=>$postdata['masterid'])); $i=1; while($postdata['employer'.$i]!="") { $tbl5Values=array('teacher_id'=>$postdata['masterid'], 'employer'=>$postdata['employer'.$i], 'designation'=>$postdata['designation'.$i], 'period'=>$postdata['period'.$i]); $this->db->insert('teacher_work_experience', $tbl5Values); $i++; if(isset($postdata['employer'.$i])) continue; else break; } $data['resfunction']='searchteacher'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function searchteachersubj($postdata,$pagenum) { $data=array(); $this->db->from('teacher'); $this->db->join('master','master.masterid=teacher.teacher_id'); $this->db->where('deleted', '0'); $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('teacher.teacher_id,teacher.first_name,teacher.last_name,teacher.mobile_no'); $this->db->from('teacher'); $this->db->join('master','master.masterid=teacher.teacher_id'); $this->db->join('teacher_address','teacher_address.teacher_id=teacher.teacher_id'); $this->db->where('deleted', '0'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function get_data_subject($teacher_id) { $data=array(); $this->db->select('subject.subject_name, classlevel.classlevel_name,classlevel_code,subject.subject_id'); $this->db->join('subject','teacher_subject.subject_id = subject.subject_id'); $this->db->join('classlevel','subject.classlevel_id = classlevel.classlevel_id'); $this->db->from('teacher_subject'); $this->db->where('teacher_id',$teacher_id); $Q=$this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function searchstaff($postdata,$pagenum) { $data=array(); $this->db->from('staff'); $this->db->join('master','master.masterid=staff.staff_id'); $this->db->join('designation','designation.designation_id=staff.designation_id'); $this->db->join('department','department.department_id=staff.department_id'); $this->db->join('staff_address','staff_address.staff_id=staff.staff_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('staff.staff_id,staff.name,designation_name,department_name,staff.mobile_no'); $this->db->from('staff'); $this->db->join('master','master.masterid=staff.staff_id'); $this->db->join('designation','designation.designation_id=staff.designation_id'); $this->db->join('department','department.department_id=staff.department_id'); $this->db->join('staff_address','staff_address.staff_id=staff.staff_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 insertstaff($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array('staff_id'=>$masterid, 'staff_no'=>$postdata['staff_no'], 'name'=>$postdata['name'], 'designation_id'=>$postdata['designation_id'], 'department_id'=>$postdata['department_id'], 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'passport_no'=>$postdata['passport_no'], 'qatar_id'=>$postdata['qatar_id'], 'sponsorship'=>$postdata['sponsorship']); $this->db->insert('staff', $tbl1Values); $tbl2Values=array('staff_id'=>$masterid, 'address_permanent'=>$postdata['address_permanent'], 'country_permanent'=>$postdata['country_permanent'], 'address_present'=>$postdata['address_present'], 'country_present'=>$postdata['country_present']); $this->db->insert('staff_address', $tbl2Values); 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']='searchstaff'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updatestaff($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl2Values=array( 'staff_no'=>$postdata['staff_no'], 'name'=>$postdata['name'], 'designation_id'=>$postdata['designation_id'], 'department_id'=>$postdata['department_id'], 'email'=>$postdata['email'], 'contact_no'=>$postdata['contact_no'], 'mobile_no'=>$postdata['mobile_no'], 'passport_no'=>$postdata['passport_no'], 'qatar_id'=>$postdata['qatar_id'], 'sponsorship'=>$postdata['sponsorship']); $this->db->where('staff_id',$postdata['masterid']); $this->db->update('staff', $tbl2Values); $tbl2Values=array( 'address_permanent'=>$postdata['address_permanent'], 'country_permanent'=>$postdata['country_permanent'], 'address_present'=>$postdata['address_present'], 'country_present'=>$postdata['country_present']); $this->db->where('staff_id',$postdata['masterid']); $this->db->update('staff_address', $tbl2Values); 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']='searchstaff'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } 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 searchemployeeattendance($postdata,$pagenum) { $data=array(); $this->db->from('employeeattendance'); $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; $postdata=$_SESSION['searchdata']; $this->db->select('id,report_label,description,target'); $this->db->from('employeeattendance'); $data['results']=$this->db->get(); return $data; } function searchteacherattendance($postdata,$pagenum) { $data=array(); $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1'); $this->db->from('teacher_attendance'); $this->db->join('master','master.masterid=teacher_attendance.attendance_id'); $this->db->join('teacher','teacher.teacher_id=teacher_attendance.teacher_id'); $this->db->where('deleted', '0'); $this->db->where('ayear', $ayear); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('teacher_attendance'); $this->db->join('master','master.masterid=teacher_attendance.attendance_id'); $this->db->join('teacher','teacher.teacher_id=teacher_attendance.teacher_id'); $this->db->where('ayear', $ayear); $this->db->where('deleted', '0'); $this->db->order_by('masterid', 'desc'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function searchntsattendance($postdata,$pagenum) { $data=array(); $ayear = $this->mastermodel->getsinglefieldvalue('academicyear','ayear','current','1'); $this->db->from('staff_attendance'); $this->db->join('master','master.masterid=staff_attendance.attendance_id'); $this->db->join('staff','staff.staff_id=staff_attendance.staff_id'); $this->db->where('deleted', '0'); $this->db->where('ayear', $ayear); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchvalue']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('staff_attendance'); $this->db->join('master','master.masterid=staff_attendance.attendance_id'); $this->db->join('staff','staff.staff_id=staff_attendance.staff_id'); $this->db->where('ayear', $ayear); $this->db->where('deleted', '0'); $this->db->order_by('masterid', 'desc'); $this->db->limit($perpage, $start); $data['results']=$this->db->get(); return $data; } function insertteacherattendance($postdata) { $leave_from_date=$this->mastermodel->convertdateformat($postdata['leave_from_date']); $leave_to_date=$this->mastermodel->convertdateformat($postdata['leave_to_date']); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array('attendance_id'=>$masterid, 'teacher_id'=>$postdata['teacher_id'], 'leave_from_date'=>$leave_from_date, 'leave_to_date'=>$leave_to_date, 'reason'=>$postdata['reason']); $this->db->insert('teacher_attendance', $tbl1Values); $data['resfunction']='searchteacherattendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updateteacherattendance($postdata) { $data=array(); $leave_from_date=$this->mastermodel->convertdateformat($postdata['leave_from_date']); $leave_to_date=$this->mastermodel->convertdateformat($postdata['leave_to_date']); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl1Values=array( 'teacher_id'=>$postdata['teacher_id'], 'leave_from_date'=>$leave_from_date, 'leave_to_date'=>$leave_to_date, 'reason'=>$postdata['reason']); $this->db->where('attendance_id',$postdata['masterid']); $this->db->update('teacher_attendance', $tbl1Values); $data['resfunction']='searchteacherattendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function insertstaffattendance($postdata) { $data=array(); $leave_from_date=$this->mastermodel->convertdateformat($postdata['leave_from_date']); $leave_to_date=$this->mastermodel->convertdateformat($postdata['leave_to_date']); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array('attendance_id'=>$masterid, 'staff_id'=>$postdata['staff_id'], 'leave_from_date'=>$leave_from_date, 'leave_to_date'=>$leave_to_date, 'reason'=>$postdata['reason']); $this->db->insert('staff_attendance', $tbl1Values); $data['resfunction']='searchntsattendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function updatestaffattendance($postdata) { $leave_from_date=$this->mastermodel->convertdateformat($postdata['leave_from_date']); $leave_to_date=$this->mastermodel->convertdateformat($postdata['leave_to_date']); $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['masterid']); $tbl1Values=array( 'staff_id'=>$postdata['staff_id'], 'leave_from_date'=>$leave_from_date, 'leave_to_date'=>$leave_to_date, 'reason'=>$postdata['reason']); $this->db->where('attendance_id',$postdata['masterid']); $this->db->update('staff_attendance', $tbl1Values); $data['resfunction']='searchntsattendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } }