80 lines
2.2 KiB
PHP
80 lines
2.2 KiB
PHP
<?php
|
|
class Employee_model extends MY_Model {
|
|
|
|
public function get_employee($business_id)
|
|
{
|
|
|
|
$this->db->select('users.*, employees.*');
|
|
$this->db->from('users');
|
|
$this->db->join('employees', 'employees.user_id = users.id');
|
|
$this->db->where('users.business_id', $business_id);
|
|
$this->db->where('users.is_active', 1);
|
|
$this->db->where('employees.is_active', 1);
|
|
$query = $this->db->get();
|
|
|
|
if ($query->num_rows() > 0) {
|
|
return $query->result();
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
|
|
public function get_emp_by_md5_id($id,$business_id)
|
|
{
|
|
|
|
$this->db->select('users.*, employees.*');
|
|
$this->db->from('users');
|
|
$this->db->join('employees', 'users.id = employees.user_id');
|
|
$this->db->where('users.is_active', 1);
|
|
$this->db->where('employees.is_active', 1);
|
|
$this->db->where('users.business_id', $business_id);
|
|
$this->db->where('md5(employees.user_id)', $id);
|
|
|
|
|
|
$query = $this->db->get();
|
|
|
|
if ($query->num_rows() > 0) {
|
|
return $query->row();
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function delete_emp_by_md5_id($id,$business_id)
|
|
{
|
|
$this->db->where('id', $id);
|
|
$this->db->where('business_id', $business_id);
|
|
$this->db->set('is_active',0);
|
|
$this->db->update('users');
|
|
$this->db->where('user_id', $id);
|
|
$this->db->where('business_id', $business_id);
|
|
$this->db->set('is_active',0);
|
|
$this->db->update('employees');
|
|
return;
|
|
}
|
|
|
|
public function get_data($business_id , $id , $table)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from($table);
|
|
$this->db->where('md5(emp_id)', $id);
|
|
$this->db->where('business_id', $business_id);
|
|
$this->db->where('is_active', 1);
|
|
$query = $this->db->get();
|
|
$query = $query->result();
|
|
return $query;
|
|
}
|
|
|
|
public function get_manager_name($manager_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('users');
|
|
$this->db->where('id', $manager_id);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
} |