?
Current Path : /home1/savoy/public_html/oscarerp.com/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/oscarerp.com/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(); } /*functions for profile */ 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(); } 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 getmoduledatamaster() { $data=array(); $res=$this->db->query("select module.module_name,module.module_title,menu.caption,menu.target,menu.menu_id,menu.module_id,menu.sort from module join menu on module.module_id=menu.module_id where module.active = '1' and menu.active='1' order by module.sort, menu.sort"); foreach ($res->result_array() as $row) { $data[] = $row; } return $data; } /*functions for profile */ function search_profile() { $data=array(); $this->db->select('*'); $this->db->from('user_profile'); $this->db->join('master','master_id=profile_id'); $this->db->order_by('profile_id','desc'); $data['results']=$this->db->get(); return $data; } function search_prefix_code() { $data=array(); $this->db->select('*'); $this->db->from('prefix'); // $this->db->join('master','master_id=profile_id'); $this->db->order_by('id','desc'); $data['results']=$this->db->get(); return $data; } function insert_profile($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array( 'profile_id'=>$masterid, 'designation_id'=>$postdata['designation_id'], 'profile_modules'=>$postdata['role_permission'], 'profile_modules_home_page'=>$postdata['role_home_page'], '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 update_profile($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['profile_id']); $tblValues=array( 'profile_modules'=>$postdata['role_permission'], 'profile_modules_home_page'=>$postdata['role_home_page'], 'profile_modules_permission'=>$postdata['role_edit_del_permission'] ); $this->db->where('profile_id',$postdata['profile_id']); $this->db->update('user_profile', $tblValues); $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; } } /* functions for reminder*/ function update_prefix_code($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'prefix_code'=>$postdata['prefix_code'], 'starting_no'=>$postdata['starting_no'], ); $this->db->where('id',$postdata['id']); $this->db->update('prefix', $tblValues); $data['resfunction']='search_prefix_code'; 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; } } /* functions for reminder*/ function search_reminder() { $data=array(); $this->db->select('*'); $this->db->from('reminder'); $this->db->join('master','master_id=reminder_id'); $this->db->order_by('reminder_id','desc'); $data['results']=$this->db->get(); return $data; } function insert_reminder($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array( 'reminder_id'=>$masterid, 'reminder_subject'=>$postdata['reminder_subject'], 'remind_before'=>$postdata['remind_before'], 'reminder_date'=>$this->mastermodel->convertdateformat($postdata['reminder_date']), '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; } } function update_reminder($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['reminder_id']); $tblValues=array( 'reminder_subject'=>$postdata['reminder_subject'], 'remind_before'=>$postdata['remind_before'], 'reminder_date'=>$this->mastermodel->convertdateformat($postdata['reminder_date']), '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; } } /* functions for user */ function search_user() { $data=array(); $this->db->select('*'); $this->db->from('user'); //$this->db->join('master','master_id=user_id'); $this->db->order_by('user_id','desc'); $data['results']=$this->db->get(); return $data; } function update_password($postdata) { $data=array(); $data['resfunction']='search_user'; 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']='1'; $data['msg']='Password Changed Sucessfully'; return $data; } else { $data['res']='0'; $data['msg']='Passwords do not match'; return $data; } } function update_paswrd($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 insert_user($postdata) { $data=array(); $this->db->trans_begin(); $employee= explode('-', $postdata['employee_id']); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array( 'user_id'=>$masterid, 'user_name'=>$postdata['user_name'], 'password'=>md5($postdata['password']), 'employee_id'=>$employee[0], 'user_modules'=>$postdata['user_modules'], 'modules_permission'=>$postdata['modules_permission'], 'home_page'=>$postdata['user_home_page'], ); $this->db->insert('user', $tblValues); foreach($postdata['report_select'] as $report) { $tblValues=array( 'user_id'=>$masterid, 'report_id'=>$report, ); $this->db->insert('user_report', $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 update_user($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'user_modules'=>$postdata['user_modules'], 'modules_permission'=>$postdata['modules_permission'], 'home_page'=>$postdata['user_home_page'], ); $this->db->where('user_id',$postdata['user_id']); $this->db->update('user', $tblValues); $this->db->where('user_id',$postdata['user_id']); $this->db->delete('user_report'); foreach($postdata['report_select'] as $report) { $tblValues=array( 'user_id'=>$postdata['user_id'], 'report_id'=>$report, ); $this->db->insert('user_report', $tblValues); } $data['resfunction']='search_user'; 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; } } /* functions for alert master*/ function search_alert_master() { $data=array(); $this->db->select('*'); $this->db->from('alert_master'); $this->db->order_by('alert_master_id','asc'); $data['results']=$this->db->get(); return $data; } function update_alert_master($postdata) { $data=array(); $this->db->trans_begin(); $limit=$postdata['limit']; $tblValues=array( 'alert_master_days'=>$postdata['alert_master_days'], ); $this->db->where('alert_master_id',$postdata['alert_master_id']); $this->db->update('alert_master', $tblValues); $this->db->where('alert_master_id',$postdata['alert_master_id']); $this->db->delete('alert_master_employee'); for($i=1;$i<$limit;$i++) { if(isset($postdata['select_employee_'.$i])) { $tblValues=array( 'alert_master_id'=>$postdata['alert_master_id'], 'alert_master_employee_id'=>$postdata['employee_id_'.$i] ); $this->db->insert('alert_master_employee',$tblValues); } } $data['resfunction']='search_alert_master'; 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; } } /* functions for alert */ function search_alert() { $data=array(); $this->db->select('*'); $this->db->from('alert_master'); $this->db->order_by('alert_master_id','asc'); $data['results']=$this->db->get(); return $data; } function remove_alert($table,$id,$field) { $data=array(); $this->db->trans_begin(); $tblvalues=array( 'alert_status'=>'0' ); $this->db->where($field,$id); $this->db->update('alert',$tblvalues); $this->db->trans_status(); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Unable to Remove record because of associated data'; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Data Removed Successfully'; } return $data; } function get_num_alert($id) { $employee_id= $this->mastermodel->get_single_field_value('user','employee_id','user_id',$_SESSION['user_id']); $this->db->join('alert_employee','alert_employee.alert_id=alert.alert_id'); $this->db->where('alert_employee.employee_id',$employee_id); $this->db->where('alert_status','1'); $this->db->where('alert_master_id',$id); $Q=$this->db->get('alert'); return $Q->num_rows(); } function get_fee_alerts_to_employee($alert_master_id,$count='',$info='') { $data = array(); $data['count']=0; $data['details']=array(); if (date('d') >= 5) { $this->db->select('*'); $this->db->from('fee_alert_employee'); $this->db->join('user', 'user.employee_id=fee_alert_employee.employee_id', 'left'); $this->db->join('employee', 'employee.employee_id=user.employee_id', 'left'); $this->db->where('user_id', $_SESSION['user_id']); $this->db->where('alert_master_id', $alert_master_id); $Q = $this->db->get(); if ($Q->num_rows() > 0) { $output=$data['details']=$this->get_student_fee_payment_alert(); $data['count']=$output['count']; $data['details']=$output['data']; // if($count==1) // $data['count'] = $this->get_student_fee_payment_alert_count(); // if($info==1) // $data['details']=$this->get_student_fee_payment_alert(); } $Q->free_result(); } return $data; } function alert_close($master_id,$alert_type,$alert_date) { if($alert_date=="") $alert_date=date('Y-m-d'); $tblValues=array( 'master_id'=>$master_id, 'alert_type'=>$alert_type, 'alert_date'=>$alert_date ); $this->db->insert('alert_close', $tblValues); } }