848 lines
29 KiB
PHP
Executable File
848 lines
29 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: karthi
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Login_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* get user login details
|
|
* params:email,password
|
|
* created by karthi
|
|
* */
|
|
|
|
/*
|
|
* Default login abc123 -> e99a18c428cb38d5f260853678922e03
|
|
*/
|
|
|
|
public function login($mobile = null, $password = null, $accessFrom = null)
|
|
{
|
|
$this->db->select('t1.MobileNumber, t1.Password,t1.ListCode,t1.UpdatedOn,t1.OTP,t1.StaffID');
|
|
$this->db->from('' . LOGIN . ' as t1');
|
|
$this->db->where('t1.MobileNumber', $mobile);
|
|
$this->db->or_where('t1.StaffID', $mobile);
|
|
// $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();
|
|
|
|
// print_r($this->db->last_query());die();
|
|
//print_r($loginDetails);die();
|
|
|
|
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);
|
|
if($diff->i <= 10){
|
|
if($password == $loginDetails->OTP){
|
|
|
|
if($accessFrom == 'Web'){
|
|
$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->join('' . STUDENTCOURSE . ' as SC', 'SC.StudentID = ST.StudentID');
|
|
$this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchID');
|
|
$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($this->db->last_query());die();
|
|
|
|
if($responseDetails){
|
|
|
|
$save['OTP'] = '';
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$this->db->where('ListCode',STUDENT);
|
|
|
|
$this->db->update('T_Login',$save);
|
|
|
|
|
|
if($responseDetails->LoginAccess == 1){
|
|
$result['loginStatus'] = true;
|
|
$result['details'] = $responseDetails;
|
|
} else {
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
}
|
|
else{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
} else {
|
|
$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->join('' . STUDENTCOURSE . ' as SC', 'SC.StudentID = ST.StudentID');
|
|
$this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchID');
|
|
$this->db->where('LO.MobileNumber', $mobile);
|
|
$this->db->where('ST.IsActive', 1);
|
|
$this->db->where('BR.Is_StudentMobileAccessActive', 1);
|
|
$responseDetails = $this->db->get()->first_row();
|
|
|
|
if($responseDetails){
|
|
|
|
$save['OTP'] = '';
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$this->db->where('ListCode',STUDENT);
|
|
|
|
$this->db->update('T_Login',$save);
|
|
|
|
|
|
if($responseDetails->LoginAccess == 1){
|
|
$result['loginStatus'] = true;
|
|
$result['details'] = $responseDetails;
|
|
} else {
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
}
|
|
else{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
}
|
|
|
|
}else{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter Valid OTP !!";
|
|
}
|
|
}else{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "OTP is Expired !!";
|
|
$save['OTP'] = '';
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$this->db->update('T_Login',$save);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
// print_r($loginDetails->ListCode);
|
|
|
|
|
|
|
|
if($loginDetails->ListCode != SUPER_ADMIN)
|
|
{
|
|
//echo 'NO_SUPER_ADMIN';die();
|
|
if ($mobile == $loginDetails->MobileNumber || strtoupper($mobile) == strtoupper($loginDetails->StaffID))
|
|
{
|
|
// echo $mobile;
|
|
// echo $password;
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('T_Login');
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$this->db->where('Password',$password);
|
|
$this->db->where('IsActive','1');
|
|
$details = $this->db->get()->first_row();
|
|
// print_r($this->db->last_query());die();
|
|
//print_r($details);die();
|
|
|
|
$time = date('Y-m-d');
|
|
$dateTime = $time;
|
|
if(!empty($details))
|
|
{
|
|
|
|
$password_date = new DateTime($details->Password_Date);
|
|
$today_date = new DateTime($dateTime);
|
|
$diff=date_diff($password_date,$today_date);
|
|
|
|
// echo $diff->format("%R%a days");
|
|
|
|
// $datediff = $diff->format("%d days");
|
|
|
|
//echo $datediff;
|
|
|
|
|
|
$start = strtotime($details->Password_Date);
|
|
$end = strtotime($dateTime);
|
|
|
|
$days_between = ceil(abs($end - $start) / 86400);
|
|
|
|
|
|
|
|
// if(!empty($details))
|
|
// {
|
|
|
|
if($days_between>'+30')
|
|
{
|
|
|
|
$result['loginStatus'] =false;
|
|
$result['passwordStatus'] =false;
|
|
$result['message'] = "Please Change the Password !!";
|
|
}
|
|
|
|
else
|
|
{
|
|
// echo 'invalid';
|
|
|
|
if($details)
|
|
{
|
|
|
|
$this->db->select('MobileNumber');
|
|
$this->db->from('T_StaffDetails');
|
|
$this->db->where('StaffID',$loginDetails->StaffID);
|
|
$searchDetails = $this->db->get();
|
|
// print_r($searchDetails->result());die();
|
|
|
|
$contact ='';
|
|
|
|
foreach($searchDetails->result() as $mo)
|
|
{
|
|
$contact = $mo->MobileNumber;
|
|
}
|
|
|
|
|
|
$string2 = str_shuffle('1234567890');
|
|
$otp = substr($string2,0,6);
|
|
//$otp = '431528';
|
|
|
|
$save['OTP'] = $otp;
|
|
$save['UpdatedOn'] = date('Y-m-d H:i:s');
|
|
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$query = $this->db->update('T_Login',$save);
|
|
|
|
$mobileno = $contact;
|
|
|
|
|
|
if($query == 1)
|
|
{
|
|
$sms = $this->smssend($mobileno,$otp);
|
|
}
|
|
|
|
$result['details'] = 'role check';
|
|
$result['pwdcheck']=true;
|
|
$result['loginemployee']=true;
|
|
$result['loginStatus'] =true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
$result['pwdcheck']=false;
|
|
$result['loginemployee']=false;
|
|
$result['loginStatus'] =false;
|
|
$result['message'] = "Please Check the Password !!";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// die();
|
|
// print_r($loginDetails);die();
|
|
|
|
// $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
|
|
// $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('LO.OTP',$password);
|
|
// $this->db->where('ST.IsActive', 1);
|
|
// // $this->db->where('BR.Is_StudentWebAccessActive', 1);
|
|
// $responseDetails = $this->db->get()->first_row();
|
|
|
|
// // print_r($responseDetails);die();
|
|
|
|
// //print_r($this->db->last_query());die();
|
|
|
|
|
|
// if($responseDetails)
|
|
// {
|
|
|
|
// $save['OTP'] = '';
|
|
// $this->db->where('MobileNumber',$mobile);
|
|
// $this->db->where('StaffID',$mobile);
|
|
// // $this->db->where('ListCode',ADMIN);
|
|
// // $this->db->or_where('ListCode',EMPLOYEE);
|
|
// // $this->db->or_where('ListCode',TRAINEE);
|
|
// $this->db->update('T_Login',$save);//print_r($this->db->last_query());die();
|
|
// if($responseDetails->IsActive == 1)
|
|
// {
|
|
// $result['loginStatus'] = true;
|
|
// $result['details'] = $responseDetails;
|
|
// }
|
|
// else
|
|
// {
|
|
// $result['loginStatus'] = false;
|
|
// $result['loginemployee'] = false;
|
|
// $result['checkemp'] = false;
|
|
// $result['message'] = "Please Enter The Correct OTP.";
|
|
// }
|
|
// }
|
|
|
|
// else
|
|
// {
|
|
// $result['loginStatus'] = false;
|
|
// $result['loginemployee'] = false;
|
|
// $result['checkemp'] = false;
|
|
// $result['message'] = "Please Enter The Correct OTP.";
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
// else
|
|
// { // echo 'no _else';die();
|
|
// $result['loginStatus'] = false;
|
|
// $result['loginemployee'] = false;
|
|
// $result['checkemp'] = false;
|
|
// $result['message'] = "Please Enter Register Mobile Number !!";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
else if($loginDetails->ListCode ==SUPER_ADMIN)
|
|
{
|
|
|
|
if ($password == $loginDetails->Password) {
|
|
/// echo 'SUPER_ADMIN';die();
|
|
|
|
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('T_Login');
|
|
$this->db->where('MobileNumber',$mobile);
|
|
$this->db->where('Password',$password);
|
|
$this->db->where('IsActive','1');
|
|
$details = $this->db->get()->first_row();
|
|
|
|
$time = date('Y-m-d');
|
|
$dateTime = $time;
|
|
|
|
$password_date = new DateTime($details->Password_Date);
|
|
$today_date = new DateTime($dateTime);
|
|
$diff=date_diff($password_date,$today_date);
|
|
$start = strtotime($details->Password_Date);
|
|
$end = strtotime($dateTime);
|
|
|
|
$days_between = ceil(abs($end - $start) / 86400);
|
|
|
|
if($days_between>'+30')
|
|
{
|
|
|
|
$result['loginStatus'] =false;
|
|
$result['passwordStatus'] =false;
|
|
$result['message'] = "Please Change the Password !!";
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
|
|
|
|
|
|
$superadminpwd= md5($password);
|
|
|
|
$this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess,t2.CallModuleAccess');
|
|
$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();// print_r($this->db->last_query());die();
|
|
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'] = "Please Enter The Correct OTP.";
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Please Enter Valid Password !!";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Your login is de-activated or don't have login.";
|
|
}
|
|
|
|
/*$this->db->join('areas a', 'a.id = e.id_area', 'inner');
|
|
$this->db->join('horario h', 'h.id = e.id_horario', 'inner');
|
|
$this->db->join('dia d', 'd.id = e.id_data', 'inner');
|
|
$this->db->join('tipo_evento t', 't.id = e.id_tipo', 'inner');
|
|
$this->db->join('campus c', 'c.id = e.id_unidade', 'inner');
|
|
if ( $id != null ){
|
|
$this->db->where('e.id', $id);
|
|
return $this->db->get('eventos')->first_row();
|
|
} else {
|
|
return $this->db->get('eventos')->result();
|
|
}*/
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function Emplogin($EmpID,$OTP,$Password)
|
|
{
|
|
|
|
|
|
$this->db->select('MobileNumber');
|
|
$this->db->from('T_StaffDetails');
|
|
$this->db->where('StaffID',$EmpID);
|
|
$searchDetails = $this->db->get();
|
|
// print_r($searchDetails->result());die();
|
|
|
|
$contact ='';
|
|
|
|
foreach($searchDetails->result() as $mo)
|
|
{
|
|
$contact = $mo->MobileNumber;
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
|
|
$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', $EmpID);
|
|
$this->db->where('LO.OTP',$OTP);
|
|
$this->db->where('LO.Password',$Password);
|
|
$this->db->where('ST.IsActive', 1);
|
|
// $this->db->where('BR.Is_StudentWebAccessActive', 1);
|
|
$responseDetails = $this->db->get()->first_row();
|
|
|
|
// print_r($responseDetails);die();
|
|
|
|
//print_r($this->db->last_query());die();
|
|
|
|
|
|
if($responseDetails)
|
|
{
|
|
|
|
$save['OTP'] = '';
|
|
$this->db->where('MobileNumber',$EmpID);
|
|
$this->db->where('StaffID',$EmpID);
|
|
|
|
$this->db->update('T_Login',$save);
|
|
if($responseDetails->IsActive == 1)
|
|
{
|
|
$result['loginStatus'] = true;
|
|
$result['details'] = $responseDetails;
|
|
}
|
|
else
|
|
{
|
|
$result['loginStatus'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
$result['loginStatus'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
$result['message'] = "Please Enter The Correct OTP.";
|
|
}
|
|
|
|
return $result;
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
public function change_Password( $userId, $newPassword, $oldPassword, $updateOn) {
|
|
$this->db->select('Password');
|
|
$this->db->from(LOGIN);
|
|
$this->db->where('ID', $userId);
|
|
$loginDetails = $this->db->get()->first_row();
|
|
if ($loginDetails->Password == $oldPassword) {
|
|
|
|
$date = date('Y-m-d');
|
|
$Password_Date = $date;
|
|
|
|
$sql = "UPDATE ".LOGIN." SET Password='$newPassword', UpdatedBy='$userId', UpdatedOn='$updateOn',Password_Date='$Password_Date' WHERE ID='$userId'";
|
|
if($this->db->query($sql) == '1'){
|
|
$result['changePassStatus'] = true;
|
|
$result['message'] = "Your Password Successfully changed !!";
|
|
} else {
|
|
$result['changePassStatus'] = false;
|
|
$result['message'] = "Please try Again !!";
|
|
}
|
|
} else {
|
|
$result['changePassStatus'] = false;
|
|
$result['message'] = "Your Current Password miss match, Please try Again !!";
|
|
}
|
|
return $result;
|
|
}
|
|
/**
|
|
* Studnet Check function*
|
|
* created_by : sriram
|
|
*/
|
|
public function checkstudnetnumber($mobile,$otpcheck,$password){
|
|
|
|
$this->db->select('t1.MobileNumber, t1.Password,t1.ListCode');
|
|
$this->db->from('' . LOGIN . ' as t1');
|
|
$this->db->where('t1.MobileNumber', $mobile);
|
|
|
|
|
|
$this->db->where('t1.IsActive', 1);
|
|
|
|
$loginDetails = $this->db->get(LOGIN)->first_row();
|
|
// print_r($loginDetails);die;
|
|
if($loginDetails){
|
|
|
|
if($loginDetails->ListCode == STUDENT)
|
|
|
|
{
|
|
$result['loginstudent'] = true;
|
|
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess,ST.EmailID,ST.Firstname');
|
|
$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->LoginAccess ==1){
|
|
|
|
$EmailID = $responseDetails->EmailID;
|
|
$name = $responseDetails->Firstname;
|
|
|
|
$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);
|
|
|
|
// $query =1;
|
|
if($query == 1){
|
|
$sms = $this->smssend($mobile,$otp);
|
|
|
|
$mail = $this->mailsend($EmailID,$otp,$name);
|
|
|
|
|
|
$result['checkstudent'] = true;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
}else{
|
|
$result['checkstudent'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
}
|
|
|
|
|
|
}else {
|
|
$result['loginStatus'] = false;
|
|
$result['message'] = "Your login is de-activated.";
|
|
}
|
|
}
|
|
|
|
else if(($loginDetails->ListCode == ADMIN)||($loginDetails->ListCode == EMPLOYEE)||(($loginDetails->ListCode == TRAINEE)))
|
|
{
|
|
|
|
$result['loginstudent'] = false;
|
|
|
|
$result['loginemployee'] = true;
|
|
|
|
if($otpcheck == 1)
|
|
{
|
|
$adminpwd= md5($password);
|
|
}
|
|
|
|
|
|
|
|
$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);
|
|
|
|
if($otpcheck == 1)
|
|
{
|
|
$this->db->where('LO.Password', $adminpwd);
|
|
}
|
|
$this->db->where('ST.IsActive', 1);
|
|
$responseDetails = $this->db->get()->first_row();
|
|
|
|
|
|
if($otpcheck == 1)
|
|
{
|
|
|
|
//print_r($this->db->last_query());
|
|
}
|
|
|
|
|
|
if(!empty($responseDetails))
|
|
{
|
|
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){
|
|
|
|
if($otpcheck == 1)
|
|
{
|
|
|
|
|
|
$sms = $this->smssend($mobileno,$otp);
|
|
}
|
|
|
|
$result['checkemp'] = true;
|
|
$result['loginstudent'] = false;
|
|
|
|
$result['loginemployee'] = true;
|
|
}else{
|
|
$result['checkemp'] = false;
|
|
}
|
|
|
|
|
|
}else {
|
|
$result['loginStatus'] = false;
|
|
$result['checkemp'] = false;
|
|
$result['loginemployee'] = false;
|
|
|
|
$result['message'] = "Please Enter Correct OTP.";
|
|
}
|
|
}
|
|
|
|
else {
|
|
$result['loginStatus'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
$result['message'] = "Please Enter Correct Password.";
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else{
|
|
$result['loginstudent'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
$result['checkstudent'] = false;
|
|
$result['loginemployee'] = false;
|
|
$result['checkemp'] = false;
|
|
$result['message'] = "Your login is de-activated or don't have login.";
|
|
}
|
|
//print_r($result);die;
|
|
return $result;
|
|
}
|
|
public function smssend($mobile,$OTP) {
|
|
|
|
//echo $mobile;
|
|
|
|
$message ="Your One Time Password to Login to apollodec.com is $OTP. This is valid for 10 minutes.";
|
|
$mobile = "91$mobile";
|
|
$message = urlencode($message);
|
|
// echo $message;die;
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=" . $mobile . "&SenderID=APODEC&Message=" . $message . "&ServiceName=TEMPLATE_BASED");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
$output = curl_exec($ch);
|
|
curl_close($ch);
|
|
return $output;
|
|
}
|
|
|
|
|
|
public function mailsend($EmailID,$otp,$name) {
|
|
$emails = array();
|
|
|
|
$list = $EmailID;
|
|
//Load email library
|
|
$this->load->library('email');
|
|
//SMTP & mail configuration
|
|
$config = array(
|
|
'protocol' => 'smtp',
|
|
'smtp_host' => 'smtp.sendgrid.net',
|
|
'smtp_port' => 587,
|
|
'smtp_user' => 'apikey',
|
|
'smtp_pass' => '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',
|
|
'mailtype' => 'html',
|
|
'charset' => 'utf-8'
|
|
);
|
|
$this->email->initialize($config);
|
|
$this->email->set_mailtype("html");
|
|
$this->email->set_newline("\r\n");
|
|
// print_r($this->email);exit();
|
|
//Email content
|
|
// $htmlContent = '<h1>Sending email via SMTP server</h1>';
|
|
$htmlContent = 'Dear '.$name.', Your OTP for login ApolloDEC is '.$otp;
|
|
// $htmlContent = $msg;
|
|
// Email body load the html template
|
|
// $body = $this->load->view('emails/anillabs.php',$data,TRUE);
|
|
$this->email->to($list);
|
|
$this->email->from('noreply@apollodec.com','Apollo');
|
|
$subj = 'OTP For Login';
|
|
$this->email->subject($subj);
|
|
$this->email->message($htmlContent);
|
|
//Send email 1
|
|
$result = $this->email->send();
|
|
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$msgGroup = date('YmdHis');
|
|
|
|
|
|
$data[] = array('MobileNumber' => $list, 'MsgBody' => $htmlContent, 'Status' => 'success', 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup);
|
|
|
|
|
|
$this->db->insert_batch('T_BroadcastStatus', $data);
|
|
|
|
// echo $this->email->print_debugger(); exit();
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function UpdateLoginPassword($updata)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_Login');
|
|
$this->db->where('MobileNumber',$updata['emp_Ph']);
|
|
$this->db->where('Password',$updata['oldPassword']);
|
|
$searchDetails = $this->db->get();
|
|
|
|
$details = $searchDetails->result();
|
|
|
|
//print_r($details);
|
|
|
|
if($details)
|
|
{
|
|
|
|
//$data['MobileNumber'] = $updata['emp_Ph'];
|
|
$data['Password'] = $updata['newPassword'];
|
|
$data['Password_Date'] = $updata['Password_Date'];
|
|
$this->db->where('MobileNumber', $updata['emp_Ph']);
|
|
//$this->db->where('Password',$updata['oldPassword']);
|
|
$this->db->update(LOGIN, $data);
|
|
|
|
|
|
$result['updateStatus'] = true;
|
|
$result['message'] = "Updated Successfully.";
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
$result['updateStatus'] = false;
|
|
$result['message'] = "Please Enter Correct Correct Details.";
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* End the function*
|
|
*/
|
|
} |