2023-01-05 12:19:39 +00:00
|
|
|
<?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()
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
2023-01-05 12:19:39 +00:00
|
|
|
$data['rol']=$this->Role_model->list_rol();
|
|
|
|
$this->load->view('roles/role_list',$data);
|
|
|
|
}
|
|
|
|
function addrole()
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
2023-02-07 13:11:26 +00:00
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
$role=$this->input->post('rolename');
|
|
|
|
|
|
|
|
$table="role";
|
|
|
|
|
|
|
|
$values=array('name'=>$role,
|
2023-01-08 20:46:58 +00:00
|
|
|
'createdOn'=>date('Y-m-d'),
|
2023-02-07 13:11:26 +00:00
|
|
|
'createdBy'=>$currentUser,
|
2023-01-05 12:19:39 +00:00
|
|
|
'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()
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
$rolename=$this->input->post('rolename');
|
|
|
|
$primaryid=$this->input->post('hiddenroleid');
|
|
|
|
|
|
|
|
$table="role";
|
2023-01-06 07:23:42 +00:00
|
|
|
$where=array("id"=>$primaryid);
|
2023-01-05 12:19:39 +00:00
|
|
|
$values=array('name'=>$rolename,
|
2023-01-08 20:46:58 +00:00
|
|
|
'updatedOn'=>date('Y-m-d'),
|
2023-02-07 13:11:26 +00:00
|
|
|
'updatedBy'=>$currentUser,
|
2023-01-05 12:19:39 +00:00
|
|
|
'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()
|
|
|
|
{
|
2023-02-07 13:11:26 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
|
|
|
$currentUser=$this->session->userdata('id');
|
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
|
|
|
|
$primaryid=$this->input->post('hiddengffgdtpid');
|
|
|
|
//echo $primaryid ; exit;
|
|
|
|
$table="role";
|
2023-01-06 07:23:42 +00:00
|
|
|
$where=array("id"=>$primaryid);
|
2023-01-05 12:19:39 +00:00
|
|
|
$values=array(
|
2023-02-07 13:11:26 +00:00
|
|
|
'status'=>0,'updatedOn'=>date('Y-m-d'),'updatedBy'=>$currentUser);
|
2023-01-05 12:19:39 +00:00
|
|
|
|
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2023-01-11 07:17:57 +00:00
|
|
|
|
2023-01-05 12:19:39 +00:00
|
|
|
}
|