McGansWebsite/application/controllers/Role.php
Sasikala a79011514c 20230105
initial update
2023-01-05 17:49:39 +05:30

114 lines
2.4 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Role extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Role_model');
$this->load->model('Commonsql_model');
}
public function listrole()
{
$data['rol']=$this->Role_model->list_rol();
$this->load->view('roles/role_list',$data);
}
function addrole()
{
if($this->input->post('submit'))
{
$role=$this->input->post('rolename');
$table="role";
$values=array('name'=>$role,
'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('roles');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('roles');
}
}
}
function editrole()
{
if($this->input->post('submit'))
{
$rolename=$this->input->post('rolename');
$primaryid=$this->input->post('hiddenroleid');
$table="role";
$where=array("role_id"=>$primaryid);
$values=array('name'=>$rolename,
'updated_on'=>date('Y-m-d'),
'updated_by'=>1,
'status'=>1);
$result=$this->Commonsql_model->updateTable($table,$where,$values);
//echo $this->db->last_query();exit;
if($result)
{
$this->session->set_userdata('suc','successfully Updated');
redirect('roles');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('roles');
}
//echo $this->db->last_query();exit;
}
$this->load->view('roles/role_list',$data);
}
function deleterole()
{
if($this->input->post('submit'))
{
$primaryid=$this->input->post('hiddengffgdtpid');
//echo $primaryid ; exit;
$table="role";
$where=array("role_id"=>$primaryid);
$values=array(
'status'=>0);
$result=$this->Commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','successfully deleted');
redirect('roles');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('roles');
}
}
}
//profile start//
public function profile_list()
{
//$data['rol']=$this->Role_model->list_rol();
$this->load->view('profile');
}
}