From ddea4b3b20686bb55486c90e647a7b667500eb99 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 22 Dec 2017 13:48:36 +0530 Subject: [PATCH] course details changes done --- .../api/application/models/Employee_model.php | 100 ++++++++++-------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index ea1e9c2b..9ae08bc7 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -83,56 +83,70 @@ class Employee_model extends CI_Model // get single employee details public function get_emp_detail($empLoginID = null) { - $this->db->select('StaffID'); + $this->db->select('StaffID,ListCode'); $this->db->from(LOGIN); $this->db->where('ID', $empLoginID); $loginEmpDetail = $this->db->get()->first_row(); if ($loginEmpDetail) { $EmpId = $loginEmpDetail->StaffID; - $this->db->select('t1.*'); - $this->db->from('' . STAFF . ' as t1'); - $this->db->where('t1.StaffID', $EmpId); - // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); - $responseDetails = $this->db->get()->first_row(); - $result['empStatus'] = true; - // print_r($result['details']);exit(); - - if ($responseDetails->ListCode == SUPER_ADMIN) { - // print_r($result['details']->ListCode);exit(); - // get branch details for super admin - $responseDetails->BranchCode = 'All'; - $result['details'] = $responseDetails; - // print_r($result['details']);exit(); - $this->db->select('t3.BranchCode, t3.BranchName'); - $this->db->from('' . STAFF_BRANCH . ' as t2'); - $this->db->where('t2.StaffID', $EmpId); - $this->db->where('t2.IsActive', 1); - $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); - $this->db->where('t3.IsActive', 1); + if($loginEmpDetail->ListCode != STUDENT){ + $this->db->select('t1.*'); + $this->db->from('' . STAFF . ' as t1'); + $this->db->where('t1.StaffID', $EmpId); // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); - $branchDetails = $this->db->get(); - $getArrs = $branchDetails->result(); - $SS['BranchCode'] = 'All'; - $SS['BranchName'] = 'All'; - array_push($getArrs, $SS); - // print_r($getArrs);exit(); - $result['branchStatus'] = true; - $result['branch_details'] = $getArrs; - - } else { - // get branch details for admin & staff - $result['details'] = $responseDetails; - $this->db->select('t3.BranchCode, t3.BranchName'); - $this->db->from('' . STAFF_BRANCH . ' as t2'); - $this->db->where('t2.StaffID', $EmpId); - $this->db->where('t2.IsActive', 1); - $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); - $this->db->where('t3.IsActive', 1); - // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); - $branchDetails = $this->db->get(); - $result['branchStatus'] = true; - $result['branch_details'] = $branchDetails->result(); + $responseDetails = $this->db->get()->first_row(); + $result['empStatus'] = true; + // print_r($result['details']);exit(); + + if ($responseDetails->ListCode == SUPER_ADMIN) { + // print_r($result['details']->ListCode);exit(); + // get branch details for super admin + $responseDetails->BranchCode = 'All'; + $result['details'] = $responseDetails; + // print_r($result['details']);exit(); + $this->db->select('t3.BranchCode, t3.BranchName'); + $this->db->from('' . STAFF_BRANCH . ' as t2'); + $this->db->where('t2.StaffID', $EmpId); + $this->db->where('t2.IsActive', 1); + $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); + $this->db->where('t3.IsActive', 1); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $branchDetails = $this->db->get(); + $getArrs = $branchDetails->result(); + $SS['BranchCode'] = 'All'; + $SS['BranchName'] = 'All'; + array_push($getArrs, $SS); + // print_r($getArrs);exit(); + $result['branchStatus'] = true; + $result['branch_details'] = $getArrs; + + } else { + // get branch details for admin & staff + $result['details'] = $responseDetails; + $this->db->select('t3.BranchCode, t3.BranchName'); + $this->db->from('' . STAFF_BRANCH . ' as t2'); + $this->db->where('t2.StaffID', $EmpId); + $this->db->where('t2.IsActive', 1); + $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); + $this->db->where('t3.IsActive', 1); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $branchDetails = $this->db->get(); + $result['branchStatus'] = true; + $result['branch_details'] = $branchDetails->result(); + } } + elseif ($loginEmpDetail->ListCode == STUDENT){ + $this->db->select('ST.*'); + $this->db->from('' . STUDENTS . ' as ST'); + $this->db->where('ST.StudentID', $EmpId); + // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $responseDetails = $this->db->get()->first_row(); + $result['empStatus'] = true; + $result['details'] = $responseDetails; + $result['branch_details'] = ""; + + } + } else { $result['empStatus'] = false; $result['message'] = "Something Went Wrong, Please try Again !!";