143 lines
7.1 KiB
PHP
143 lines
7.1 KiB
PHP
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="float-right">
|
|
<a href="<?= base_url()."user_page/0/0"; ?>" class="btn btn-primary"><i class="ri-user-add-line"></i> Add User </a>
|
|
</div><!-- end col-->
|
|
<br>
|
|
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
|
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
|
<?php if (session()->getFlashdata('success')) : ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<?= session('success') ?>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (session()->getFlashdata('error')) : ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<?= session('error') ?>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<div class="table-responsive">
|
|
<!-- <table id="datatable-buttons" class="table dt-responsive w-100"> -->
|
|
<table id="scroll-horizontal-datatable_user" class="table w-100 nowrap">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th hidden ></th>
|
|
<th>Name</th>
|
|
<?php if($loged_user === 'sadmin'){ ?>
|
|
<th>Org Name</th>
|
|
<?php } ?>
|
|
<th>Branch</th>
|
|
<th>Email</th>
|
|
<th>Mobile Number</th>
|
|
<th>Role</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
<?php foreach ($details as $row):
|
|
if ($row['isactive']) {
|
|
$class = 'badge badge-soft-success';
|
|
$message = 'Active';
|
|
} else {
|
|
$class = 'badge badge-soft-danger';
|
|
$message = 'In-Active';
|
|
}
|
|
$edit_page_route = base_url()."user_page/".$row['user_id']."/0";
|
|
$addressParts = array(
|
|
$row['address'],
|
|
$row['city'],
|
|
$row['state'].($row['postal_code'] ? "-".$row['postal_code'] : "")
|
|
);
|
|
// echo implode(', ', array_filter($addressParts)) . '.';
|
|
?>
|
|
<tr>
|
|
<td hidden><?= $row['user_id'] ?></td>
|
|
<td><?php echo $row['first_name'].' '.$row['last_name'] ; ?></td>
|
|
<?php if($loged_user === 'sadmin'){ ?>
|
|
<td><?php echo $row['org_name'] ; ?></td>
|
|
<?php } ?>
|
|
<td><?php echo $row['branch_name'] ; ?></td>
|
|
<td><?php echo $row['email'] ; ?></td>
|
|
<td><?php echo $row['mobile_no'] ; ?></td>
|
|
<td><?php echo ucfirst($row['role']) ; ?></td>
|
|
<td>
|
|
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
|
|
</td>
|
|
<td>
|
|
<a href="<?= $edit_page_route; ?>" class="edit-button" title="Click to Edit User" ><i class="ri-pencil-line"></i></a>
|
|
<?php if(get_user_role() != 'auditor') {
|
|
if($row['isactive'] == 1) { ?>
|
|
<a href="#" class="delete-button" data-user-id="<?php echo $row['user_id']; ?>" title="Click to In-Active User"><i class="ri-delete-bin-line"></i></a>
|
|
<?php } else {?>
|
|
<a href="<?php echo "activate_user/".$row['user_id']; ?>" class="fe-user-check" title="Click to Active User" ></a>
|
|
<?php }
|
|
}?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
<!-- end row-->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#scroll-horizontal-datatable_user').DataTable({
|
|
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
|
|
// Other DataTables configuration options
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('.delete-button').click(function(event) {
|
|
event.preventDefault();
|
|
var user_id = $(this).data('user-id');
|
|
Swal.fire({
|
|
title: "Are you sure?",
|
|
text: "You won't be able to revert this!",
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Yes, delete it!"
|
|
}).then(function(result) {
|
|
if (result.value) {
|
|
$.ajax({
|
|
url: "<?= base_url('delete_user/') ?>" + user_id,
|
|
method: 'GET',
|
|
success: function(response) {
|
|
console.log(response);
|
|
if(response && response.status){
|
|
Swal.fire("Deleted!", response.message, "success");
|
|
location.reload();
|
|
} else {
|
|
Swal.fire("Error!", response ? response.message : "An error occurred while deleting the file.", "error");
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr, status, error);
|
|
Swal.fire("Error!", "An error occurred while deleting the file.", "error");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|