101 lines
2.9 KiB
PHP
101 lines
2.9 KiB
PHP
<?php
|
|
class User_model extends MY_Model {
|
|
|
|
public function get_user($id , $business_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('users');
|
|
$this->db->where('business_id', $business_id);
|
|
$this->db->order_by('id','DESC');
|
|
$this->db->where('md5(id) !=', $id);
|
|
// $this->db->where('role', 'user');
|
|
// $this->db->where('is_active', 1);
|
|
$query = $this->db->get();
|
|
$query = $query->result();
|
|
return $query;
|
|
}
|
|
|
|
public function get_admin()
|
|
{
|
|
$this->db->select('a.* , business.business_name as business');
|
|
$this->db->from('users a');
|
|
$this->db->join('business', 'business.uid = a.business_id', 'left');
|
|
$this->db->where('role !=', 'sadmin');
|
|
// $this->db->order_by('id','ASC');
|
|
$query = $this->db->get();
|
|
$query = $query->result();
|
|
return $query;
|
|
}
|
|
|
|
public function get_user_by_md5_id($id,$business_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('users');
|
|
if ($business_id != 0) {
|
|
$this->db->where('business_id', $business_id);
|
|
}
|
|
$this->db->where('md5(id)', $id);
|
|
$query = $this->db->get();
|
|
$query = $query->row();
|
|
return $query;
|
|
}
|
|
|
|
public function delete_user_by_md5_id($id,$business_id)
|
|
{
|
|
// echo $id;
|
|
// echo $business_id; die;
|
|
$this->db->where('md5(id)', $id);
|
|
if ($business_id != 0) {
|
|
$this->db->where('business_id', $business_id);
|
|
}
|
|
$this->db->set('is_active',0);
|
|
$this->db->update('users');
|
|
$this->db->where('md5(user_id)', $id);
|
|
if ($business_id != 0) {
|
|
$this->db->where('business_id', $business_id);
|
|
}
|
|
$this->db->set('is_active',0);
|
|
$this->db->update('employees');
|
|
return;
|
|
}
|
|
|
|
public function activate_inactive_users($id,$business_id)
|
|
{
|
|
$this->db->where('md5(id)', $id);
|
|
if ($business_id != 0) {
|
|
$this->db->where('business_id', $business_id);
|
|
}
|
|
$this->db->set('is_active',1);
|
|
$this->db->update('users');
|
|
$this->db->where('md5(user_id)', $id);
|
|
if ($business_id != 0) {
|
|
$this->db->where('business_id', $business_id);
|
|
}
|
|
$this->db->set('is_active',1);
|
|
$this->db->update('employees');
|
|
return;
|
|
}
|
|
|
|
public function business()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('business');
|
|
$query = $this->db->get();
|
|
$query = $query->result();
|
|
return $query;
|
|
}
|
|
|
|
public function get_business_by_md5_id($business_id)
|
|
{
|
|
$this->db->select('B.* , state.name as state_name ');
|
|
$this->db->from('business B');
|
|
$this->db->join('state', 'state.id = B.state', 'left');
|
|
$this->db->where('B.is_active', 1);
|
|
$this->db->where('md5(uid)', $business_id);
|
|
$query = $this->db->get();
|
|
$query = $query->row();
|
|
return $query;
|
|
}
|
|
|
|
|
|
} |