bb_sign/app/Views/staff_list.php
2024-06-01 17:23:06 +05:30

142 lines
5.8 KiB
PHP

<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<div class="content-page">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Staff List</h4>
<div class="page-title-right">
<a href="<?= base_url('staff_create'); ?>" class="btn btn-primary waves-effect waves-light">
Create Staff
</a>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttonss" class="table table-striped dt-responsive nowrap w-100">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
<th>Role</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($staffList as $key => $value) { ?>
<tr>
<td> <?php echo $value['name']; ?></td>
<td><?php echo $value['email']; ?></td>
<td><?php echo $value['mobile_no']; ?></td>
<td><?php echo $value['role']; ?></td>
<td>
<?php if($value['is_active'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url()."staff_edit?staff_id=".md5($value['staff_id']); ?>" ><i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['staff_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="ri-user-line"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['staff_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="ri-user-line" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div> <!-- container -->
</div> <!-- content -->
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
<script>
$(document).ready(function() {
$('#datatable-buttonss').DataTable({
"ordering": false
});
});
function statusChange(params) {
var status = params.getAttribute('data-isactive');
var staff_id = params.getAttribute('data-id');
if(status == 1){
var is_active= 0;
}else{
var is_active= 1;
}
var formData = {
staff_id: staff_id,
is_active: is_active
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_staff"?>',
data: formData,
dataType: 'json',
success: function(response) {
if (response.data) {
window.location.reload();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>