updated admin dashboard-additional accommodation section
This commit is contained in:
parent
b9f4249adf
commit
a6023e2979
3 changed files with 116 additions and 7 deletions
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive-md" style="height: 400px; overflow-y: scroll;">
|
<div class="table-responsive-md" style="height: 400px; overflow-y: scroll;">
|
||||||
<table class="table table-hover border">
|
<table class="table table-hover border">
|
||||||
<thead class="sticky-top">
|
<thead>
|
||||||
<tr style="background-color: #D3D3D3;">
|
<tr style="background-color: #D3D3D3;">
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
|
@ -57,11 +57,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive-md" style="height: 400px; overflow-y: scroll;">
|
<div class="table-responsive-md" style="height: 400px; overflow-y: scroll;">
|
||||||
<table class="table table-hover border">
|
<table class="table table-hover border">
|
||||||
<thead class="sticky-top">
|
<thead>
|
||||||
<tr style="background-color: #D3D3D3;">
|
<tr style="background-color: #D3D3D3;">
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
<th scope="col">Detail</th>
|
<th scope="col" width="40%">Detail</th>
|
||||||
<th scope="col">Status</th>
|
<th scope="col">Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
<!--additional accommodation modal-->
|
<!--additional accommodation modal-->
|
||||||
<div class="modal fade" id="add-accomm-setting" data-bs-backdrop="static" data-bs-keyboard="true" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
<div class="modal fade" id="add-accomm-setting" data-bs-backdrop="static" data-bs-keyboard="true" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<form id="team_setting_form">
|
<form id="add_accomm_setting_form">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">Add Additional Accommodation</h5>
|
<h5 class="modal-title">Add Additional Accommodation</h5>
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label" style="font-weight: 600;">Detail</label>
|
<label class="form-label" style="font-weight: 600;">Detail</label>
|
||||||
<textarea class="form-control" rows="3" style="resize: none;"></textarea>
|
<textarea class="form-control" name="add_accomm_detail" rows="3" style="resize: none;"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -130,6 +130,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let accomm_setting_form = document.getElementById('accomm_setting_form');
|
let accomm_setting_form = document.getElementById('accomm_setting_form');
|
||||||
|
let add_accomm_setting_form = document.getElementById('add_accomm_setting_form');
|
||||||
|
|
||||||
accomm_setting_form.addEventListener('submit', function(e){
|
accomm_setting_form.addEventListener('submit', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -155,7 +156,7 @@
|
||||||
accomm_setting_form.elements['accomm_name'].value ='';
|
accomm_setting_form.elements['accomm_name'].value ='';
|
||||||
get_accomm();
|
get_accomm();
|
||||||
} else{
|
} else{
|
||||||
alert('error', 'Fail to upload new accommodation')
|
alert('error', 'Fail to update new accommodation')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.send(data);
|
xhr.send(data);
|
||||||
|
@ -193,8 +194,77 @@
|
||||||
xhr.send('remove_accomm='+val);
|
xhr.send('remove_accomm='+val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_accomm_setting_form.addEventListener('submit', function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
add_addiAccomm();
|
||||||
|
})
|
||||||
|
|
||||||
|
function add_addiAccomm(){
|
||||||
|
let data = new FormData();
|
||||||
|
data.append('name', add_accomm_setting_form.elements['add_accomm_name'].value);
|
||||||
|
data.append('detail', add_accomm_setting_form.elements['add_accomm_detail'].value);
|
||||||
|
data.append('add_addiAccomm', '');
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "ajax/accomm.php", true);
|
||||||
|
|
||||||
|
xhr.onload = function(){
|
||||||
|
console.log(this.responseText);
|
||||||
|
var myModal = document.getElementById('add-accomm-setting');
|
||||||
|
var modal = bootstrap.Modal.getInstance(myModal);
|
||||||
|
modal.hide()
|
||||||
|
|
||||||
|
if(this.responseText == 1){
|
||||||
|
alert('success', 'New additional accommodation is added');
|
||||||
|
add_accomm_setting_form.reset();
|
||||||
|
get_addiAccomm();
|
||||||
|
} else{
|
||||||
|
alert('error', 'Fail to update new additional accommodation')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_addiAccomm(){
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "ajax/accomm.php", true);
|
||||||
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
xhr.onload = function(){
|
||||||
|
document.getElementById('add-accomm-data').innerHTML = this.responseText;
|
||||||
|
}
|
||||||
|
xhr.send('get_addiAccomm');
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_addiAccomm(val){
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "ajax/accomm.php", true);
|
||||||
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
xhr.onload = function(){
|
||||||
|
if(this.responseText == 1){
|
||||||
|
alert('success', 'Deleted');
|
||||||
|
get_addiAccomm();
|
||||||
|
}
|
||||||
|
else if(this.responseText == 'room_add' ){
|
||||||
|
alert('error', 'This additional accommodation is already addedd')
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alert('error', 'Fail to delete data')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.send('remove_addiAccomm='+val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
get_accomm();
|
get_accomm();
|
||||||
|
get_addiAccomm();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -37,4 +37,39 @@
|
||||||
$res = delete($q, $values, 'i');
|
$res = delete($q, $values, 'i');
|
||||||
echo $res;
|
echo $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['add_addiAccomm'])){
|
||||||
|
$frm_data = filteration($_POST);
|
||||||
|
$q = "INSERT INTO `additional_accomm`(`name`, `detail`) VALUES (?, ?)";
|
||||||
|
$values = [$frm_data['name'], $frm_data['detail']];
|
||||||
|
$res = insert($q, $values, 'ss');
|
||||||
|
echo $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['get_addiAccomm'])){
|
||||||
|
$res = selectAll('additional_accomm');
|
||||||
|
$i = 1;
|
||||||
|
while($row = mysqli_fetch_assoc($res)){
|
||||||
|
echo <<<data
|
||||||
|
<tr>
|
||||||
|
<td>$i</td>
|
||||||
|
<td>$row[name]</td>
|
||||||
|
<td>$row[detail]</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" onclick="remove_addiAccomm($row[id])" class="btn-cancle">Delete</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
data;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['remove_addiAccomm'])){
|
||||||
|
$frm_data = filteration($_POST);
|
||||||
|
$values = [$frm_data['remove_addiAccomm']];
|
||||||
|
$q = "DELETE FROM `additional_accomm` WHERE `id`=?";
|
||||||
|
$res = delete($q, $values, 'i');
|
||||||
|
echo $res;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -11,9 +11,13 @@
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
document.body.append(element);
|
document.body.append(element);
|
||||||
|
setTimeout(removeAlert, 2000)
|
||||||
}
|
}
|
||||||
|
function removeAlert(){
|
||||||
|
document.getElementsByClassName('alert')[0].remove();
|
||||||
|
}
|
||||||
|
|
||||||
//navbar-active(admin)
|
//navbar-active(admin)
|
||||||
function setActive(){
|
function setActive(){
|
||||||
let navbar = document.getElementById('dashboard-menu');
|
let navbar = document.getElementById('dashboard-menu');
|
||||||
|
|
Loading…
Add table
Reference in a new issue