?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/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/sgms/application/models/settingsmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Settingsmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function add($postdata) { $data=array(); $data['resfunction']=$postdata['resfunction']; $table = $postdata['tab_name']; unset ($postdata['tab_name']); unset ($postdata['resfunction']); $res=$this->db->insert($table,$postdata); $cnt=$this->db->insert_id(); if($res>0) { $data['res']=1; $data['msg']='Record Added Successfully'; } else { $data['res']=0; $data['msg']='Error On Adding Record'; } return $data; } /*Search function starts here*/ function search_user($pagenum) { $data=array(); $this->db->from('user'); $this->db->join('employee','employee.employee_id=user.employee_id'); $this->db->join('designation','employee.employee_designation_id=designation.designation_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $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['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('user'); $this->db->join('employee','employee.employee_id=user.employee_id'); $this->db->join('designation','employee.employee_designation_id=designation.designation_id'); $this->db->limit($perpage, $start); $this->db->order_by('user_id','asc'); $data['results']=$this->db->get(); return $data; } function search_profile($pagenum) { $data=array(); $this->db->from('user_profile'); $this->db->join('designation','user_profile.designation_id=designation.designation_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $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['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('user_profile'); $this->db->join('designation','user_profile.designation_id=designation.designation_id'); $this->db->limit($perpage, $start); $this->db->order_by('profile_id','asc'); $data['results']=$this->db->get(); return $data; } function search_reminder($pagenum) { $data=array(); $this->db->from('reminder'); $this->db->join('master','masterid=reminder_id'); $this->db->where('creator_id',$_SESSION['sgms_userid']); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'reminder_date') { $searchtext=$this->mastermodel->convdatformat($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; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'reminder_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('reminder'); $this->db->join('master','masterid=reminder_id'); $this->db->where('creator_id',$_SESSION['sgms_userid']); $this->db->order_by('reminder_date','asc'); $data['results']=$this->db->get(); return $data; } /*Search function ends here*/ /*Add function starts here*/ function insert_user($postdata) { $data=array(); $this->db->trans_begin(); // // $profile_details = $this->mastermodel->get_data_srow('user_profile',$postdata['profile_id'],'profile_id'); // $postdata['user_modules'] = $postdata['user_modules'];// $profile_details->profile_modules; // $postdata['modules_permission'] = $postdata['modules_permission'];//$profile_details->profile_modules_permission; // $postdata['private'] = $postdata['user_privates'];//$profile_details->profile_modules_private; $tblValues=array( 'username'=>$postdata['username'], 'password'=>md5($postdata['password']), 'employee_id'=>$postdata['employee_id'], 'user_modules'=>$postdata['user_modules'], 'modules_permission'=>$postdata['modules_permission'], 'private'=>$postdata['user_privates'],); $this->db->insert('user', $tblValues); $data['resfunction']='search_user'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_profile($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'designation_id'=>$postdata['designation_id'], 'profile_modules'=>$postdata['role_permission'], 'profile_modules_private'=>$postdata['role_privates'], 'profile_modules_permission'=>$postdata['role_edit_del_permission']); $this->db->insert('user_profile', $tblValues); $data['resfunction']='search_profile'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_reminder($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $reminder_date = $this->mastermodel->convertdateformat($postdata['reminder_date']); $tblValues=array('reminder_id'=>$masterid, 'reminder_date'=>$reminder_date, 'remind_before'=>$postdata['remind_before'], 'reminder_subject'=>$postdata['reminder_subject'], 'reminder_description'=>$postdata['reminder_description']); $this->db->insert('reminder', $tblValues); $data['resfunction']='search_reminder'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } /*Add function ends here*/ /*Update function starts here*/ /*Update function ends here*/ function update_user($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'user_modules'=>$postdata['user_modules'], 'modules_permission'=>$postdata['modules_permission'], 'private'=>$postdata['user_privates'],); $this->db->where('user_id',$postdata['user_id']); $this->db->update('user', $tblValues); $data['resfunction']='search_user'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_password($postdata) { $data=array(); $data['resfunction']='password'; if($postdata['newpassword'] == $postdata['retypepassword']) { $tblValues=array('password'=>md5($postdata['newpassword'])); $this->db->where('user_id',$postdata['user_id']); $this->db->update('user', $tblValues); $data['res']='password'; $data['msg']='Password Changed Sucessfully'; return $data; } else { $data['res']='password'; $data['msg']='Passwords do not match'; return $data; } } function update_profile($postdata) { $data=array(); $this->db->trans_begin(); $query=$this->db->query("update user_profile set profile_modules='$postdata[role_permission]', profile_modules_permission='$postdata[role_edit_del_permission]' , profile_modules_private='$postdata[role_privates]' where profile_id='$postdata[role_id]'"); $data['resfunction']='search_profile'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_reminder($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['reminder_id']); $reminder_date = $this->mastermodel->convertdateformat($postdata['reminder_date']); $tblValues=array( 'reminder_date'=>$reminder_date, 'remind_before'=>$postdata['remind_before'], 'reminder_subject'=>$postdata['reminder_subject'], 'reminder_description'=>$postdata['reminder_description']); $this->db->where('reminder_id', $postdata['reminder_id']); $this->db->update('reminder', $tblValues); $data['resfunction']='search_reminder'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function profile_list() { $data=array(); $this->db->select('*'); $this->db->from('user_profile'); $this->db->join('designation','user_profile.designation_id=designation.designation_id'); $this->db->order_by('profile_id','asc'); $Q=$this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_profile_permission_by_empid($employee_id) { $data=array(); $this->db->select('*'); $this->db->from('user_profile'); $this->db->join('employee','user_profile.designation_id=employee.employee_designation_id'); $this->db->where('employee_id',$employee_id); $this->db->order_by('profile_id','asc'); $Q=$this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_user_permission_by_user_id($user_id) { $data=array(); $this->db->select('*'); $this->db->from('user'); $this->db->where('user_id',$user_id); $Q=$this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function checkprofileset($employee_id) { $this->db->from('user_profile'); $this->db->join('employee','employee.employee_designation_id=user_profile.designation_id'); $this->db->where('employee_id',$employee_id); return $this->db->count_all_results(); } }