db->table('t_employee_details Emp') ->select(' Emp.*,Dep.DepartmentName as DepartmentName') ->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode', 'left') ->orderBy("Emp.EmpID", "asc"); $query = $builder->get(); $result = $query->getResult(); return $result; } function getUserRoles() { $builder = $this->db->table('tbl_roles')->select('roleId, role') ->where('roleId !=', 1); $query = $builder->get(); return $query->getResult(); } /** * This function is used to get the Config value from configuration table * @return array $result : This is result of the query */ function getConfigValue($ConfigID) { $builder = $this->db->table('t_configdetails')->select('ConfigValue') ->where('Config_id ', $ConfigID); $query = $builder->get(); return $query->getResult(); } /* */ /** * This function is used to get the Department details from t_departmentdetails * @return array $result : This is result of the query */ function getDepartment() { $builder = $this->db->table('t_departmentdetails') ->select('DEPCode, DepartmentName') ->where('IsActive =', 1); $query = $builder->get(); return $query->getResult(); } /** * This function used to get user information by id * @param number $userId : This is user id * @return array $result : This is user information */ function addNewemployee($Employee) { $builder = $this->db->table('t_employee_details'); $builder->insert($Employee); if ($this->db->affectedRows() > 0) { $builder->select('*'); $builder->orderBy('created_date', 'DESC'); $builder->limit(1); $query = $builder->get(); $result = $query->getRowArray(); return $result; } else { return 0; } } function UpdateEmployee($Emp, $EmpID) { $this->db->table('t_employee_details') ->where('EmpID', $EmpID) ->update($Emp); $res = $this->db->affectedRows(); return $res; } function viewemployee($EmpID) { $builder = $this->db->table('t_employee_details AS Emp')->select('Emp.*,Dep.DepartmentName as DepartmentName') ->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode', 'left') ->where('Emp.EmpID', $EmpID); $query = $builder->get(); $result = $query->getResult(); return $result; } /* This function to get the Employee department on respective Employee */ function GetEmployeeDepartment($EmployeeID) { $builder = $this->db->table('T_EmployeeDetails') ->select('DepartmentName') ->where($EmployeeID); $query = $builder->get(); return $query->getResultArray(); } function checkMailExists($emailId = '', $Empid = '') { $builder = $this->db->table('t_employee_details')->select('EmailId') ->where('EmailId', $emailId); if ($Empid != '') { $builder->where('EmpID !=', $Empid); } $query = $builder->get(); return $query; } function checkAadharExists($aadharNo, $Empid = '') { $builder = $this->db->table('t_employee_details')->select('AadharNo') ->where('AadharNo', $aadharNo); if ($Empid != '') { $builder->where('EmpID !=', $Empid); } $query = $builder->get(); return $query; } function checkPANExists($panNo, $Empid = '') { $builder = $this->db->table('t_employee_details')->select('PANNo') ->where('PANNo', $panNo); if ($Empid != '') { $builder->where('EmpID !=', $Empid); } $query = $builder->get(); return $query; } function checkPhotoExists($Pic) { $builder = $this->db->table('t_employee_details')->select('ProfilePic')->where($Pic); $query = $builder->get(); if ($query->getNumRows() > 0) { return $query->getResultArray(); } } function getEmployeeCount() { $builder = $this->db->table('t_employee_details') ->select('count(*) as EmpCount')->where('IsActive ', 1); $query = $builder->get(); return $query->getResult(); } function getBankDetails() { $builder = $this->db->table('t_bank_details')->select('*'); $query = $builder->get(); $result = $query->getResult(); return $result; } function export_excel() { $builder = $this->db->table('t_employee_details as det') ->select(' det.*,Dep.DepartmentName as DepartmentName,det.firstname,emp1.firstname as UpdatedByName,emp1.firstname as CreatedByName') ->join('t_departmentdetails Dep', 'det.Departmentcode = Dep.DEPCode', 'left') ->join('tbl_users as tbl', ' det.createdby = tbl.userid', 'left') ->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left') ->join('tbl_users as tbl1', ' det.UpdatedBy = tbl1.userid', 'left') ->join('t_employee_details as emp1', 'emp1.empid=tbl1.empid', 'left'); return $builder->get()->getResultArray(); } }