97 lines
2.7 KiB
PHP
97 lines
2.7 KiB
PHP
<?php
|
|
class Expence_model extends MY_Model {
|
|
|
|
public function get_employee_name($business_id)
|
|
{
|
|
|
|
$this->db->select('users.name, employees.user_id, employees.manager');
|
|
$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_expence_list($business_id)
|
|
{
|
|
$this->db->select('A.* , name', 'users.name');
|
|
$this->db->from('expence_list A');
|
|
$this->db->join('users', 'users.id = A.emp_id', 'left');
|
|
//$this->db->join('delegation', 'delegation.emp_id = users.id', 'left');
|
|
$this->db->where('A.business_id', $business_id);
|
|
$this->db->order_by('id','DESC');
|
|
$this->db->where('A.is_active', 1);
|
|
$query = $this->db->get();
|
|
$query = $query->result();
|
|
return $query;
|
|
|
|
}
|
|
|
|
public function decline_dropdown($business_id)
|
|
|
|
{
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('enum');
|
|
$this->db->where('enum_type', 'decline');
|
|
$this->db->where('business_id', $business_id);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
return $query->result();
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
public function get_expence_list_by_id($id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('expence_list');
|
|
$this->db->where('md5(id)', $id);
|
|
$this->db->where('is_active', 1);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
return $query->result();
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function ExpenceDecline($id, $data)
|
|
{
|
|
$this->db->where('id',$id);
|
|
$this->db->where('status', 'pending');
|
|
$this->db->update('expence_list', $data);
|
|
return;
|
|
}
|
|
|
|
public function Expencecancle($id, $data)
|
|
{
|
|
$this->db->where('md5(id)',$id);
|
|
$this->db->where('status', 'pending');
|
|
$this->db->update('expence_list', $data);
|
|
return;
|
|
}
|
|
|
|
public function Get_delegation_id($business_id)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('delegation');
|
|
$this->db->where('business_id', $business_id);
|
|
//$this->db->where('delegated_to', $emp_id);
|
|
$this->db->where('is_active', 1);
|
|
$query = $this->db->get();
|
|
return $query->result();
|
|
}
|
|
|
|
} |