From 211a05f0e3fb2f68093eaa309098ee601d88394f Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 22 Dec 2017 13:48:21 +0530 Subject: [PATCH] course details changes done --- Apollo/api/application/models/Login_model.php | 69 ++++++++++++++----- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index d8dd377a..ad28884b 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -22,32 +22,65 @@ class Login_model extends CI_Model public function login($mobile = null, $password = null) { - $this->db->select('t1.MobileNumber, t1.Password'); + $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); + //$this->db->where('t2.IsActive', 1); $loginDetails = $this->db->get(LOGIN)->first_row(); if ($loginDetails) { if ($mobile == $loginDetails->MobileNumber) { if ($password == $loginDetails->Password) { - //print_r($loginDetails);exit(); - $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode'); - $this->db->from('' . LOGIN . ' as t1'); - $this->db->where('t1.MobileNumber', $mobile); - $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); - $responseDetails = $this->db->get()->first_row(); - 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; - } else { - $result['loginStatus'] = true; - $result['details'] = $responseDetails; + if($loginDetails->ListCode !=STUDENT){ + //print_r($loginDetails);exit(); + $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode'); + $this->db->from('' . LOGIN . ' as t1'); + $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + $this->db->where('t1.MobileNumber', $mobile); + $this->db->where('t2.IsActive', 1); + $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; + } else { + $result['loginStatus'] = true; + $result['details'] = $responseDetails; + } + } + else{ + $result['loginStatus'] = false; + $result['message'] = "Your login is de-activated."; + } + } + else if($loginDetails->ListCode == STUDENT){ + $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode'); + $this->db->from('' . LOGIN . ' as LO'); + $this->db->join('' . STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID'); + $this->db->where('LO.MobileNumber', $mobile); + $this->db->where('ST.IsActive', 1); + $responseDetails = $this->db->get()->first_row(); + if($responseDetails){ + $result['loginStatus'] = true; + $result['details'] = $responseDetails; + } + else{ + $result['loginStatus'] = false; + $result['message'] = "Your login is de-activated."; + } + + } + else{ + $result['loginStatus'] = false; + $result['message'] = "Your login is de-activated or don't have login."; + } + + } else { $result['loginStatus'] = false; @@ -59,7 +92,7 @@ class Login_model extends CI_Model } } else { $result['loginStatus'] = false; - $result['message'] = "Something Went Wrong, Please try Again !!"; + $result['message'] = "Your login is de-activated or don't have login."; } /*$this->db->join('areas a', 'a.id = e.id_area', 'inner');