McGansWebsite/admin/application/controllers/Role.php
dotwingssoftware d5a0e0987c 10012023
20230110
2023-01-10 15:11:20 +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,
'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('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("id"=>$primaryid);
$values=array('name'=>$rolename,
'updatedOn'=>date('Y-m-d'),
'updatedBy'=>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("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');
}
}