From 2ca3632258b75f4d5c9114207c90435ed321490e Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Thu, 19 Apr 2018 16:11:05 +0530 Subject: [PATCH] super admin branch access details : kdk --- .../api/application/models/Employee_model.php | 21 +++++++++--------- Apollo/api/application/models/Login_model.php | 22 ++++++++++++++----- Apollo/assets/views/partials/top-navbar.html | 1 - 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index 73b4bb1e..d60cf7f8 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -104,18 +104,19 @@ class Employee_model extends CI_Model $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'); + $this->db->select('t1.BranchCode, t1.BranchName, t2.ListCode, t3.ListName'); + // $this->db->from('' . STAFF_BRANCH . ' as t2'); + // $this->db->where('t2.StaffID', $EmpId); + // $this->db->where('t2.IsActive', 1); + $this->db->from('' . BRANCH . ' as t1'); + // $this->db->where('t3.IsActive', 1); + $this->db->join(''.LOGIN.' as t2', 't2.ID = t1.CreatedBy', 'LEFT'); + $this->db->join('' . PICK_LIST_DETAILS . ' as t3', 't3.ListCode = t2.ListCode', 'LEFT'); $branchDetails = $this->db->get(); $getArrs = $branchDetails->result(); - $SS['BranchCode'] = 'All'; - $SS['BranchName'] = 'All'; - array_push($getArrs, $SS); + $SS['ListCode'] = $responseDetails->ListCode; + $SS['ListName'] = ''; + // array_push($getArrs, $SS); // print_r($getArrs);exit(); $result['branchStatus'] = true; $result['branch_details'] = $getArrs; diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index fa2c1e74..f2168169 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -25,7 +25,7 @@ class Login_model extends CI_Model $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode'); $this->db->from('' . LOGIN . ' as t1'); $this->db->where('t1.MobileNumber', $mobile); - // $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + // $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $this->db->where('t1.IsActive', 1); //$this->db->where('t2.IsActive', 1); $loginDetails = $this->db->get(LOGIN)->first_row(); @@ -44,10 +44,22 @@ class Login_model extends CI_Model $responseDetails = $this->db->get()->first_row(); if($responseDetails){ if ($responseDetails->ListCode == SUPER_ADMIN) { - // For First time Super admin login, will set all branch detail - $result['loginStatus'] = true; - $responseDetails->BranchCode = 'All'; - $result['details'] = $responseDetails; + $this->db->select('t1.BranchCode'); + $this->db->from('' . BRANCH . ' as t1'); + $this->db->order_by('t1.CreatedOn', 'ASC'); + $this->db->limit(1); + $getBranch = $this->db->get()->first_row(); + if($getBranch){ + // For First time Super admin login, will set all branch detail + $result['loginStatus'] = true; + $responseDetails->BranchCode = $getBranch->BranchCode; + $result['details'] = $responseDetails; + }else { + // For First time Super admin login, will set all branch detail + $result['loginStatus'] = true; + $responseDetails->BranchCode = 'All'; + $result['details'] = $responseDetails; + } } else { $result['loginStatus'] = true; $result['details'] = $responseDetails; diff --git a/Apollo/assets/views/partials/top-navbar.html b/Apollo/assets/views/partials/top-navbar.html index 71d99eea..2c73c5c3 100755 --- a/Apollo/assets/views/partials/top-navbar.html +++ b/Apollo/assets/views/partials/top-navbar.html @@ -4,7 +4,6 @@ - {{app.name}}