business module group changes : Venkateshwaran
This commit is contained in:
parent
af73de3740
commit
cf204da2b9
@ -95,6 +95,91 @@ function employee()
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('modules'))
|
||||
{
|
||||
function modules()
|
||||
{
|
||||
$ci =& get_instance();
|
||||
$module_id = $ci->auth_model->modules();
|
||||
|
||||
$ModuleData = [];
|
||||
foreach($module_id as $key => $val){
|
||||
array_push($ModuleData,$val->module_id);
|
||||
}
|
||||
return $ModuleData;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!function_exists('Asset_module'))
|
||||
{
|
||||
function Asset_module()
|
||||
{
|
||||
$myArray = modules();
|
||||
$elementToCheck = '1';
|
||||
return in_array($elementToCheck, $myArray);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('Employee_module'))
|
||||
{
|
||||
function Employee_module()
|
||||
{
|
||||
$myArray = modules();
|
||||
$elementToCheck = '2';
|
||||
|
||||
return in_array($elementToCheck, $myArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('group_membership'))
|
||||
{
|
||||
function group_membership()
|
||||
{
|
||||
$ci =& get_instance();
|
||||
$group_id = $ci->auth_model->group_membership();
|
||||
|
||||
$GroupData = [];
|
||||
foreach($group_id as $key => $val){
|
||||
array_push($GroupData,$val->group_id,$val->module_id);
|
||||
}
|
||||
return $GroupData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!function_exists('Employee_group'))
|
||||
{
|
||||
function Employee_group()
|
||||
{
|
||||
$myArray = group_membership();
|
||||
// $ci =& get_instance();
|
||||
// return $Employee_group = $ci->auth_model->Employee_group($myArray);
|
||||
|
||||
$elementToCheck = '4';
|
||||
$elementToCheck = '1';
|
||||
return in_array($elementToCheck, $myArray);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('HR_group'))
|
||||
{
|
||||
function HR_group()
|
||||
{
|
||||
$myArray = group_membership();
|
||||
// $ci =& get_instance();
|
||||
// return $Employee_group = $ci->auth_model->Employee_group($myArray);
|
||||
|
||||
$elementToCheck = '6';
|
||||
$elementToCheck = '2';
|
||||
return in_array($elementToCheck, $myArray);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists(''))
|
||||
|
||||
if (!function_exists('hash_password')) {
|
||||
function hash_password($password)
|
||||
{
|
||||
|
||||
@ -46,6 +46,46 @@ public function get_logged_employee()
|
||||
}
|
||||
}
|
||||
|
||||
public function modules()
|
||||
{
|
||||
$this->db->select('module_id');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->where('uid', $this->session->userdata('business_id'));
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function group_membership()
|
||||
{
|
||||
|
||||
$this->db->select('group_permisssion.group_id, group_permisssion.module_id');
|
||||
$this->db->from('group_permisssion');
|
||||
$this->db->join('group_membership', 'group_membership.group_id = group_permisssion.group_id');
|
||||
$this->db->where('group_membership.emp_id', $this->session->userdata('id'));
|
||||
$this->db->where('group_membership.business_id', $this->session->userdata('business_id'));
|
||||
$this->db->where('group_permisssion.is_active', '1');
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function Employee_group($myArray)
|
||||
{
|
||||
//$this->db->select('group_permisssion.group_id, group_permisssion.module_id');
|
||||
$this->db->from('group_permisssion');
|
||||
$this->db->join('group_membership', 'group_membership.group_id = group_permisssion.group_id');
|
||||
$this->db->where('group_membership.group_id', $myArray[0]);
|
||||
$this->db->where('group_membership.emp_id', $this->session->userdata('id'));
|
||||
$this->db->where('group_permisssion.module_id', $myArray[1]);
|
||||
$this->db->where('group_permisssion.is_active', '1');
|
||||
$query = $this->db->get();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//get user by id
|
||||
public function get_user($id)
|
||||
{
|
||||
@ -106,6 +146,8 @@ public function is_user()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//is pro user
|
||||
public function is_pro_user()
|
||||
{
|
||||
|
||||
@ -87,18 +87,17 @@ public function create_business()
|
||||
$add_admin = $this->input->post('add_admin');
|
||||
unset($data['add_admin']);
|
||||
}
|
||||
|
||||
$mtable = "permit_modules";
|
||||
$mdata['module_id'] = $this->input->post('module_id');
|
||||
$mdata['uid'] = $this->input->post('uid');
|
||||
$mdata['is_active'] = 1;
|
||||
|
||||
$add_module = $this->MY_Model->insert($mdata,$mtable);
|
||||
unset($data['module_id']);
|
||||
|
||||
$count = count($this->input->post('module_id'));
|
||||
for($i=0;$i<$count;$i++)
|
||||
{
|
||||
$mdata['module_id'] = $this->input->post('module_id')[$i];
|
||||
$mdata['uid'] = $this->input->post('uid');
|
||||
$mdata['is_active'] = 1;
|
||||
$add_module = $this->MY_Model->insert($mdata, "permit_modules");
|
||||
}
|
||||
unset($data['module_id']);
|
||||
$create_business = $this->MY_Model->insert($data,$table);
|
||||
|
||||
|
||||
// audit history
|
||||
if($create_business)
|
||||
{
|
||||
@ -122,17 +121,21 @@ public function create_business()
|
||||
}
|
||||
|
||||
|
||||
public function get_business($id)
|
||||
public function get_business($id, $uid)
|
||||
{
|
||||
//select dropdown values
|
||||
$this->layout->set('stateData', $this->MY_Model->select('state'));
|
||||
// select business value by id
|
||||
$table="business";
|
||||
$businessData = $this->Business_model->get_business_by_md5_id($id);
|
||||
|
||||
$this->layout->set('businessData', $businessData);
|
||||
$this->layout->buffer('main_content', 'Business/edit_business');
|
||||
$this->layout->render('default_layout');
|
||||
|
||||
//select dropdown values
|
||||
$this->layout->set('stateData', $this->MY_Model->select('state'));
|
||||
|
||||
// select business value by id
|
||||
$table="business";
|
||||
$businessData = $this->Business_model->get_business_by_md5_id($id);
|
||||
$businessModuleData = $this->Business_model->get_business_modules($uid);
|
||||
$this->layout->set('ModuleData', $this->MY_Model->select('modules'));
|
||||
$this->layout->set('businessModuleData', $businessModuleData);
|
||||
$this->layout->set('businessData', $businessData);
|
||||
$this->layout->buffer('main_content', 'Business/edit_business');
|
||||
$this->layout->render('default_layout');
|
||||
|
||||
}
|
||||
|
||||
@ -164,16 +167,82 @@ public function edit_business()
|
||||
//fetch old_data before new_data update
|
||||
$this->audit->fetch('old_data');
|
||||
|
||||
//insert new data
|
||||
$mtable = "permit_modules";
|
||||
$mdata['module_id'] = $this->input->post('module_id');
|
||||
$mdata['uid'] = $this->input->post('uid');
|
||||
$mdata['is_active'] = 1;
|
||||
//insert new data
|
||||
$get_business_module_is_active = $this->Business_model->get_business_module_is_active($this->input->post('uid'));
|
||||
|
||||
if(count($get_business_module_is_active) != 0)
|
||||
{
|
||||
$DbData = [];
|
||||
foreach($get_business_module_is_active as $key => $val){
|
||||
array_push($DbData,$val->module_id);
|
||||
}
|
||||
|
||||
$businessData = $this->MY_Model->edit_option($action, $id, $table);
|
||||
unset($data['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;
|
||||
|
||||
if(count($final_array) != 0)
|
||||
{
|
||||
foreach($final_array as $key => $value){
|
||||
$check_if_exist = $this->Business_model->get_group_module_data_by_id($this->input->post('uid'), $value);
|
||||
if($check_if_exist)
|
||||
{
|
||||
$this->Business_model->delete_group_module_data_by_id($this->input->post('uid') , $value);
|
||||
$data['is_active'] = 0;
|
||||
$this->Business_model->diable_module_in_group_permisssion($value, $data);
|
||||
//$group_id=$this->Business_model->get_group_id_by_module_id($value);
|
||||
//$GroupIdData = [];
|
||||
// foreach($group_id as $key => $val){
|
||||
// array_push($GroupIdData,$val->group_id);
|
||||
// }
|
||||
// $this->Business_model->diable_group_in_group_membership($value, $data);
|
||||
|
||||
}else{
|
||||
$mdata['module_id'] = $value;
|
||||
$mdata['uid'] = $this->input->post('uid');
|
||||
$mdata['is_active'] = 1;
|
||||
$add_module = $this->MY_Model->insert($mdata, "permit_modules");
|
||||
$data['is_active'] = 1;
|
||||
$this->Business_model->Enable_module_in_group_permisssion($value, $data);
|
||||
// $group_id=$this->Business_model->get_group_id_by_module_id($value);
|
||||
// $GroupIdData = [];
|
||||
// foreach($group_id as $key => $val){
|
||||
// array_push($GroupIdData,$val->group_id);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ for($i=0;$i<count($this->input->post('module_id'));$i++)
|
||||
{
|
||||
$mdata['module_id'] = $this->input->post('module_id')[$i];
|
||||
$mdata['uid'] = $this->input->post('uid');
|
||||
$mdata['is_active'] = 1;
|
||||
$add_module = $this->MY_Model->insert($mdata, "permit_modules");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unset($action['module_id']);
|
||||
$businessData = $this->MY_Model->edit_option($action, $id, $table);
|
||||
if($businessData)
|
||||
{
|
||||
@ -236,7 +305,15 @@ public function edit_module_data()
|
||||
$action['is_active'] = 1;
|
||||
$add_module = $this->MY_Model->edit_option($action, $id, $table);
|
||||
redirect('Business/module_list');
|
||||
}
|
||||
}
|
||||
|
||||
public function getDeleteConfirmationPopup()
|
||||
{
|
||||
$data = array();
|
||||
$htmlPage = $this->load->view('confirmation_popup.php',$data,true);
|
||||
echo json_encode($htmlPage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -34,4 +34,73 @@ public function delete_by_md5_id($id,$business_id,$table)
|
||||
return;
|
||||
}
|
||||
|
||||
public function get_business_modules($business_id)
|
||||
{
|
||||
$this->db->select('permit_modules.*,modules.modules');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left');
|
||||
$this->db->where('uid', $business_id);
|
||||
$this->db->where('permit_modules.is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_business_module_is_active($business_id)
|
||||
{
|
||||
$this->db->select('module_id');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->where('uid', $business_id);
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function get_group_module_data_by_id($id , $module_id = null)
|
||||
{
|
||||
$this->db->select('module_id');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->where('uid', $id);
|
||||
if($module_id != null){ $this->db->where('module_id', $module_id); }
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
public function delete_group_module_data_by_id($id , $module_id )
|
||||
{
|
||||
$this->db->where('uid', $id);
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->delete('permit_modules');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function diable_module_in_group_permisssion($module_id, $data)
|
||||
{
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->update('group_permisssion', $data);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function Enable_module_in_group_permisssion($module_id, $mdata)
|
||||
{
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->update('group_permisssion', $mdata);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function get_group_id_by_module_id($module_id)
|
||||
{
|
||||
$this->db->select('group_membership.group_id');
|
||||
$this->db->from('group_membership');
|
||||
$this->db->join('group_permisssion', 'group_permisssion.group_id = group_membership.group_id');
|
||||
$this->db->where('module_id', $module_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,128 @@
|
||||
|
||||
<!-- Body page content -->
|
||||
|
||||
<script src="<?php echo base_url(); ?>/assets/default/jquery/dist/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div class="">
|
||||
@ -56,8 +178,7 @@
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Select Modules<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="modules" name="module_id" required="required" class="form-control" >
|
||||
<option value=""> Select Module </option>
|
||||
<select id="people" name="module_id[]" class="form-control select2_multiple" multiple>
|
||||
<?php foreach ($ModuleData as $key => $value) { ?>
|
||||
<option value="<?php echo $value->id; ?>"><?php echo $value->modules; ?></option>
|
||||
<?php } ?>
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
<?php foreach ($tableData as $key => $value) { ?>
|
||||
<tr class="even pointer">
|
||||
|
||||
|
||||
<td class=" "> <?php echo $value->business_name; ?> </td>
|
||||
<td class=" "><?php echo $value->email; ?> </td>
|
||||
<td class=" "><?php echo $value->phone; ?></td>
|
||||
@ -54,7 +53,7 @@
|
||||
<td class=" "><?php echo $value->logo; ?> </td>
|
||||
|
||||
<td style=" text-align: center; font-size: 16px;">
|
||||
<a href="<?php echo base_url()?>Business/get_business/<?php echo md5($value->id);?>" ><i class="fa fa-pencil"></i></a>
|
||||
<a href="<?php echo base_url()?>Business/get_business/<?php echo md5($value->id);?>/<?php echo($value->uid);?>" ><i class="fa fa-pencil"></i></a>
|
||||
|
||||
|
||||
<a href="<?php echo base_url()?>Business/delete_business/<?php echo md5($value->id);?>" ><i class="fa fa-trash"></i></a>
|
||||
|
||||
26
application/modules/Business/views/confirmation_popup.php
Normal file
26
application/modules/Business/views/confirmation_popup.php
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h6 class="modal-title" id="myModalLabel2">Are you sure you want to delete</h6>
|
||||
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
</br>
|
||||
<center>
|
||||
<form class="delete_url" method="post" action="" id="">
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
|
||||
|
||||
<input type="hidden" class="delete_id" name="id" value="">
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
|
||||
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button>
|
||||
</form>
|
||||
</center>
|
||||
</br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -1,7 +1,124 @@
|
||||
|
||||
<!-- Body page content -->
|
||||
<script src="<?php echo base_url(); ?>/assets/default/jquery/dist/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div class="">
|
||||
<div class="page-title">
|
||||
@ -31,26 +148,58 @@
|
||||
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
<input type="hidden" name="id" value="<?php echo $businessData->id; ?>">
|
||||
<input type="hidden" name="uid" value="<?php echo $businessData->uid; ?>">
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Business Name<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input type="text" id="business_name" name="business_name" value="<?php echo $businessData->business_name; ?>" required="required" class="form-control ">
|
||||
<div class="col-md-3 col-sm-3">
|
||||
<input type="text" id="business_name" name="business_name" value="<?php echo $businessData->business_name; ?>" required="required" class="form-control">
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Email<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<div class="col-md-3 col-sm-3">
|
||||
<input type="email" id="email" name="email" value="<?php echo $businessData->email; ?>" required="required" class="form-control ">
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Phone<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-3 col-sm-3">
|
||||
<input id="phone" type="text" pattern="[6-9]{1}[0-9]{9}"
|
||||
title="Phone number with 6-9 and remaing 9 digit with 0-9" name="phone" value="<?php echo $businessData->phone; ?>" required="required" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Phone<a style="color:red;">*</a> </label>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Select Modules<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input id="phone" type="text" pattern="[6-9]{1}[0-9]{9}"
|
||||
title="Phone number with 6-9 and remaing 9 digit with 0-9" name="phone" value="<?php echo $businessData->phone; ?>" required="required" class="form-control">
|
||||
</div>
|
||||
|
||||
|
||||
<select id="people" name="module_id[]" class="form-control select2_multiple" multiple >
|
||||
|
||||
<?php ?>
|
||||
|
||||
<?php
|
||||
|
||||
$modulesArray = [];
|
||||
|
||||
foreach ($businessModuleData as $object) {
|
||||
if (isset($object->modules)) {
|
||||
$modulesArray[] = $object->modules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($ModuleData as $key => $data) { ?>
|
||||
<?php if(in_array($data->modules, $modulesArray)) { ?>
|
||||
<option value="<?php echo $data->id; ?>" selected> <?php echo $data->modules; ?> </option>
|
||||
<?php } else { ?>
|
||||
<option value="<?php echo $data->id; ?>"><?php echo $data->modules;?> </option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Select Logo<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
@ -58,16 +207,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<br /> <div class="x_title"> </div> <br />
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Address<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input id="address" name="address" value="<?php echo $businessData->address; ?>" required="required" class="form-control" type="text" >
|
||||
<div class="col-md-5 col-sm-5">
|
||||
<input id="address" name="address" value="<?php echo $businessData->address; ?>" required="required" class="form-control" type="text">
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">City<a style="color:red;">*</a> </label>
|
||||
@ -83,7 +229,7 @@
|
||||
<select id="state" name="state" required="required" class="form-control" >
|
||||
<option value="<?php echo $businessData->state; ?>"> <?php echo $businessData->state_name; ?> </option>
|
||||
<?php foreach ($stateData as $key => $value) { ?>
|
||||
<option value="<?php echo $value->id; ?>"><?php echo $value->name; ?></option>
|
||||
<option value="<?php echo $value->id; ?>"><?php echo $value->name;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -92,11 +238,8 @@
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input id="country" name="country" value="<?php echo $businessData->country; ?>" required="required" class="form-control" type="text" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Pin code<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5">
|
||||
@ -104,17 +247,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="ln_solid"></div>
|
||||
<div class="item form-group">
|
||||
<div class="offset-md-8">
|
||||
@ -122,19 +254,39 @@
|
||||
<button type="submit" class="btn btn-success">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
|
||||
// $(document).ready(function() {
|
||||
// $("#people").on("click", function() {
|
||||
// // Get the selected values as an array
|
||||
// var selectedValues = $("#people").val();
|
||||
|
||||
// // Do something with the selected values (e.g., display them)
|
||||
// if (selectedValues) {
|
||||
// var selectedValuesString = selectedValues.join(", ");
|
||||
// alert("Selected Values: " + selectedValuesString);
|
||||
// } else {
|
||||
// alert("No values selected.");
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var selected = [];
|
||||
for (var option of document.getElementById('people').options)
|
||||
{
|
||||
if (option.selected) {
|
||||
selected.push(option.value);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Body page content -->
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<td style=" text-align: center; font-size: 16px;">
|
||||
<a href="<?php echo base_url()?>Business/edit_module/<?php echo md5($value->id);?>" ><i class="fa fa-pencil"></i></a>
|
||||
|
||||
<a href="<?php echo base_url()?>Business/delete_business/<?php echo md5($value->id);?>"><i class="fa fa-trash"></i></a>
|
||||
<a href="#"><i class="fa fa-trash delete" aria-hidden="true" title="Delete" data-toggle="modal" data-target=".bs-example-modal-sm" id= "<?php echo md5($value->id); ?>"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -41,28 +41,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div style="display:none" id="sub-value">
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Large modal -->
|
||||
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> -->
|
||||
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
|
||||
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
|
||||
|
||||
<div style="display:none" id="sub-value">
|
||||
|
||||
<script>
|
||||
$(document).on('click','.bi-card-list',function(){
|
||||
var id = $(this).attr("id")
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "<?php echo base_url()?>User/view_business_history/"+id,
|
||||
success: function(response) {
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('.bs-example-modal-lg').html(response);
|
||||
$('.bs-example-modal-lg').modal("show");
|
||||
},
|
||||
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
|
||||
$('.delete').click(function() {
|
||||
var id = $(this).attr('id');
|
||||
alert(id);
|
||||
var url = "<?php echo base_url()?>Business/delete_module";
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo base_url()?>Business/getDeleteConfirmationPopup",
|
||||
type:"GET",
|
||||
success:function(data){
|
||||
$('#popup').html(JSON.parse(data));
|
||||
$('.delete_id').attr('value',id);
|
||||
$('.delete_url').attr('action',url);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -49,7 +49,7 @@ public function index()
|
||||
|
||||
|
||||
public function empList()
|
||||
{
|
||||
{
|
||||
$emp_list = $this->Emp_model->get_employee(user()->business_id);
|
||||
$this->layout->set('tableData', $emp_list);
|
||||
$this->layout->buffer('main_content', 'Employee/emp_list');
|
||||
@ -57,10 +57,12 @@ public function empList()
|
||||
}
|
||||
|
||||
public function addEmployee($businessId = 0)
|
||||
{
|
||||
{
|
||||
$get_group_list = $this->Emp_model->get_group_list(user()->business_id);
|
||||
$manager = $this->Emp_model->get_employee(user()->business_id);
|
||||
$ModuleData = $this->Emp_model->get_modules(user()->business_id);
|
||||
$this->layout->set('ModuleData', $ModuleData);
|
||||
$this->layout->set('get_group_list', $get_group_list);
|
||||
$this->layout->set('ModuleData', $ModuleData);
|
||||
$this->layout->set('manager', $manager);
|
||||
$this->layout->set('departmentData', $this->MY_Model->select_by_department_data('department_master',user()->business_id));
|
||||
$this->layout->buffer('main_content', 'Employee/add_emp');
|
||||
@ -173,6 +175,7 @@ public function createEmp()
|
||||
unset($data['mobile']);
|
||||
unset($data['password']);
|
||||
unset($data['confirm_password']);
|
||||
unset($data['group_id']);
|
||||
$data['user_id'] = $create_user;
|
||||
$data['profile_pic'] = $upload_image['file_name'];
|
||||
$data['business_id'] = user()->business_id;
|
||||
@ -185,7 +188,7 @@ public function createEmp()
|
||||
$joining_month = date('m', strtotime($this->input->post('j_date')));
|
||||
$all_leave_count = $this->Emp_model->get_leave_type(user()->business_id);
|
||||
$joining_month_total = (12 - $joining_month) + 1 ;
|
||||
//echo $joining_month_total; die();
|
||||
|
||||
foreach ($all_leave_count as $key => $value) {
|
||||
|
||||
$remaining_days = ceil(((int)$value->days / 12) * $joining_month_total);
|
||||
@ -204,6 +207,22 @@ public function createEmp()
|
||||
}
|
||||
}
|
||||
|
||||
if($create_user == true)
|
||||
{
|
||||
for($i=0;$i<count($this->input->post('group_id'));$i++)
|
||||
{
|
||||
$group['emp_id']=$create_user;
|
||||
$group['business_id']=user()->business_id;
|
||||
$group['group_id']=$this->input->post('group_id')[$i];
|
||||
$group['is_active']=1;
|
||||
$this->MY_Model->insert($group,'group_membership');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//audit
|
||||
if($create_emp_details)
|
||||
{
|
||||
@ -263,7 +282,8 @@ public function add_employee_file()
|
||||
|
||||
|
||||
public function editEmployee($id)
|
||||
{
|
||||
{
|
||||
|
||||
$images = $this->Emp_model->get_data(user()->business_id , $id , 'employee_doc'); //984647 , 1
|
||||
$add_education = $this->Emp_model->get_data(user()->business_id , $id , 'employee_qualification');
|
||||
$employee_history = $this->Emp_model->get_data(user()->business_id , $id , 'employee_history');
|
||||
@ -281,6 +301,13 @@ public function editEmployee($id)
|
||||
);
|
||||
|
||||
$emp_sub_list_htmlPage = $this->load->view('emp_sub_list.php',$data,true);
|
||||
$get_group_list = $this->Emp_model->get_group_list(user()->business_id);
|
||||
$get_members_list = $this->Emp_model->get_members_list($id,user()->business_id);
|
||||
// print_r($get_group_list);
|
||||
// echo"<pre>";
|
||||
// print_r($get_members_list); die;
|
||||
$this->layout->set('get_members_list', $get_members_list);
|
||||
$this->layout->set('get_group_list', $get_group_list);
|
||||
$this->layout->set('manager', $manager);
|
||||
$this->layout->set('manager_name', $manager_name);
|
||||
$this->layout->set('departmentData', $this->MY_Model->select_by_department_data('department_master',user()->business_id));
|
||||
@ -329,6 +356,7 @@ public function editEmployees()
|
||||
unset($action['name']);
|
||||
unset($action['email']);
|
||||
unset($action['mobile']);
|
||||
unset($action['group_id']);
|
||||
|
||||
//file upload confic
|
||||
$config['upload_path'] = APPPATH. '../assets/uploads/';
|
||||
@ -349,6 +377,72 @@ public function editEmployees()
|
||||
}
|
||||
|
||||
$id = $this->input->post('id');
|
||||
$get_membership = $this->Emp_model->get_members_details($this->input->post('user_id'), user()->business_id);
|
||||
// print_r($get_membership); die();
|
||||
if(count($get_membership) != 0)
|
||||
{
|
||||
$DbData = [];
|
||||
foreach($get_membership as $key => $val){
|
||||
array_push($DbData,$val->group_id);
|
||||
}
|
||||
|
||||
if($this->input->post('group_id') == null)
|
||||
{
|
||||
$module_id_array = [];
|
||||
}else{
|
||||
$module_id_array = $this->input->post('group_id');
|
||||
}
|
||||
|
||||
// Find the values unique to array1 (not in array2)
|
||||
$differentValues1 = array_diff($module_id_array , $DbData);
|
||||
|
||||
// Find the values unique to array2 (not in array1)
|
||||
$differentValues2 = array_diff($DbData , $module_id_array);
|
||||
|
||||
// Merge the two results to get all the different values from both arrays
|
||||
$final_array = array_merge($differentValues1, $differentValues2);
|
||||
// echo "<pre>";
|
||||
// print_r($DbData); print_r($this->input->post('group_id')); print_r($final_array);
|
||||
// echo "<pre>";
|
||||
// die;
|
||||
|
||||
if(count($final_array) != 0)
|
||||
{
|
||||
foreach($final_array as $key => $value){
|
||||
$check_if_exist = $this->Emp_model->get_group_module_data_by_id($this->input->post('user_id') , $value);
|
||||
if($check_if_exist)
|
||||
{
|
||||
$this->Emp_model->delete_group_module_data_by_id($this->input->post('user_id') , $value);
|
||||
}else{
|
||||
$group['emp_id']=$this->input->post('user_id');
|
||||
$group['business_id']=user()->business_id;
|
||||
$group['group_id']=$value;
|
||||
$group['is_active']=1;
|
||||
$this->MY_Model->insert($group,'group_membership');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ for($i=0;$i<count($this->input->post('group_id'));$i++)
|
||||
{
|
||||
$group['emp_id']=$this->input->post('user_id');
|
||||
$group['business_id']=user()->business_id;
|
||||
$group['group_id']=$this->input->post('group_id')[$i];
|
||||
$group['is_active']=1;
|
||||
$this->MY_Model->insert($group,'group_membership');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//set id $ table name for audit history
|
||||
$this->audit->set('id',$this->input->post('id'));
|
||||
$this->audit->set('table',$table);
|
||||
@ -429,158 +523,5 @@ public function editEmp_history($id)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function expence_form()
|
||||
// {
|
||||
|
||||
// $this->layout->buffer('main_content', 'Employee/expence_form');
|
||||
// $this->layout->render('Employee_Layout');
|
||||
// }
|
||||
|
||||
// public function get_emp_name()
|
||||
// {
|
||||
// $emp = $this->Emp_model->get_employee_name(user()->business_id);
|
||||
// $html = '<option>--select Employee--</option>';
|
||||
// foreach($emp as $val)
|
||||
// {
|
||||
// if($val->user_id != user()->id)
|
||||
// {
|
||||
// $html .='<option id="'.$val->manager.'" value="'.$val->user_id.'">'.$val->name.'</option>';
|
||||
// }
|
||||
// }
|
||||
// echo json_encode($html);
|
||||
// }
|
||||
|
||||
// public function rise_expence_request()
|
||||
// {
|
||||
|
||||
// $data = $this->input->post();
|
||||
// unset($data['bill']);
|
||||
|
||||
|
||||
// //file upload confic
|
||||
// $config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
||||
// $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
|
||||
// $config['file_name'] = time();
|
||||
// $config['max_size'] = 80000;
|
||||
// //upload
|
||||
// $this->load->library('upload', $config);
|
||||
// $this->upload->initialize($config);
|
||||
// $this->upload->do_upload('bill');
|
||||
// if ( ! $this->upload->do_upload('bill'))
|
||||
// {
|
||||
// $error = array('error' => $this->upload->display_errors());
|
||||
// //print_r($error);
|
||||
|
||||
// } else{
|
||||
// $upload_image = $this->upload->data();
|
||||
// $data['bill'] = $upload_image['file_name'];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// if(isset($data['emp_id'])){
|
||||
// $emp_id =$this->input->post('emp_id');
|
||||
// }else{
|
||||
// $emp_id = user()->id;
|
||||
// }
|
||||
// $data['emp_id'] = $emp_id;
|
||||
// $data['business_id'] = user()->business_id;
|
||||
// $data['status'] = 'pending';
|
||||
// $data['created_at'] = date('Y-m-d H:i:s');
|
||||
// $data['is_active'] = 1;
|
||||
// // echo '<pre>';
|
||||
// // print_r($data); die();
|
||||
|
||||
|
||||
// $table="expence_list";
|
||||
// $create_leave = $this->MY_Model->insert($data,$table);
|
||||
|
||||
// redirect('Employee/expence_form');
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// public function expence_list()
|
||||
// {
|
||||
// $business_id = user()->business_id;
|
||||
// $expence_list = $this->Emp_model->get_expence_list($business_id);
|
||||
// // echo '<pre>';
|
||||
// // print_r($expence_list); die();
|
||||
// $decline_dropdown = $this->Emp_model->decline_dropdown($business_id);
|
||||
// $this->layout->set('tableData', $expence_list);
|
||||
// $this->layout->set('dropdown', $decline_dropdown);
|
||||
// $this->layout->buffer('main_content', 'Employee/expence_list');
|
||||
// $this->layout->render('Employee_Layout');
|
||||
// }
|
||||
|
||||
|
||||
// public function Approve_Expence()
|
||||
// {
|
||||
// $id=$this->input->get('id');
|
||||
// $action['status'] = 'Approved';
|
||||
// $action['approved_by']= user()->name;
|
||||
// $action['approved_at'] = date('d-m-Y H:i:s');
|
||||
// $table = "expence_list";
|
||||
// $this->MY_Model->edit_option($action, $id, $table);
|
||||
// redirect('Employee/expence_list');
|
||||
// }
|
||||
|
||||
// public function Manager_Approvel()
|
||||
// {
|
||||
// $id=$this->input->get('id');
|
||||
// $action['status'] = 'Approved';
|
||||
// $action['approved_by']= user()->name;
|
||||
// $action['approved_at'] = date('d-m-Y H:i:s');
|
||||
// $table = "expence_list";
|
||||
// $this->MY_Model->edit_option($action, $id, $table);
|
||||
// redirect('Employee/expence_list');
|
||||
// }
|
||||
|
||||
// public function Decline_expence()
|
||||
// {
|
||||
// $id=$this->input->get('id');
|
||||
// $data['status'] = 'Declined';
|
||||
// $data['declined_at'] = date('d-m-Y H:i:s');
|
||||
// $data['DReason'] = $this->input->get('reason');
|
||||
// $this->Leave_model->LeaveDecline($id, $data);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public function cancled_expence()
|
||||
// {
|
||||
// $id=$this->input->get('id');
|
||||
// $data['status'] = 'canceled';
|
||||
// $data['cancled_at'] = date('d-m-Y H:i:s');
|
||||
// $this->Leave_model->Leavecancle($id, $data);
|
||||
// redirect('Leave/LeaveHistory');
|
||||
// }
|
||||
|
||||
// public function expence_emp_list()
|
||||
// {
|
||||
// $expence_emp_list = $this->Leave_model->get_leave_with_emp_name(user()->business_id);
|
||||
// $this->layout->set('tableData', $expence_emp_list);
|
||||
// $this->layout->buffer('main_content', 'Leave/leavehistory');
|
||||
// $this->layout->render('Employee_Layout');
|
||||
// }
|
||||
|
||||
|
||||
// public function manager_approvel_list()
|
||||
// {
|
||||
// $business_id = user()->business_id;
|
||||
// $user_id = user()->id;
|
||||
// $manager = $this->Leave_model->under_emp_manager($user_id, $business_id);
|
||||
// $decline_dropdown = $this->Leave_model->decline_dropdown($business_id);
|
||||
// $leave_list = $this->Leave_model->get_with_emp_name(user()->business_id);
|
||||
// $this->layout->set('tableData', $leave_list);
|
||||
// $this->layout->set('manager', $manager);
|
||||
// $this->layout->buffer('main_content', 'Leave/manager_approvel');
|
||||
// $this->layout->render('Employee_Layout');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -112,4 +112,55 @@ public function get_modules($business_id)
|
||||
|
||||
}
|
||||
|
||||
public function get_group_list($business_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('groups');
|
||||
$this->db->where('business_id', $business_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function get_members_details($user_id, $business_id)
|
||||
{
|
||||
$this->db->select('group_id');
|
||||
$this->db->from('group_membership');
|
||||
$this->db->where('emp_id', $user_id);
|
||||
$this->db->where('business_id', $business_id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_members_list($id, $business_id)
|
||||
{
|
||||
$this->db->select('group_membership.*,groups.group_name');
|
||||
$this->db->from('group_membership');
|
||||
$this->db->join('groups', 'group_membership.group_id = groups.id and groups.is_active = 1', 'left');
|
||||
$this->db->where('md5(emp_id)', $id);
|
||||
$this->db->where('group_membership.business_id', $business_id);
|
||||
$this->db->where('group_membership.is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_group_module_data_by_id($id , $group_id = null)
|
||||
{
|
||||
$this->db->select('group_id');
|
||||
$this->db->from('group_membership');
|
||||
$this->db->where('emp_id', $id);
|
||||
if($group_id != null){ $this->db->where('group_id', $group_id); }
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
public function delete_group_module_data_by_id($user_id , $group_id )
|
||||
{
|
||||
$this->db->where('group_id', $group_id);
|
||||
$this->db->where('emp_id', $user_id);
|
||||
$this->db->delete('group_membership');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,128 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div class="">
|
||||
<div class="page-title">
|
||||
<div class="title_left"><h3>Add Employee</h3></div>
|
||||
@ -17,7 +139,7 @@
|
||||
<div class="clearfix"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 ">
|
||||
<div class="x_panel">
|
||||
|
||||
<!-- <div class="x_title">
|
||||
|
||||
<ul class="nav navbar-right panel_toolbox">
|
||||
@ -33,11 +155,11 @@
|
||||
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Personal Information<a style="color:red;">*</a> <i id="chevron1" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo" style="font-size:20px;"></i></h5>
|
||||
<div class="clearfix"></div>
|
||||
<h5>Personal Information<a style="color:red;">*</a>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo">
|
||||
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name<a style="color:red;">*</a> </label>
|
||||
@ -97,16 +219,6 @@
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Manager</label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="manager" name="manager" class="form-control">
|
||||
<option value="">--Select--</option>
|
||||
<?php foreach ($ModuleData as $key => $value) { ?>
|
||||
<option value="<?php echo $value->id;?>"><?php echo $value->modules;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Marital Status<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
@ -140,14 +252,11 @@
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Emergency Contact <i id="chevron2" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo1" style="font-size:20px;"></i></h5>
|
||||
<div class=""></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo1">
|
||||
<h5>Emergency Contact </h5>
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name</label>
|
||||
@ -176,12 +285,12 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Address Details <i id="chevron3" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo2" style="font-size:20px;"></i></h5>
|
||||
<div class="clearfix"></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo2">
|
||||
<h5>Address Details</h5>
|
||||
</div><br />
|
||||
|
||||
<div class="item form-group">
|
||||
|
||||
@ -212,16 +321,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------------------------------------------------->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Additional Information <i id="chevron4" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo3" style="font-size:20px;"></i></h5>
|
||||
<h5>Additional Information</h5>
|
||||
<div class="clearfix"></div>
|
||||
</div><br/>
|
||||
<div class="collapse" id="demo3">
|
||||
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Employee Id</label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input type="text" id="employee_id" name="emp_id" value="<?php if(isset($editData)) { echo $editData->name; } ?>" class="form-control ">
|
||||
<input type="text" id="employee_id" name="emp_id" value="<?php if(isset($editData)) { echo $editData->name; } ?>" class="form-control">
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="email"> Salary</label>
|
||||
@ -259,17 +369,36 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Permission</h5>
|
||||
<div class="clearfix"></div>
|
||||
</div><br/>
|
||||
|
||||
<div class="item form-group">
|
||||
|
||||
<div class="ln_solid"></div>
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Modules List<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="people" name="group_id[]" class="form-control select2_multiple" multiple >
|
||||
<?php foreach ($get_group_list as $key => $value) { ?>
|
||||
<option value="<?php echo $value->id; ?>"><?php echo $value->group_name; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="x_panel"><br>
|
||||
<div class="item form-group">
|
||||
<div class="offset-md-8">
|
||||
<a href="<?php echo base_url();?>Employee/empList" class="btn btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -383,3 +512,14 @@ function validateFile(input) {
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Get the select element
|
||||
var select = document.getElementById("module");
|
||||
|
||||
// Add event listener to handle checkbox selection
|
||||
select.addEventListener("change", function() {
|
||||
var selectedOptions = Array.from(this.selectedOptions).map(option => option.value);
|
||||
console.log(selectedOptions); // You can perform further operations with the selected values
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -6,6 +6,126 @@
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@ -40,12 +160,11 @@
|
||||
<input type="hidden" name="user_id" value="<?php echo $editData->user_id; ?>">
|
||||
|
||||
<div class="x_title">
|
||||
<h5>Personal Information<a style="color:red;">*</a> <i id="chevron1" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo" style="font-size:20px;"></i></h5>
|
||||
<h5>Personal Information<a style="color:red;">*</a></h5>
|
||||
<div class="clearfix"></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo">
|
||||
<div class="item form-group">
|
||||
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input type="text" id="name" name="name" value="<?php if(isset($editData)) { echo $editData->name; } ?>" required="required" class="form-control " onkeypress="validateKeyPress(event)">
|
||||
@ -143,11 +262,11 @@
|
||||
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Emergency Contact <i id="chevron2" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo1" style="font-size:20px;"></i></h5>
|
||||
<h5>Emergency Contact </h5>
|
||||
<div class=""></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo1">
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name</label>
|
||||
@ -177,11 +296,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Address Detail <i id="chevron2" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo2" style="font-size:20px;"></i></h5>
|
||||
<h5>Address Detail</h5>
|
||||
<div class=""></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo2">
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Address</label>
|
||||
@ -211,11 +330,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Additional Information <i id="chevron4" class="fa fa-chevron-circle-down" aria-hidden="true" data-toggle="collapse" data-target="#demo3" style="font-size:20px;"></i></h5>
|
||||
<h5>Additional Information</h5>
|
||||
<div class="clearfix"></div>
|
||||
</div><br />
|
||||
<div class="collapse" id="demo3">
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Employee Id</label>
|
||||
@ -249,33 +368,59 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- ----------------------------------------- -->
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h5>Permissions</h5>
|
||||
<div class=""></div>
|
||||
</div><br />
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Modules List<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="people" name="group_id[]" class="form-control select2_multiple" multiple >
|
||||
|
||||
<?php
|
||||
|
||||
$modulesArray = [];
|
||||
|
||||
foreach ($get_members_list as $object) {
|
||||
if (isset($object->group_name)) {
|
||||
$modulesArray[] = $object->group_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($get_group_list as $key => $data) { ?>
|
||||
<?php if(in_array($data->group_name, $modulesArray)) { ?>
|
||||
<option value="<?php echo $data->id; ?>" selected> <?php echo $data->group_name; ?> </option>
|
||||
<?php } else { ?>
|
||||
<option value="<?php echo $data->id; ?>"><?php echo $data->group_name;?> </option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="ln_solid"></div> -->
|
||||
<div class="x_panel"><br>
|
||||
<div class="item form-group">
|
||||
<div class=" offset-md-8">
|
||||
<a href="<?php echo base_url();?>Employee/empList" class="btn btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn btn-success">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
<div id="sub-value" class="col-md-12 col-sm-12">
|
||||
|
||||
@ -122,7 +122,7 @@ public function rise_expence_request()
|
||||
$table="expence_list";
|
||||
$create_leave = $this->MY_Model->insert($data,$table);
|
||||
|
||||
$this->session->set_flashdata('Create', 'Claim Request Rised Successfully');
|
||||
$this->session->set_flashdata('Create', '1');
|
||||
redirect('Expence/Emp_Expence_List');
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Action</h6>
|
||||
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Expense</h6>
|
||||
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -58,21 +58,23 @@
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
|
||||
<?php if ($this->session->userdata('update')): ?>
|
||||
<div class="alert-success flash-message" id="customPrompt" style="text-align: right;">
|
||||
<?php echo $this->session->userdata('update'); ?>
|
||||
<span onclick="$('#customPrompt').hide()" style="text-align: right;" ><i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $this->session->unset_userdata('update');?>
|
||||
<button hidden id="button" class="btn btn-secondary source" onclick="new PNotify({
|
||||
text: '<html><h2>Submmited for Approvel.<h2></html>',
|
||||
type: 'success',
|
||||
styling: 'bootstrap3'
|
||||
});">Success</button>
|
||||
<input type="hidden" id="error" value="<?php echo $this->session->userdata('Create');?>" >
|
||||
<?php $this->session->unset_userdata('Create');?>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
<?php if ($this->session->userdata('cancel')): ?>
|
||||
<div class="alert alert-dark flash-message" id="customPrompt" style="text-align: right;">
|
||||
<?php echo $this->session->userdata('cancel'); ?>
|
||||
<span onclick="$('#customPrompt').hide()" style="text-align: right;" ><i class="fa fa-times" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $this->session->unset_userdata('cancel');?>
|
||||
if($('#error').val() == 1 )
|
||||
{
|
||||
$('#button').click();
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<ul class="nav navbar-right panel_toolbox">
|
||||
|
||||
192
application/modules/Group/controllers/Group.php
Normal file
192
application/modules/Group/controllers/Group.php
Normal file
@ -0,0 +1,192 @@
|
||||
<?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');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
0
application/modules/Group/models/.gitkeep
Normal file
0
application/modules/Group/models/.gitkeep
Normal file
114
application/modules/Group/models/Group_model.php
Normal file
114
application/modules/Group/models/Group_model.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
class Group_model extends MY_Model {
|
||||
|
||||
public function get_group_access_modules($business_id)
|
||||
{
|
||||
$this->db->select('permit_modules.*,modules.modules');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->join('modules', 'permit_modules.module_id = modules.id and modules.is_active = 1', 'left');
|
||||
$this->db->where('uid', $business_id);
|
||||
$this->db->where('permit_modules.is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_Group_list($business_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('groups');
|
||||
$this->db->where('business_id', $business_id);
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_Group_module_list($business_id)
|
||||
{
|
||||
$this->db->select('group_permisssion.*,modules.modules');
|
||||
$this->db->from('group_permisssion');
|
||||
$this->db->join('modules', 'group_permisssion.module_id = modules.id and modules.is_active = 1', 'left');
|
||||
$this->db->where('group_permisssion.is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_group_module_data_by_md5_id($id)
|
||||
{
|
||||
$this->db->select('group_permisssion.*,modules.modules');
|
||||
$this->db->from('group_permisssion');
|
||||
$this->db->join('modules', 'group_permisssion.module_id = modules.id and modules.is_active = 1', 'left');
|
||||
$this->db->where('md5(group_permisssion.group_id)', $id);
|
||||
$this->db->where('group_permisssion.is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_group_module_data_by_id($id , $module_id = null)
|
||||
{
|
||||
$this->db->select('module_id');
|
||||
$this->db->from('group_permisssion');
|
||||
$this->db->where('group_id', $id);
|
||||
if($module_id != null){ $this->db->where('module_id', $module_id); }
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
public function delete_group_module_data_by_id($id , $module_id )
|
||||
{
|
||||
$this->db->where('group_id', $id);
|
||||
$this->db->where('module_id', $module_id);
|
||||
$this->db->delete('group_permisssion');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_group_data_by_md5_id($id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('groups');
|
||||
$this->db->where('md5(id)', $id);
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function delete_group($id, $business_id)
|
||||
{
|
||||
$this->db->where('md5(id)', $id);
|
||||
$this->db->where('business_id', $business_id);
|
||||
$this->db->set('is_active',0);
|
||||
$this->db->update('groups');
|
||||
return;
|
||||
}
|
||||
|
||||
public function delete_group_permission($id)
|
||||
{
|
||||
$this->db->where('md5(group_id)', $id);
|
||||
$this->db->set('is_active',0);
|
||||
$this->db->update('group_permisssion');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public function get_business_module_not_is_active($business_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('permit_modules');
|
||||
$this->db->where('uid', $business_id);
|
||||
$this->db->where('is_active', 0);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function updateModule($mdata, $uid, $table)
|
||||
{
|
||||
$this->db->where('uid', $uid);
|
||||
return $this->db->update($table, $mdata);
|
||||
}
|
||||
|
||||
}
|
||||
177
application/modules/Group/views/Create_Group.php
Normal file
177
application/modules/Group/views/Create_Group.php
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
<!-- Body page content -->
|
||||
|
||||
<script src="<?php echo base_url(); ?>/assets/default/jquery/dist/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div class="">
|
||||
<div class="page-title">
|
||||
|
||||
<div class="title_left">
|
||||
<h1>Create Group</h1>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 ">
|
||||
<div class="x_panel">
|
||||
<div class="x_content">
|
||||
<br />
|
||||
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Group/Create_Group" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Group Name<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input type="text" id="group_name" name="group_name" required="required" class="form-control ">
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Modules List<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="people" name="module_id[]" class="form-control" multiple required>
|
||||
<?php foreach ($access_modules as $key => $value) { ?>
|
||||
<option value="<?php echo $value->module_id; ?>"><?php echo $value->modules; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 col-sm-5 offset-md-1">
|
||||
<button class="btn btn-secondary" onclick="history.back()">Cancel</button>
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Body page content -->
|
||||
196
application/modules/Group/views/Edit_Group.php
Normal file
196
application/modules/Group/views/Edit_Group.php
Normal file
@ -0,0 +1,196 @@
|
||||
|
||||
<!-- Body page content -->
|
||||
|
||||
<script src="<?php echo base_url(); ?>/assets/default/jquery/dist/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>/assets/jquery.multi-select.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
$('#people').multiSelect();
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 2em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: block;
|
||||
margin-top:2px;
|
||||
width:100%;
|
||||
max-width: 100%!important;
|
||||
font-size: 0.875em;
|
||||
padding: 0.85em 0.6em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
right:5px;
|
||||
top:17px;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div class="">
|
||||
<div class="page-title">
|
||||
|
||||
<div class="title_left">
|
||||
<h1>Edit Group</h1>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 ">
|
||||
<div class="x_panel">
|
||||
<div class="x_content">
|
||||
<br />
|
||||
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Group/Edit_Group_list" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $Group_Data->id ?>">
|
||||
|
||||
|
||||
<div class="item form-group">
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Group Name<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input type="text" id="group_name" name="group_name" required="required" class="form-control " value="<?php echo $Group_Data->group_name ?>" >
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name">Modules List<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="people" name="module_id[]" class="form-control select2_multiple" multiple >
|
||||
|
||||
<?php
|
||||
|
||||
$modulesArray = [];
|
||||
|
||||
foreach ($Group_Module_Data as $object) {
|
||||
if (isset($object->modules)) {
|
||||
$modulesArray[] = $object->modules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($access_modules as $key => $data) { ?>
|
||||
<?php if(in_array($data->modules, $modulesArray)) { ?>
|
||||
<option value="<?php echo $data->module_id; ?>" selected> <?php echo $data->modules; ?> </option>
|
||||
<?php } else { ?>
|
||||
<option value="<?php echo $data->module_id; ?>"><?php echo $data->modules;?> </option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 col-sm-5 offset-md-1">
|
||||
<button class="btn btn-secondary" onclick="history.back()">Cancel</button>
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Body page content -->
|
||||
72
application/modules/Group/views/Group_list.php
Normal file
72
application/modules/Group/views/Group_list.php
Normal file
@ -0,0 +1,72 @@
|
||||
<head>
|
||||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
|
||||
</head>
|
||||
<div class="col-md-12 col-sm-12 ">
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h2>Group List</h2>
|
||||
|
||||
<ul class="nav navbar-right panel_toolbox">
|
||||
<a href="<?php echo base_url();?>Group/Create_Group_Form" class="btn btn-sm btn-primary">Add Group</a>
|
||||
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="x_content">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="card-box table-responsive">
|
||||
|
||||
<table id="datatable" class="table table-striped table-bordered dataTable no-footer" width="100%">
|
||||
<thead>
|
||||
<tr class="headings">
|
||||
<th class="column-title">Group Name</th>
|
||||
<th class="column-title">Modules </th>
|
||||
<th class="column-title" >Action </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tableData as $key => $value) { ?>
|
||||
|
||||
<tr class="even pointer">
|
||||
|
||||
<td class=" "> <?php echo $value->group_name; ?> </td>
|
||||
|
||||
<td class=" ">
|
||||
|
||||
|
||||
<?php
|
||||
$modules = array();
|
||||
foreach ($Group_module_list as $one => $val) {
|
||||
if($value->id == $val->group_id)
|
||||
$modules[] = $val->modules;
|
||||
} echo implode(" , ", $modules);
|
||||
?>
|
||||
</td>
|
||||
<td style=" text-align: center; font-size: 16px;">
|
||||
<a href="<?php echo base_url()?>Group/Edit_Group/<?php echo md5($value->id);?>"><i class="fa fa-pencil"></i></a>
|
||||
|
||||
<a href="<?php echo base_url()?>Group/delete_group/<?php echo md5($value->id);?>" ><i class="fa fa-trash"></i></a>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div style="display:none" id="sub-value">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
26
application/modules/Group/views/confirmation_popup.php
Normal file
26
application/modules/Group/views/confirmation_popup.php
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h6 class="modal-title" id="myModalLabel2">Are you sure you want to delete</h6>
|
||||
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
</br>
|
||||
<center>
|
||||
<form class="delete_url" method="post" action="" id="">
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
|
||||
|
||||
<input type="hidden" class="delete_id" name="id" value="">
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
|
||||
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button>
|
||||
</form>
|
||||
</center>
|
||||
</br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php if (is_admin() || is_user()) { ?>
|
||||
<?php if (is_admin() || is_user() || Employee_group()) { ?>
|
||||
<a class="dropdown-item" href="<?php echo base_url()?>Asset/masterDataList/">Masters</a>
|
||||
<?php } ?>
|
||||
<a class="dropdown-item" href="#">Settings</a>
|
||||
|
||||
@ -50,7 +50,40 @@
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<?php if(check_auth() && is_admin() || is_user() ) { ?>
|
||||
|
||||
<?php if(check_auth() && is_superadmin() ) { ?>
|
||||
<li><a><i class="fa fa-archive"></i> Business <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Business/business_list">Business List</a></li>
|
||||
<li><a href="<?php echo base_url();?>Business/add_business">Add Business</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if(check_auth() && is_superadmin() ) { ?>
|
||||
|
||||
<li><a><i class="fa fa-user"></i> Module <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Business/module_list">Module List</a></li>
|
||||
<li><a href="<?php echo base_url();?>Business/add_module">Add Module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(check_auth() && is_admin() ) { ?>
|
||||
|
||||
<li><a><i class="fa fa-user"></i>Group <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Group/Group_list">Group List</a></li>
|
||||
<li><a href="<?php echo base_url();?>Group/Create_Group_Form">Add Group</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php if(check_auth() && is_admin() && Asset_module() || Employee_group() ) { ?>
|
||||
<li><a><i class="fa fa-university"></i> Assets <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Asset/assetLandingPage">Assets List</a></li>
|
||||
@ -59,40 +92,23 @@
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if(check_auth() && is_superadmin() ) { ?>
|
||||
<li><a><i class="fa fa-archive"></i> Business <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Business/business_list">Business List</a></li>
|
||||
<li><a href="<?php echo base_url();?>Business/add_business">Add Business</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php if(check_auth() && is_admin() || is_superadmin() || is_user() ) { ?>
|
||||
<li><a><i class="fa fa-user"></i> Users <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Business/userList">Users List</a></li>
|
||||
<li><a href="<?php echo base_url();?>User/userList">Users List</a></li>
|
||||
<?php if(user()->action_permit != 'view' ) { ?>
|
||||
<li><a href="<?php echo base_url();?>User/addUser">Add Users</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(check_auth() && is_superadmin() ) { ?>
|
||||
|
||||
<li><a><i class="fa fa-user"></i> Module <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Business/module_list">Module List</a></li>
|
||||
<li><a href="<?php echo base_url();?>Business/add_module">Add Module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php if(check_auth() && is_admin() || is_user() ) { ?>
|
||||
<?php if(check_auth() && is_admin() && Asset_module()) { ?>
|
||||
<li><a><i class="fa fa-clipboard"></i> Reports <span class="fa fa-chevron-down"></span></a>
|
||||
<ul class="nav child_menu">
|
||||
<li><a href="<?php echo base_url();?>Asset/depreciation_report">Depreciation Reports</a></li>
|
||||
@ -102,11 +118,14 @@
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php if(check_auth() && is_admin() || is_user() ) { ?>
|
||||
|
||||
<br><br>
|
||||
<h3>Employee</h3>
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
<li><a href="<?php echo base_url();?>Employee/empList"><i class="fa fa-group"></i> Employee</a></li>
|
||||
|
||||
@ -45,6 +45,14 @@
|
||||
<ul class="nav side-menu">
|
||||
<li><a href="<?php echo base_url();?>Auth/"><i class="fa fa-home"></i> Home </a>
|
||||
</li>
|
||||
|
||||
<?php if(check_auth() && Employee_group()) { ?>
|
||||
<li><a href="<?php echo base_url();?>Asset/assetLandingPage" ><i class="fa fa-university"></i> Assets <span class="fa fa-chevron-down"></span></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- <?php if(check_auth() && Employee_group()) { ?>
|
||||
<li><a href="<?php echo base_url();?>Asset/depreciation_report" ><i class="fa fa-clipboard"></i> Reports <span class="fa fa-chevron-down"></span></a></li>
|
||||
<?php } ?> -->
|
||||
|
||||
|
||||
<?php if(check_auth() && is_admin() || is_superadmin() || is_user() ) { ?>
|
||||
|
||||
114
assets/demo-styles.css
Normal file
114
assets/demo-styles.css
Normal file
@ -0,0 +1,114 @@
|
||||
*, *:before, *:after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
*, body, button, input, textarea, select {
|
||||
text-rendering: optimizeLegibility;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse:collapse;
|
||||
border-spacing:0;
|
||||
}
|
||||
|
||||
fieldset,img {
|
||||
border:0;
|
||||
}
|
||||
|
||||
address,caption,cite,code,dfn,em,strong,th,var {
|
||||
font-style:normal;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
ol,ul {
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
caption,th {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-size:100%;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
q:before,q:after {
|
||||
content:'';
|
||||
}
|
||||
|
||||
abbr,acronym {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.4;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.demo-example {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.demo-example > label {
|
||||
display: block;
|
||||
margin-bottom: 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.position-menu-within {
|
||||
width: 18em;
|
||||
height: 15em;
|
||||
background: #eee;
|
||||
overflow: auto;
|
||||
padding: 2em 0 0 2em;
|
||||
}
|
||||
|
||||
.modal-example .multi-select-menu {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
max-height: 50%;
|
||||
min-width: 0;
|
||||
overflow: auto;
|
||||
border: none;
|
||||
border-radius: 0.3em;
|
||||
box-shadow: 0 1em 3em rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.modal-example .multi-select-menuitem {
|
||||
font-size: 1em;
|
||||
padding: 1.5em 2.5em 1.5em 3.5em;
|
||||
}
|
||||
|
||||
.modal-example .multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.modal-example .multi-select-menuitem input {
|
||||
margin-left: -2.5em;
|
||||
}
|
||||
|
||||
.multi-select-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-modal {
|
||||
display: block;
|
||||
}
|
||||
107
assets/example-styles.css
Normal file
107
assets/example-styles.css
Normal file
@ -0,0 +1,107 @@
|
||||
.multi-select-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.multi-select-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0.8em;
|
||||
z-index: 1;
|
||||
float: left;
|
||||
min-width: 100%;
|
||||
background: #fff;
|
||||
margin: 1em 0;
|
||||
border: 1px solid #aaa;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.multi-select-menuitem {
|
||||
display: block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.6em 1em 0.6em 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titled:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
margin: 0 0 0.25em -20px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem--titledsr:before {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
content: attr(data-group-title);
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.multi-select-menuitem + .multi-select-menuitem {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.multi-select-presets {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.multi-select-menuitem input {
|
||||
position: absolute;
|
||||
margin-top: 0.25em;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
.multi-select-button {
|
||||
display: inline-block;
|
||||
font-size: 0.875em;
|
||||
padding: 0.2em 0.6em;
|
||||
max-width: 16em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: -0.5em;
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.multi-select-button:after {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.4em 0.4em 0 0.4em;
|
||||
border-color: #999 transparent transparent transparent;
|
||||
margin-left: 0.4em;
|
||||
vertical-align: 0.1em;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.multi-select-container--open .multi-select-button:after {
|
||||
border-width: 0 0.4em 0.4em 0.4em;
|
||||
border-color: transparent transparent #999 transparent;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu {
|
||||
/* Avoid border/padding on menu messing with JavaScript width calculation */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.multi-select-container--positioned .multi-select-menu label {
|
||||
/* Allow labels to line wrap when menu is artificially narrowed */
|
||||
white-space: normal;
|
||||
}
|
||||
4
assets/jquery-2.2.4.min.js
vendored
Normal file
4
assets/jquery-2.2.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
452
assets/jquery.multi-select.js
Normal file
452
assets/jquery.multi-select.js
Normal file
@ -0,0 +1,452 @@
|
||||
// jquery.multi-select.js
|
||||
// by mySociety
|
||||
// https://github.com/mysociety/jquery-multi-select
|
||||
|
||||
;(function($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var pluginName = "multiSelect",
|
||||
defaults = {
|
||||
'containerHTML': '<div class="multi-select-container">',
|
||||
'menuHTML': '<div class="multi-select-menu">',
|
||||
'buttonHTML': '<span class="multi-select-button">',
|
||||
'menuItemsHTML': '<div class="multi-select-menuitems">',
|
||||
'menuItemHTML': '<label class="multi-select-menuitem">',
|
||||
'presetsHTML': '<div class="multi-select-presets">',
|
||||
'modalHTML': undefined,
|
||||
'menuItemTitleClass': 'multi-select-menuitem--titled',
|
||||
'activeClass': 'multi-select-container--open',
|
||||
'noneText': '-- Select --',
|
||||
'allText': undefined,
|
||||
'presets': undefined,
|
||||
'positionedMenuClass': 'multi-select-container--positioned',
|
||||
'positionMenuWithin': undefined,
|
||||
'viewportBottomGutter': 20,
|
||||
'menuMinHeight': 200
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function MultiSelect(element, options) {
|
||||
this.element = element;
|
||||
this.$element = $(element);
|
||||
this.settings = $.extend( {}, defaults, options );
|
||||
this._defaults = defaults;
|
||||
this._name = pluginName;
|
||||
this.init();
|
||||
}
|
||||
|
||||
function arraysAreEqual(array1, array2) {
|
||||
if ( array1.length != array2.length ){
|
||||
return false;
|
||||
}
|
||||
|
||||
array1.sort();
|
||||
array2.sort();
|
||||
|
||||
for ( var i = 0; i < array1.length; i++ ){
|
||||
if ( array1[i] !== array2[i] ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$.extend(MultiSelect.prototype, {
|
||||
|
||||
init: function() {
|
||||
this.checkSuitableInput();
|
||||
this.findLabels();
|
||||
this.constructContainer();
|
||||
this.constructButton();
|
||||
this.constructMenu();
|
||||
this.constructModal();
|
||||
|
||||
this.setUpBodyClickListener();
|
||||
this.setUpLabelsClickListener();
|
||||
|
||||
this.hideOriginalElement();
|
||||
},
|
||||
|
||||
checkSuitableInput: function(text) {
|
||||
if ( this.$element.is('select[multiple]') === false ) {
|
||||
throw new Error('$.multiSelect only works on <select multiple> elements');
|
||||
}
|
||||
},
|
||||
|
||||
findLabels: function() {
|
||||
this.$labels = $('label[for="' + this.$element.attr('id') + '"]');
|
||||
},
|
||||
|
||||
constructContainer: function() {
|
||||
this.$container = $(this.settings['containerHTML']);
|
||||
this.$element.data('multi-select-container', this.$container);
|
||||
this.$container.insertAfter(this.$element);
|
||||
},
|
||||
|
||||
constructButton: function() {
|
||||
var _this = this;
|
||||
this.$button = $(this.settings['buttonHTML']);
|
||||
this.$button.attr({
|
||||
'role': 'button',
|
||||
'aria-haspopup': 'true',
|
||||
'tabindex': 0,
|
||||
'aria-label': this.$labels.eq(0).text()
|
||||
})
|
||||
.on('keydown.multiselect', function(e) {
|
||||
var key = e.which;
|
||||
var returnKey = 13;
|
||||
var escapeKey = 27;
|
||||
var spaceKey = 32;
|
||||
var downArrow = 40;
|
||||
if ((key === returnKey) || (key === spaceKey)) {
|
||||
e.preventDefault();
|
||||
_this.$button.click();
|
||||
} else if (key === downArrow) {
|
||||
e.preventDefault();
|
||||
_this.menuShow();
|
||||
var group = _this.$presets || _this.$menuItems;
|
||||
group.children().first().focus();
|
||||
} else if (key === escapeKey) {
|
||||
_this.menuHide();
|
||||
}
|
||||
}).on('click.multiselect', function(e) {
|
||||
_this.menuToggle();
|
||||
}).on('blur.multiselect', this.checkBlur.bind(this))
|
||||
.appendTo(this.$container);
|
||||
|
||||
this.$element.on('change.multiselect', function() {
|
||||
_this.updateButtonContents();
|
||||
});
|
||||
|
||||
this.updateButtonContents();
|
||||
},
|
||||
|
||||
updateButtonContents: function() {
|
||||
var _this = this;
|
||||
var options = [];
|
||||
var selected = [];
|
||||
|
||||
this.$element.find('option').each(function() {
|
||||
var text = /** @type string */ ($(this).text());
|
||||
options.push(text);
|
||||
if ($(this).is(':selected')) {
|
||||
selected.push( $.trim(text) );
|
||||
}
|
||||
});
|
||||
|
||||
this.$button.empty();
|
||||
|
||||
if (selected.length == 0) {
|
||||
this.$button.text( this.settings['noneText'] );
|
||||
} else if ( (selected.length === options.length) && this.settings['allText']) {
|
||||
this.$button.text( this.settings['allText'] );
|
||||
} else {
|
||||
this.$button.text( selected.join(', ') );
|
||||
}
|
||||
},
|
||||
|
||||
constructMenu: function() {
|
||||
var _this = this;
|
||||
|
||||
this.$menu = $(this.settings['menuHTML']);
|
||||
this.$menu.attr({
|
||||
'role': 'menu'
|
||||
}).on('keyup.multiselect', function(e){
|
||||
var key = e.which;
|
||||
var escapeKey = 27;
|
||||
if (key === escapeKey) {
|
||||
_this.menuHide();
|
||||
_this.$button.focus();
|
||||
}
|
||||
})
|
||||
.appendTo(this.$container);
|
||||
|
||||
this.constructMenuItems();
|
||||
|
||||
if ( this.settings['presets'] ) {
|
||||
this.constructPresets();
|
||||
}
|
||||
},
|
||||
|
||||
constructMenuItems: function() {
|
||||
var _this = this;
|
||||
|
||||
this.$menuItems = $(this.settings['menuItemsHTML']);
|
||||
this.$menu.append(this.$menuItems);
|
||||
|
||||
this.$element.on('change.multiselect', function(e, internal) {
|
||||
// Don't need to update the menu items if this
|
||||
// change event was fired by our tickbox handler.
|
||||
if(internal !== true){
|
||||
_this.updateMenuItems();
|
||||
}
|
||||
});
|
||||
|
||||
this.updateMenuItems();
|
||||
},
|
||||
|
||||
updateMenuItems: function() {
|
||||
var _this = this;
|
||||
this.$menuItems.empty();
|
||||
|
||||
this.$element.children('optgroup,option').each(function(index, element) {
|
||||
var $item;
|
||||
if (element.nodeName === 'OPTION') {
|
||||
$item = _this.constructMenuItem($(element), index);
|
||||
_this.$menuItems.append($item);
|
||||
} else {
|
||||
_this.constructMenuItemsGroup($(element), index);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
upDown: function(type, e) {
|
||||
var key = e.which;
|
||||
var upArrow = 38;
|
||||
var downArrow = 40;
|
||||
|
||||
if (key === upArrow) {
|
||||
e.preventDefault();
|
||||
var prev = $(e.currentTarget).prev();
|
||||
if (prev.length) {
|
||||
prev.focus();
|
||||
} else if (this.$presets && type === 'menuitem') {
|
||||
this.$presets.children().last().focus();
|
||||
} else {
|
||||
this.$button.focus();
|
||||
}
|
||||
} else if (key === downArrow) {
|
||||
e.preventDefault();
|
||||
var next = $(e.currentTarget).next();
|
||||
if (next.length || type === 'menuitem') {
|
||||
next.focus();
|
||||
} else {
|
||||
this.$menuItems.children().first().focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
constructPresets: function() {
|
||||
var _this = this;
|
||||
this.$presets = $(this.settings['presetsHTML']);
|
||||
this.$menu.prepend(this.$presets);
|
||||
|
||||
$.each(this.settings['presets'], function(i, preset){
|
||||
var unique_id = _this.$element.attr('name') + '_preset_' + i;
|
||||
var $item = $(_this.settings['menuItemHTML'])
|
||||
.attr({
|
||||
'for': unique_id,
|
||||
'role': 'menuitem'
|
||||
})
|
||||
.text(' ' + preset.name)
|
||||
.on('keydown.multiselect', _this.upDown.bind(_this, 'preset'))
|
||||
.appendTo(_this.$presets);
|
||||
|
||||
var $input = $('<input>')
|
||||
.attr({
|
||||
'type': 'radio',
|
||||
'name': _this.$element.attr('name') + '_presets',
|
||||
'id': unique_id
|
||||
})
|
||||
.prependTo($item);
|
||||
|
||||
if (preset.all) {
|
||||
preset.options = [];
|
||||
_this.$element.find('option').each(function() {
|
||||
var val = $(this).val();
|
||||
preset.options.push(val);
|
||||
});
|
||||
}
|
||||
|
||||
$input.on('change.multiselect', function(){
|
||||
_this.$element.val(preset.options);
|
||||
_this.$element.trigger('change');
|
||||
}).on('blur.multiselect', _this.checkBlur.bind(_this));
|
||||
});
|
||||
|
||||
this.$element.on('change.multiselect', function() {
|
||||
_this.updatePresets();
|
||||
});
|
||||
|
||||
this.updatePresets();
|
||||
},
|
||||
|
||||
updatePresets: function() {
|
||||
var _this = this;
|
||||
|
||||
$.each(this.settings['presets'], function(i, preset){
|
||||
var unique_id = _this.$element.attr('name') + '_preset_' + i;
|
||||
var $input = _this.$presets.find('#' + unique_id);
|
||||
|
||||
if ( arraysAreEqual(preset.options || [], _this.$element.val() || []) ){
|
||||
$input.prop('checked', true);
|
||||
} else {
|
||||
$input.prop('checked', false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
constructMenuItemsGroup: function($optgroup, optgroup_index) {
|
||||
var _this = this;
|
||||
|
||||
$optgroup.children('option').each(function(option_index, option) {
|
||||
var $item = _this.constructMenuItem($(option), optgroup_index + '_' + option_index);
|
||||
var cls = _this.settings['menuItemTitleClass'];
|
||||
if (option_index !== 0) {
|
||||
cls += 'sr';
|
||||
}
|
||||
$item.addClass(cls).attr('data-group-title', $optgroup.attr('label'));
|
||||
_this.$menuItems.append($item);
|
||||
});
|
||||
},
|
||||
|
||||
constructMenuItem: function($option, option_index) {
|
||||
var unique_id = this.$element.attr('name') + '_' + option_index;
|
||||
var $item = $(this.settings['menuItemHTML'])
|
||||
.attr({
|
||||
'for': unique_id,
|
||||
'role': 'menuitem'
|
||||
})
|
||||
.on('keydown.multiselect', this.upDown.bind(this, 'menuitem'))
|
||||
.text(' ' + $option.text());
|
||||
|
||||
var $input = $('<input>')
|
||||
.attr({
|
||||
'type': 'checkbox',
|
||||
'id': unique_id,
|
||||
'value': $option.val()
|
||||
})
|
||||
.prependTo($item);
|
||||
|
||||
if ( $option.is(':disabled') ) {
|
||||
$input.attr('disabled', 'disabled');
|
||||
}
|
||||
if ( $option.is(':selected') ) {
|
||||
$input.prop('checked', 'checked');
|
||||
}
|
||||
|
||||
$input.on('change.multiselect', function() {
|
||||
if ($(this).prop('checked')) {
|
||||
$option.prop('selected', true);
|
||||
} else {
|
||||
$option.prop('selected', false);
|
||||
}
|
||||
|
||||
// .prop() on its own doesn't generate a change event.
|
||||
// Other plugins might want to do stuff onChange.
|
||||
$option.trigger('change', [true]);
|
||||
}).on('blur.multiselect', this.checkBlur.bind(this));
|
||||
|
||||
return $item;
|
||||
},
|
||||
|
||||
constructModal: function() {
|
||||
var _this = this;
|
||||
|
||||
if (this.settings['modalHTML']) {
|
||||
this.$modal = $(this.settings['modalHTML']);
|
||||
this.$modal.on('click.multiselect', function(){
|
||||
_this.menuHide();
|
||||
})
|
||||
this.$modal.insertBefore(this.$menu);
|
||||
}
|
||||
},
|
||||
|
||||
setUpBodyClickListener: function() {
|
||||
var _this = this;
|
||||
|
||||
// Hide the $menu when you click outside of it.
|
||||
$('html').on('click.multiselect', function(){
|
||||
_this.menuHide();
|
||||
});
|
||||
|
||||
// Stop click events from inside the $button or $menu from
|
||||
// bubbling up to the body and closing the menu!
|
||||
this.$container.on('click.multiselect', function(e){
|
||||
e.stopPropagation();
|
||||
});
|
||||
},
|
||||
|
||||
setUpLabelsClickListener: function() {
|
||||
var _this = this;
|
||||
this.$labels.on('click.multiselect', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
_this.menuToggle();
|
||||
});
|
||||
},
|
||||
|
||||
hideOriginalElement: function() {
|
||||
this.$element.hide();
|
||||
this.$labels.removeAttr('for');
|
||||
},
|
||||
|
||||
menuShow: function() {
|
||||
$('html').trigger('click.multiselect'); // Close any other open menus
|
||||
this.$container.addClass(this.settings['activeClass']);
|
||||
|
||||
if ( this.settings['positionMenuWithin'] && this.settings['positionMenuWithin'] instanceof $ ) {
|
||||
var menuLeftEdge = this.$menu.offset().left + this.$menu.outerWidth();
|
||||
var withinLeftEdge = this.settings['positionMenuWithin'].offset().left +
|
||||
this.settings['positionMenuWithin'].outerWidth();
|
||||
|
||||
if ( menuLeftEdge > withinLeftEdge ) {
|
||||
this.$menu.css( 'width', (withinLeftEdge - this.$menu.offset().left) );
|
||||
this.$container.addClass(this.settings['positionedMenuClass']);
|
||||
}
|
||||
}
|
||||
|
||||
var menuBottom = this.$menu.offset().top + this.$menu.outerHeight();
|
||||
var viewportBottom = $(window).scrollTop() + $(window).height();
|
||||
if ( menuBottom > viewportBottom - this.settings['viewportBottomGutter'] ) {
|
||||
this.$menu.css({
|
||||
'maxHeight': Math.max(
|
||||
viewportBottom - this.settings['viewportBottomGutter'] - this.$menu.offset().top,
|
||||
this.settings['menuMinHeight']
|
||||
),
|
||||
'overflow': 'scroll'
|
||||
});
|
||||
} else {
|
||||
this.$menu.css({
|
||||
'maxHeight': '',
|
||||
'overflow': ''
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
menuHide: function() {
|
||||
this.$container.removeClass(this.settings['activeClass']);
|
||||
this.$container.removeClass(this.settings['positionedMenuClass']);
|
||||
this.$menu.css('width', 'auto');
|
||||
},
|
||||
|
||||
menuToggle: function() {
|
||||
if ( this.$container.hasClass(this.settings['activeClass']) ) {
|
||||
this.menuHide();
|
||||
} else {
|
||||
this.menuShow();
|
||||
}
|
||||
},
|
||||
|
||||
checkBlur: function(e) {
|
||||
if (e.relatedTarget && !$(e.relatedTarget).closest(this.$container).length) {
|
||||
this.menuHide();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$.fn[ pluginName ] = function(options) {
|
||||
return this.each(function() {
|
||||
if ( !$.data(this, "plugin_" + pluginName) ) {
|
||||
$.data(this, "plugin_" + pluginName,
|
||||
new MultiSelect(this, options) );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
Loading…
Reference in New Issue
Block a user