diff --git a/Apollo/api/application/models/Data_correction.php b/Apollo/api/application/models/Data_correction.php index 6911201e..c2721f82 100644 --- a/Apollo/api/application/models/Data_correction.php +++ b/Apollo/api/application/models/Data_correction.php @@ -303,7 +303,11 @@ group by Student_id,cid"; { // print_r($search);die(); - $qry="select * from T_Students_Fees_PaidDetails where StudentID='".$search['studentId']."' and FeesId=(select FeesID from T_Students_Fees_Status where StudentID='".$search['studentId']."' and CourseID='".$search['CourseId']."')"; + // $qry="select * from T_Students_Fees_PaidDetails where StudentID='".$search['studentId']."' and FeesId=(select FeesID from T_Students_Fees_Status where StudentID='".$search['studentId']."' and CourseID='".$search['CourseId']."')"; + + $qry="select * from T_Students_Fees_PaidDetails sfp +Join T_Students_Fees_Status sfs on sfs.FeesID= sfp.FeesId +where sfp.StudentID='".$search['studentId']."' and sfs.CourseID='".$search['CourseId']."';"; $fee=$this->db->query($qry); $feepaid = $fee->result(); @@ -345,21 +349,32 @@ group by Student_id,cid"; $getAct_CourseFeeId = $getAct_CourseFeeId->result(); + //print_r($this->db->last_query());die(); + + + // print_r($getAct_CourseFeeId );die(); + $newfeeId = ''; - foreach($getAct_CourseFeeId as $fi) - { + // foreach($getAct_CourseFeeId as $fi) + // { - $newfeeId = $fi->FeesID; - } + // $newfeeId = $fi[0]->FeesID; + // } + + + $newfeeId = $getAct_CourseFeeId[0]->FeesID; + + //echo $newfeeId;die(); - $this->db->select('FeesID'); + $this->db->select('sfs.FeesID,BillAmount'); $this->db->from('T_Students_Fees_Status sfs'); + $this->db->join('T_Students_Fees_PaidDetails sfp','sfs.FeesID=sfp.FeesId'); $this->db->where('sfs.StudentID',$search['studentId']); $this->db->where('sfs.CourseID',$search['DeAct_CourseId']); @@ -373,9 +388,9 @@ group by Student_id,cid"; { $oldfeeId = $fi->FeesID; - } - + //} + // print_r($this->db->last_query());die(); $time = date('Y-m-d H:i:s'); $dateTime = $time; @@ -391,6 +406,8 @@ group by Student_id,cid"; $this->db->where('FeesId',$oldfeeId); $this->db->update('T_Students_Fees_PaidDetails', $feearr); + } + return true; } diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index 3796d709..50cdfab5 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -31,13 +31,15 @@ class Login_model extends CI_Model //$this->db->where('t2.IsActive', 1); $loginDetails = $this->db->get(LOGIN)->first_row(); - + // print_r($this->db->last_query());die(); // print_r($loginDetails); if($loginDetails) { $mobileno= $loginDetails->MobileNumber; $mobileno= $loginDetails->MobileNumber; if($loginDetails->ListCode == STUDENT){ + + $start = date_create($loginDetails->UpdatedOn); $end = date_create(); $diff = date_diff($end,$start); @@ -55,6 +57,8 @@ class Login_model extends CI_Model $this->db->where('BR.Is_StudentWebAccessActive', 1); $responseDetails = $this->db->get()->first_row(); + // print_r($this->db->last_query());die(); + if($responseDetails){ $save['OTP'] = ''; @@ -122,102 +126,129 @@ class Login_model extends CI_Model $this->db->update('T_Login',$save); } - }else{ - if ($mobile == $loginDetails->MobileNumber || strtoupper($mobile) == strtoupper($loginDetails->StaffID)) { - - if ($password == $loginDetails->Password) { - if($loginDetails->ListCode == SUPER_ADMIN){ - //print_r($loginDetails);exit(); - $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess'); - $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) { - $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; - } - } - else{ - $result['loginStatus'] = false; - $result['message'] = "Your login is de-activated."; - } - } else if ($loginDetails->ListCode == ADMIN || $loginDetails->ListCode == EMPLOYEE || $loginDetails->ListCode == TRAINEE) { - //print_r($loginDetails);exit(); - $this->db->select('t1.MobileNumber, t3.ListCode, t1.ID, t3.BranchCode, t3.FinanceModuleAccess'); - $this->db->from('' . LOGIN . ' as t1'); - $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); - $this->db->join('' . STAFF_BRANCH . ' as t3', 't3.StaffID = t2.StaffID', 'LEFT'); - $this->db->where('t1.MobileNumber', $mobile); - $this->db->where('t2.IsActive', 1); - $this->db->where('t3.IsActive', 1); - $this->db->order_by('t3.CreatedOn', 'ASC'); - $this->db->group_by('t3.StaffID'); - $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 if($loginDetails->ListCode == STUDENT){ - $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess'); - $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){ - if($responseDetails->LoginAccess == 1){ - $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."; - } - } - else{ - $result['loginStatus'] = false; - $result['message'] = "Your login is de-activated or don't have login."; - } - } else { + + else + { + // print_r($loginDetails->ListCode); + + if($loginDetails->ListCode != SUPER_ADMIN) + { + if ($mobile == $loginDetails->MobileNumber || strtoupper($mobile) == strtoupper($loginDetails->StaffID)) + { + + // print_r($loginDetails);die(); + + $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID'); + $this->db->from('' . LOGIN . ' as LO'); + $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); + $this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID'); + $this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode'); + $this->db->where('LO.MobileNumber', $mobile); + $this->db->where('ST.IsActive', 1); + // $this->db->where('BR.Is_StudentWebAccessActive', 1); + $responseDetails = $this->db->get()->first_row(); + + //print_r($responseDetails);die(); + + + if($responseDetails) + { + + $save['OTP'] = ''; + $this->db->where('MobileNumber',$mobile); + $this->db->where('ListCode',STUDENT); + $this->db->update('T_Login',$save); + if($responseDetails->IsActive == 1) + { + $result['loginStatus'] = true; + $result['details'] = $responseDetails; + } + else + { $result['loginStatus'] = false; - $result['message'] = "Please Enter Valid Password !!"; + $result['message'] = "Your login is de-activated."; } - } else { + } + + else + { + $result['loginStatus'] = false; + $result['message'] = "Your login is de-activated."; + } + + + } + + else + { $result['loginStatus'] = false; $result['message'] = "Please Enter Register Mobile Number !!"; - } } - } else { + + } + + + else if($loginDetails->ListCode ==SUPER_ADMIN) + { + + // echo 'in';die(); + + + + $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess'); + $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) + { + $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; + } + } + 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."; } @@ -262,6 +293,7 @@ class Login_model extends CI_Model * created_by : sriram */ public function checkstudnetnumber($mobile){ + $this->db->select('t1.MobileNumber, t1.Password,t1.ListCode'); $this->db->from('' . LOGIN . ' as t1'); $this->db->where('t1.MobileNumber', $mobile); @@ -270,9 +302,12 @@ class Login_model extends CI_Model $this->db->where('t1.IsActive', 1); $loginDetails = $this->db->get(LOGIN)->first_row(); - //print_r($loginDetails);die; + // print_r($loginDetails);die; if($loginDetails){ - if($loginDetails->ListCode == STUDENT){ + + if($loginDetails->ListCode == STUDENT) + + { $result['loginstudent'] = true; $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess'); $this->db->from('' . LOGIN . ' as LO'); @@ -306,13 +341,71 @@ class Login_model extends CI_Model $result['loginStatus'] = false; $result['message'] = "Your login is de-activated."; } - }else{ + } + + else if(($loginDetails->ListCode == ADMIN)||($loginDetails->ListCode == EMPLOYEE)||(($loginDetails->ListCode == TRAINEE))) + { + + $result['loginstudent'] = true; + + $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.IsActive,LO.StaffID,ST.MobileNumber as Mobile'); + $this->db->from('' . LOGIN . ' as LO'); + $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID'); + $this->db->where('LO.MobileNumber', $mobile); + $this->db->where('ST.IsActive', 1); + $responseDetails = $this->db->get()->first_row(); + + //print_r($responseDetails);die(); + + + + if($responseDetails->IsActive ==1){ + $string2 = str_shuffle('1234567890'); + $otp = substr($string2,0,6); + //$otp = '431528'; + // //echo $otp;die; + $save['OTP'] = $otp; + $save['UpdatedOn'] = date('Y-m-d H:i:s'); + // print_r($save);die; + $this->db->where('MobileNumber',$mobile); + //$this->db->where('ListCode',STUDENT); + $query = $this->db->update('T_Login',$save); + + $mobileno = $responseDetails->Mobile; + + // $query =1; + if($query == 1){ + $sms = $this->smssend($mobileno,$otp); + + $result['checkstudent'] = true; + }else{ + $result['checkstudent'] = false; + } + + + }else { + $result['loginStatus'] = false; + $result['message'] = "Your login is de-activated."; + } + + + + + } + + + + + else{ $result['loginstudent'] = false; } - }else{ + } + + else + { $result['checkstudent'] = false; $result['message'] = "Your login is de-activated or don't have login."; - } + } //print_r($result);die; return $result; }