File: /var/www/html/taxicamera/old/application/models/admin/Muser.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Muser extends CI_Model {
/*
author: soumya hazra
purpose: get active user roles
date: 9-9-2019
*/
public function actv_roles()
{
$result = array();
$this->db->select('*');
$this->db->from('master_role');
$this->db->where('is_active',1);
$this->db->where('role_id !=',1);
$this->db->where('role_id !=',2);
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Add a new user
date: 9-9-2019
*/
public function submit_new_user($data)
{
$this->db->set('role_id', $data['role_id']);
$this->db->set('email', $data['email']);
$this->db->set('password', $data['password']);
$this->db->set('org_password', $data['org_password']);
/***************** SREELA (22/10/19) **************/
$this->db->set('status', '1');
$this->db->set('is_active', 1);
$this->db->set('is_admin', 1);
$this->db->set('created_by', $this->session->userdata('user_data'));
//$this->db->set('created_by', $data['user_data']);
$this->db->set('created_ts', date('Y-m-d H:i:s'));
if($this->db->insert('master_user'))
{
$insert_id = $this->db->insert_id();
unset($data['role_id']);
unset($data['email']);
unset($data['password']);
unset($data['org_password']);
$data['user_id'] = $insert_id;
$this->db->insert('user_profile',$data);
}
return true;
}
/*
author: soumya hazra
purpose: Update a user
date: 9-9-2019
*/
public function update_user($data,$uid)
{
$this->db->set('role_id', $data['role_id']);
$this->db->set('email', $data['email']);
$this->db->set('password', $data['password']);
$this->db->set('org_password', $data['org_password']);
//$this->db->set('updated_by', $data['user_data']);
$this->db->set('updated_by', $this->session->userdata('user_data'));
$this->db->where('user_id', $uid);
if($this->db->update('master_user'))
{
unset($data['role_id']);
unset($data['email']);
unset($data['password']);
unset($data['org_password']);
$this->db->where('user_id',$uid);
$this->db->update('user_profile',$data);
}
return true;
}
/*
author: soumya hazra
purpose: Get active user
date: 9-9-2019
*/
public function get_user()
{
$result = array();
// $this->db->select('master_user.*,user_profile.role_name,user_profile.flat_no,user_profile.street_no,,user_profile.street_name,user_profile.suburb,user_profile.state,user_profile.pin,user_profile.dob,user_profile.abn,user_profile.state,user_profile.first_name,user_profile.last_name,user_profile.middle_name');
$this->db->select('master_user.*,user_profile.*,master_role.role_id,master_role.role_name');
$this->db->from('master_user');
$this->db->join('user_profile','user_profile.user_id = master_user.user_id');
$this->db->join('master_role','master_role.role_id = master_user.role_id');
$this->db->where('master_user.is_admin',1);
$this->db->where('master_user.is_active',1);
$this->db->order_by('master_user.user_id','DESC');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
/*
author: soma
purpose: Get inactive user
date: 19-9-2019
*/
public function get_user_inactive()
{
$result = array();
// $this->db->select('*');
$this->db->select('master_user.*,user_profile.*,master_role.role_id,master_role.role_name');
$this->db->from('master_user');
$this->db->join('user_profile','user_profile.user_id = master_user.user_id');
$this->db->join('master_role','master_role.role_id = master_user.role_id');
$this->db->where('master_user.is_admin',1);
$this->db->where('master_user.is_active',0);
$query = $this->db->get();
// echo $this->db->last_query();die;
$result = $query->result_array();
return $result;
}
/*
author: soumya hazra
purpose: Get a single user
date: 9-9-2019
*/
public function singl_user($uid)
{
$result = array();
$this->db->select('*');
$this->db->from('master_user');
$this->db->join('user_profile','user_profile.user_id = master_user.user_id');
$this->db->join('master_role','master_role.role_id = master_user.role_id');
$this->db->where('master_user.user_id',$uid);
$query = $this->db->get();
$result = $query->row_array();
return $result;
}
/*
author: soma
purpose: Set a user deactive
date: 18-9-2019
*/
public function set_deactive_user($user_id)
{
$this->db->set('is_active',0);
$this->db->where('user_id',$user_id);
$this->db->update('master_user');
// echo $this->db->last_query();die;
return true;
}
/*
author: soma
purpose: Set a user active
date: 18-9-2019
*/
public function set_active_user($user_id)
{
$this->db->set('is_active',1);
$this->db->where('user_id',$user_id);
$this->db->update('master_user');
return true;
}
/*
author: soma
purpose: delete user
date: 18-9-2019
*/
public function delete_user($user_id)
{
$this->db->set('is_delete',1);
$this->db->set('is_active',0);
$this->db->where('user_id',$user_id);
$this->db->update('master_user');
return true;
}
/*
author: soma
purpose: restore user
date: 18-9-2019
*/
public function restore_user($user_id)
{
$this->db->set('is_delete',0);
$this->db->set('is_active',1);
$this->db->where('user_id',$user_id);
$this->db->update('master_user');
return true;
}
}