225 lines
9.1 KiB
PHP
225 lines
9.1 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="staff_table" 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>
|
||
<a class="dropdown-item" data-toggle="modal" data-target="#staff_business_list_modal" href="#" onclick="view_business(<?= $value['staff_id'] ?>)"><i class='mdi mdi-briefcase-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Business View</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 -->
|
||
|
||
|
||
|
||
|
||
<div id="staff_business_list_modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||
<div class="modal-dialog modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 id="branch_action_type">Staff Business List</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<table class="table table-striped dt-responsive nowrap w-100">
|
||
<thead>
|
||
<tr>
|
||
<th>
|
||
Business Name
|
||
</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
<tbody>
|
||
|
||
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right">
|
||
<!-- <button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button> -->
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
|
||
|
||
|
||
<!-- ============================================================== -->
|
||
<!-- End Page content -->
|
||
<!-- ============================================================== -->
|
||
|
||
|
||
<script>
|
||
|
||
function view_business(params) {
|
||
console.log(params);
|
||
$('#staff_business_list_modal').click();
|
||
$.ajax({
|
||
type: 'GET',
|
||
url: '<?php echo base_url()."business_view/"?>'+ params,
|
||
dataType: 'json',
|
||
success:function (response) {
|
||
console.log(response);
|
||
var tbody = $('#staff_business_list_modal tbody');
|
||
tbody.empty();
|
||
response.forEach(element => {
|
||
console.log(element);
|
||
var row = '<tr>' +
|
||
'<td>' + element.business_name + '</td>' +
|
||
'</tr>';
|
||
|
||
tbody.append(row);
|
||
});
|
||
},
|
||
error: function name(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
}
|
||
})
|
||
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
|
||
datatable_bikeModel = $('#staff_table').DataTable({
|
||
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
|
||
"dom": 'Bfrtip', // Show export buttons
|
||
"buttons": [{extend: 'pdfHtml5',title: 'Staff_List', text: 'PDF',},
|
||
{extend: 'print',title: 'Staff_List',text: 'Print',},
|
||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||
{extend: 'csv',text: 'CSV', title: 'Staff_List', }],
|
||
"language": {
|
||
"search": "Search: " // Customize search label
|
||
},
|
||
});
|
||
|
||
});
|
||
|
||
|
||
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>
|