135 lines
5.0 KiB
PHP
135 lines
5.0 KiB
PHP
<?php
|
|
class Notification_model extends MY_Model {
|
|
|
|
public function get_leave_data_using_leave_id($leave_id)
|
|
{
|
|
$this->db->select('A.* ,U1.name as emp_name, U1.email as emp_email, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby, E.manager as ManagerId, LM.code as leave_code, LM.type as leave_type, U5.email as managerEmail, U6.email as delegatePersonEmail,');
|
|
$this->db->from('leave_list A');
|
|
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
|
|
$this->db->join('users U2', 'U2.id = A.approved_by', 'left');
|
|
$this->db->join('users U3', 'U3.id = A.declined_by', 'left');
|
|
$this->db->join('users U4', 'U4.id = A.risedby', 'left');
|
|
$this->db->join('employees E', 'E.user_id = A.emp_id', 'left');
|
|
$this->db->join('users U5', 'U5.id = E.manager', 'left');
|
|
$this->db->join('leave_master LM', 'LM.id = A.type', 'left');
|
|
$this->db->join('delegation D', 'D.emp_id = U5.id', 'left');
|
|
$this->db->join('users U6', 'U6.id = D. delegated_to', 'left');
|
|
$this->db->where('A.id', $leave_id);
|
|
$this->db->order_by('A.id','DESC');
|
|
$this->db->where('A.is_active', 1);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
$row = $query->row();
|
|
// return $this->db->last_query();
|
|
return $row;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public function get_delegation_data_using_delegation_id($delegation_id)
|
|
{
|
|
$this->db->select('D.* ,U1.name as emp_name, U1.email as emp_email, U2.name as delegatePersonName, U2.email as delegatePersonEmail,');
|
|
$this->db->from('delegation D');
|
|
$this->db->join('users U1', 'U1.id = D.emp_id', 'left');
|
|
$this->db->join('employees E', 'E.user_id = D.emp_id', 'left');
|
|
$this->db->join('users U2', 'U2.id = D.delegated_to', 'left');
|
|
$this->db->join('users U3', 'U3.id = E.manager', 'left');
|
|
$this->db->where('D.id', $delegation_id);
|
|
$this->db->order_by('D.id','DESC');
|
|
$this->db->where('D.is_active', 1);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
$row = $query->row();
|
|
// return $this->db->last_query();
|
|
return $row;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function get_expence_data_using_expence_id($expence_id)
|
|
{
|
|
$this->db->select('A.*, u1.email as emp_email, u1.name as requested_name, u2.name as emp_name, u3.name as managerName, u3.email as managerEmail, u4.email as delegatePersonEmail');
|
|
$this->db->from('expense A');
|
|
$this->db->join('users u1', 'u1.id = A.requested_for', 'left');
|
|
$this->db->join('users u2', 'u2.id = A.created_by', 'left');
|
|
$this->db->join('employees E', 'E.user_id = u2.id', 'left');
|
|
$this->db->join('users u3', 'u3.id = E.manager', 'left');
|
|
$this->db->join('delegation D', 'D.emp_id = u3.id', 'left');
|
|
$this->db->join('users u4', 'u4.id = D. delegated_to', 'left');
|
|
$this->db->where('A.id', $expence_id);
|
|
$this->db->where('A.status !=', 'Draft');
|
|
$this->db->order_by('A.id', 'DESC');
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
$row = $query->row();
|
|
// return $this->db->last_query();
|
|
return $row;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
public function get_expence_child_data_using_expence_id($expence_id)
|
|
{
|
|
$this->db->select('EC.date_of_expense as childExpenceDate, EC.amount as childAmount, EC.description as childDescription, EC.status as childStatus');
|
|
$this->db->from('expense_child EC');
|
|
$this->db->where('expense_id', $expence_id);
|
|
$this->db->order_by('id', 'DESC');
|
|
$query = $this->db->get();
|
|
$result_array = $query->result_array();
|
|
// $values_only = array_map('array_values', $result_array);
|
|
return $result_array;
|
|
|
|
}
|
|
|
|
public function get_template_data_using_code($code, $type){
|
|
$this->db->select('*');
|
|
$this->db->from('templates');
|
|
$this->db->where('templet_code', $code);
|
|
$this->db->where('templet_type', $type);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
return $query->row();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function get_user_data($user_id){
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('users');
|
|
$this->db->where('id', $user_id);
|
|
$query = $this->db->get();
|
|
// $query = $query->result();
|
|
if ($query->num_rows() > 0) {
|
|
return $query->row();
|
|
} else {
|
|
return false;
|
|
}
|
|
// return $query;
|
|
|
|
}
|
|
|
|
public function get_admin_and_hr_mail_id($id){
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('business');
|
|
$this->db->where('uid', $id);
|
|
$query = $this->db->get();
|
|
if ($query->num_rows() > 0) {
|
|
return $query->row();
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} |