109 lines
4.9 KiB
PHP
Executable File
109 lines
4.9 KiB
PHP
Executable File
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="float-right">
|
|
<a href="new_event/0" class="btn btn-primary"><i class="fe-shopping-bag"></i> Add Event </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="basic-datatable_new" class="table dt-responsive nowrap w-100">
|
|
<thead class="thead-light">
|
|
|
|
<tr>
|
|
<th hidden ></th>
|
|
<th>Event Name</th>
|
|
<th align="center" id="action-column">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<?php foreach ($event as $value) :?>
|
|
<tr>
|
|
<td hidden><?= $value['event_id']; ?></td>
|
|
<td data-order="<?= $value['event_name']; ?>"><?= $value['event_name']; ?></td>
|
|
<td>
|
|
<div class="custom-control custom-switch">
|
|
<input type="radio" class="custom-control-input" name="is_the_default" value="<?= $value['event_id'] ?>" id="<?= $value['event_id'] ?>" <?= $value['is_the_default'] ? "checked" : ""; ?> >
|
|
<label class="custom-control-label" for="<?= $value['event_id']; ?>"></label>
|
|
<a href="<?= "new_event/" . $value['event_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
|
<a href="<?= base_url() . "delete_event/" . $value['event_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div><!-- end row-->
|
|
<script>
|
|
$(document).ready(function() {
|
|
var actionColumnIndex = $('#action-column').index();
|
|
var table = $('#basic-datatable_new').DataTable({
|
|
"order": [[0, "dsc"]], // Sort by the first (index 0) column (id) in ascending order
|
|
"columnDefs": [{ "targets": [actionColumnIndex], "orderable": false }]
|
|
});
|
|
});
|
|
|
|
$("input[type=radio][name=is_the_default]").change(function(event) {
|
|
var id = $(this).val();
|
|
var confirmed = window.confirm("Are you sure, you want to set the event as the default event?");
|
|
|
|
if (confirmed) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "<?= base_url() . 'change_default_event' ?>",
|
|
data: {
|
|
event_id: id,
|
|
is_the_default: 1
|
|
},
|
|
success: function(response) {
|
|
alert(response.response);
|
|
$(this).prop('checked', true);
|
|
console.error(response);
|
|
},
|
|
error: function(error) {
|
|
alert(error.response);
|
|
console.error(error);
|
|
// $(this).prop('checked', false);
|
|
refreshPage();
|
|
|
|
}
|
|
});
|
|
} else {
|
|
alert("Action canceled");
|
|
console.log("Action canceled");
|
|
refreshPage();
|
|
// console.log(event);
|
|
// console.log(id);$event->event_id
|
|
// $(this).prop('checked', false);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
|
|
|