McGansWebsite/admin/application/controllers/Employee.php
dotwingssoftware d5a0e0987c 10012023
20230110
2023-01-10 15:11:20 +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');
$mobileNumber=$this->input->post('mobileNumber');
$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,
'mobileNumber'=>$mobileNumber,
'address'=>$address,
'email'=>$email,
'pincode'=>$code,
'image'=>$img,
'username'=>$user,
'password'=>$password,
'createdOn'=>date('Y-m-d'),
'createdBy'=>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');
$mobileNumber=$this->input->post('mobileNumber');
$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,
'mobileNumber'=>$mobileNumber,
'address'=>$address,
'email'=>$email,
'pincode'=>$code,
'username'=>$user,
'image'=>$img,
'password'=>$newpassword,
'updatedOn'=>date('Y-m-d'),
'updatedBy'=>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');
}
}
}
}