115 lines
3.3 KiB
PHP
115 lines
3.3 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);
|
|
$this->db->order_by('users.id', 'desc');
|
|
$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();
|
|
}
|
|
|
|
public function get_user_data_by_insert_id($insert_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('users');
|
|
$this->db->join('employees', 'users.id = employees.user_id');
|
|
$this->db->where('users.id', $insert_id);
|
|
$query = $this->db->get();
|
|
$result = $query->result();
|
|
|
|
}
|
|
|
|
public function get_leave_type($business_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('leave_master');
|
|
$this->db->where('business_id', $business_id);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
public function get_modules($business_id)
|
|
{
|
|
|
|
|
|
$this->db->select('permit_modules.*,modules.modules');
|
|
$this->db->from('permit_modules');
|
|
$this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left');
|
|
$this->db->where('uid', $business_id);
|
|
$this->db->where('permit_modules.is_active', 1);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
} |