2023-01-10 09:41:20 +00:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Welcome extends CI_Controller {
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-10 09:41:20 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('Common_model');
|
2023-02-07 13:11:26 +00:00
|
|
|
$this->load->model('Commonsql_model');
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->load->model('Project_model');
|
2023-01-10 09:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$this->load->view('login');
|
|
|
|
}
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-10 09:41:20 +00:00
|
|
|
public function dashboard()
|
|
|
|
{
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['project']=$this->Project_model->totalProjects();
|
|
|
|
$data['student']=$this->Project_model->totalStudents();
|
|
|
|
$data['subject']=$this->Project_model->totalSubject();
|
|
|
|
$data['faculty']=$this->Project_model->totalFaculties();
|
|
|
|
$data['projectList']=$this->Project_model->recentlyAddedProject();
|
|
|
|
$this->load->view('dashboard',$data);
|
2023-01-10 09:41:20 +00:00
|
|
|
}
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
public function login()
|
2023-01-10 09:41:20 +00:00
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
//echo "dsds";exit;
|
2023-01-11 07:17:57 +00:00
|
|
|
$username=$this->input->post('username');
|
|
|
|
$password=$this->input->post('password');
|
|
|
|
|
|
|
|
$check=$this->Common_model->get_login_detail($username,$password);
|
2023-01-21 13:41:47 +00:00
|
|
|
//echo $this->db->last_query();exit;
|
2023-01-11 07:17:57 +00:00
|
|
|
if($check->num_rows()>0)
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
$ch=$check->row();
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->session->set_userdata('username',$ch->username);
|
2023-02-07 13:11:26 +00:00
|
|
|
$this->session->set_userdata('role',$ch->roleId);
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->session->set_userdata('id',$ch->id);
|
|
|
|
$this->session->set_userdata('suc',' Successfully Logged in..!');
|
|
|
|
redirect('dashboard');
|
|
|
|
|
2023-01-11 07:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->session->set_userdata('err','The username or password is incorrect.');
|
|
|
|
redirect('');
|
2023-01-11 07:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public function logout()
|
|
|
|
{
|
|
|
|
$admin_id=$this->session->userdata('id');
|
2023-01-10 09:41:20 +00:00
|
|
|
|
2023-01-11 07:17:57 +00:00
|
|
|
$data = array('id' => '', 'username' => '');
|
|
|
|
$this->session->unset_userdata($data);
|
|
|
|
$this->session->sess_destroy();
|
|
|
|
redirect('');
|
2023-01-10 09:41:20 +00:00
|
|
|
}
|
2023-02-07 13:11:26 +00:00
|
|
|
public function getOldPassword()
|
|
|
|
{
|
|
|
|
$id=$_POST['employeeId'];
|
|
|
|
$oldpassword=$_POST['oldPassword'];
|
|
|
|
$currentPassword=md5($oldpassword);
|
|
|
|
|
|
|
|
$password=$this->Project_model->getOldPassword($id);
|
|
|
|
if(isset($password) && $password->num_rows()>0)
|
|
|
|
{
|
|
|
|
$li=$password->row();
|
|
|
|
$dbpassword=$li->password;
|
|
|
|
}
|
|
|
|
if($currentPassword==$dbpassword)
|
|
|
|
{
|
|
|
|
echo "true";
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
echo "false";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public function changePassword()
|
|
|
|
{
|
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
|
|
|
|
$newpassword=$this->input->post('newpassword');
|
|
|
|
$employeeId=$this->input->post('employeeId');
|
|
|
|
|
|
|
|
$table="employee";
|
|
|
|
$where=array("id"=>$employeeId);
|
|
|
|
$values=array('password'=>md5($newpassword),
|
|
|
|
'updatedBy'=>$currentUser);
|
|
|
|
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
|
|
if($result)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
|
|
redirect('change-password');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('change-password');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
$this->load->view('changepassword');
|
|
|
|
}
|
2023-01-10 09:41:20 +00:00
|
|
|
}
|