193 lines
5.2 KiB
PHP
193 lines
5.2 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
/**
|
|
* AMS
|
|
*
|
|
* @package HMVC
|
|
* @author Venba
|
|
* @copyright 2022 Venba
|
|
* @license https://venbainfotech.com/licenses/MIT MIT License
|
|
* @link <URI> (description)
|
|
* @version GIT: $Id$
|
|
* @since Version 0.0.1
|
|
* @filesource
|
|
*
|
|
*/
|
|
|
|
class Group extends Admin_Controller
|
|
{
|
|
/**
|
|
* [__construct description]
|
|
*
|
|
* @method __construct
|
|
*/
|
|
public function __construct()
|
|
{
|
|
// To inherit directly the attributes of the parent class.
|
|
parent::__construct();
|
|
### Syntax : $this->load->model('Model Path' , 'Alias name');
|
|
### The second parameter (optional) is used to call the method.
|
|
$this->load->model('MY_Model','MY_Model');
|
|
$this->load->model('Group_model','G_model');
|
|
$this->load->helper(array('form', 'url'));
|
|
}
|
|
|
|
public function Group_list()
|
|
{
|
|
$Group_list = $this->G_model->get_Group_list(user()->business_id);
|
|
$Group_module_list = $this->G_model->get_Group_module_list(user()->business_id);
|
|
|
|
$this->layout->set('tableData', $Group_list);
|
|
$this->layout->set('Group_module_list', $Group_module_list);
|
|
$this->layout->buffer('main_content', 'Group/Group_list');
|
|
$this->layout->render('default_layout');
|
|
}
|
|
|
|
public function Create_Group_Form()
|
|
{
|
|
$access_modules = $this->G_model->get_group_access_modules(user()->business_id);
|
|
$this->layout->set('access_modules', $access_modules);
|
|
$this->layout->buffer('main_content', 'Group/Create_Group');
|
|
$this->layout->render('default_layout');
|
|
}
|
|
|
|
|
|
public function Create_Group()
|
|
{
|
|
$data = $this->input->post();
|
|
unset($data['module_id']);
|
|
$data['business_id'] = user()->business_id;
|
|
$data['is_active'] = 1;
|
|
$get_last_insert_id = $this->MY_Model->insert($data,"groups");
|
|
if($get_last_insert_id)
|
|
{
|
|
$count = count($this->input->post('module_id'));
|
|
for($i=0;$i<$count;$i++)
|
|
{
|
|
$mdata['module_id'] = $this->input->post('module_id')[$i];
|
|
$mdata['group_id'] = $get_last_insert_id;
|
|
$mdata['is_active'] = 1;
|
|
$add_module = $this->MY_Model->insert($mdata, "group_permisssion");
|
|
}
|
|
}
|
|
|
|
redirect('Group/Group_list');
|
|
}
|
|
|
|
|
|
public function Edit_Group($id)
|
|
{
|
|
$Group_Data = $this->G_model->get_group_data_by_md5_id($id);
|
|
$Group_Module_Data = $this->G_model->get_group_module_data_by_md5_id($id);
|
|
$access_modules = $this->G_model->get_group_access_modules(user()->business_id);
|
|
$this->layout->set('access_modules', $access_modules);
|
|
$this->layout->set('Group_Module_Data', $Group_Module_Data);
|
|
$this->layout->set('Group_Data', $Group_Data);
|
|
$this->layout->buffer('main_content', 'Group/Edit_Group');
|
|
$this->layout->render('default_layout');
|
|
|
|
}
|
|
|
|
public function Edit_Group_list()
|
|
{
|
|
$action = $this->input->post();
|
|
$id = $this->input->post('id');
|
|
$Group_Module_Data = $this->G_model->get_group_module_data_by_id($id);
|
|
if(count($Group_Module_Data) != 0)
|
|
{
|
|
$DbData = [];
|
|
foreach($Group_Module_Data as $key => $val){
|
|
array_push($DbData,$val->module_id);
|
|
}
|
|
|
|
if($this->input->post('module_id') == null)
|
|
{
|
|
$module_id_array = [];
|
|
}else{
|
|
$module_id_array = $this->input->post('module_id');
|
|
}
|
|
|
|
|
|
$differentValues1 = array_diff($module_id_array , $DbData);
|
|
$differentValues2 = array_diff($DbData , $module_id_array);
|
|
$final_array = array_merge($differentValues1, $differentValues2);
|
|
// echo "<pre>";
|
|
// print_r($DbData); print_r($this->input->post('module_id')); print_r($final_array);
|
|
// echo "<pre>";
|
|
|
|
// die;
|
|
//echo count($final_array); die;
|
|
|
|
if(count($final_array) != 0)
|
|
{
|
|
foreach($final_array as $key => $value){
|
|
$check_if_exist = $this->G_model->get_group_module_data_by_id($id , $value);
|
|
if($check_if_exist)
|
|
{
|
|
$this->G_model->delete_group_module_data_by_id($id , $value);
|
|
}else{
|
|
$mdata['module_id'] = $value;
|
|
$mdata['group_id'] = $id;
|
|
$mdata['is_active'] = 1;
|
|
$add_module = $this->MY_Model->insert($mdata, "group_permisssion");
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
echo "string";
|
|
}
|
|
}
|
|
else
|
|
{ for($i=0;$i<count($this->input->post('module_id'));$i++)
|
|
{
|
|
$mdata['module_id'] = $this->input->post('module_id')[$i];
|
|
$mdata['group_id'] = $id;
|
|
$mdata['is_active'] = 1;
|
|
$add_module = $this->MY_Model->insert($mdata, "group_permisssion");
|
|
}
|
|
}
|
|
unset($action['module_id']);
|
|
$EditGroupData = $this->MY_Model->edit_option($action, $id, 'groups');
|
|
redirect('Group/Group_list');
|
|
|
|
}
|
|
|
|
public function delete_group($id)
|
|
{
|
|
$Data = $this->G_model->delete_group($id, user()->business_id);
|
|
$Data = $this->G_model->delete_group_permission($id);
|
|
redirect('Group/Group_list');
|
|
}
|
|
|
|
public function delete_module()
|
|
{
|
|
|
|
print_r(Employee_module());
|
|
//print_r( group_membership());
|
|
//echo $this->session->userdata('id');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|