McGansWebsite/admin/application/controllers/Role.php

108 lines
2.5 KiB
PHP
Raw Normal View History

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-11 07:17:57 +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-11 07:17:57 +00:00
//if($this->session->userdata('id')==""){redirect('');}
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'),
'createdBy'=>1,
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-01-11 07:17:57 +00:00
//if($this->session->userdata('id')==""){redirect('');}
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'),
'updatedBy'=>1,
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-01-11 07:17:57 +00:00
//if($this->session->userdata('id')==""){redirect('');}
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(
'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');
}
}
}
2023-01-11 07:17:57 +00:00
2023-01-05 12:19:39 +00:00
}