153 lines
8.9 KiB
PHP
153 lines
8.9 KiB
PHP
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="float-right">
|
|
<a href="<?= base_url()."view_customer_group/0"; ?>" class="btn btn-primary"><i class="ri-team-line"></i> Add Donor Group </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="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th hidden></th>
|
|
<th>Group Name</th>
|
|
<th>Created at</th>
|
|
<th>Created by</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<?php foreach ($customer_group as $group) :
|
|
if ($group['isactive']) {
|
|
$class = 'badge badge-soft-success';
|
|
$message = 'Active';
|
|
} else {
|
|
$class = 'badge badge-soft-danger';
|
|
$message = 'In-Active';
|
|
} ?>
|
|
<tr>
|
|
<td hidden><?= $group['group_id']; ?></td>
|
|
<td><?= $group['group_name']; ?></td>
|
|
<td><?= $group['formatted_created_on']; ?></td>
|
|
<td><?= $group['created_by_name']; ?></td>
|
|
<td><span class="<?php echo $class; ?>"><?php echo $message; ?></span></td>
|
|
<td>
|
|
<a href="<?= base_url() . "view_customer_group/" . $group['group_id']; ?>" class="edit-button" title="Edit" ><i class="ri-pencil-line"></i></a>
|
|
<a class="preview-button" title="Customer list" data-toggle="modal" data-target="#scrollable-modal" data-primary-key="<?php echo $group['group_id']; ?>" data-group-name="<?php echo $group['group_name']; ?>"><i class="ri-pages-line"></i></a>
|
|
<?php if ($group['isactive']) { ?> <a href="<?= base_url() . "delete_customer_group/" . $group['group_id']; ?>" class="delete-button" title="Delete" ><i class="ri-delete-bin-line"></i></a> <?php } ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
<div class="modal" id="scrollable-modal" tabindex="-1" role="dialog" aria-labelledby="scrollableModalTitle" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="scrollableModalTitle">Customer list</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body" id="ajax-content">
|
|
<table class="table table-bordered" id="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:10%;">#</th>
|
|
<th style="width:30%;">Name</th>
|
|
<th style="width:30%;">Email</th>
|
|
<th style="width:30%;">Mobile</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<!-- Table rows will be populated here -->
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
</div>
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div><!-- /.modal -->
|
|
<!-- end row-->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#scroll-horizontal-datatable_customer').DataTable({
|
|
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
|
|
// Other DataTables configuration options
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
$('#scrollable-modal').on('show.bs.modal', function(event) {
|
|
// Get the data-primary-key attribute from the modal trigger
|
|
var primaryKey = $(event.relatedTarget).data('primary-key');
|
|
var groupName = $(event.relatedTarget).data('group-name');
|
|
$('#scrollableModalTitle').text(groupName + ' - Customer list');
|
|
|
|
// Get the table reference
|
|
var table = $("#data-table tbody");
|
|
var route = "<?= base_url().'preview_customer_group/'?>"+primaryKey;
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: route,
|
|
success: function(response) {
|
|
if (response.length > 0) {
|
|
// Clear existing rows
|
|
table.empty();
|
|
$x=0;
|
|
// Loop through the response and create table rows
|
|
$.each(response, function (index, item) {
|
|
var row = $("<tr>");
|
|
row.append($("<td style='width:10%;'>").text(++$x));
|
|
row.append($("<td style='width:30%;'>").text(item.customer_name));
|
|
row.append($("<td style='width:30%;'>").text(item.email));
|
|
row.append($("<td style='width:30%;'>").text(item.mobile_no));
|
|
table.append(row);
|
|
});
|
|
} else {
|
|
// Handle the case where there is no data
|
|
table.empty();
|
|
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
|
|
}
|
|
},
|
|
error: function () {
|
|
// alert("An error occurred.");
|
|
console.log("CG Preview List - An error occurred.");
|
|
table.empty();
|
|
table.append("<tr><td colspan='4' style='width:100%; text-align: center; vertical-align: middle;'>No data available</td></tr>");
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|