201 lines
7.5 KiB
PHP
Executable File
201 lines
7.5 KiB
PHP
Executable File
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class Permission extends MX_Controller {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->load->model('Permission_model');
|
|
|
|
if (!$this->ion_auth->in_group(array('admin'))) {
|
|
if(!$this->ion_auth->group_permission())
|
|
redirect('home/permission');
|
|
}
|
|
}
|
|
|
|
public function index() {
|
|
$data = array();
|
|
|
|
$data['permission'] = $this->Permission_model->getPermission();
|
|
|
|
$this->load->view('home/dashboard',$data); // just the header file
|
|
$this->load->view('permission');
|
|
$this->load->view('home/footer'); // just the header file
|
|
}
|
|
|
|
public function addNewView() {
|
|
$data = array();
|
|
$data['parents'] = $this->Permission_model->getPermission();
|
|
|
|
$this->load->view('home/dashboard',$data); // just the header file
|
|
$this->load->view('add_new',$data);
|
|
$this->load->view('home/footer'); // just the header file
|
|
}
|
|
|
|
public function addNew() {
|
|
$id = $this->input->post('id');
|
|
$parent_id = $this->input->post('parent_id');
|
|
$name = $this->input->post('name');
|
|
$url = $this->input->post('url');
|
|
$menu_order = $this->input->post('menu_order');
|
|
$menu_icon = $this->input->post('menu_icon');
|
|
|
|
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
|
|
// Validating Name Field
|
|
$this->form_validation->set_rules('name', 'name', 'trim|required|min_length[1]|max_length[100]|xss_clean');
|
|
// Validating Email Field
|
|
$this->form_validation->set_rules('url', 'url', 'trim|required|min_length[1]|max_length[100]|xss_clean');
|
|
|
|
|
|
if ($this->form_validation->run() == FALSE) {
|
|
if (!empty($id)) {
|
|
$data = array();
|
|
$data['permission'] = $this->Permission_model->getPermissionById($id);
|
|
$this->load->view('home/dashboard'); // just the header file
|
|
$this->load->view('add_new', $data);
|
|
$this->load->view('home/footer'); // just the footer file
|
|
} else {
|
|
$data = array();
|
|
$data['setval'] = 'setval';
|
|
$this->load->view('home/dashboard'); // just the header file
|
|
$this->load->view('add_new', $data);
|
|
$this->load->view('home/footer'); // just the header file
|
|
}
|
|
} else {
|
|
|
|
|
|
$data = array();
|
|
$data = array(
|
|
'parent_id' => $parent_id,
|
|
'name' => $name,
|
|
'url' => $url,
|
|
'menu_order' => $menu_order,
|
|
'menu_icon' => $menu_icon,
|
|
);
|
|
|
|
if (empty($id)) { // Adding New Group
|
|
$this->Permission_model->insertPermission($data);
|
|
$this->session->set_flashdata('feedback', 'Added');
|
|
|
|
} else { // Updating Group
|
|
$this->Permission_model->updatePermission($id, $data);
|
|
$this->session->set_flashdata('feedback', 'Updated');
|
|
}
|
|
// Loading View
|
|
redirect('permission');
|
|
}
|
|
}
|
|
|
|
function editPermission() {
|
|
$id = $this->input->get('id');
|
|
$data = array();
|
|
|
|
$data['parents'] = $this->Permission_model->getPermission();
|
|
$data['permission'] = $this->Permission_model->getPermissionById($id);
|
|
//echo '<pre>'; print_r($data); echo '</pre>';die;
|
|
$this->load->view('home/dashboard', $data); // just the header file
|
|
$this->load->view('add_new', $data);
|
|
$this->load->view('home/footer'); // just the footer file
|
|
}
|
|
|
|
|
|
|
|
function delete() {
|
|
$id = $this->input->get('id');
|
|
//echo $id;die;
|
|
$this->Permission_model->delete($id);
|
|
$this->session->set_flashdata('feedback', 'Deleted');
|
|
redirect('permission');
|
|
}
|
|
|
|
function getPermission() {
|
|
|
|
$requestData = $_REQUEST;
|
|
$start = $requestData['start'];
|
|
$limit = $requestData['length'];
|
|
$search = $this->input->post('search')['value'];
|
|
|
|
if ($limit == -1) {
|
|
if (!empty($search)) {
|
|
$data['permission'] = $this->Permission_model->getPermissionBySearch($search);
|
|
} else {
|
|
$data['permission'] = $this->Permission_model->getPermission();
|
|
}
|
|
} else {
|
|
if (!empty($search)) {
|
|
$data['permission'] = $this->Permission_model->getPermissionByLimitBySearch($limit, $start, $search);
|
|
} else {
|
|
$data['permission'] = $this->Permission_model->getPermissionByLimit($limit, $start);
|
|
}
|
|
}
|
|
|
|
//$data['permission'] = $this->Permission_model->getPermission();
|
|
|
|
|
|
foreach ($data['permission'] as $permission) {
|
|
|
|
if ($this->ion_auth->in_group(array('admin'))) {
|
|
//$options1 = '<a type="button" class="btn btn-info btn-xs btn_width editbutton" title="' . lang('edit') . '" data-toggle="modal" data-id="' . $permission->id . '"><i class="fa fa-edit"> </i> ' . lang('edit') . '</a>';
|
|
$options1 = '<a class="btn btn-info btn-xs btn_width" title="' . lang('edit') . '" href="permission/editPermission?id='.$permission->id.'"><i class="fa fa-edit"> </i> ' . lang('edit') . '</a>';
|
|
}
|
|
|
|
if ($this->ion_auth->in_group(array('admin'))) {
|
|
$options3 = '<a class="btn btn-info btn-xs btn_width delete_button" title="' . lang('delete') . '" href="permission/delete?id=' . $permission->id . '" onclick="return confirm(\'Are you sure you want to delete this item?\');"><i class="fa fa-trash"> </i> ' . lang('delete') . '</a>';
|
|
}
|
|
|
|
$info[] = array(
|
|
$permission->id,
|
|
$permission->name,
|
|
$permission->url,
|
|
$options1 . ' ' . $options3,
|
|
// $options2
|
|
);
|
|
}
|
|
|
|
if (!empty($data['permission'])) {
|
|
$output = array(
|
|
"draw" => intval($requestData['draw']),
|
|
"recordsTotal" => $this->db->get('permissions')->num_rows(),
|
|
"recordsFiltered" => $this->db->get('permissions')->num_rows(),
|
|
"data" => $info
|
|
);
|
|
} else {
|
|
$output = array(
|
|
// "draw" => 1,
|
|
"recordsTotal" => 0,
|
|
"recordsFiltered" => 0,
|
|
"data" => []
|
|
);
|
|
}
|
|
|
|
echo json_encode($output);
|
|
}
|
|
|
|
public function getMenuInfo() {
|
|
// Search term
|
|
$searchTerm = $this->input->post('searchTerm');
|
|
|
|
// Get users
|
|
$response = $this->menu_model->getMenuInfo($searchTerm);
|
|
|
|
echo json_encode($response);
|
|
}
|
|
|
|
public function getMenuWithAddNewOption() {
|
|
// Search term
|
|
$searchTerm = $this->input->post('searchTerm');
|
|
|
|
// Get users
|
|
$response = $this->menu_model->getMenuWithAddNewOption($searchTerm);
|
|
|
|
echo json_encode($response);
|
|
}
|
|
|
|
}
|
|
|
|
/* End of file doctor.php */
|
|
/* Location: ./application/modules/doctor/controllers/doctor.php */ |