BBnepal-Accounts/application/views/admin/roles.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

171 lines
5.1 KiB
PHP

<main class="wraper responsive-width" id="main">
<div class="from-group adding-class form-group_lng form-group_full-width ">
<a href="<?php echo base_url() . 'admin/roles/ae-role/0' ?>"><button type="button" class="btn btn-success btn-sm">Add New Role</button></a>
</div>
<!----admin template section---->
<div class="admin_tempblock form-group_full-width">
<div class="admin_tempsec">
<div class="admin_sec">
<form>
<div class="subsec_sec ">
<div class="subject_r subject_r_lng">
<div class="subject_lsec">
<div class="subject_lhead">Roles List</div>
<?php if($this->session->flashdata('success')) { ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<p><?php echo $this->session->flashdata('success') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<?php if($this->session->flashdata('failed')) { ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<p><?php echo $this->session->flashdata('failed') ?></p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
</div>
<div class="">
<table id="tbl" class="display table-responsive">
<thead>
<tr>
<th>Sl.No</th>
<th>Role</th>
<th>Permissions</th>
<th>Status</th>
<th>Created On</th>
<th>Modified On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach($result as $key => $value) {
$createdDate = date(MY_DATE_FORMAT, strtotime($value['created']));
$modifiedDate = $value['modified'] == null ? '-' : date(MY_DATE_FORMAT, strtotime($value['modified']));
$updated_menu_str = str_replace(',', ' OR id = ', $value['menu_ids']??'');
$where = 'id = '. $updated_menu_str;
$CI = &get_instance();
$CI->load->model('Admin_model');
$get_roles = $CI->Admin_model->get_table_info('admin_menu',$where);
$rolesArr = array_column($get_roles, 'menu_name');
$roles = implode('<br>', $rolesArr);
// $roles = count($rolesArr) == 19 ? 'All' : implode('<br>', $rolesArr);
?>
<tr>
<td><?php echo $key + 1 ?></td>
<td><?php echo ucfirst($value['role_name']) ?></td>
<td><?php echo $roles ?></td>
<td><?php echo ucfirst($value['status']) ?></td>
<td><?php echo $createdDate ?></td>
<td><?php echo $modifiedDate ?></td>
<td>
<div class="sub_tabbtnsec">
<div class="sub_editbtn"><a href="<?php echo base_url() ?>admin/roles/ae-role/<?php echo $value['id'] ?>"><i class="fas fa-pencil-alt"></i></a></div>
<?php
if($value['can_delete'] == 'Yes') { ?>
<a data-toggle="modal" onclick = "adminroledel(<?php echo $value['id'] ?>)" href="#deleteModal">
<div class="sub_delbtn" >
<i class="fa fa-trash" aria-hidden="true"></i>
</div>
</a>
<?php } ?>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!----admin template section end---->
</main>
<!--End right-top side-->
<div class="viewDoc delete-modal-wrap">
<div class="modal fade" id="deleteModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<div class="delete-modal">
<i class="far fa-times-circle"></i>
<input type = "hidden" id = "btid" />
<h4>Are you sure?</h4>
<p><?php echo str_replace('%s', 'Role', THE_DELETE_ALERT_MSG) ?></p>
<div class="delete-modal-btn">
<a onclick="deletedata($('#btid').val());" class="text-white subject_addbtn subject_addbtn_red">Delete</a>
<button type="button" class="subject_addbtn subject_addbtn_cancel" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.user-drpdown').click(function(){
$('.drpdown-items').toggle();
});
//table js
$('#tbl').DataTable( {
"lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]]
} );
//table js end
});
</script>
<script type="text/javascript">
function adminroledel(icn){
// alert(icn);
$('#btid').val(icn);
}
function deletedata(id){
let url = window.location.pathname.split( '/' );
let postUrl = url[1] +'/'+ url[2];
// console.log('admin/delete-section/'+postUrl + id);
window.location.replace('<?php echo base_url() ?>' + 'admin/delete_role/' + id);
}
</script>