McGansWebsite/application/controllers/Employee.php
Sasikala ec3d3dc27d 20230106
Mcgans updated
2023-01-06 12:53:42 +05:30

151 lines
3.6 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Employee extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Employee_model');
$this->load->model('Commonsql_model');
}
public function listrole()
{
$this->load->view('roles/role_list');
}
public function employee_list()
{
$data['emp']=$this->Employee_model->list_emp();
$this->load->view('employee/employee',$data);
}
public function add_list()
{
$this->load->view('add_emplayee/add');
}
function add_employee()
{
if($this->input->post('submit'))
{
$employeename=$this->input->post('employeename');
$mobile_Number=$this->input->post('mobile_Number');
$address=$this->input->post('address');
$email=$this->input->post('email');
$code=$this->input->post('code');
$img=$this->input->post('img');
$user=$this->input->post('User');
$password=$this->input->post('Password');
$table="employee";
$values=array('name'=>$employeename,
'mobile_Number'=>$mobile_Number,
'address'=>$address,
'email'=>$email,
'pincode'=>$code,
'image'=>$img,
'username'=>$user,
'password'=>$password,
'created_on'=>date('Y-m-d'),
'created_by'=>1,
'status'=>1);
$result=$this->Commonsql_model->insert_table($table,$values);
if($result)
{
$this->session->set_userdata('suc','successfully added');
redirect('employee');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('employee');
}
}
}
function editemployee($empid)
{
if($this->input->post('submit'))
{
$employeename=$this->input->post('employeename');
$mobile_Number=$this->input->post('mobile_Number');
$address=$this->input->post('address');
$email=$this->input->post('email');
$code=$this->input->post('code');
$img=$this->input->post('img');
$user=$this->input->post('User');
$password=$this->input->post('Password');
$hiddenpass=$this->input->post('hiddenpass');
if($password=="")
{
$newpassword=$hiddenpass;
}
else
{
$newpassword=md5($password);
}
$table="employee";
$where=array("id"=>$empid);
$values=array('name'=>$employeename,
'mobile_Number'=>$mobile_Number,
'address'=>$address,
'email'=>$email,
'pincode'=>$code,
'username'=>$user,
'image'=>$img,
'password'=>$newpassword,
'update_on'=>date('Y-m-d'),
'update_by'=>1,
'status'=>1);
$result=$this->Commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','successfully Updated');
redirect('employee');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('employee');
}
}
//echo "sdsd";exit;
$data['emp']=$this->Employee_model->get_emp($empid);
//echo $this->db->last_query();exit;
$this->load->view('add_emplayee/edit',$data);
}
function deleted_employee()
{
if($this->input->post('submit'))
{
$empid=$this->input->post('hiddenpass');
$table="employee";
$where=array("id"=>$empid);
$values=array(
'status'=>0);
$result=$this->Commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','successfully deleted');
redirect('employee');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('employee');
}
}
}
}